mirror of
https://github.com/davatorium/rofi.git
synced 2025-02-17 15:45:56 -05:00
Fixes issue #370: Move dmenu option into dmenu.
This commit is contained in:
parent
8f565b11c6
commit
541f5b1fc9
4 changed files with 15 additions and 12 deletions
|
@ -92,8 +92,6 @@ Settings config = {
|
||||||
.levenshtein_sort = FALSE,
|
.levenshtein_sort = FALSE,
|
||||||
/** Case sensitivity of the search */
|
/** Case sensitivity of the search */
|
||||||
.case_sensitive = FALSE,
|
.case_sensitive = FALSE,
|
||||||
/** Separator to use for dmenu mode */
|
|
||||||
.separator = '\n',
|
|
||||||
/** Height of an element in #chars */
|
/** Height of an element in #chars */
|
||||||
.element_height = 1,
|
.element_height = 1,
|
||||||
/** Sidebar mode, show the modi */
|
/** Sidebar mode, show the modi */
|
||||||
|
|
|
@ -88,8 +88,6 @@ typedef struct
|
||||||
unsigned int levenshtein_sort;
|
unsigned int levenshtein_sort;
|
||||||
/** Search case sensitivity */
|
/** Search case sensitivity */
|
||||||
unsigned int case_sensitive;
|
unsigned int case_sensitive;
|
||||||
/** Separator to use for dmenu mode */
|
|
||||||
char separator;
|
|
||||||
/** Height of an element in number of rows */
|
/** Height of an element in number of rows */
|
||||||
int element_height;
|
int element_height;
|
||||||
/** Sidebar mode, show the modi */
|
/** Sidebar mode, show the modi */
|
||||||
|
|
|
@ -51,7 +51,12 @@ struct range_pair
|
||||||
};
|
};
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
/** Settings */
|
||||||
|
// Prompt
|
||||||
char *prompt;
|
char *prompt;
|
||||||
|
// Separator.
|
||||||
|
char separator;
|
||||||
|
|
||||||
unsigned int selected_line;
|
unsigned int selected_line;
|
||||||
char *message;
|
char *message;
|
||||||
char *format;
|
char *format;
|
||||||
|
@ -68,7 +73,7 @@ typedef struct
|
||||||
unsigned int only_selected;
|
unsigned int only_selected;
|
||||||
} DmenuModePrivateData;
|
} 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" );
|
TICK_N ( "Read stdin START" );
|
||||||
char **retv = NULL;
|
char **retv = NULL;
|
||||||
|
@ -78,12 +83,12 @@ static char **get_dmenu ( FILE *fd, unsigned int *length )
|
||||||
gchar *data = NULL;
|
gchar *data = NULL;
|
||||||
size_t data_l = 0;
|
size_t data_l = 0;
|
||||||
ssize_t 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 ) ) {
|
if ( rvlength < ( *length + 2 ) ) {
|
||||||
rvlength *= 2;
|
rvlength *= 2;
|
||||||
retv = g_realloc ( retv, ( rvlength ) * sizeof ( char* ) );
|
retv = g_realloc ( retv, ( rvlength ) * sizeof ( char* ) );
|
||||||
}
|
}
|
||||||
if ( data[l - 1] == config.separator ) {
|
if ( data[l - 1] == pd->separator ) {
|
||||||
data[l - 1] = '\0';
|
data[l - 1] = '\0';
|
||||||
l--;
|
l--;
|
||||||
}
|
}
|
||||||
|
@ -265,10 +270,14 @@ static int dmenu_mode_init ( Mode *sw )
|
||||||
DmenuModePrivateData *pd = (DmenuModePrivateData *) mode_get_private_data ( sw );
|
DmenuModePrivateData *pd = (DmenuModePrivateData *) mode_get_private_data ( sw );
|
||||||
|
|
||||||
pd->prompt = "dmenu ";
|
pd->prompt = "dmenu ";
|
||||||
|
pd->separator = '\n';
|
||||||
pd->selected_line = UINT32_MAX;
|
pd->selected_line = UINT32_MAX;
|
||||||
|
|
||||||
find_arg_str ( "-mesg", &( pd->message ) );
|
find_arg_str ( "-mesg", &( pd->message ) );
|
||||||
|
|
||||||
|
// Input data separator.
|
||||||
|
find_arg_char ( "-sep", &( pd->separator ) );
|
||||||
|
|
||||||
// Check prompt
|
// Check prompt
|
||||||
find_arg_str ( "-p", &( pd->prompt ) );
|
find_arg_str ( "-p", &( pd->prompt ) );
|
||||||
find_arg_uint ( "-selected-row", &( pd->selected_line ) );
|
find_arg_uint ( "-selected-row", &( pd->selected_line ) );
|
||||||
|
@ -319,7 +328,7 @@ static int dmenu_mode_init ( Mode *sw )
|
||||||
}
|
}
|
||||||
g_free ( estr );
|
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 ) {
|
if ( fd != NULL ) {
|
||||||
fclose ( fd );
|
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 ( "-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 ( "-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 ( "-markup-rows", "", "Allow and render pango markup as input data.", NULL, is_term );
|
||||||
|
print_help_msg ( "-sep", "[char]", "Element separator.", "'\\n'", is_term );
|
||||||
}
|
}
|
||||||
|
|
|
@ -813,10 +813,7 @@ int main ( int argc, char *argv[] )
|
||||||
// setup_modi
|
// setup_modi
|
||||||
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 ) {
|
if ( find_arg ( "-no-config" ) < 0 ) {
|
||||||
// Reload for dynamic part.
|
// Reload for dynamic part.
|
||||||
load_configuration_dynamic ( );
|
load_configuration_dynamic ( );
|
||||||
|
|
Loading…
Add table
Reference in a new issue