diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/rofi.h | 30 | ||||
-rw-r--r-- | include/textbox.h | 18 | ||||
-rw-r--r-- | include/view.h | 69 |
3 files changed, 93 insertions, 24 deletions
diff --git a/include/rofi.h b/include/rofi.h index 60699674..d6bab116 100644 --- a/include/rofi.h +++ b/include/rofi.h @@ -17,7 +17,7 @@ * Pointer to xdg cache directory. */ extern const char *cache_dir; -typedef struct MenuState MenuState; +typedef struct RofiViewState RofiViewState; /** * @param msg The error message to show. @@ -50,9 +50,9 @@ typedef enum * * @returns The command issued (see MenuReturn) */ -MenuState *menu ( Mode *sw, - char *input, char *prompt, - const char *message, MenuFlags flags ) +RofiViewState *rofi_view_create ( Mode *sw, + char *input, char *prompt, + const char *message, MenuFlags flags ) __attribute__ ( ( nonnull ( 1, 2, 3 ) ) ); /** Reset terminal */ @@ -84,16 +84,16 @@ int show_error_message ( const char *msg, int markup ); " <i>https://github.com/DaveDavenport/rofi/</i>" #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 ); -void menu_state_restart ( MenuState *state ); -void menu_state_set_selected_line ( MenuState *state, unsigned int selected_line ); -void menu_state_queue_redraw ( void ); -void menu_state_set_active ( MenuState *state ); +MenuReturn rofi_view_get_return_value ( const RofiViewState *state ); +unsigned int rofi_view_get_selected_line ( const RofiViewState *state ); +unsigned int rofi_view_get_next_position ( const RofiViewState *state ); +void rofi_view_itterrate ( RofiViewState *state, XEvent *event ); +unsigned int rofi_view_get_completed ( const RofiViewState *state ); +const char * rofi_view_get_user_input ( const RofiViewState *state ); +void rofi_view_free ( RofiViewState *state ); +void rofi_view_restart ( RofiViewState *state ); +void rofi_view_set_selected_line ( RofiViewState *state, unsigned int selected_line ); +void rofi_view_queue_redraw ( void ); +void rofi_view_set_active ( RofiViewState *state ); /*@}*/ #endif diff --git a/include/textbox.h b/include/textbox.h index 757b1c62..c321eb47 100644 --- a/include/textbox.h +++ b/include/textbox.h @@ -42,15 +42,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 diff --git a/include/view.h b/include/view.h new file mode 100644 index 00000000..8c7d02bc --- /dev/null +++ b/include/view.h @@ -0,0 +1,69 @@ + +// State of the menu. + +typedef struct RofiViewState +{ + Mode *sw; + unsigned int menu_lines; + unsigned int max_elements; + unsigned int max_rows; + unsigned int columns; + + // window width,height + unsigned int w, h; + int x, y; + unsigned int element_width; + int top_offset; + + // Update/Refilter list. + int update; + int refilter; + int rchanged; + int cur_page; + + // Entries + textbox *text; + textbox *prompt_tb; + textbox *message_tb; + textbox *case_indicator; + textbox **boxes; + scrollbar *scrollbar; + int *distance; + unsigned int *line_map; + + unsigned int num_lines; + + // Selected element. + unsigned int selected; + unsigned int filtered_lines; + // Last offset in paginating. + unsigned int last_offset; + + KeySym prev_key; + Time last_button_press; + + int quit; + int skip_absorb; + // Return state + unsigned int selected_line; + MenuReturn retv; + int *lines_not_ascii; + int line_height; + unsigned int border; + workarea mon; + + ssize_t num_modi; + textbox **modi; + // Handlers. + void ( *x11_event_loop )( struct RofiViewState *state, XEvent *ev ); + void ( *finalize )( struct RofiViewState *state ); +}RofiViewState; + +/** + * @param state The Menu Handle + * + * Check if a finalize function is set, and if sets executes it. + */ +void rofi_view_finalize ( RofiViewState *state ); + +RofiViewState * rofi_view_state_create ( void ); |