2016-01-07 18:47:37 +00:00
|
|
|
#ifndef ROFI_MODE_H
|
|
|
|
#define ROFI_MODE_H
|
|
|
|
/**
|
|
|
|
* @defgroup MODE Mode
|
|
|
|
*
|
|
|
|
* The 'object' that makes a mode in rofi.
|
|
|
|
* @{
|
|
|
|
*/
|
2016-11-15 07:24:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Type of a mode.
|
2016-11-15 07:24:27 +00:00
|
|
|
* Access should be done via mode_* functions.
|
2016-11-15 07:24:06 +00:00
|
|
|
*/
|
2016-04-10 10:05:34 +00:00
|
|
|
typedef struct rofi_mode Mode;
|
2016-01-07 18:47:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Enum used to sum the possible states of ROFI.
|
|
|
|
*/
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
/** Exit. */
|
|
|
|
MODE_EXIT = 1000,
|
|
|
|
/** Skip to the next cycle-able dialog. */
|
|
|
|
NEXT_DIALOG = 1001,
|
|
|
|
/** Reload current DIALOG */
|
|
|
|
RELOAD_DIALOG = 1002,
|
|
|
|
/** Previous dialog */
|
2016-12-12 07:52:27 +00:00
|
|
|
PREVIOUS_DIALOG = 1003,
|
|
|
|
/** Reloads the dialog and unset user input */
|
|
|
|
RESET_DIALOG = 1004,
|
2016-01-07 18:47:37 +00:00
|
|
|
} ModeMode;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* State returned by the rofi window.
|
|
|
|
*/
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
/** Entry is selected. */
|
2016-03-17 12:14:30 +00:00
|
|
|
MENU_OK = 0x00010000,
|
2016-01-07 18:47:37 +00:00
|
|
|
/** User canceled the operation. (e.g. pressed escape) */
|
2016-03-17 12:14:30 +00:00
|
|
|
MENU_CANCEL = 0x00020000,
|
2016-01-07 18:47:37 +00:00
|
|
|
/** User requested a mode switch */
|
2016-03-17 12:14:30 +00:00
|
|
|
MENU_NEXT = 0x00040000,
|
2016-01-07 18:47:37 +00:00
|
|
|
/** Custom (non-matched) input was entered. */
|
2016-03-17 12:14:30 +00:00
|
|
|
MENU_CUSTOM_INPUT = 0x00080000,
|
2016-01-07 18:47:37 +00:00
|
|
|
/** User wanted to delete entry from history. */
|
2016-03-17 12:14:30 +00:00
|
|
|
MENU_ENTRY_DELETE = 0x00100000,
|
2016-01-07 18:47:37 +00:00
|
|
|
/** User wants to jump to another switcher. */
|
2016-03-17 12:14:30 +00:00
|
|
|
MENU_QUICK_SWITCH = 0x00200000,
|
2016-01-07 18:47:37 +00:00
|
|
|
/** Go to the previous menu. */
|
2016-03-17 12:14:30 +00:00
|
|
|
MENU_PREVIOUS = 0x00400000,
|
|
|
|
/** Bindings specifics */
|
|
|
|
MENU_CUSTOM_ACTION = 0x10000000,
|
2016-01-07 18:47:37 +00:00
|
|
|
/** Mask */
|
2016-03-17 12:14:30 +00:00
|
|
|
MENU_LOWER_MASK = 0x0000FFFF
|
2016-01-07 18:47:37 +00:00
|
|
|
} MenuReturn;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param mode The mode to initialize
|
|
|
|
*
|
|
|
|
* Initialize mode
|
2016-01-08 08:16:59 +00:00
|
|
|
*
|
|
|
|
* @returns FALSE if there was a failure, TRUE if successful
|
2016-01-07 18:47:37 +00:00
|
|
|
*/
|
2016-01-08 08:16:59 +00:00
|
|
|
int mode_init ( Mode *mode );
|
2016-01-07 18:47:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param mode The mode to destroy
|
|
|
|
*
|
|
|
|
* Destroy the mode
|
|
|
|
*/
|
|
|
|
void mode_destroy ( Mode *mode );
|
|
|
|
|
|
|
|
/**
|
2016-06-01 05:34:41 +00:00
|
|
|
* @param sw The mode to query
|
2016-01-07 18:47:37 +00:00
|
|
|
*
|
|
|
|
* Get the number of entries in the mode.
|
|
|
|
*
|
|
|
|
* @returns an unsigned in with the number of entries.
|
|
|
|
*/
|
|
|
|
unsigned int mode_get_num_entries ( const Mode *sw );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param mode The mode to query
|
|
|
|
* @param selected_line The entry to query
|
|
|
|
* @param state The state of the entry [out]
|
2017-03-10 22:39:29 +00:00
|
|
|
* @param attribute_list List of extra (pango) attribute to apply when displaying. [out][null]
|
2016-01-07 18:47:37 +00:00
|
|
|
* @param get_entry If the should be returned.
|
|
|
|
*
|
|
|
|
* Returns the string as it should be displayed for the entry and the state of how it should be displayed.
|
|
|
|
*
|
|
|
|
* @returns allocated new string and state when get_entry is TRUE otherwise just the state.
|
|
|
|
*/
|
2017-03-10 22:39:29 +00:00
|
|
|
char * mode_get_display_value ( const Mode *mode, unsigned int selected_line, int *state, GList **attribute_list, int get_entry );
|
2016-01-07 20:27:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param mode The mode to query
|
|
|
|
* @param selected_line The entry to query
|
|
|
|
*
|
|
|
|
* Return a string that can be used for completion. It has should have no markup.
|
|
|
|
*
|
|
|
|
* @returns allocated string.
|
|
|
|
*/
|
|
|
|
char * mode_get_completion ( const Mode *mode, unsigned int selected_line );
|
|
|
|
|
|
|
|
/**
|
2016-01-08 08:29:15 +00:00
|
|
|
* @param mode The mode to query
|
2016-07-29 06:32:34 +00:00
|
|
|
* @param menu_retv The menu return value.
|
|
|
|
* @param input Pointer to the user input string. [in][out]
|
2016-01-07 20:27:20 +00:00
|
|
|
* @param selected_line the line selected by the user.
|
|
|
|
*
|
|
|
|
* Acts on the user interaction.
|
|
|
|
*
|
|
|
|
* @returns the next #ModeMode.
|
|
|
|
*/
|
|
|
|
ModeMode mode_result ( Mode *mode, int menu_retv, char **input, unsigned int selected_line );
|
|
|
|
|
|
|
|
/**
|
2016-01-08 08:29:15 +00:00
|
|
|
* @param mode The mode to query
|
2016-01-07 20:27:20 +00:00
|
|
|
* @param tokens The set of tokens to match against
|
|
|
|
* @param selected_line The index of the entry to match
|
|
|
|
*
|
|
|
|
* Match entry against the set of tokens.
|
|
|
|
*
|
|
|
|
* @returns TRUE if matches
|
|
|
|
*/
|
2016-05-22 15:47:34 +00:00
|
|
|
int mode_token_match ( const Mode *mode, GRegex **tokens, unsigned int selected_line );
|
2016-01-07 20:27:20 +00:00
|
|
|
|
|
|
|
/**
|
2016-01-08 08:29:15 +00:00
|
|
|
* @param mode The mode to query
|
2016-01-07 20:27:20 +00:00
|
|
|
*
|
|
|
|
* Get the name of the mode.
|
|
|
|
*
|
|
|
|
* @returns the name of the mode.
|
|
|
|
*/
|
|
|
|
const char * mode_get_name ( const Mode *mode );
|
|
|
|
|
|
|
|
/**
|
2016-01-08 08:29:15 +00:00
|
|
|
* @param mode The mode to query
|
2016-01-07 20:27:20 +00:00
|
|
|
*
|
|
|
|
* Free the resources allocated for this mode.
|
|
|
|
*/
|
|
|
|
void mode_free ( Mode **mode );
|
|
|
|
|
2016-01-08 08:29:15 +00:00
|
|
|
/**
|
|
|
|
* @param mode The mode to query
|
|
|
|
*
|
|
|
|
* Helper functions for mode.
|
|
|
|
* Get the private data object.
|
|
|
|
*/
|
2016-01-07 20:27:20 +00:00
|
|
|
void *mode_get_private_data ( const Mode *mode );
|
2016-01-08 08:29:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param mode The mode to query
|
2016-07-29 06:32:34 +00:00
|
|
|
* @param pd Pointer to private data to attach to the mode.
|
2016-01-08 08:29:15 +00:00
|
|
|
*
|
|
|
|
* Helper functions for mode.
|
|
|
|
* Set the private data object.
|
|
|
|
*/
|
2016-01-07 20:27:20 +00:00
|
|
|
void mode_set_private_data ( Mode *mode, void *pd );
|
2016-01-12 21:17:53 +00:00
|
|
|
|
2016-11-15 07:24:06 +00:00
|
|
|
/**
|
|
|
|
* @param mode The mode to query
|
|
|
|
*
|
|
|
|
* Get the name of the mode as it should be presented to the user.
|
|
|
|
*
|
|
|
|
* @return the user visible name of the mode
|
|
|
|
*/
|
2016-01-12 21:17:53 +00:00
|
|
|
const char *mode_get_display_name ( const Mode *mode );
|
|
|
|
|
2016-11-15 07:24:06 +00:00
|
|
|
/**
|
|
|
|
* @param mode The mode to query
|
|
|
|
*
|
|
|
|
* Should be called once for each mode. This adds the display-name configuration option for the mode.
|
|
|
|
*/
|
2016-01-12 21:17:53 +00:00
|
|
|
void mode_set_config ( Mode *mode );
|
2016-11-15 07:24:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param mode The mode to query
|
2016-11-15 20:54:31 +00:00
|
|
|
* @param input The input to process
|
2016-11-15 07:24:06 +00:00
|
|
|
*
|
|
|
|
* This processes the input so it can be used for matching and sorting.
|
|
|
|
* This includes removing pango markup.
|
|
|
|
*
|
|
|
|
* @returns a newly allocated string
|
|
|
|
*/
|
2016-05-26 06:39:33 +00:00
|
|
|
char * mode_preprocess_input ( Mode *mode, const char *input );
|
2017-03-01 08:57:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param mode The mode to query
|
|
|
|
*
|
|
|
|
* Query the mode for a user display.
|
|
|
|
*
|
|
|
|
* @return a new allocated (valid pango markup) message to display (user should free).
|
|
|
|
*/
|
|
|
|
char *mode_get_message ( const Mode *mode );
|
2016-01-07 18:47:37 +00:00
|
|
|
/*@}*/
|
|
|
|
#endif
|