|
rofi 2.1.0
|
#include "config.h"#include "display.h"#include "helper-theme.h"#include "helper.h"#include "rofi.h"#include "settings.h"#include "view.h"#include <ctype.h>#include <errno.h>#include <fcntl.h>#include <glib.h>#include <glib/gstdio.h>#include <limits.h>#include <pango/pango-fontmap.h>#include <pango/pango.h>#include <pango/pangocairo.h>#include <pwd.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/file.h>#include <sys/stat.h>#include <sys/types.h>#include <unistd.h>
Go to the source code of this file.
Macros | |
| #define | G_LOG_DOMAIN "Helper" |
| #define | MIN3(a, 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 |
| #define | FZF_V2_SCORE_MATCH 16 |
| #define | FZF_V2_SCORE_GAP_START (-3) |
| #define | FZF_V2_SCORE_GAP_EXTENSION (-1) |
| #define | FZF_V2_BONUS_BOUNDARY 8 |
| #define | FZF_V2_BONUS_NON_WORD 8 |
| #define | FZF_V2_BONUS_CAMEL_123 (FZF_V2_BONUS_BOUNDARY + FZF_V2_SCORE_GAP_EXTENSION) |
| #define | FZF_V2_BONUS_CONSECUTIVE (-(FZF_V2_SCORE_GAP_START + FZF_V2_SCORE_GAP_EXTENSION)) |
| #define | FZF_V2_BONUS_FIRST_CHAR_MULTIPLIER 2 |
| #define | FZF_V2_BONUS_BOUNDARY_WHITE (FZF_V2_BONUS_BOUNDARY + 2) |
| #define | FZF_V2_BONUS_BOUNDARY_DELIMITER (FZF_V2_BONUS_BOUNDARY + 1) |
| #define | FZF_V2_MIN_SCORE (G_MININT / 2) |
Enumerations | |
| enum | CharClass { LOWER , UPPER , DIGIT , NON_WORD } |
| enum | FzfV2CharClass { FZF_V2_CHAR_WHITE = 0 , FZF_V2_CHAR_NON_WORD , FZF_V2_CHAR_DELIMITER , FZF_V2_CHAR_LOWER , FZF_V2_CHAR_UPPER , FZF_V2_CHAR_LETTER , FZF_V2_CHAR_NUMBER } |
Functions | |
| char * | helper_string_replace_if_exists_v (char *string, GHashTable *h) |
| const char * | helper_get_matching_mode_str (void) |
| void | helper_select_next_matching_mode (void) |
| void | helper_select_previous_matching_mode (void) |
| void | cmd_set_arguments (int argc, char **argv) |
| 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 gchar * | prefix_regex (const char *input) |
| static char * | utf8_helper_simplify_string (const char *os) |
| 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) |
| void | helper_token_match_set_pango_attr_on_style (PangoAttrList *retv, int start, int end, RofiHighlightColorStyle th) |
| 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, gboolean kill_running) |
| 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, int case_sensitive) |
| char * | rofi_latin_to_utf8_strdup (const char *input, gssize length) |
| 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 case_sensitive) |
| static enum FzfV2CharClass | rofi_scorer_fzf_v2_char_class (gunichar c) |
| static int | rofi_scorer_fzf_v2_bonus_for (enum FzfV2CharClass prev, enum FzfV2CharClass cur) |
| static int | rofi_scorer_fzf_v2_term (const gunichar *pat, glong M, const gunichar *tmatch, const int *B, glong N, int case_sensitive) |
| int | rofi_scorer_fzf_v2_evaluate (const char *pattern, glong plen, const char *str, glong slen, int case_sensitive) |
| static guint16 | rofi_scorer_fzf_v2_as_uint16 (int val) |
| static guint16 | rofi_scorer_fzf_v2_trim_length (const char *str) |
| int | rofi_scorer_fzf_v2_sort_key (int score, const char *str) |
| 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_env (const char *wd, char **args, const char *error_precmd, const char *error_cmd, RofiHelperExecuteContext *context, gchar **envp) |
| 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) |
| static char * | helper_get_theme_path_check_file (const char *filename, const char *parent_file) |
| char * | helper_get_theme_path (const char *file, const char **ext, const char *parent_file) |
| static gboolean | parse_pair (char *input, rofi_range_pair *item) |
| 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) |
| static gboolean | helper_eval_cb2 (const GMatchInfo *info, GString *res, gpointer data) |
| char * | helper_string_replace_if_exists (char *string,...) |
Variables | |
| const char *const | MatchingMethodStr [MM_NUM_MATCHERS] |
| static int | MatchingMethodEnabled [MM_NUM_MATCHERS] |
| static int | NUMMatchingMethodEnabled = 1 |
| static int | CurrentMatchingMethod = 0 |
| const char *const | monitor_position_entries [] |
| int | stored_argc = 0 |
| 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 912 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 898 of file helper.c.
Referenced by rofi_scorer_fuzzy_evaluate(), and rofi_scorer_fzf_v2_evaluate().
| #define FZF_V2_BONUS_BOUNDARY 8 |
Bonus for a match at a word boundary.
Definition at line 1060 of file helper.c.
Referenced by rofi_scorer_fzf_v2_bonus_for(), and rofi_scorer_fzf_v2_term().
| #define FZF_V2_BONUS_BOUNDARY_DELIMITER (FZF_V2_BONUS_BOUNDARY + 1) |
Bonus for a boundary right after a delimiter character.
Definition at line 1074 of file helper.c.
Referenced by rofi_scorer_fzf_v2_bonus_for().
| #define FZF_V2_BONUS_BOUNDARY_WHITE (FZF_V2_BONUS_BOUNDARY + 2) |
Bonus for a boundary right after whitespace.
Definition at line 1072 of file helper.c.
Referenced by rofi_scorer_fzf_v2_bonus_for().
| #define FZF_V2_BONUS_CAMEL_123 (FZF_V2_BONUS_BOUNDARY + FZF_V2_SCORE_GAP_EXTENSION) |
Bonus for a camelCase / letter-to-digit boundary.
Definition at line 1064 of file helper.c.
Referenced by rofi_scorer_fzf_v2_bonus_for().
| #define FZF_V2_BONUS_CONSECUTIVE (-(FZF_V2_SCORE_GAP_START + FZF_V2_SCORE_GAP_EXTENSION)) |
Bonus for a consecutive match.
Definition at line 1067 of file helper.c.
Referenced by rofi_scorer_fzf_v2_term().
| #define FZF_V2_BONUS_FIRST_CHAR_MULTIPLIER 2 |
Multiplier applied to the bonus of the first matched character.
Definition at line 1070 of file helper.c.
Referenced by rofi_scorer_fzf_v2_term().
| #define FZF_V2_BONUS_NON_WORD 8 |
Bonus for a match on a non-word character.
Definition at line 1062 of file helper.c.
Referenced by rofi_scorer_fzf_v2_bonus_for().
| #define FZF_V2_MIN_SCORE (G_MININT / 2) |
Returned for a non-match (pattern is not a subsequence).
Definition at line 1076 of file helper.c.
Referenced by rofi_scorer_fzf_v2_evaluate(), and rofi_scorer_fzf_v2_term().
| #define FZF_V2_SCORE_GAP_EXTENSION (-1) |
Penalty for extending a gap.
Definition at line 1058 of file helper.c.
Referenced by rofi_scorer_fzf_v2_term().
| #define FZF_V2_SCORE_GAP_START (-3) |
Penalty for opening a gap.
Definition at line 1056 of file helper.c.
Referenced by rofi_scorer_fzf_v2_term().
| #define FZF_V2_SCORE_MATCH 16 |
Score for a matched character.
Definition at line 1054 of file helper.c.
Referenced by rofi_scorer_fzf_v2_term().
| #define G_LOG_DOMAIN "Helper" |
| #define GAP_SCORE -5 |
| #define LEADING_GAP_SCORE -4 |
Leading gap score
Definition at line 902 of file helper.c.
Referenced by rofi_scorer_fuzzy_evaluate().
| #define MIN3 | ( | a, | |
| b, | |||
| c ) |
Return the minimum value of a,b,c
Definition at line 816 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 914 of file helper.c.
Referenced by rofi_scorer_fuzzy_evaluate().
| #define PATTERN_START_MULTIPLIER 2 |
start multiplier
Definition at line 916 of file helper.c.
Referenced by rofi_scorer_fuzzy_evaluate().
| #define WORD_START_SCORE 50 |
start of word score
Definition at line 906 of file helper.c.
Referenced by rofi_scorer_get_score_for().
| enum CharClass |
| enum FzfV2CharClass |
|
static |
Definition at line 245 of file helper.c.
References config, fuzzy_to_regex(), glob_to_regex(), rofi_int_matcher_t::invert, MM_FUZZY, MM_GLOB, MM_PREFIX, MM_REGEX, prefix_regex(), R(), and rofi_int_matcher_t::regex.
Referenced by helper_tokenize().


