rofi 2.1.0
Helper
Collaboration diagram for Helper:

Data Structures

struct  RofiHelperExecuteContext

Macros

#define rofi_fallthrough

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, gboolean kill_running)
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, const int case_sensitive)
char * rofi_force_utf8 (const gchar *data, ssize_t length)
char * rofi_latin_to_utf8_strdup (const char *input, gssize length)
int rofi_scorer_fuzzy_evaluate (const char *pattern, glong plen, const char *str, glong slen, const int case_sensitive)
int rofi_scorer_fzf_v2_evaluate (const char *pattern, glong plen, const char *str, glong slen, int case_sensitive)
int rofi_scorer_fzf_v2_sort_key (int score, const char *str)
int utf8_strncmp (const char *a, const char *b, size_t n) __attribute__((nonnull(1
gboolean helper_execute_env (const char *wd, char **args, const char *error_precmd, const char *error_cmd, RofiHelperExecuteContext *context, gchar **envp)
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)
gboolean helper_execute_command_env (const char *wd, const char *cmd, gboolean run_in_term, RofiHelperExecuteContext *context, char **envp)
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)
int parse_case_sensitivity (const char *input)
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,...)
char * helper_get_theme_path (const char *file, const char **ext, const char *parent_dir) __attribute__((nonnull(1
char ConfigEntry * rofi_config_find_widget (const char *name, const char *state, gboolean exact)
Property * rofi_theme_find_property (ConfigEntry *widgetwidget, PropertyType type, const char *property, gboolean exact)
const char * helper_get_matching_mode_str (void)
void helper_select_next_matching_mode (void)
void helper_select_previous_matching_mode (void)

Detailed Description

Macro Definition Documentation

◆ rofi_fallthrough

#define rofi_fallthrough
Value:
do { \
} while (0)

Method to indicate fallthrough. This will help gcc/llvm warning/static code analysis.

Definition at line 540 of file helper.h.

Referenced by listview_element_trigger_action(), rofi_view_trigger_action(), x11_button_to_nk_bindings_scroll(), and xcb_rofi_view_calculate_window_position().

Function Documentation

◆ cairo_image_surface_create_from_svg()

cairo_surface_t * cairo_image_surface_create_from_svg ( const gchar * file,
int height )
Parameters
fileThe file path
heightThe wanted height Gets a surface from an svg path
Returns
a cairo surface from an svg path

References cairo_image_surface_create_from_svg(), helper_string_replace_if_exists(), parse_case_sensitivity(), parse_ranges(), and rofi_output_formatted_line().

Referenced by cairo_image_surface_create_from_svg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cmd_set_arguments()

void cmd_set_arguments ( int argc,
char ** argv )
Parameters
argcnumber of arguments.
argvArray of arguments.

Set the application arguments.

Definition at line 97 of file helper.c.

References cmd_set_arguments(), stored_argc, and stored_argv.

Referenced by cmd_set_arguments(), and main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ config_sanity_check()

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 671 of file helper.c.

References Settings::backend, config, config_sanity_check(), DISPLAY_XCB, Settings::element_height, Settings::location, Settings::matching, Settings::matching_method, MatchingMethodEnabled, MatchingMethodStr, MM_NUM_MATCHERS, Settings::monitor, monitor_active(), monitor_position_entries, NUMMatchingMethodEnabled, rofi_add_error_message(), SORT_FZF, SORT_FZF_V2, SORT_NORMAL, Settings::sorting_method, Settings::sorting_method_enum, and WL_CENTER.

Referenced by config_sanity_check(), and startup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_pid_file()

int create_pid_file ( const char * pidfile,
gboolean kill_running )
Parameters
pidfileThe pidfile to create.
kill_runningTry killing running instance.

returns file descriptor (or -1 when failed)

Definition at line 585 of file helper.c.

References create_pid_file(), pidfile, and remove_pid_file().

Referenced by create_pid_file(), and main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ execute_generator()

int execute_generator ( const char * cmd)
Parameters
cmdThe command to execute.

Execute cmd using config.run_command and outputs the result (stdout) to the opened file descriptor.

Returns
a valid file descriptor on success, or -1 on failure.

Definition at line 562 of file helper.c.

References config, execute_generator(), helper_parse_setup(), rofi_view_error_dialog(), and Settings::run_command.

Referenced by execute_generator(), and get_apps_external().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_arg()

int find_arg ( const char *const key)
Parameters
keyThe key to search for

Check if key is passed as argument.

Returns
return position of string or -1 if not found.

Definition at line 325 of file helper.c.

References find_arg(), stored_argc, and stored_argv.

Referenced by config_parse_cmd_option(), dmenu_finalize(), dmenu_mode_dialog(), dmenu_mode_init(), find_arg(), find_arg_char(), find_arg_int(), find_arg_str(), find_arg_uint(), help(), main(), rofi_collect_modes(), run_mode_index(), startup(), and xcb_display_late_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_arg_char()

int find_arg_char ( const char *const key,
char * val )
Parameters
keyThe key to search for
valPointer to the string to set to the key value (if found)

Parse command line argument 'key' to character. This one supports character escaping.

Returns
TRUE if key was found and val was set.

Definition at line 431 of file helper.c.

References find_arg(), find_arg_char(), helper_parse_char(), stored_argc, and stored_argv.

Referenced by config_parse_cmd_option(), dmenu_mode_init(), and find_arg_char().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_arg_int()

int find_arg_int ( const char *const key,
int * val )
Parameters
keyThe key to search for
valPointer to the string to set to the key value (if found)

Parse command line argument 'key' to int.

Returns
TRUE if key was found and val was set.

Definition at line 364 of file helper.c.

References find_arg(), find_arg_int(), stored_argc, and stored_argv.

Referenced by config_parse_cmd_option(), and find_arg_int().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_arg_str()

int find_arg_str ( const char *const key,
char ** val )
Parameters
keyThe key to search for
valPointer to the string to set to the key value (if found)

Parse command line argument 'key' to string.

Returns
TRUE if key was found and val was set.

Definition at line 334 of file helper.c.

References find_arg(), find_arg_str(), stored_argc, and stored_argv.

Referenced by config_parse_cmd_option(), dmenu_mode_dialog(), dmenu_mode_init(), find_arg_str(), main(), rofi_collect_modes(), startup(), and xcb_display_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_arg_strv()

const char ** find_arg_strv ( const char *const key)
Parameters
keyThe key to search for

Parse all command line options 'key' to string vector.

Returns
str vector. user should free array.

Definition at line 344 of file helper.c.

References find_arg_strv(), stored_argc, and stored_argv.

Referenced by find_arg_strv(), and main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_arg_uint()

int find_arg_uint ( const char *const key,
unsigned int * val )
Parameters
keyThe key to search for
valPointer to the string to set to the key value (if found)

Parse command line argument 'key' to unsigned int.

Returns
TRUE if key was found and val was set.

Definition at line 373 of file helper.c.

References find_arg(), find_arg_uint(), stored_argc, and stored_argv.

Referenced by config_parse_cmd_option(), dmenu_mode_init(), find_arg_uint(), main(), and run_mode_index().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ helper_execute()

gboolean helper_execute ( const char * wd,
char ** args,
const char * error_precmd,
const char * error_cmd,
RofiHelperExecuteContext * context )
Parameters
wdThe working directory.
argsThe arguments of the command to exec.
error_precmdPrefix to error message command.
error_cmdError message command
contextThe startup notification context, if any

Executes the command

Returns
TRUE when successful, FALSE when failed.

Definition at line 1424 of file helper.c.

References helper_execute(), and helper_execute_env().

Referenced by execshssh(), helper_execute(), rofi_error_user_callback(), rofi_quit_user_callback(), screenshot_taken_user_callback(), and selection_changed_user_callback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ helper_execute_command()

gboolean helper_execute_command ( const char * wd,
const char * cmd,
gboolean run_in_term,
RofiHelperExecuteContext * context )
Parameters
wdThe work directory (optional)
cmdThe cmd to execute
run_in_termIndicate if command should be run in a terminal
contextThe startup notification context, if any

Execute command. If needed members of context are NULL, they will be filled.

Returns
FALSE On failure, TRUE on success

Definition at line 1457 of file helper.c.

References helper_execute_command(), and helper_execute_command_env().

Referenced by exec_cmd(), file_browser_mode_result(), helper_execute_command(), recursive_browser_mode_result(), and rofi_quit_user_callback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ helper_execute_command_env()

gboolean helper_execute_command_env ( const char * wd,
const char * cmd,
gboolean run_in_term,
RofiHelperExecuteContext * context,
char ** envp )
Parameters
wdThe work directory (optional)
cmdThe cmd to execute
run_in_termIndicate if command should be run in a terminal
contextThe startup notification context, if any
envpThe environment to launch the application with

Execute command. If needed members of context are NULL, they will be filled.

Returns
FALSE On failure, TRUE on success

Definition at line 1463 of file helper.c.

References RofiHelperExecuteContext::binary, RofiHelperExecuteContext::command, config, RofiHelperExecuteContext::description, helper_execute_command_env(), helper_execute_env(), helper_parse_setup(), RofiHelperExecuteContext::name, Settings::run_command, and Settings::run_shell_command.

Referenced by helper_execute_command(), and helper_execute_command_env().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ helper_execute_env()

gboolean helper_execute_env ( const char * wd,
char ** args,
const char * error_precmd,
const char * error_cmd,
RofiHelperExecuteContext * context,
gchar ** envp )
Parameters
wdThe working directory.
argsThe arguments of the command to exec.
error_precmdPrefix to error message command.
error_cmdError message command
contextThe startup notification context, if any
envpThe environment to launch the application with.

Executes the command

Returns
TRUE when successful, FALSE when failed.

Definition at line 1429 of file helper.c.

References display_startup_notification(), helper_execute_env(), and rofi_view_error_dialog().

Referenced by helper_execute(), helper_execute_command_env(), and helper_execute_env().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ helper_get_matching_mode_str()

const char * helper_get_matching_mode_str ( void )
Returns
get a human readable string with the current matching method.

Definition at line 80 of file helper.c.

References config, helper_get_matching_mode_str(), Settings::matching_method, and MatchingMethodStr.

Referenced by helper_get_matching_mode_str(), helper_get_theme_path(), and rofi_view_trigger_global_action().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ helper_get_theme_path()

char * helper_get_theme_path ( const char * file,
const char ** ext,
const char * parent_dir )
Parameters
fileFile name passed to option.
extNULL terminated array of file extension passed to option.
parent_dirThe file that was used to import this file, or NULL.

Get the full path to the theme, trying to resolve it over the possible locations.

Returns
path to theme or copy of filename if not found.

References helper_get_matching_mode_str(), helper_get_theme_path(), helper_select_next_matching_mode(), helper_select_previous_matching_mode(), rofi_config_find_widget(), and rofi_theme_find_property().

Here is the call graph for this function:

◆ helper_parse_char()

char helper_parse_char ( const char * arg)
Parameters
argstring to parse.

Parses a string into an character.

Returns
character.

Definition at line 383 of file helper.c.

References helper_parse_char().

Referenced by find_arg_char(), helper_parse_char(), and parse_header_entry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ helper_parse_setup()

int helper_parse_setup ( char * string,
char *** output,
int * length,
... )
Parameters
stringThe input string.
outputPointer to 2 dimensional array with parsed string.
lengthLength of 2 dimensional array.
...Key, value parse. Replaces the string Key with value.

Parses a string into arguments. While replacing keys with values.

Returns
TRUE when successful, FALSE when failed.

Definition at line 102 of file helper.c.

References config, helper_parse_setup(), helper_string_replace_if_exists_v(), rofi_view_error_dialog(), Settings::ssh_client, and Settings::terminal_emulator.

Referenced by execshssh(), execute_generator(), helper_execute_command_env(), helper_parse_setup(), rofi_error_user_callback(), rofi_icon_fetcher_worker(), rofi_quit_user_callback(), screenshot_taken_user_callback(), and selection_changed_user_callback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ helper_select_next_matching_mode()

void helper_select_next_matching_mode ( void )

Switch to the next matching method.

Definition at line 83 of file helper.c.

References config, CurrentMatchingMethod, helper_select_next_matching_mode(), Settings::matching_method, MatchingMethodEnabled, and NUMMatchingMethodEnabled.

Referenced by helper_get_theme_path(), helper_select_next_matching_mode(), and rofi_view_trigger_global_action().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ helper_select_previous_matching_mode()

void helper_select_previous_matching_mode ( void )

Switch to the previous matching method.

Definition at line 89 of file helper.c.

References config, CurrentMatchingMethod, helper_select_previous_matching_mode(), Settings::matching_method, MatchingMethodEnabled, and NUMMatchingMethodEnabled.

Referenced by helper_get_theme_path(), helper_select_previous_matching_mode(), and rofi_view_trigger_global_action().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ helper_string_replace_if_exists()

char * helper_string_replace_if_exists ( char * string,
... )
Parameters
stringThe 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.

Returns
a new string with the keys replaced.

Definition at line 1794 of file helper.c.

References helper_string_replace_if_exists(), and helper_string_replace_if_exists_v().

Referenced by cairo_image_surface_create_from_svg(), combi_mgrv(), and helper_string_replace_if_exists().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ helper_token_match()

int helper_token_match ( rofi_int_matcher *const * tokens,
const char * input )
Parameters
tokensList of (input) tokens to match.
inputThe entry to match against.

Tokenized match, match tokens to line input.

Returns
TRUE when matches, FALSE otherwise

Definition at line 541 of file helper.c.

References config, helper_token_match(), Settings::normalize_match, and utf8_helper_simplify_string().

Referenced by dmenu_mode_dialog(), dmenu_token_match(), file_browser_token_match(), help_keys_token_match(), helper_token_match(), recursive_browser_token_match(), run_token_match(), script_token_match(), and ssh_token_match().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ helper_tokenize()

rofi_int_matcher ** helper_tokenize ( const char * input,
int case_sensitive )
Parameters
inputThe input string.
case_sensitiveWhether case is significant.

Tokenize the string on spaces.

Returns
a newly allocated array of matching objects

Definition at line 286 of file helper.c.

References config, create_regex(), helper_tokenize(), and Settings::tokenize.

Referenced by dmenu_mode_dialog(), helper_tokenize(), and rofi_view_refilter_real().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ helper_tokenize_free()

void helper_tokenize_free ( rofi_int_matcher ** tokens)
Parameters
tokensArray of regex objects

Frees the array of matching objects.

Definition at line 146 of file helper.c.

References helper_tokenize_free().

Referenced by dmenu_mode_dialog(), helper_tokenize_free(), rofi_view_free(), and rofi_view_refilter_real().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ levenshtein()

unsigned int levenshtein ( const char * needle,
const glong needlelen,
const char * haystack,
const glong haystacklen,
const int case_sensitive )
Parameters
needleThe string to find match weight off
needlelenThe length of the needle
haystackThe string to match against
haystacklenThe length of the haystack
case_sensitiveWhether case is significant.

UTF-8 aware levenshtein distance calculation

Returns
the levenshtein distance between needle and haystack

Definition at line 819 of file helper.c.

References levenshtein(), and MIN3.

Referenced by filter_elements(), and levenshtein().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_case_sensitivity()

int parse_case_sensitivity ( const char * input)
Parameters
inputString to parse
Returns
String matching should be case sensitive or insensitive

Definition at line 1687 of file helper.c.

References Settings::case_sensitive, Settings::case_smart, config, and parse_case_sensitivity().

Referenced by cairo_image_surface_create_from_svg(), dmenu_mode_dialog(), parse_case_sensitivity(), and rofi_view_refilter_real().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_ranges()

void parse_ranges ( char * input,
rofi_range_pair ** list,
unsigned int * length )

Ranges.

Parameters
inputString to parse
listList of ranges
lengthLength of list.

ranges

Definition at line 1669 of file helper.c.

References parse_pair(), and parse_ranges().

Referenced by cairo_image_surface_create_from_svg(), dmenu_mode_init(), parse_header_entry(), and parse_ranges().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove_pid_file()

void remove_pid_file ( int fd)

Remove pid file

Definition at line 644 of file helper.c.

References remove_pid_file().

Referenced by create_pid_file(), remove_pid_file(), and teardown().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rofi_config_find_widget()

char ConfigEntry * rofi_config_find_widget ( const char * name,
const char * state,
gboolean exact )
Parameters
nameThe name of the element to find.
stateThe state of the element.
exactIf the match should be exact, or parent can be included.

Find the configuration element. If not exact, the closest specified element is returned.

Returns
the ThemeWidget if found, otherwise NULL.

Definition at line 782 of file theme.c.

References rofi_config_find_widget(), rofi_configuration, rofi_theme_find(), and rofi_theme_find_single().

Referenced by combi_mgrv(), file_browser_mode_init_config(), file_browser_mode_init_current_dir(), file_browser_mode_result(), helper_get_theme_path(), input_history_save(), mode_get_display_name(), mode_get_icon(), recursive_browser_mode_init_config(), recursive_browser_mode_init_current_dir(), recursive_browser_mode_result(), rofi_config_find_widget(), rofi_view_set_user_timeout(), and rofi_view_take_action().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rofi_expand_path()

char * rofi_expand_path ( const char * input)
Parameters
inputThe path to expand

Expand path, both ~ and ~<user>

Returns
path

Definition at line 784 of file helper.c.

References rofi_expand_path().

Referenced by dmenu_mode_init(), file_browser_mode_completer(), file_browser_mode_result(), get_apps(), get_ssh(), helper_get_theme_path(), main(), parse_ssh_config_file(), rofi_expand_path(), script_mode_parse_setup(), and xcb_rofi_view_setup_fake_transparency().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rofi_force_utf8()

char * rofi_force_utf8 ( const gchar * data,
ssize_t length )
Parameters
datathe unvalidated character array holding possible UTF-8 data
lengththe length of the data array

Convert string to valid utf-8, replacing invalid parts with replacement character.

Returns
the converted UTF-8 string

Definition at line 862 of file helper.c.

References rofi_force_utf8().

Referenced by clipboard_read_glib_callback(), execute_executor(), get_file_browser(), read_add(), read_add_block(), rofi_force_utf8(), scan_dir(), and window_get_text_prop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rofi_latin_to_utf8_strdup()

char * rofi_latin_to_utf8_strdup ( const char * input,
gssize length )
Parameters
inputthe char array holding latin text
lengththe length of the data array

Converts latin to UTF-8.

Returns
the UTF-8 representation of data

Definition at line 856 of file helper.c.

References rofi_latin_to_utf8_strdup().

Referenced by rofi_latin_to_utf8_strdup(), and window_get_text_prop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rofi_output_formatted_line()

void rofi_output_formatted_line ( const char * format,
const char * string,
int selected_line,
const char * filter )
Parameters
formatThe format string used. See below for possible syntax.
stringThe selected entry.
selected_lineThe selected line index.
filterThe entered filter.

Function that outputs the selected line in the user-specified format. Currently the following formats are supported:

  • i: Print the index (0-(N-1))
  • d: Print the index (1-N)
  • s: Print input string.
  • q: Print quoted input string.
  • f: Print the entered filter.
  • F: Print the entered filter, quoted

This functions outputs the formatted string to stdout, appends a newline (
) character and calls flush on the file descriptor.

Definition at line 1708 of file helper.c.

References rofi_output_formatted_line().

Referenced by cairo_image_surface_create_from_svg(), dmenu_mode_dialog(), dmenu_print_results(), and rofi_output_formatted_line().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rofi_scorer_fuzzy_evaluate()

int rofi_scorer_fuzzy_evaluate ( const char * pattern,
glong plen,
const char * str,
glong slen,
const int case_sensitive )
Parameters
patternThe user input to match against.
plenPattern length.
strThe input to match against pattern.
slenLength of str.
case_sensitiveWhether case is significant.

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

  • Prefer matches at the start of a word, or the start of subwords in CamelCase/camelCase/camel123 words. See WORD_START_SCORE/CAMEL_SCORE.
  • Non-word characters matter. See NON_WORD_SCORE.
  • The first characters of words of pattern receive bonus because they usually have more significance than the rest. See PATTERN_START_MULTIPLIER/PATTERN_NON_START_MULTIPLIER.
  • Superfluous characters in str will reduce the score (gap penalty). See GAP_SCORE.
  • Prefer early occurrence of the first character. See LEADING_GAP_SCORE/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)

Returns
the sorting weight.

Definition at line 971 of file helper.c.

References CONSECUTIVE_SCORE, FUZZY_SCORER_MAX_LENGTH, GAP_SCORE, LEADING_GAP_SCORE, MIN_SCORE, NON_WORD, PATTERN_NON_START_MULTIPLIER, PATTERN_START_MULTIPLIER, rofi_scorer_fuzzy_evaluate(), rofi_scorer_get_character_class(), and rofi_scorer_get_score_for().

Referenced by filter_elements(), and rofi_scorer_fuzzy_evaluate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rofi_scorer_fzf_v2_evaluate()

int rofi_scorer_fzf_v2_evaluate ( const char * pattern,
glong plen,
const char * str,
glong slen,
int case_sensitive )
Parameters
patternThe user input to match against.
plenPattern length.
strThe input to match against pattern.
slenLength of str.
case_sensitiveWhether case is significant.

rofi_scorer_fzf_v2_evaluate is a port of fzf's default fuzzy scoring algorithm (FuzzyMatchV2 from junegunn/fzf). Unlike rofi_scorer_fuzzy_evaluate, it aims to match fzf's ranking: it rewards contiguous matches and word-boundary/camelCase starts with fzf's own weights and gap penalties, without penalising how deep in the string the match begins.

Whitespace-separated terms in pattern are treated as independent AND conditions: each term is scored separately against str and the scores are summed, exactly like fzf. A line matches only if every term matches.

A higher return value is a better match. FZF_V2_MIN_SCORE is returned when any term is not a subsequence of str.

Returns
the fzf match score (higher is better).

Definition at line 1274 of file helper.c.

References config, FUZZY_SCORER_MAX_LENGTH, FZF_V2_CHAR_WHITE, FZF_V2_MIN_SCORE, Settings::normalize_match, rofi_scorer_fzf_v2_bonus_for(), rofi_scorer_fzf_v2_char_class(), rofi_scorer_fzf_v2_evaluate(), rofi_scorer_fzf_v2_term(), and utf8_helper_simplify_string().

Referenced by filter_elements(), and rofi_scorer_fzf_v2_evaluate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rofi_scorer_fzf_v2_sort_key()

int rofi_scorer_fzf_v2_sort_key ( int score,
const char * str )
Parameters
scoreA score as returned by rofi_scorer_fzf_v2_evaluate.
strThe string that was scored.

Builds the key fzf orders results by, so rows with equal scores break the way fzf breaks them: on length, ignoring surrounding whitespace. Rows equal on both compare equal here, leaving the caller to break them on the input position.

Only meaningful for scores from rofi_scorer_fzf_v2_evaluate. The key is between 0 and G_MAXINT, so differences between keys do not overflow.

Returns
the sort key (lower is better).

Definition at line 1374 of file helper.c.

References rofi_scorer_fzf_v2_as_uint16(), rofi_scorer_fzf_v2_sort_key(), and rofi_scorer_fzf_v2_trim_length().

Referenced by filter_elements(), and rofi_scorer_fzf_v2_sort_key().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rofi_theme_find_property()

Property * rofi_theme_find_property ( ConfigEntry * widget,
PropertyType type,
const char * property,
gboolean exact )
Parameters
widgetThe widget to find the property on.
typeThe PropertyType to find.
propertyThe property to find.
exactIf the property should only be found on this widget, or on parents if not found.

Find the property on the widget. If not exact, the parents are searched recursively until match is found.

Returns
the Property if found, otherwise NULL.

Definition at line 745 of file theme.c.

References _PropertyValue::link, ThemeWidget::name, P_INHERIT, P_INTEGER, P_LINK, P_PADDING, ThemeWidget::parent, ThemeWidget::properties, PropertyTypeName, rofi_theme_find_property(), rofi_theme_resolve_link_property(), Property::type, and Property::value.

Referenced by combi_mgrv(), file_browser_mode_init_config(), file_browser_mode_init_current_dir(), file_browser_mode_result(), helper_get_theme_path(), input_history_save(), mode_get_display_name(), mode_get_icon(), recursive_browser_mode_init_config(), recursive_browser_mode_init_current_dir(), recursive_browser_mode_result(), rofi_theme_find_property(), rofi_theme_get_boolean(), rofi_theme_get_boolean_inside(), rofi_theme_get_color(), rofi_theme_get_color_inside(), rofi_theme_get_cursor_type(), rofi_theme_get_cursor_type_inside(), rofi_theme_get_distance(), rofi_theme_get_distance_inside(), rofi_theme_get_double(), rofi_theme_get_double_inside(), rofi_theme_get_double_integer_fb_inside(), rofi_theme_get_highlight(), rofi_theme_get_highlight_inside(), rofi_theme_get_image(), rofi_theme_get_image_inside(), rofi_theme_get_integer(), rofi_theme_get_integer_inside(), rofi_theme_get_list_distance(), rofi_theme_get_list_inside(), rofi_theme_get_list_strings(), rofi_theme_get_orientation(), rofi_theme_get_orientation_inside(), rofi_theme_get_padding(), rofi_theme_get_padding_inside(), rofi_theme_get_position(), rofi_theme_get_position_inside(), rofi_theme_get_string(), rofi_theme_get_string_inside(), rofi_theme_has_property(), rofi_theme_has_property_inside(), rofi_view_set_user_timeout(), and rofi_view_take_action().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ utf8_strncmp()

int utf8_strncmp ( const char * a,
const char * b,
size_t n )
Parameters
aUTF-8 string to compare
bUTF-8 string to compare
nMaximum number of characters to compare

Compares the G_NORMALIZE_ALL_COMPOSE forms of the two strings.

Returns
less than, equal to, or greater than zero if the first 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.

References utf8_strncmp().

Here is the call graph for this function: