rofi/include/mode-private.h

143 lines
3.6 KiB
C
Raw Normal View History

2016-01-07 18:47:37 +00:00
#ifndef ROFI_MODE_PRIVATE_H
#define ROFI_MODE_PRIVATE_H
2017-02-14 17:12:07 +00:00
#define ABI_VERSION 0x00000001
2016-10-14 16:56:09 +00:00
/**
2016-11-15 20:54:31 +00:00
* @param data Pointer to #Mode object.
2016-10-14 16:56:09 +00:00
*
* Mode free function.
*/
2016-01-07 20:27:20 +00:00
typedef void ( *_mode_free )( Mode *data );
2016-01-07 18:47:37 +00:00
2016-10-14 16:56:09 +00:00
/**
* @param sw The #Mode pointer
* @param selected_line The selected line
* @param state The state to display [out]
* @param get_entry if it should only return the state
*
* Get the value for displaying.
*
* @return the string and state for displaying.
*/
2016-01-07 20:27:20 +00:00
typedef char * ( *_mode_get_display_value )( const Mode *sw, unsigned int selected_line, int *state, int get_entry );
2016-01-07 18:47:37 +00:00
2016-10-14 16:56:09 +00:00
/**
* @param sw The #Mode pointer
* @param selected_line The selected line
*
* Obtains the string to complete.
*
* @return Get the completion string
*/
2016-01-07 20:27:20 +00:00
typedef char * ( *_mode_get_completion )( const Mode *sw, unsigned int selected_line );
2016-10-14 16:56:09 +00:00
2016-01-07 18:47:37 +00:00
/**
* @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.
*/
2016-05-22 15:47:34 +00:00
typedef int ( *_mode_token_match )( const Mode *data, GRegex **tokens, unsigned int index );
2016-01-07 18:47:37 +00:00
2016-10-14 16:56:09 +00:00
/**
* @param sw The #Mode pointer
*
* Initialize the mode.
*
* @returns TRUE is successfull
*/
typedef int ( *__mode_init )( Mode *sw );
2016-01-07 18:47:37 +00:00
2016-10-14 16:56:09 +00:00
/**
* @param sw The #Mode pointer
*
* Get the number of entries.
*
* @returns the number of entries
*/
2016-01-07 18:47:37 +00:00
typedef unsigned int ( *__mode_get_num_entries )( const Mode *sw );
2016-10-14 16:56:09 +00:00
/**
* @param sw The #Mode pointer
*
* Destroy the current mode. Still ready to restart.
*
*/
2016-01-07 18:47:37 +00:00
typedef void ( *__mode_destroy )( Mode *sw );
2016-10-14 16:56:09 +00:00
/**
* @param sw The #Mode pointer
* @param menu_retv The return value
* @param input The input string
* @param selected_line The selected line
*
* Handle the user accepting an entry.
*
* @returns the next action to take
*/
2016-01-07 20:27:20 +00:00
typedef ModeMode ( *_mode_result )( Mode *sw, int menu_retv, char **input, unsigned int selected_line );
2016-01-07 18:47:37 +00:00
2016-10-14 16:56:09 +00:00
/**
* @param sw The #Mode pointer
* @param input The input string
*
* Preprocess the input for sorting.
*
2016-10-15 13:39:08 +00:00
* @returns Entry stripped from markup for sorting
2016-10-14 16:56:09 +00:00
*/
typedef char* ( *_mode_preprocess_input )( Mode *sw, const char *input );
2016-01-07 18:47:37 +00:00
/**
* Structure defining a switcher.
* It consists of a name, callback and if enabled
* a textbox for the sidebar-mode.
*/
2016-03-24 21:13:19 +00:00
struct rofi_mode
2016-01-07 18:47:37 +00:00
{
2017-02-14 17:12:07 +00:00
/** Used for external plugins. */
unsigned int abi_version;
2016-01-07 18:47:37 +00:00
/** Name (max 31 char long) */
char name[32];
char cfg_name_key[128];
char *display_name;
2016-01-07 18:47:37 +00:00
/**
* A switcher normally consists of the following parts:
*/
/** Initialize the Mode */
2016-01-07 20:27:20 +00:00
__mode_init _init;
2016-01-07 18:47:37 +00:00
/** Destroy the switcher, e.g. free all its memory. */
2016-01-07 20:27:20 +00:00
__mode_destroy _destroy;
2016-01-07 18:47:37 +00:00
/** Get number of entries to display. (unfiltered). */
2016-01-07 20:27:20 +00:00
__mode_get_num_entries _get_num_entries;
2016-01-07 18:47:37 +00:00
/** Process the result of the user selection. */
2016-01-07 20:27:20 +00:00
_mode_result _result;
2016-01-07 18:47:37 +00:00
/** Token match. */
2016-01-07 20:27:20 +00:00
_mode_token_match _token_match;
2016-01-07 18:47:37 +00:00
/** Get the string to display for the entry. */
2016-01-07 20:27:20 +00:00
_mode_get_display_value _get_display_value;
2016-01-07 18:47:37 +00:00
/** Get the 'completed' entry. */
2016-01-07 20:27:20 +00:00
_mode_get_completion _get_completion;
2016-01-07 18:47:37 +00:00
_mode_preprocess_input _preprocess_input;
2016-01-07 18:47:37 +00:00
/** Pointer to private data. */
2016-01-07 20:27:20 +00:00
void *private_data;
2016-01-07 18:47:37 +00:00
/**
* Free SWitcher
* Only to be used when the switcher object itself is dynamic.
* And has data in `ed`
*/
2016-01-07 20:27:20 +00:00
_mode_free free;
2016-01-07 18:47:37 +00:00
/** Extra fields for script */
2016-01-07 20:27:20 +00:00
void *ed;
2016-01-07 18:47:37 +00:00
};
#endif // ROFI_MODE_PRIVATE_H