diff options
author | Dave Davenport <qball@blame.services> | 2021-08-18 01:16:45 +0200 |
---|---|---|
committer | Dave Davenport <qball@blame.services> | 2021-08-18 01:16:45 +0200 |
commit | 954fc728b29d3c63a09a84870f29b57640062966 (patch) | |
tree | b9b09c132bc1b9b92632e34b1f29c5e0adab1001 | |
parent | 3a1b768bf4d387b3a37ceb94d295dfbad9179f91 (diff) |
[Cleanup] Using clang-tidy
41 files changed, 13468 insertions, 13303 deletions
diff --git a/include/css-colors.h b/include/css-colors.h index e442c6aa..b357a65c 100644 --- a/include/css-colors.h +++ b/include/css-colors.h @@ -1,6 +1,7 @@ #ifndef ROFI_INCLUDE_CSS_COLORS_H #define ROFI_INCLUDE_CSS_COLORS_H +#include <stdint.h> /** * @defgroup CSSCOLORS CssColors * @ingroup HELPERS @@ -13,16 +14,16 @@ /** * Structure of colors. */ -typedef struct CSSColor -{ - /** CSS name of the color. */ - char *name; - /** BGRA 8 bit color components. */ - uint8_t b, g, r, a; -}CSSColor; +typedef struct CSSColor { + /** CSS name of the color. */ + char *name; + /** BGRA 8 bit color components. */ + uint8_t b, g, r, a; +} CSSColor; /** - * Array with all the named colors. Of type #CSSColor, there are #num_CSSColors items in this array. + * Array with all the named colors. Of type #CSSColor, there are #num_CSSColors + * items in this array. */ extern const CSSColor CSSColors[]; /** diff --git a/include/dialogs/drun.h b/include/dialogs/drun.h index be6e0afa..c74a2673 100644 --- a/include/dialogs/drun.h +++ b/include/dialogs/drun.h @@ -28,12 +28,13 @@ #ifndef ROFI_DIALOG_DRUN_H #define ROFI_DIALOG_DRUN_H +#include "mode.h" + /** * @defgroup DRUNMode DRun * @ingroup MODES * @{ */ -#include <config.h> #ifdef ENABLE_DRUN /** #Mode object representing the desktop menu run dialog. */ extern Mode drun_mode; diff --git a/include/dialogs/filebrowser.h b/include/dialogs/filebrowser.h index aa77cd32..1e9c0fd6 100644 --- a/include/dialogs/filebrowser.h +++ b/include/dialogs/filebrowser.h @@ -27,7 +27,7 @@ #ifndef ROFI_DIALOG_FILE_BROWSER_H #define ROFI_DIALOG_FILE_BROWSER_H - +#include "mode.h" /** * @defgroup FileBrowserMode FileBrowser * @ingroup MODES @@ -42,7 +42,7 @@ extern Mode file_browser_mode; * Create a new filebrowser. * @returns a new filebrowser structure. */ -Mode *create_new_file_browser ( void ); +Mode *create_new_file_browser(void); /** * @param sw Mode object. * @param mretv return value passed in. @@ -52,6 +52,7 @@ Mode *create_new_file_browser ( void ); * * @returns the state the user selected. */ -ModeMode file_browser_mode_completer ( Mode *sw, int mretv, char **input, unsigned int selected_line, char **path ); +ModeMode file_browser_mode_completer(Mode *sw, int mretv, char **input, + unsigned int selected_line, char **path); /**@}*/ #endif // ROFI_DIALOG_FILE_BROWSER_H diff --git a/include/dialogs/help-keys.h b/include/dialogs/help-keys.h index 062a4278..64f0c0b2 100644 --- a/include/dialogs/help-keys.h +++ b/include/dialogs/help-keys.h @@ -28,6 +28,7 @@ #ifndef ROFI_DIALOG_HELPKEYS_H #define ROFI_DIALOG_HELPKEYS_H +#include "mode.h" /** * @defgroup HELPKEYSMode KeysHelp * @ingroup MODES diff --git a/include/dialogs/script.h b/include/dialogs/script.h index c1d1b8d4..090139d6 100644 --- a/include/dialogs/script.h +++ b/include/dialogs/script.h @@ -28,6 +28,8 @@ #ifndef ROFI_DIALOG_SCRIPT_H #define ROFI_DIALOG_SCRIPT_H +#include "mode.h" + /** * @defgroup SCRIPTMode Script * @ingroup MODES @@ -42,7 +44,7 @@ * * @returns NULL when it fails, a newly allocated ScriptOptions when successful. */ -Mode *script_switcher_parse_setup ( const char *str ); +Mode *script_switcher_parse_setup(const char *str); /** * @param token The modi str to check @@ -51,6 +53,6 @@ Mode *script_switcher_parse_setup ( const char *str ); * * @returns true when valid. */ -gboolean script_switcher_is_valid ( const char *token ); +gboolean script_switcher_is_valid(const char *token); /**@}*/ #endif // ROFI_DIALOG_SCRIPT_H diff --git a/include/dialogs/ssh.h b/include/dialogs/ssh.h index 9f72797a..ab95022b 100644 --- a/include/dialogs/ssh.h +++ b/include/dialogs/ssh.h @@ -27,7 +27,7 @@ #ifndef ROFI_DIALOG_SSH_H #define ROFI_DIALOG_SSH_H - +#include "mode.h" /** * @defgroup SSHMode SSH * @ingroup MODES diff --git a/include/dialogs/window.h b/include/dialogs/window.h index 4f0e0526..c25c1368 100644 --- a/include/dialogs/window.h +++ b/include/dialogs/window.h @@ -28,13 +28,14 @@ #ifndef ROFI_DIALOG_WINDOW_H #define ROFI_DIALOG_WINDOW_H +#include "mode.h" + /** * @defgroup WINDOWMode Window * @ingroup MODES * * @{ */ -#include <config.h> #ifdef WINDOW_MODE extern Mode window_mode; diff --git a/include/display.h b/include/display.h index 1972d48f..12c9eb09 100644 --- a/include/display.h +++ b/include/display.h @@ -28,9 +28,9 @@ #ifndef ROFI_DISPLAY_H #define ROFI_DISPLAY_H -#include <glib.h> #include "helper.h" #include "nkutils-bindings.h" +#include <glib.h> /** * @param main_loop The GMainLoop @@ -40,29 +40,29 @@ * * @returns Whether the setup succeeded or not */ -gboolean display_setup ( GMainLoop *main_loop, NkBindings *bindings ); +gboolean display_setup(GMainLoop *main_loop, NkBindings *bindings); /** * Do some late setup of the display backend * * @returns Whether the setup succeeded or not */ -gboolean display_late_setup ( void ); +gboolean display_late_setup(void); /** * Do some early cleanup, like unmapping the surface */ -void display_early_cleanup ( void ); +void display_early_cleanup(void); /** * Cleanup any remaining display related stuff */ -void display_cleanup ( void ); +void display_cleanup(void); /** * Dumps the display layout for -help output */ -void display_dump_monitor_layout ( void ); +void display_dump_monitor_layout(void); /** * @param context The startup notification context for the application to launch @@ -71,6 +71,8 @@ void display_dump_monitor_layout ( void ); * * Provides the needed child setup function */ -void display_startup_notification ( RofiHelperExecuteContext *context, GSpawnChildSetupFunc *child_setup, gpointer *user_data ); +void display_startup_notification(RofiHelperExecuteContext *context, + GSpawnChildSetupFunc *child_setup, + gpointer *user_data); #endif diff --git a/include/helper.h b/include/helper.h index 6204776a..6de3c74c 100644 --- a/include/helper.h +++ b/include/helper.h @@ -27,8 +27,8 @@ #ifndef ROFI_HELPER_H #define ROFI_HELPER_H -#include <cairo.h> #include "rofi-types.h" +#include <cairo.h> G_BEGIN_DECLS /** @@ -51,7 +51,7 @@ G_BEGIN_DECLS * * @returns TRUE when successful, FALSE when failed. */ -int helper_parse_setup ( char * string, char ***output, int *length, ... ); +int helper_parse_setup(char *string, char ***output, int *length, ...); /** * @param input The input string. @@ -61,14 +61,14 @@ int helper_parse_setup ( char * string, char ***output, int *length, ... ); * * @returns a newly allocated array of matching objects */ -rofi_int_matcher **helper_tokenize ( const char *input, int case_sensitive ); +rofi_int_matcher **helper_tokenize(const char *input, int case_sensitive); /** * @param tokens Array of regex objects * * Frees the array of matching objects. */ -void helper_tokenize_free ( rofi_int_matcher ** tokens ); +void helper_tokenize_free(rofi_int_matcher **tokens); /** * @param key The key to search for @@ -79,7 +79,7 @@ void helper_tokenize_free ( rofi_int_matcher ** tokens ); * * @returns TRUE if key was found and val was set. */ -int find_arg_char ( const char * const key, char *val ); +int find_arg_char(const char *const key, char *val); /** * @param key The key to search for @@ -89,7 +89,7 @@ int find_arg_char ( const char * const key, char *val ); * * @returns TRUE if key was found and val was set. */ -int find_arg_uint ( const char * const key, unsigned int *val ); +int find_arg_uint(const char *const key, unsigned int *val); /** * @param key The key to search for @@ -99,7 +99,7 @@ int find_arg_uint ( const char * const key, unsigned int *val ); * * @returns TRUE if key was found and val was set. */ -int find_arg_int ( const char * const key, int *val ); +int find_arg_int(const char *const key, int *val); /** * @param key The key to search for @@ -109,7 +109,7 @@ int find_arg_int ( const char * const key, int *val ); * * @returns TRUE if key was found and val was set. */ -int find_arg_str ( const char * const key, char** val ); +int find_arg_str(const char *const key, char **val); /** * @param key The key to search for @@ -118,7 +118,7 @@ int find_arg_str ( const char * const key, char** val ); * * @returns str vector. user should free array. */ -const char ** find_arg_strv ( const char *const key ); +const char **find_arg_strv(const char *const key); /** * @param key The key to search for * @@ -126,7 +126,7 @@ const char ** find_arg_strv ( const char *const key ); * * @returns return position of string or -1 if not found. */ -int find_arg ( const char * const key ); +int find_arg(const char *const key); /** * @param tokens List of (input) tokens to match. @@ -136,36 +136,37 @@ int find_arg ( const char * const key ); * * @returns TRUE when matches, FALSE otherwise */ -int helper_token_match ( rofi_int_matcher * const *tokens, const char *input ); +int helper_token_match(rofi_int_matcher *const *tokens, const char *input); /** * @param cmd The command to execute. * - * Execute cmd using config.run_command and outputs the result (stdout) to the opened file - * descriptor. + * 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. */ -int execute_generator ( const char * cmd ) __attribute__( ( nonnull ) ); +int execute_generator(const char *cmd) __attribute__((nonnull)); /** * @param pidfile The pidfile to create. * * returns file descriptor (or -1 when failed) */ -int create_pid_file ( const char *pidfile ); +int create_pid_file(const char *pidfile); /** * Remove pid file */ -void remove_pid_file ( int fd ); +void remove_pid_file(int fd); /** * 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. + * This functions exits the program with 1 when it finds an invalid + * configuration. */ -int config_sanity_check ( void ); +int config_sanity_check(void); /** * @param arg string to parse. @@ -174,7 +175,7 @@ int config_sanity_check ( void ); * * @returns character. */ -char helper_parse_char ( const char *arg ); +char helper_parse_char(const char *arg); /** * @param argc number of arguments. @@ -182,7 +183,7 @@ char helper_parse_char ( const char *arg ); * * Set the application arguments. */ -void cmd_set_arguments ( int argc, char **argv ); +void cmd_set_arguments(int argc, char **argv); /** * @param input The path to expand @@ -191,7 +192,7 @@ void cmd_set_arguments ( int argc, char **argv ); * * @returns path */ -char *rofi_expand_path ( const char *input ); +char *rofi_expand_path(const char *input); /** * @param needle The string to find match weight off @@ -203,17 +204,19 @@ char *rofi_expand_path ( const char *input ); * * @returns the levenshtein distance between needle and haystack */ -unsigned int levenshtein ( const char *needle, const glong needlelen, const char *haystack, const glong haystacklen ); +unsigned int levenshtein(const char *needle, const glong needlelen, + const char *haystack, const glong haystacklen); /** * @param data the unvalidated character array holding possible UTF-8 data * @param length the length of the data array * - * Convert string to valid utf-8, replacing invalid parts with replacement character. + * Convert string to valid utf-8, replacing invalid parts with replacement + * character. * * @returns the converted UTF-8 string */ -char * rofi_force_utf8 ( const gchar *data, ssize_t length ); +char *rofi_force_utf8(const gchar *data, ssize_t length); /** * @param input the char array holding latin text @@ -223,7 +226,7 @@ char * rofi_force_utf8 ( const gchar *data, ssize_t length ); * * @return the UTF-8 representation of data */ -char * rofi_latin_to_utf8_strdup ( const char *input, gssize length ); +char *rofi_latin_to_utf8_strdup(const char *input, gssize length); /** * @param text the string to escape @@ -232,7 +235,7 @@ char * rofi_latin_to_utf8_strdup ( const char *input, gssize length ); * * @return the escaped string */ -gchar *rofi_escape_markup ( gchar *text ); +gchar *rofi_escape_markup(gchar *text); /** * @param pattern The user input to match against. @@ -240,28 +243,35 @@ gchar *rofi_escape_markup ( gchar *text ); * @param str The input to match against pattern. * @param 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`. + * 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. + * - 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 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)) + * 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) + * 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. */ -int rofi_scorer_fuzzy_evaluate ( const char *pattern, glong plen, const char *str, glong slen ); +int rofi_scorer_fuzzy_evaluate(const char *pattern, glong plen, const char *str, + glong slen); /*@}*/ /** @@ -271,31 +281,31 @@ int rofi_scorer_fuzzy_evaluate ( const char *pattern, glong plen, const char *st * * 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`. + * @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`. */ -int utf8_strncmp ( const char *a, const char* b, size_t n ) __attribute__( ( nonnull ( 1, 2 ) ) ); +int utf8_strncmp(const char *a, const char *b, size_t n) + __attribute__((nonnull(1, 2))); /** * The startup notification context of the application to launch */ -typedef struct -{ - /** The name of the application */ - const gchar *name; - /** The binary name of the application */ - const gchar *binary; - /** The description of the launch */ - const gchar *description; - /** The icon name of the application */ - const gchar *icon; - /** The application id (desktop file with the .desktop suffix) */ - const gchar *app_id; - /** The window manager class of the application */ - const gchar *wmclass; - /** The command we run */ - const gchar *command; +typedef struct { + /** The name of the application */ + const gchar *name; + /** The binary name of the application */ + const gchar *binary; + /** The description of the launch */ + const gchar *description; + /** The icon name of the application */ + const gchar *icon; + /** The application id (desktop file with the .desktop suffix) */ + const gchar *app_id; + /** The window manager class of the application */ + const gchar *wmclass; + /** The command we run */ + const gchar *command; } RofiHelperExecuteContext; /** @@ -309,7 +319,9 @@ typedef struct * * @returns TRUE when successful, FALSE when failed. */ -gboolean helper_execute ( const char *wd, char **args, const char *error_precmd, const char *error_cmd, RofiHelperExecuteContext *context ); +gboolean helper_execute(const char *wd, char **args, const char *error_precmd, + const char *error_cmd, + RofiHelperExecuteContext *context); /** * @param wd The work directory (optional) @@ -322,7 +334,9 @@ gboolean helper_execute ( const char *wd, char **args, const char *error_precmd, * * @returns FALSE On failure, TRUE on success */ -gboolean helper_execute_command ( const char *wd, const char *cmd, gboolean run_in_term, RofiHelperExecuteContext *context ); +gboolean helper_execute_command(const char *wd, const char *cmd, + gboolean run_in_term, + RofiHelperExecuteContext *context); /** * @param file The file path @@ -331,7 +345,8 @@ gboolean helper_execute_command ( const char *wd, const char *cmd, gboolean run_ * * @returns a cairo surface from an svg path */ -cairo_surface_t *cairo_image_surface_create_from_svg ( const gchar* file, int height ); +cairo_surface_t *cairo_image_surface_create_from_svg(const gchar *file, + int height); /** * Ranges. @@ -344,7 +359,7 @@ cairo_surface_t *cairo_image_surface_create_from_svg ( const gchar* file, int he * * ranges */ -void parse_ranges ( char *input, rofi_range_pair **list, unsigned int *length ); +void parse_ranges(char *input, rofi_range_pair **list, unsigned int *length); /** * @param format The format string used. See below for possible syntax. @@ -361,25 +376,28 @@ void parse_ranges ( char *input, rofi_range_pair **list, unsigned int *length ); * * f: Print the entered filter. * * F: Print the entered filter, quoted * - * This functions outputs the formatted string to stdout, appends a newline (\n) character and - * calls flush on the file descriptor. + * This functions outputs the formatted string to stdout, appends a newline (\n) + * character and calls flush on the file descriptor. */ -void rofi_output_formatted_line ( const char *format, const char *string, int selected_line, const char *filter ); +void rofi_output_formatted_line(const char *format, const char *string, + int selected_line, const char *filter); /** * @param string The string with elements to be replaced - * @param ... Set of {key}, value that will be replaced, terminated by a NULL + * @param ... 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. + * 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. */ -char *helper_string_replace_if_exists ( char * string, ... ); +char *helper_string_replace_if_exists(char *string, ...); /** * @param file File name passed to option. @@ -387,9 +405,7 @@ char *helper_string_replace_if_exists ( char * string, ... ); * * @returns path to theme or copy of filename if not found. */ -char *helper_get_theme_path ( const char *file, const char *ext ); - - +char *helper_get_theme_path(const char *file, const char *ext); G_END_DECLS diff --git a/include/rofi-types.h b/include/rofi-types.h index e3f862e5..49ea42c6 100644 --- a/include/rofi-types.h +++ b/include/rofi-types.h @@ -1,6 +1,5 @@ #ifndef INCLUDE_ROFI_TYPES_H #define INCLUDE_ROFI_TYPES_H - #include <glib.h> #include <stdint.h> G_BEGIN_DECLS @@ -8,232 +7,213 @@ G_BEGIN_DECLS /** * Type of property */ -typedef enum -{ - /** Integer */ - P_INTEGER, - /** Double */ - P_DOUBLE, - /** String */ - P_STRING, - /** Character */ - P_CHAR, - /** Boolean */ - P_BOOLEAN, - /** Color */ - P_COLOR, - /** Image */ - P_IMAGE, - /** RofiPadding */ - P_PADDING, - /** Link to global setting */ - P_LINK, - /** Position */ - P_POSITION, - /** Highlight */ - P_HIGHLIGHT, - /** List */ - P_LIST, - /** Orientation */ - P_ORIENTATION, - /** Cursor */ - P_CURSOR, - /** Inherit */ - P_INHERIT, - /** Number of types. */ - P_NUM_TYPES, +typedef enum { + /** Integer */ + P_INTEGER, + /** Double */ + P_DOUBLE, + /** String */ + P_STRING, + /** Character */ + P_CHAR, + /** Boolean */ + P_BOOLEAN, + /** Color */ + P_COLOR, + /** Image */ + P_IMAGE, + /** RofiPadding */ + P_PADDING, + /** Link to global setting */ + P_LINK, + /** Position */ + P_POSITION, + /** Highlight */ + P_HIGHLIGHT, + /** List */ + P_LIST, + /** Orientation */ + P_ORIENTATION, + /** Cursor */ + P_CURSOR, + /** Inherit */ + P_INHERIT, + /** Number of types. */ + P_NUM_TYPES, } PropertyType; /** * This array maps PropertyType to a user-readable name. * It is important this is kept in sync. */ -extern const char * const PropertyTypeName[P_NUM_TYPES]; +extern const char *const PropertyTypeName[P_NUM_TYPES]; /** Style of text highlight */ -typedef enum -{ - /** no highlight */ - ROFI_HL_NONE = 0, - /** bold */ - ROFI_HL_BOLD = 1, - /** underline */ - ROFI_HL_UNDERLINE = 2, - /** strikethrough */ - ROFI_HL_STRIKETHROUGH = 16, - /** small caps */ - ROFI_HL_SMALL_CAPS = 32, - /** italic */ - ROFI_HL_ITALIC = 4, - /** color */ - ROFI_HL_COLOR = 8 +typedef enum { + /** no highlight */ + ROFI_HL_NONE = 0, + /** bold */ + ROFI_HL_BOLD = 1, + /** underline */ + ROFI_HL_UNDERLINE = 2, + /** strikethrough */ + ROFI_HL_STRIKETHROUGH = 16, + /** small caps */ + ROFI_HL_SMALL_CAPS = 32, + /** italic */ |