mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Cleanups, rename and document.
This commit is contained in:
parent
00a555b685
commit
d1591273e7
3 changed files with 69 additions and 54 deletions
115
include/rofi.h
115
include/rofi.h
|
@ -31,11 +31,6 @@ typedef enum
|
||||||
PREVIOUS_DIALOG = 1003
|
PREVIOUS_DIALOG = 1003
|
||||||
} SwitcherMode;
|
} SwitcherMode;
|
||||||
|
|
||||||
typedef void ( *switcher_free )( Switcher *data );
|
|
||||||
|
|
||||||
typedef char * ( *get_display_value )( const Switcher *sw, unsigned int selected_line, int *state, int get_entry );
|
|
||||||
|
|
||||||
typedef char * ( *get_completion )( const Switcher *sw, unsigned int selected_line );
|
|
||||||
/**
|
/**
|
||||||
* State returned by the rofi window.
|
* State returned by the rofi window.
|
||||||
*/
|
*/
|
||||||
|
@ -61,38 +56,6 @@ typedef enum
|
||||||
MENU_LOWER_MASK = 0x0000FFFF
|
MENU_LOWER_MASK = 0x0000FFFF
|
||||||
} MenuReturn;
|
} MenuReturn;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tokens List of (input) tokens to match.
|
|
||||||
* @param input The entry to match against.
|
|
||||||
* @param case_sensitive Whether case is significant.
|
|
||||||
* @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 )( const Switcher *data, char **tokens, int not_ascii, int case_sensitive, unsigned int index );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param sw the Switcher to show.
|
|
||||||
* @param lines An array of strings to display.
|
|
||||||
* @param num_lines Length of the array with strings to display.
|
|
||||||
* @param input A pointer to a string where the inputted data is placed.
|
|
||||||
* @param prompt The prompt to show.
|
|
||||||
* @param shift pointer to integer that is set to the state of the shift key.
|
|
||||||
* @param mmc Menu menu match callback, used for matching user input.
|
|
||||||
* @param mmc_data data to pass to mmc.
|
|
||||||
* @param selected_line pointer to integer holding the selected line.
|
|
||||||
* @param message Extra message to display.
|
|
||||||
*
|
|
||||||
* Main menu callback.
|
|
||||||
*
|
|
||||||
* @returns The command issued (see MenuReturn)
|
|
||||||
*/
|
|
||||||
MenuReturn menu ( Switcher *sw, char **input, char *prompt, unsigned int *selected_line, unsigned int *next_pos, const char *message )
|
|
||||||
__attribute__ ( ( nonnull ( 1, 2, 3, 4 ) ) );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param sig The caught signal
|
* @param sig The caught signal
|
||||||
*
|
*
|
||||||
|
@ -132,6 +95,24 @@ typedef enum _WindowLocation
|
||||||
WL_WEST = 8
|
WL_WEST = 8
|
||||||
} WindowLocation;
|
} WindowLocation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param sw the Switcher to show.
|
||||||
|
* @param lines An array of strings to display.
|
||||||
|
* @param num_lines Length of the array with strings to display.
|
||||||
|
* @param input A pointer to a string where the inputted data is placed.
|
||||||
|
* @param prompt The prompt to show.
|
||||||
|
* @param shift pointer to integer that is set to the state of the shift key.
|
||||||
|
* @param mmc Menu menu match callback, used for matching user input.
|
||||||
|
* @param mmc_data data to pass to mmc.
|
||||||
|
* @param selected_line pointer to integer holding the selected line.
|
||||||
|
* @param message Extra message to display.
|
||||||
|
*
|
||||||
|
* Main menu callback.
|
||||||
|
*
|
||||||
|
* @returns The command issued (see MenuReturn)
|
||||||
|
*/
|
||||||
|
MenuReturn menu ( Switcher *sw, char **input, char *prompt, unsigned int *selected_line, unsigned int *next_pos, const char *message )
|
||||||
|
__attribute__ ( ( nonnull ( 1, 2, 3, 4 ) ) );
|
||||||
/**
|
/**
|
||||||
* Settings
|
* Settings
|
||||||
*/
|
*/
|
||||||
|
@ -262,6 +243,34 @@ extern Settings config;
|
||||||
*/
|
*/
|
||||||
void error_dialog ( const char *msg, int markup );
|
void error_dialog ( const char *msg, int markup );
|
||||||
|
|
||||||
|
typedef void ( *switcher_free )( Switcher *data );
|
||||||
|
|
||||||
|
typedef char * ( *switcher_get_display_value )( const Switcher *sw, unsigned int selected_line, int *state, int get_entry );
|
||||||
|
|
||||||
|
typedef char * ( *switcher_get_completion )( const Switcher *sw, unsigned int selected_line );
|
||||||
|
/**
|
||||||
|
* @param tokens List of (input) tokens to match.
|
||||||
|
* @param input The entry to match against.
|
||||||
|
* @param case_sensitive Whether case is significant.
|
||||||
|
* @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 ( *switcher_token_match )( const Switcher *data, char **tokens, int not_ascii, int case_sensitive, unsigned int index );
|
||||||
|
|
||||||
|
typedef void ( *switcher_init )( Switcher *sw );
|
||||||
|
|
||||||
|
typedef unsigned int ( *switcher_get_num_entries )( const Switcher *sw );
|
||||||
|
|
||||||
|
typedef void ( *switcher_destroy )( Switcher *sw );
|
||||||
|
|
||||||
|
typedef SwitcherMode ( *switcher_result )( Switcher *sw, int menu_retv, char **input, unsigned int selected_line );
|
||||||
|
|
||||||
|
typedef int ( *switcher_is_not_ascii )( const Switcher *sw, unsigned int index );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Structure defining a switcher.
|
* Structure defining a switcher.
|
||||||
* It consists of a name, callback and if enabled
|
* It consists of a name, callback and if enabled
|
||||||
|
@ -280,26 +289,32 @@ struct _Switcher
|
||||||
/**
|
/**
|
||||||
* A switcher normally consists of the following parts:
|
* A switcher normally consists of the following parts:
|
||||||
*/
|
*/
|
||||||
void ( *init )( struct _Switcher *sw );
|
// Initialize the Switcher
|
||||||
unsigned int ( *get_num_entries )( const struct _Switcher *sw );
|
switcher_init init;
|
||||||
SwitcherMode ( *result )( struct _Switcher *sw, int menu_retv, char **input, unsigned int selected_line );
|
// Destroy the switcher, e.g. free all its memory.
|
||||||
void ( *destroy )( struct _Switcher *pd );
|
switcher_destroy destroy;
|
||||||
|
// Get number of entries to display. (unfiltered).
|
||||||
|
switcher_get_num_entries get_num_entries;
|
||||||
|
// Check if the element is ascii.
|
||||||
|
switcher_is_not_ascii is_not_ascii;
|
||||||
|
// Process the result of the user selection.
|
||||||
|
switcher_result result;
|
||||||
// Token match.
|
// Token match.
|
||||||
menu_match_cb token_match;
|
switcher_token_match token_match;
|
||||||
|
// Get the string to display for the entry.
|
||||||
get_display_value mgrv;
|
switcher_get_display_value mgrv;
|
||||||
|
// Get the 'completed' entry.
|
||||||
int ( *is_not_ascii )( const struct _Switcher *sw, unsigned int index );
|
switcher_get_completion get_completion;
|
||||||
|
|
||||||
get_completion get_completion;
|
|
||||||
|
|
||||||
// Pointer to private data.
|
// Pointer to private data.
|
||||||
void *private_data;
|
void *private_data;
|
||||||
|
|
||||||
|
// Free SWitcher
|
||||||
|
// Only to be used when the switcher object itself is dynamic.
|
||||||
|
// And has data in `ed`
|
||||||
|
switcher_free free;
|
||||||
// Extra fields for script
|
// Extra fields for script
|
||||||
void *ed;
|
void *ed;
|
||||||
// Free SWitcher
|
|
||||||
switcher_free free;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define color_reset "\033[0m"
|
#define color_reset "\033[0m"
|
||||||
|
|
Loading…
Reference in a new issue