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 | |
parent | 8f565b11c6ce759bc1eec183cebffdda54144ff4 (diff) |
Fixes issue #370: Move dmenu option into dmenu.
-rw-r--r-- | config/config.c | 2 | ||||
-rw-r--r-- | include/settings.h | 2 | ||||
-rw-r--r-- | source/dialogs/dmenu.c | 18 | ||||
-rw-r--r-- | source/rofi.c | 5 |
4 files changed, 15 insertions, 12 deletions
diff --git a/config/config.c b/config/config.c index ea808e50..756e59c2 100644 --- a/config/config.c +++ b/config/config.c @@ -92,8 +92,6 @@ Settings config = { .levenshtein_sort = FALSE, /** Case sensitivity of the search */ .case_sensitive = FALSE, - /** Separator to use for dmenu mode */ - .separator = '\n', /** Height of an element in #chars */ .element_height = 1, /** Sidebar mode, show the modi */ diff --git a/include/settings.h b/include/settings.h index af89e94e..2633354a 100644 --- a/include/settings.h +++ b/include/settings.h @@ -88,8 +88,6 @@ typedef struct unsigned int levenshtein_sort; /** Search case sensitivity */ unsigned int case_sensitive; - /** Separator to use for dmenu mode */ - char separator; /** Height of an element in number of rows */ int element_height; /** Sidebar mode, show the modi */ 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 ); } diff --git a/source/rofi.c b/source/rofi.c index fa4d6095..c79490ed 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -813,10 +813,7 @@ int main ( int argc, char *argv[] ) // setup_modi setup_modi (); } - else { - // Add dmenu options. - config_parser_add_option ( xrm_Char, "sep", (void * *) &( config.separator ), "Element separator" ); - } + if ( find_arg ( "-no-config" ) < 0 ) { // Reload for dynamic part. load_configuration_dynamic ( ); |