rofi
1.5.1
|
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <glib.h>
#include <glib/gstdio.h>
#include <sys/types.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <pwd.h>
#include <ctype.h>
#include <pango/pango.h>
#include <pango/pango-fontmap.h>
#include <pango/pangocairo.h>
#include <librsvg/rsvg.h>
#include "display.h"
#include "xcb.h"
#include "helper.h"
#include "helper-theme.h"
#include "settings.h"
#include "rofi.h"
#include "view.h"
Go to the source code of this file.
Macros | |
#define | G_LOG_DOMAIN "Helper" |
#define | MIN3(a, b, c) ( ( a ) < ( b ) ? ( ( a ) < ( c ) ? ( a ) : ( c ) ) : ( ( b ) < ( c ) ? ( b ) : ( c ) ) ) |
#define | FUZZY_SCORER_MAX_LENGTH 256 |
#define | MIN_SCORE ( INT_MIN / 2 ) |
#define | LEADING_GAP_SCORE -4 |
#define | GAP_SCORE -5 |
#define | WORD_START_SCORE 50 |
#define | NON_WORD_SCORE 40 |
#define | CAMEL_SCORE ( WORD_START_SCORE + GAP_SCORE - 1 ) |
#define | CONSECUTIVE_SCORE ( WORD_START_SCORE + GAP_SCORE ) |
#define | PATTERN_NON_START_MULTIPLIER 1 |
#define | PATTERN_START_MULTIPLIER 2 |
Enumerations | |
enum | CharClass { LOWER, UPPER, DIGIT, NON_WORD } |
Functions | |
void | cmd_set_arguments (int argc, char **argv) |
static gboolean | helper_eval_cb (const GMatchInfo *info, GString *res, gpointer data) |
int | helper_parse_setup (char *string, char ***output, int *length,...) |
void | helper_tokenize_free (rofi_int_matcher **tokens) |
static gchar * | glob_to_regex (const char *input) |
static gchar * | fuzzy_to_regex (const char *input) |
static GRegex * | R (const char *s, int case_sensitive) |
static rofi_int_matcher * | create_regex (const char *input, int case_sensitive) |
rofi_int_matcher ** | helper_tokenize (const char *input, int case_sensitive) |
int | find_arg (const char *const key) |
int | find_arg_str (const char *const key, char **val) |
const char ** | find_arg_strv (const char *const key) |
int | find_arg_int (const char *const key, int *val) |
int | find_arg_uint (const char *const key, unsigned int *val) |
char | helper_parse_char (const char *arg) |
int | find_arg_char (const char *const key, char *val) |
PangoAttrList * | helper_token_match_get_pango_attr (RofiHighlightColorStyle th, rofi_int_matcher **tokens, const char *input, PangoAttrList *retv) |
int | helper_token_match (rofi_int_matcher *const *tokens, const char *input) |
int | execute_generator (const char *cmd) |
int | create_pid_file (const char *pidfile) |
void | remove_pid_file (int fd) |
gboolean | helper_validate_font (PangoFontDescription *pfd, const char *font) |
int | config_sanity_check (void) |
char * | rofi_expand_path (const char *input) |
unsigned int | levenshtein (const char *needle, const glong needlelen, const char *haystack, const glong haystacklen) |
char * | rofi_latin_to_utf8_strdup (const char *input, gssize length) |
gchar * | rofi_escape_markup (gchar *text) |
char * | rofi_force_utf8 (const gchar *data, ssize_t length) |
static enum CharClass | rofi_scorer_get_character_class (gunichar c) |
static int | rofi_scorer_get_score_for (enum CharClass prev, enum CharClass curr) |
int | rofi_scorer_fuzzy_evaluate (const char *pattern, glong plen, const char *str, glong slen) |
int | utf8_strncmp (const char *a, const char *b, size_t n) |
gboolean | helper_execute (const char *wd, char **args, const char *error_precmd, const char *error_cmd, RofiHelperExecuteContext *context) |
gboolean | helper_execute_command (const char *wd, const char *cmd, gboolean run_in_term, RofiHelperExecuteContext *context) |
char * | helper_get_theme_path (const char *file) |
cairo_surface_t * | cairo_image_surface_create_from_svg (const gchar *file, int height) |
static void | parse_pair (char *input, rofi_range_pair *item) |
void | parse_ranges (char *input, rofi_range_pair **list, unsigned int *length) |
void | rofi_output_formatted_line (const char *format, const char *string, int selected_line, const char *filter) |
Variables | |
const char *const | monitor_position_entries [] |
static int | stored_argc = 0 |
static char ** | stored_argv = NULL |
#define CAMEL_SCORE ( WORD_START_SCORE + GAP_SCORE - 1 ) |
#define CONSECUTIVE_SCORE ( WORD_START_SCORE + GAP_SCORE ) |
Consecutive score
Definition at line 801 of file helper.c.
Referenced by rofi_scorer_fuzzy_evaluate().
#define FUZZY_SCORER_MAX_LENGTH 256 |
Max length of input to score.
Definition at line 787 of file helper.c.
Referenced by rofi_scorer_fuzzy_evaluate().
#define GAP_SCORE -5 |
#define LEADING_GAP_SCORE -4 |
Leading gap score
Definition at line 791 of file helper.c.
Referenced by rofi_scorer_fuzzy_evaluate().
#define MIN3 | ( | a, | |
b, | |||
c | |||
) | ( ( a ) < ( b ) ? ( ( a ) < ( c ) ? ( a ) : ( c ) ) : ( ( b ) < ( c ) ? ( b ) : ( c ) ) ) |
Return the minimum value of a,b,c
Definition at line 700 of file helper.c.
Referenced by levenshtein().
#define MIN_SCORE ( INT_MIN / 2 ) |
#define NON_WORD_SCORE 40 |
#define PATTERN_NON_START_MULTIPLIER 1 |
non-start multiplier
Definition at line 803 of file helper.c.
Referenced by rofi_scorer_fuzzy_evaluate().
#define PATTERN_START_MULTIPLIER 2 |
start multiplier
Definition at line 805 of file helper.c.
Referenced by rofi_scorer_fuzzy_evaluate().
#define WORD_START_SCORE 50 |
start of word score
Definition at line 795 of file helper.c.
Referenced by rofi_scorer_get_score_for().
enum CharClass |
cairo_surface_t* cairo_image_surface_create_from_svg | ( | const gchar * | file, |
int | height | ||
) |
file | The file path |
height | The wanted height Gets a surface from an svg path |
Rendering fails
Definition at line 1085 of file helper.c.
References config, and Settings::dpi.
|
static |
Definition at line 218 of file helper.c.
References config, fuzzy_to_regex(), glob_to_regex(), rofi_int_matcher_t::invert, Settings::matching_method, MM_FUZZY, MM_GLOB, MM_REGEX, R(), and rofi_int_matcher_t::regex.
Referenced by helper_tokenize().
|
static |
Definition at line 181 of file helper.c.
Referenced by create_regex().
|
static |
Definition at line 164 of file helper.c.
Referenced by create_regex().
|
static |
info | To Match information on. |
res | The string being generated. |
data | User data |
Replace the entries. This function gets called by g_regex_replace_eval.
Definition at line 88 of file helper.c.
Referenced by helper_parse_setup().
gboolean helper_execute | ( | const char * | wd, |
char ** | args, | ||
const char * | error_precmd, | ||
const char * | error_cmd, | ||
RofiHelperExecuteContext * | context | ||
) |
wd | The working directory. |
args | The arguments of the command to exec. |
error_precmd | Prefix to error message command. |
error_cmd | Error message command |
context | The startup notification context, if any |
Executes the command
Definition at line 975 of file helper.c.
References display_startup_notification(), and rofi_view_error_dialog().
Referenced by execshssh(), and helper_execute_command().
gboolean helper_execute_command | ( | const char * | wd, |
const char * | cmd, | ||
gboolean | run_in_term, | ||
RofiHelperExecuteContext * | context | ||
) |
wd | The work directory (optional) |
cmd | The cmd to execute |
run_in_term | Indicate if command should be run in a terminal |
context | The startup notification context, if any |
Execute command. If needed members of
context | are NULL, they will be filled. |
Definition at line 1000 of file helper.c.
References RofiHelperExecuteContext::binary, RofiHelperExecuteContext::command, config, RofiHelperExecuteContext::description, helper_execute(), helper_parse_setup(), RofiHelperExecuteContext::name, Settings::run_command, and Settings::run_shell_command.
Referenced by exec_cmd().
char* helper_get_theme_path | ( | const char * | file | ) |
file | File name passed to option. |
Definition at line 1034 of file helper.c.
References rofi_expand_path().
|
static |
Definition at line 1129 of file helper.c.
References rofi_range_pair::start, and rofi_range_pair::stop.
Referenced by parse_ranges().
void parse_ranges | ( | char * | input, |
rofi_range_pair ** | list, | ||
unsigned int * | length | ||
) |
Ranges.
input | String to parse |
list | List of ranges |
length | Length of list. |
ranges
Definition at line 1148 of file helper.c.
References parse_pair().
Referenced by dmenu_mode_init(), and parse_header_entry().
|
inlinestatic |
Definition at line 213 of file helper.c.
Referenced by create_regex().
void rofi_output_formatted_line | ( | const char * | format, |
const char * | string, | ||
int | selected_line, | ||
const char * | filter | ||
) |
format | The format string used. See below for possible syntax. |
string | The selected entry. |
selected_line | The selected line index. |
filter | The entered filter. |
Function that outputs the selected line in the user-specified format. Currently the following formats are supported:
This functions outputs the formatted string to stdout, appends a newline (
) character and calls flush on the file descriptor.
Definition at line 1182 of file helper.c.
Referenced by dmenu_print_results(), and dmenu_switcher_dialog().
|
static |
prev | The previous character. |
curr | The current character |
Scrore the transition.
Definition at line 849 of file helper.c.
References CAMEL_SCORE, DIGIT, LOWER, NON_WORD, NON_WORD_SCORE, UPPER, and WORD_START_SCORE.
Referenced by rofi_scorer_fuzzy_evaluate().
int utf8_strncmp | ( | const char * | a, |
const char * | b, | ||
size_t | n | ||
) |
a | UTF-8 string to compare |
b | UTF-8 string to compare |
n | Maximum number of characters to compare |
Compares the G_NORMALIZE_ALL_COMPOSE
forms of the two strings.
n
characters (not bytes) of a
are found, respectively, to be less than, to match, or be greater than the first n
characters (not bytes) of b
. Definition at line 963 of file helper.c.
Referenced by combi_mode_result(), and combi_preprocess_input().
const char* const monitor_position_entries[] |
Textual description of positioning rofi.
Definition at line 61 of file helper.c.
Referenced by config_sanity_check().
|
static |
copy of the argc for use in commandline argument parser.
Definition at line 69 of file helper.c.
Referenced by cmd_set_arguments(), find_arg(), find_arg_char(), find_arg_int(), find_arg_str(), find_arg_strv(), and find_arg_uint().
|
static |
copy of the argv pointer for use in the commandline argument parser
Definition at line 71 of file helper.c.
Referenced by cmd_set_arguments(), find_arg(), find_arg_char(), find_arg_int(), find_arg_str(), find_arg_strv(), and find_arg_uint().