rofi
1.5.4
|
Data Structures | |
struct | RofiHelperExecuteContext |
Functions | |
int | helper_parse_setup (char *string, char ***output, int *length,...) |
rofi_int_matcher ** | helper_tokenize (const char *input, int case_sensitive) |
void | helper_tokenize_free (rofi_int_matcher **tokens) |
int | find_arg_char (const char *const key, char *val) |
int | find_arg_uint (const char *const key, unsigned int *val) |
int | find_arg_int (const char *const key, int *val) |
int | find_arg_str (const char *const key, char **val) |
const char ** | find_arg_strv (const char *const key) |
int | find_arg (const char *const key) |
int | helper_token_match (rofi_int_matcher *const *tokens, const char *input) |
int | execute_generator (const char *cmd) __attribute__((nonnull)) |
int | create_pid_file (const char *pidfile) |
void | remove_pid_file (int fd) |
int | config_sanity_check (void) |
char | helper_parse_char (const char *arg) |
void | cmd_set_arguments (int argc, char **argv) |
char * | rofi_expand_path (const char *input) |
unsigned int | levenshtein (const char *needle, const glong needlelen, const char *haystack, const glong haystacklen) |
char * | rofi_force_utf8 (const gchar *data, ssize_t length) |
char * | rofi_latin_to_utf8_strdup (const char *input, gssize length) |
gchar * | rofi_escape_markup (gchar *text) |
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) __attribute__((nonnull(1 |
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) |
cairo_surface_t * | cairo_image_surface_create_from_svg (const gchar *file, int height) |
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) |
char * | helper_string_replace_if_exists (char *string,...) |
Variables | |
const gchar * | RofiHelperExecuteContext::name |
const gchar * | RofiHelperExecuteContext::binary |
const gchar * | RofiHelperExecuteContext::description |
const gchar * | RofiHelperExecuteContext::icon |
const gchar * | RofiHelperExecuteContext::app_id |
const gchar * | RofiHelperExecuteContext::wmclass |
const gchar * | RofiHelperExecuteContext::command |
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 1074 of file helper.c.
References config, and Settings::dpi.
Referenced by rofi_icon_fetcher_worker().
void cmd_set_arguments | ( | int | argc, |
char ** | argv | ||
) |
argc | number of arguments. |
argv | Array of arguments. |
Set the application arguments.
Definition at line 76 of file helper.c.
References stored_argc, and stored_argv.
Referenced by main().
int config_sanity_check | ( | void | ) |
Do some input validation, especially the first few could break things. It is good to catch them beforehand.
This functions exits the program with 1 when it finds an invalid configuration.
Definition at line 546 of file helper.c.
References config, Settings::element_height, Settings::fullscreen, Settings::location, Settings::matching, Settings::matching_method, Settings::menu_columns, Settings::menu_font, Settings::menu_width, MM_FUZZY, MM_GLOB, MM_NORMAL, MM_REGEX, mon, Settings::monitor, monitor_active(), monitor_position_entries, rofi_add_error_message(), SORT_FZF, SORT_NORMAL, Settings::sorting_method, Settings::sorting_method_enum, and WL_CENTER.
Referenced by startup().
int create_pid_file | ( | const char * | pidfile | ) |
int execute_generator | ( | const char * | cmd | ) |
cmd | The command to execute. |
Execute cmd using config.run_command and outputs the result (stdout) to the opened file descriptor.
Definition at line 458 of file helper.c.
References config, helper_parse_setup(), rofi_view_error_dialog(), and Settings::run_command.
Referenced by get_apps_external().
int find_arg | ( | const char *const | key | ) |
key | The key to search for |
Check if key is passed as argument.
Definition at line 267 of file helper.c.
References stored_argc, and stored_argv.
Referenced by config_parse_cmd_option(), display_late_setup(), dmenu_finalize(), dmenu_mode_init(), dmenu_switcher_dialog(), find_arg_char(), find_arg_int(), find_arg_str(), find_arg_uint(), help(), main(), rofi_collect_modi(), and startup().
int find_arg_char | ( | const char *const | key, |
char * | val | ||
) |
key | The key to search for |
val | Pointer to the string to set to the key value (if found) |
Parse command line argument 'key' to character. This one supports character escaping.
Definition at line 371 of file helper.c.
References find_arg(), helper_parse_char(), stored_argc, and stored_argv.
Referenced by config_parse_cmd_option(), and dmenu_mode_init().
int find_arg_int | ( | const char *const | key, |
int * | val | ||
) |
key | The key to search for |
val | Pointer to the string to set to the key value (if found) |
Parse command line argument 'key' to int.
Definition at line 309 of file helper.c.
References find_arg(), stored_argc, and stored_argv.
Referenced by config_parse_cmd_option().
int find_arg_str | ( | const char *const | key, |
char ** | val | ||
) |
key | The key to search for |
val | Pointer to the string to set to the key value (if found) |
Parse command line argument 'key' to string.
Definition at line 277 of file helper.c.
References find_arg(), stored_argc, and stored_argv.
Referenced by config_parse_cmd_option(), display_setup(), dmenu_mode_init(), dmenu_switcher_dialog(), main(), rofi_collect_modi(), and startup().
const char** find_arg_strv | ( | const char *const | key | ) |
key | The key to search for |
Parse all command line options 'key' to string vector.
Definition at line 288 of file helper.c.
References stored_argc, and stored_argv.
Referenced by main().
int find_arg_uint | ( | const char *const | key, |
unsigned int * | val | ||
) |
key | The key to search for |
val | Pointer to the string to set to the key value (if found) |
Parse command line argument 'key' to unsigned int.
Definition at line 319 of file helper.c.
References find_arg(), stored_argc, and stored_argv.
Referenced by config_parse_cmd_option(), dmenu_mode_init(), dmenu_switcher_dialog(), and main().
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 964 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 989 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_parse_char | ( | const char * | arg | ) |
arg | string to parse. |
Parses a string into an character.
Definition at line 330 of file helper.c.
Referenced by config_parser_set(), and find_arg_char().
int helper_parse_setup | ( | char * | string, |
char *** | output, | ||
int * | length, | ||
... | |||
) |
string | The input string. |
output | Pointer to 2 dimensional array with parsed string. |
length | Length of 2 dimensional array. |
... | Key, value parse. Replaces the string Key with value. |
Parses a string into arguments. While replacing keys with values.
Definition at line 83 of file helper.c.
References config, helper_string_replace_if_exists_v(), rofi_view_error_dialog(), Settings::ssh_client, and Settings::terminal_emulator.
Referenced by execshssh(), execute_generator(), and helper_execute_command().
char* helper_string_replace_if_exists | ( | char * | string, |
... | |||
) |
string | The string with elements to be replaced |
... | Set of {key}, value that will be replaced, terminated by a NULL |
Items {key} are replaced by the value if '{key}' is passed as key/value pair, otherwise removed from string. If the {key} is in between [] all the text between [] are removed if {key} is not found. Otherwise key is replaced and [ & ] removed.
This allows for optional replacement, f.e. '{ssh-client} [-t {title}] -e "{cmd}"' the '-t {title}' is only there if {title} is set.
Definition at line 1265 of file helper.c.
References helper_string_replace_if_exists_v().
int helper_token_match | ( | rofi_int_matcher *const * | tokens, |
const char * | input | ||
) |
tokens | List of (input) tokens to match. |
input | The entry to match against. |
Tokenized match, match tokens to line input.
Definition at line 445 of file helper.c.
Referenced by dmenu_switcher_dialog(), dmenu_token_match(), help_keys_token_match(), run_token_match(), script_token_match(), and ssh_token_match().
rofi_int_matcher** helper_tokenize | ( | const char * | input, |
int | case_sensitive | ||
) |
input | The input string. |
case_sensitive | Whether case is significant. |
Tokenize the string on spaces.
Definition at line 228 of file helper.c.
References config, create_regex(), and Settings::tokenize.
Referenced by dmenu_switcher_dialog(), and rofi_view_refilter().
void helper_tokenize_free | ( | rofi_int_matcher ** | tokens | ) |
tokens | Array of regex objects |
Frees the array of matching objects.
Definition at line 127 of file helper.c.
Referenced by dmenu_switcher_dialog(), rofi_view_free(), and rofi_view_refilter().
unsigned int levenshtein | ( | const char * | needle, |
const glong | needlelen, | ||
const char * | haystack, | ||
const glong | haystacklen | ||
) |
needle | The string to find match weight off |
needlelen | The length of the needle |
haystack | The string to match against |
haystacklen | The length of the haystack |
UTF-8 aware levenshtein distance calculation
Definition at line 691 of file helper.c.
References Settings::case_sensitive, config, and MIN3.
Referenced by filter_elements().
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 1137 of file helper.c.
References parse_pair().
Referenced by dmenu_mode_init(), and parse_header_entry().
void remove_pid_file | ( | int | fd | ) |
Remove pid file
Definition at line 519 of file helper.c.
Referenced by create_pid_file(), and teardown().
gchar* rofi_escape_markup | ( | gchar * | text | ) |
char* rofi_expand_path | ( | const char * | input | ) |
input | The path to expand |
Expand path, both ~
and ~<user>
Definition at line 658 of file helper.c.
Referenced by dmenu_mode_init(), get_apps(), get_ssh(), helper_get_theme_path(), main(), parse_ssh_config_file(), rofi_theme_parse_prepare_file(), rofi_view_setup_fake_transparency(), and script_switcher_parse_setup().
char* rofi_force_utf8 | ( | const gchar * | data, |
ssize_t | length | ||
) |
data | the unvalidated character array holding possible UTF-8 data |
length | the length of the data array |
Convert string to valid utf-8, replacing invalid parts with replacement character.
Definition at line 742 of file helper.c.
Referenced by read_add().
char* rofi_latin_to_utf8_strdup | ( | const char * | input, |
gssize | length | ||
) |
input | the char array holding latin text |
length | the length of the data array |
Converts latin to UTF-8.
Definition at line 726 of file helper.c.
Referenced by window_get_text_prop().
void rofi_output_formatted_line | ( | const char * | format, |
const char * | string, | ||
int | selected_line, | ||
const char * | filter | ||
) |
format | |
string | |
selected_line | |
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 1171 of file helper.c.
Referenced by dmenu_print_results(), and dmenu_switcher_dialog().
int rofi_scorer_fuzzy_evaluate | ( | const char * | pattern, |
glong | plen, | ||
const char * | str, | ||
glong | slen | ||
) |
pattern | The user input to match against. |
plen | Pattern length. |
str | The input to match against pattern. |
slen | Length of str. |
FZF like fuzzy sorting algorithm.
pattern | The user input to match against. |
plen | Pattern length. |
str | The input to match against pattern. |
slen | Length of str. |
rofi_scorer_fuzzy_evaluate implements a global sequence alignment algorithm to find the maximum accumulated score by aligning pattern
to str
. It applies when pattern
is a subsequence of str
.
Scoring criteria
pattern
receive bonus because they usually have more significance than the rest. See PATTERN_START_MULTIPLIER/PATTERN_NON_START_MULTIPLIER.str
will reduce the score (gap penalty). See GAP_SCORE.The recurrence of the dynamic programming: dp[i][j]: maximum accumulated score by aligning pattern[0..i] to str[0..j] dp[0][j] = leading_gap_penalty(0, j) + score[j] dp[i][j] = max(dp[i-1][j-1] + CONSECUTIVE_SCORE, max(dp[i-1][k] + gap_penalty(k+1, j) + score[j] : k < j))
The first dimension can be suppressed since we do not need a matching scheme, which reduces the space complexity from O(N*M) to O(M)
Definition at line 880 of file helper.c.
References Settings::case_sensitive, config, CONSECUTIVE_SCORE, FUZZY_SCORER_MAX_LENGTH, GAP_SCORE, LEADING_GAP_SCORE, MIN_SCORE, NON_WORD, PATTERN_NON_START_MULTIPLIER, PATTERN_START_MULTIPLIER, rofi_scorer_get_character_class(), and rofi_scorer_get_score_for().
Referenced by filter_elements().
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
. const gchar* RofiHelperExecuteContext::app_id |
The application id (desktop file with the .desktop suffix)
Definition at line 277 of file helper.h.
Referenced by display_startup_notification().
const gchar* RofiHelperExecuteContext::binary |
The binary name of the application
Definition at line 271 of file helper.h.
Referenced by display_startup_notification(), and helper_execute_command().
const gchar* RofiHelperExecuteContext::command |
The command we run
Definition at line 281 of file helper.h.
Referenced by display_startup_notification(), and helper_execute_command().
const gchar* RofiHelperExecuteContext::description |
The description of the launch
Definition at line 273 of file helper.h.
Referenced by display_startup_notification(), and helper_execute_command().
const gchar* RofiHelperExecuteContext::icon |
The icon name of the application
Definition at line 275 of file helper.h.
Referenced by display_startup_notification().
const gchar* RofiHelperExecuteContext::name |
The name of the application
Definition at line 269 of file helper.h.
Referenced by display_startup_notification(), exec_cmd(), execshssh(), and helper_execute_command().
const gchar* RofiHelperExecuteContext::wmclass |
The window manager class of the application
Definition at line 279 of file helper.h.
Referenced by display_startup_notification().