diff --git a/config/config.c b/config/config.c index 40460c50..2eab087a 100644 --- a/config/config.c +++ b/config/config.c @@ -29,58 +29,79 @@ #include "rofi.h" Settings config = { - // List of enabled switchers. - // -switchers + /** List of enabled switchers. */ + /** -switchers */ .switchers = "window,run,ssh", - // Set the default window opacity. - // This option only works when running a composite manager. - // -o + /** Set the default window opacity. */ + /** This option only works when running a composite manager. */ + /** -o */ .window_opacity = 100, - // Border width around the window. + /** Border width around the window. */ .menu_bw = 1, - // The width of the switcher. (0100 in % > 100 in pixels) + /** The width of the switcher. (0100 in % > 100 in pixels) */ .menu_width = 50, - // Maximum number of options to show. + /** Maximum number of options to show. */ .menu_lines = 15, - // Number of columns + /** Number of columns */ .menu_columns = 1, - // Font + /** Font */ .menu_font = "mono 12", - // Foreground color + /** Foreground color */ .menu_fg = "#222222", - // Background color + /** Background color */ .menu_bg = "#f2f1f0", - // Foreground color (selected) + /** Foreground color (selected) */ .menu_hlfg = "#ffffff", - // Background color (selected) + /** Background color (selected) */ .menu_hlbg = "#005577", - // Border color. + /** Border color. */ .menu_bc = "black", - // Terminal to use. (for ssh and open in terminal) + /** Terminal to use. (for ssh and open in terminal) */ .terminal_emulator = "x-terminal-emulator", .ssh_client = "ssh", - // Command when executing ssh. + /** Command when executing ssh. */ .ssh_command = "{terminal} -e {ssh-client} {host}", - // Command when running + /** Command when running */ .run_command = "{cmd}", + /** Command executed when running application in terminal */ .run_shell_command = "{terminal} -e {cmd}", - // Key binding + /** Key binding */ .window_key = "F12", + /** Key to open run dialog */ .run_key = "mod1+F2", + /** Key to open ssh dialog */ .ssh_key = "mod1+F3", - // Location of the window. WL_CENTER, WL_NORTH_WEST, WL_NORTH,WL_NORTH_EAST, etc. + /** + * Location of the window. + * Enumeration indicating location or gravity of window. + * + * WL_NORTH_WEST WL_NORTH WL_NORTH_EAST + * + * WL_EAST WL_CENTER WL_EAST + * + * WL_SOUTH_WEST WL_SOUTH WL_SOUTH_EAST + * + */ .location = WL_CENTER, - // Mode of window, list (Vertical) or dmenu like (Horizontal) + /** Mode of window, list (Vertical) or dmenu like (Horizontal) */ .hmode = FALSE, - // Padding of the window. + /** Padding between elements */ .padding = 5, + /** Y offset */ .y_offset = 0, + /** X offset */ .x_offset = 0, + /** Always should config.menu_lines lines, even if less lines are available */ .fixed_num_lines = FALSE, + /** Do not use history */ .disable_history = FALSE, + /** Use levenshtein sorting when matching */ .levenshtein_sort = FALSE, + /** Separator to use for dmenu mode */ .separator = '\n', + /** Height of an element in #chars */ .element_height = 1, + /** Sidebar mode, show the switchers */ .sidebar_mode = FALSE }; diff --git a/include/rofi.h b/include/rofi.h index 5eb74a60..bcf870af 100644 --- a/include/rofi.h +++ b/include/rofi.h @@ -6,6 +6,9 @@ #define OVERLAP( a, b, c, d ) ( ( ( a ) == ( c ) && ( b ) == ( d ) ) || MIN ( ( a ) + ( b ), ( c ) + ( d ) ) - MAX ( ( a ), ( c ) ) > 0 ) #define INTERSECT( x, y, w, h, x1, y1, w1, h1 ) ( OVERLAP ( ( x ), ( w ), ( x1 ), ( w1 ) ) && OVERLAP ( ( y ), ( h ), ( y1 ), ( h1 ) ) ) +/** + * Pointer to xdg cache directory. + */ extern const char *cache_dir; @@ -24,7 +27,14 @@ typedef enum PREVIOUS_DIALOG = 1003 } SwitcherMode; -// switcher callback +/** + * @param input Pointer to the user input. + * @param data Usr data. + * + * Callback typedef for a switcher + * + * @returns SwitcherMode + */ typedef SwitcherMode ( *switcher_callback )( char **input, void *data ); /** @@ -42,13 +52,22 @@ typedef enum MENU_CUSTOM_INPUT = -3, /** User wanted to delete entry from history. */ MENU_ENTRY_DELETE = -4, + /** User wants to jump to another switcher. */ MENU_QUICK_SWITCH = -5, + /** Go to the previous menu. */ MENU_PREVIOUS = -6 } MenuReturn; /** + * @param tokens List of (input) tokens to match. + * @param input The entry to match against. + * @param index The current selected index. + * @param data User data. + * * Function prototype for the matching algorithm. + * + * @returns 1 when it matches, 0 if not. */ typedef int ( *menu_match_cb )( char **tokens, const char *input, int index, void *data ); @@ -71,19 +90,42 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom Time *time, int *shift, menu_match_cb mmc, void *mmc_data, int *selected_line, int sorting ) __attribute__ ( ( nonnull ( 1, 3, 4, 9 ) ) ); - +/** + * @param sig The caught signal + * + * Catch the exit signal generated by X. + */ void catch_exit ( __attribute__( ( unused ) ) int sig ); +/** + * Enumeration indicating location or gravity of window. + * + * WL_NORTH_WEST WL_NORTH WL_NORTH_EAST + * + * WL_EAST WL_CENTER WL_EAST + * + * WL_SOUTH_WEST WL_SOUTH WL_SOUTH_EAST + * + */ typedef enum _WindowLocation { + /** Center */ WL_CENTER = 0, + /** Left top corner. */ WL_NORTH_WEST = 1, + /** Top middle */ WL_NORTH = 2, + /** Top right */ WL_NORTH_EAST = 3, + /** Middle right */ WL_EAST = 4, + /** Bottom right */ WL_EAST_SOUTH = 5, + /** Bottom middle */ WL_SOUTH = 6, + /** Bottom left */ WL_SOUTH_WEST = 7, + /** Middle left */ WL_WEST = 8 } WindowLocation; @@ -93,57 +135,94 @@ typedef enum _WindowLocation typedef struct _Settings { + /** List of enabled switchers */ char *switchers; - // Window settings + /** Window settings */ unsigned int window_opacity; - // Menu settings + /** Border width */ unsigned int menu_bw; + /** Width (0-100 in %, > 100 in pixels, < 0 in char width.) */ int menu_width; + /** # lines */ unsigned int menu_lines; + /** # Columns */ unsigned int menu_columns; + /** Font string (pango format) */ char * menu_font; + /** Foreground color */ char * menu_fg; + /** Background color */ char * menu_bg; + /** Highlight foreground color */ char * menu_hlfg; + /** Highlight background color */ char * menu_hlbg; + /** Border color */ char * menu_bc; - // Behavior + /** Terminal to use */ char * terminal_emulator; + /** SSH client to use */ char * ssh_client; - - // Command to execute when ssh session is selected. + /** Command to execute when ssh session is selected */ char * ssh_command; - // Command for executing an application. + /** Command for executing an application */ char * run_command; + /** Command for executing an application in a terminal */ char * run_shell_command; - // Key bindings + /** Key to open window switcher */ char * window_key; + /** Key to open run dialog */ char * run_key; + /** Key to open ssh dialog */ char * ssh_key; + /** Windows location/gravity */ WindowLocation location; + /** Horizontal mode. */ unsigned int hmode; + /** Padding between elements */ unsigned int padding; + /** Y offset */ int y_offset; + /** X offset */ int x_offset; - + /** Always should config.menu_lines lines, even if less lines are available */ unsigned int fixed_num_lines; - + /** Do not use history */ unsigned int disable_history; - + /** Use levenshtein sorting when matching */ unsigned int levenshtein_sort; + /** Separator to use for dmenu mode */ char separator; + /** Height of an element in #chars */ int element_height; + /** Sidebar mode, show the switchers */ int sidebar_mode; } Settings; +/** Global Settings structure. */ extern Settings config; - +/** + * @params tokens + * @param tokens List of (input) tokens to match. + * @param input The entry to match against. + * @param index The current selected index. + * @param data User data. + * + * Tokenized match, match tokens to line input. + * + * @returns 1 when matches, 0 otherwise + */ int token_match ( char **tokens, const char *input, __attribute__( ( unused ) ) int index, __attribute__( ( unused ) ) void *data ); - +/** + * @param msg The error message to show. + * + * The error message to show. + */ void error_dialog ( char *msg ); + #endif diff --git a/include/script-dialog.h b/include/script-dialog.h index 94d66f2e..0ce8c5b1 100644 --- a/include/script-dialog.h +++ b/include/script-dialog.h @@ -6,22 +6,36 @@ */ typedef struct { - // Prompt to display. + /** Prompt to display. */ char *name; - // The script + /** The script */ char *script_path; } ScriptOptions; + +/** + * @param input Pointer to the user-input string. + * @param data Custom data pointer for callback. + * + * Run the script dialog + * + * @returns SwitcherMode selected by user. + */ SwitcherMode script_switcher_dialog ( char **input, void *data ); /** + * @param str The input string to parse + * * Parse an argument string into the right ScriptOptions data object. * This is off format: :