diff options
author | Dave Davenport <qball@gmpclient.org> | 2016-04-02 10:39:02 +0200 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2016-04-02 10:39:02 +0200 |
commit | 541f5b1fc981d663c694dcf6b1b4e219a034df7c (patch) | |
tree | d2283781eb674359e2f9cc1b494ee966659da1c6 /source/dialogs | |
parent | 8f565b11c6ce759bc1eec183cebffdda54144ff4 (diff) |
Fixes issue #370: Move dmenu option into dmenu.
Diffstat (limited to 'source/dialogs')
-rw-r--r-- | source/dialogs/dmenu.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c index 814a69b8..02594572 100644 --- a/source/dialogs/dmenu.c +++ b/source/dialogs/dmenu.c @@ -51,7 +51,12 @@ struct range_pair }; typedef struct { + /** Settings */ + // Prompt char *prompt; + // Separator. + char separator; + unsigned int selected_line; char *message; char *format; @@ -68,7 +73,7 @@ typedef struct unsigned int only_selected; } DmenuModePrivateData; -static char **get_dmenu ( FILE *fd, unsigned int *length ) +static char **get_dmenu ( DmenuModePrivateData *pd, FILE *fd, unsigned int *length ) { TICK_N ( "Read stdin START" ); char **retv = NULL; @@ -78,12 +83,12 @@ static char **get_dmenu ( FILE *fd, unsigned int *length ) gchar *data = NULL; size_t data_l = 0; ssize_t l = 0; - while ( ( l = getdelim ( &data, &data_l, config.separator, fd ) ) > 0 ) { + while ( ( l = getdelim ( &data, &data_l, pd->separator, fd ) ) > 0 ) { if ( rvlength < ( *length + 2 ) ) { rvlength *= 2; retv = g_realloc ( retv, ( rvlength ) * sizeof ( char* ) ); } - if ( data[l - 1] == config.separator ) { + if ( data[l - 1] == pd->separator ) { data[l - 1] = '\0'; l--; } @@ -265,10 +270,14 @@ static int dmenu_mode_init ( Mode *sw ) DmenuModePrivateData *pd = (DmenuModePrivateData *) mode_get_private_data ( sw ); pd->prompt = "dmenu "; + pd->separator = '\n'; pd->selected_line = UINT32_MAX; find_arg_str ( "-mesg", &( pd->message ) ); + // Input data separator. + find_arg_char ( "-sep", &( pd->separator ) ); + // Check prompt find_arg_str ( "-p", &( pd->prompt ) ); find_arg_uint ( "-selected-row", &( pd->selected_line ) ); @@ -319,7 +328,7 @@ static int dmenu_mode_init ( Mode *sw ) } g_free ( estr ); } - pd->cmd_list = get_dmenu ( fd == NULL ? stdin : fd, &( pd->cmd_list_length ) ); + pd->cmd_list = get_dmenu ( pd, fd == NULL ? stdin : fd, &( pd->cmd_list_length ) ); if ( fd != NULL ) { fclose ( fd ); } @@ -558,4 +567,5 @@ void print_dmenu_options ( void ) print_help_msg ( "-select", "[string]", "Select the first row that matches", NULL, is_term ); print_help_msg ( "-password", "", "Do not show what the user inputs. Show '*' instead.", NULL, is_term ); print_help_msg ( "-markup-rows", "", "Allow and render pango markup as input data.", NULL, is_term ); + print_help_msg ( "-sep", "[char]", "Element separator.", "'\\n'", is_term ); } |