|
static |
Definition at line 169 of file helper.c.
Referenced by create_regex().

|
static |
Definition at line 154 of file helper.c.
Referenced by create_regex().

|
static |
Definition at line 1748 of file helper.c.
Referenced by helper_string_replace_if_exists_v().

| char * helper_get_theme_path | ( | const char * | file, |
| const char ** | ext, | ||
| const char * | parent_file ) |
Definition at line 1590 of file helper.c.
References helper_get_theme_path_check_file(), and rofi_expand_path().
Referenced by main(), and rofi_icon_fetcher_worker().


|
static |
Definition at line 1504 of file helper.c.
Referenced by helper_get_theme_path().

| char * helper_string_replace_if_exists_v | ( | char * | string, |
| GHashTable * | h ) |
| string | The string with elements to be replaced |
| h | Hash table with 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 1829 of file helper.c.
References helper_eval_cb2(), and rofi_view_error_dialog().
Referenced by helper_parse_setup(), and helper_string_replace_if_exists().


|
static |
Definition at line 1635 of file helper.c.
References rofi_range_pair::start, and rofi_range_pair::stop.
Referenced by parse_ranges().

|
static |
Definition at line 198 of file helper.c.
Referenced by create_regex().

|
inlinestatic |
Definition at line 230 of file helper.c.
References config, and utf8_helper_simplify_string().
Referenced by create_regex().


