From d0716efe12487668fcab9ba55f8e75da87058ff5 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Wed, 20 Jan 2016 18:24:31 +0100 Subject: Refactor menu function into three parts, setup, itterrate and finalize. --- include/rofi.h | 18 +++++++++++++----- include/textbox.h | 18 +++++++++--------- 2 files changed, 22 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/rofi.h b/include/rofi.h index a43a29eb..c1824090 100644 --- a/include/rofi.h +++ b/include/rofi.h @@ -17,6 +17,7 @@ * Pointer to xdg cache directory. */ extern const char *cache_dir; +typedef struct MenuState MenuState; /** * @param msg The error message to show. @@ -49,12 +50,11 @@ typedef enum * * @returns The command issued (see MenuReturn) */ -MenuReturn menu ( Mode *sw, - char **input, char *prompt, - unsigned int *selected_line, - unsigned int *next_pos, +MenuState *menu ( Mode *sw, + char *input, char *prompt, + unsigned int selected_line, const char *message, MenuFlags flags ) -__attribute__ ( ( nonnull ( 1, 2, 3, 4 ) ) ); +__attribute__ ( ( nonnull ( 1, 2, 3 ) ) ); /** Reset terminal */ #define color_reset "\033[0m" @@ -84,5 +84,13 @@ int show_error_message ( const char *msg, int markup ); " * The version of rofi you are running\n\n" \ " https://github.com/DaveDavenport/rofi/" #define ERROR_MSG_MARKUP TRUE + +MenuReturn menu_state_get_return_value ( const MenuState *state ); +unsigned int menu_state_get_selected_line ( const MenuState *state ); +unsigned int menu_state_get_next_position ( const MenuState *state ); +void menu_state_itterrate ( MenuState *state, XEvent *event ); +unsigned int menu_state_get_completed ( const MenuState *state ); +const char * menu_state_get_user_input ( const MenuState *state ); +void menu_state_free ( MenuState *state ); /*@}*/ #endif diff --git a/include/textbox.h b/include/textbox.h index fe59b02a..ecc52784 100644 --- a/include/textbox.h +++ b/include/textbox.h @@ -40,15 +40,15 @@ typedef struct typedef enum { - TB_AUTOHEIGHT = 1 << 0, - TB_AUTOWIDTH = 1 << 1, - TB_LEFT = 1 << 16, - TB_RIGHT = 1 << 17, - TB_CENTER = 1 << 18, - TB_EDITABLE = 1 << 19, - TB_MARKUP = 1 << 20, - TB_WRAP = 1 << 21, - TB_PASSWORD = 1 << 22, + TB_AUTOHEIGHT = 1 << 0, + TB_AUTOWIDTH = 1 << 1, + TB_LEFT = 1 << 16, + TB_RIGHT = 1 << 17, + TB_CENTER = 1 << 18, + TB_EDITABLE = 1 << 19, + TB_MARKUP = 1 << 20, + TB_WRAP = 1 << 21, + TB_PASSWORD = 1 << 22, } TextboxFlags; typedef enum -- cgit v1.2.3 From eadf455c8c4d74a9b66a47ad97de274fb3d16241 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Wed, 20 Jan 2016 18:50:33 +0100 Subject: Let DMenu mode reuse open dialog and not restart it. handy for multi-select. --- include/rofi.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/rofi.h b/include/rofi.h index c1824090..95fd06c6 100644 --- a/include/rofi.h +++ b/include/rofi.h @@ -52,7 +52,6 @@ typedef enum */ MenuState *menu ( Mode *sw, char *input, char *prompt, - unsigned int selected_line, const char *message, MenuFlags flags ) __attribute__ ( ( nonnull ( 1, 2, 3 ) ) ); @@ -92,5 +91,7 @@ void menu_state_itterrate ( MenuState *state, XEvent *event ); unsigned int menu_state_get_completed ( const MenuState *state ); const char * menu_state_get_user_input ( const MenuState *state ); void menu_state_free ( MenuState *state ); +void menu_state_restart ( MenuState *state ); +void menu_state_set_selected_line ( MenuState *state, unsigned int selected_line ); /*@}*/ #endif -- cgit v1.2.3