|
static |
fzf's util.AsUint16.
Definition at line 1347 of file helper.c.
Referenced by rofi_scorer_fzf_v2_sort_key(), and rofi_scorer_fzf_v2_trim_length().

|
static |
Definition at line 1112 of file helper.c.
References FZF_V2_BONUS_BOUNDARY, FZF_V2_BONUS_BOUNDARY_DELIMITER, FZF_V2_BONUS_BOUNDARY_WHITE, FZF_V2_BONUS_CAMEL_123, FZF_V2_BONUS_NON_WORD, FZF_V2_CHAR_DELIMITER, FZF_V2_CHAR_LOWER, FZF_V2_CHAR_NON_WORD, FZF_V2_CHAR_NUMBER, FZF_V2_CHAR_UPPER, and FZF_V2_CHAR_WHITE.
Referenced by rofi_scorer_fzf_v2_evaluate().

|
static |
Definition at line 1089 of file helper.c.
References FZF_V2_CHAR_DELIMITER, FZF_V2_CHAR_LETTER, FZF_V2_CHAR_LOWER, FZF_V2_CHAR_NON_WORD, FZF_V2_CHAR_NUMBER, FZF_V2_CHAR_UPPER, and FZF_V2_CHAR_WHITE.
Referenced by rofi_scorer_fzf_v2_evaluate().

|
static |
Score a single term (no embedded whitespace) against pre-decoded text.
| pat | The term as UTF-32 code points. |
| M | Term length. |
| tmatch | Text code points, already case-folded when !case_sensitive. |
| B | Per-position character bonus for the text (text-only, so it is computed once and reused for every term). |
| N | Text length. |
| case_sensitive | Whether case is significant. |
Definition at line 1156 of file helper.c.
References FZF_V2_BONUS_BOUNDARY, FZF_V2_BONUS_CONSECUTIVE, FZF_V2_BONUS_FIRST_CHAR_MULTIPLIER, FZF_V2_MIN_SCORE, FZF_V2_SCORE_GAP_EXTENSION, FZF_V2_SCORE_GAP_START, and FZF_V2_SCORE_MATCH.
Referenced by rofi_scorer_fzf_v2_evaluate().

|
static |
Code points in str ignoring surrounding whitespace; fzf's TrimLength().
Definition at line 1358 of file helper.c.
References rofi_scorer_fzf_v2_as_uint16().
Referenced by rofi_scorer_fzf_v2_sort_key().


|
static |
| prev | The previous character. |
| curr | The current character |
Scrore the transition.
Definition at line 958 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().

|
static |
Definition at line 205 of file helper.c.
Referenced by helper_token_match(), R(), and rofi_scorer_fzf_v2_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 1401 of file helper.c.
Referenced by combi_mode_result(), and combi_preprocess_input().

|
static |
Definition at line 65 of file helper.c.
Referenced by helper_select_next_matching_mode(), and helper_select_previous_matching_mode().
|
static |
Definition at line 60 of file helper.c.
Referenced by config_sanity_check(), helper_select_next_matching_mode(), and helper_select_previous_matching_mode().
| const char* const MatchingMethodStr[MM_NUM_MATCHERS] |
Definition at line 57 of file helper.c.
Referenced by config_sanity_check(), and helper_get_matching_mode_str().
| const char* const monitor_position_entries[] |
Textual description of positioning rofi.
Definition at line 70 of file helper.c.
Referenced by config_sanity_check().
|
static |
Definition at line 64 of file helper.c.
Referenced by config_sanity_check(), helper_select_next_matching_mode(), and helper_select_previous_matching_mode().
| int stored_argc = 0 |
copy of the argc for use in commandline argument parser.
Definition at line 74 of file helper.c.
Referenced by cmd_set_arguments(), config_parse_cmd_options(), find_arg(), find_arg_char(), find_arg_int(), find_arg_str(), find_arg_strv(), and find_arg_uint().
| char** stored_argv = NULL |
copy of the argv pointer for use in the commandline argument parser
Definition at line 76 of file helper.c.
Referenced by cmd_set_arguments(), config_parse_cmd_options(), find_arg(), find_arg_char(), find_arg_int(), find_arg_str(), find_arg_strv(), and find_arg_uint().