mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
Issue: #207 add generic -filter
mode.
This commit is contained in:
parent
610c738377
commit
c170eae8c8
8 changed files with 48 additions and 43 deletions
|
@ -133,5 +133,6 @@ Settings config = {
|
||||||
/** Monitor */
|
/** Monitor */
|
||||||
.monitor = -1,
|
.monitor = -1,
|
||||||
.line_margin = 3,
|
.line_margin = 3,
|
||||||
|
.filter = NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,8 @@
|
||||||
[ -display *display* ]
|
[ -display *display* ]
|
||||||
[ -bc *color* ]
|
[ -bc *color* ]
|
||||||
[ -bw *width* ]
|
[ -bw *width* ]
|
||||||
[ -dmenu [ -p *prompt* ] [ -sep *separator* ] [ -l *selected line* ] [ -mesg ] [ -filter ] [ -select ] ]
|
[ -dmenu [ -p *prompt* ] [ -sep *separator* ] [ -l *selected line* ] [ -mesg ] [ -select ] ]
|
||||||
|
[ -filter *filter* ]
|
||||||
[ -ssh-client *client* ]
|
[ -ssh-client *client* ]
|
||||||
[ -ssh-command *command* ]
|
[ -ssh-command *command* ]
|
||||||
[ -disable-history ]
|
[ -disable-history ]
|
||||||
|
@ -197,6 +198,10 @@ Below is a list of the most important options:
|
||||||
|
|
||||||
Enable experimental fuzzy matching.
|
Enable experimental fuzzy matching.
|
||||||
|
|
||||||
|
`-filter` *filter*
|
||||||
|
|
||||||
|
Preset user filter to *filter* in the entry box and pre-filter the list.
|
||||||
|
|
||||||
|
|
||||||
### Theming
|
### Theming
|
||||||
|
|
||||||
|
@ -560,10 +565,6 @@ The following options are further explained in the theming section:
|
||||||
|
|
||||||
Default: 's'
|
Default: 's'
|
||||||
|
|
||||||
`-filter` *filter*
|
|
||||||
|
|
||||||
Preset user filter to *filter* in the entry box and pre-filter the list.
|
|
||||||
|
|
||||||
`-select` *string*
|
`-select` *string*
|
||||||
|
|
||||||
Select first line that matches the given string
|
Select first line that matches the given string
|
||||||
|
|
38
doc/rofi.1
38
doc/rofi.1
|
@ -7,7 +7,7 @@
|
||||||
\fBrofi\fR \- A window switcher, run launcher, ssh dialog and dmenu replacement
|
\fBrofi\fR \- A window switcher, run launcher, ssh dialog and dmenu replacement
|
||||||
.
|
.
|
||||||
.SH "SYNOPSIS"
|
.SH "SYNOPSIS"
|
||||||
\fBrofi\fR [ \-width \fIpct_scr\fR ] [ \-lines \fIlines\fR ] [ \-columns \fIcolumns\fR ] [ \-font \fIpangofont\fR ] [ \-fg \fIcolor\fR ] [ \-fg\-urgent \fIcolor\fR ] [ \-fg\-active \fIcolor\fR ] [ \-bg\-urgent \fIcolor\fR ] [ \-bg\-active \fIcolor\fR ] [ \-bg \fIcolor\fR ] [ \-bgalt \fIcolor\fR ] [ \-hlfg \fIcolor\fR ] [ \-hlbg \fIcolor\fR ] [ \-key\-\fBmode\fR \fIcombo\fR ] [ \-terminal \fIterminal\fR ] [ \-location \fIposition\fR ] [ \-fixed\-num\-lines ] [ \-padding \fIpadding\fR ] [ \-opacity \fIopacity%\fR ] [ \-display \fIdisplay\fR ] [ \-bc \fIcolor\fR ] [ \-bw \fIwidth\fR ] [ \-dmenu [ \-p \fIprompt\fR ] [ \-sep \fIseparator\fR ] [ \-l \fIselected line\fR ] [ \-mesg ] [ \-filter ] [ \-select ] ] [ \-ssh\-client \fIclient\fR ] [ \-ssh\-command \fIcommand\fR ] [ \-disable\-history ] [ \-levenshtein\-sort ] [ \-case\-sensitive ] [ \-show \fImode\fR ] [ \-modi \fImode1,mode2\fR ] [ \-eh \fIelement height\fR ] [ \-lazy\-filter\-limit \fIlimit\fR ] [ \-e \fImessage\fR] [ \-a \fIrow\fR ] [ \-u \fIrow\fR ] [ \-pid \fIpath\fR ] [ \-now ] [ \-rnow ] [ \-snow ] [ \-version ] [ \-help] [ \-dump\-xresources ] [ \-auto\-select ] [ \-parse\-hosts ] [ \-combi\-modi \fImode1,mode2\fR ] [ \-quiet ]
|
\fBrofi\fR [ \-width \fIpct_scr\fR ] [ \-lines \fIlines\fR ] [ \-columns \fIcolumns\fR ] [ \-font \fIpangofont\fR ] [ \-fg \fIcolor\fR ] [ \-fg\-urgent \fIcolor\fR ] [ \-fg\-active \fIcolor\fR ] [ \-bg\-urgent \fIcolor\fR ] [ \-bg\-active \fIcolor\fR ] [ \-bg \fIcolor\fR ] [ \-bgalt \fIcolor\fR ] [ \-hlfg \fIcolor\fR ] [ \-hlbg \fIcolor\fR ] [ \-key\-\fBmode\fR \fIcombo\fR ] [ \-terminal \fIterminal\fR ] [ \-location \fIposition\fR ] [ \-fixed\-num\-lines ] [ \-padding \fIpadding\fR ] [ \-opacity \fIopacity%\fR ] [ \-display \fIdisplay\fR ] [ \-bc \fIcolor\fR ] [ \-bw \fIwidth\fR ] [ \-dmenu [ \-p \fIprompt\fR ] [ \-sep \fIseparator\fR ] [ \-l \fIselected line\fR ] [ \-mesg ] [ \-select ] ] [ \-filter \fIfilter\fR ] [ \-ssh\-client \fIclient\fR ] [ \-ssh\-command \fIcommand\fR ] [ \-disable\-history ] [ \-levenshtein\-sort ] [ \-case\-sensitive ] [ \-show \fImode\fR ] [ \-modi \fImode1,mode2\fR ] [ \-eh \fIelement height\fR ] [ \-lazy\-filter\-limit \fIlimit\fR ] [ \-e \fImessage\fR] [ \-a \fIrow\fR ] [ \-u \fIrow\fR ] [ \-pid \fIpath\fR ] [ \-now ] [ \-rnow ] [ \-snow ] [ \-version ] [ \-help] [ \-dump\-xresources ] [ \-auto\-select ] [ \-parse\-hosts ] [ \-combi\-modi \fImode1,mode2\fR ] [ \-quiet ]
|
||||||
.
|
.
|
||||||
.SH "DESCRIPTION"
|
.SH "DESCRIPTION"
|
||||||
\fBrofi\fR is an X11 popup window switcher, run dialog, dmenu replacement and more\. It focuses on being fast to use and have minimal distraction\. It supports keyboard and mouse navigation, type to filter, tokenized search and more\.
|
\fBrofi\fR is an X11 popup window switcher, run dialog, dmenu replacement and more\. It focuses on being fast to use and have minimal distraction\. It supports keyboard and mouse navigation, type to filter, tokenized search and more\.
|
||||||
|
@ -297,6 +297,19 @@ Enable experimental fuzzy matching\.
|
||||||
.
|
.
|
||||||
.IP "" 0
|
.IP "" 0
|
||||||
.
|
.
|
||||||
|
.P
|
||||||
|
\fB\-filter\fR \fIfilter\fR
|
||||||
|
.
|
||||||
|
.IP "" 4
|
||||||
|
.
|
||||||
|
.nf
|
||||||
|
|
||||||
|
Preset user filter to *filter* in the entry box and pre\-filter the list\.
|
||||||
|
.
|
||||||
|
.fi
|
||||||
|
.
|
||||||
|
.IP "" 0
|
||||||
|
.
|
||||||
.SS "Theming"
|
.SS "Theming"
|
||||||
\fB\-bg\fR
|
\fB\-bg\fR
|
||||||
.
|
.
|
||||||
|
@ -741,11 +754,11 @@ When one entry is left, automatically select this\.
|
||||||
.
|
.
|
||||||
.IP "" 4
|
.IP "" 4
|
||||||
.
|
.
|
||||||
.P
|
.nf
|
||||||
Select (Xinerama) monitor to display **rofi** on\. The special number -1 denotes the currently focused monitor, the number -2 denotes the currently focused window (i.e. rofi will be displayed on top of the focused window).
|
|
||||||
.
|
Select (Xinerama) monitor to display **rofi** on\. The special number \-1 denotes the currently focused monitor, the number \-2 denotes the currently focused window (i\.e\. rofi will be displayed on top of the focused window)\.
|
||||||
.P
|
|
||||||
Default: \fI{cmd}\fR
|
Default: *\-1*
|
||||||
.
|
.
|
||||||
.fi
|
.fi
|
||||||
.
|
.
|
||||||
|
@ -1021,19 +1034,6 @@ Default: \'s\'
|
||||||
.IP "" 0
|
.IP "" 0
|
||||||
.
|
.
|
||||||
.P
|
.P
|
||||||
\fB\-filter\fR \fIfilter\fR
|
|
||||||
.
|
|
||||||
.IP "" 4
|
|
||||||
.
|
|
||||||
.nf
|
|
||||||
|
|
||||||
Preset user filter to *filter* in the entry box and pre\-filter the list\.
|
|
||||||
.
|
|
||||||
.fi
|
|
||||||
.
|
|
||||||
.IP "" 0
|
|
||||||
.
|
|
||||||
.P
|
|
||||||
\fB\-select\fR \fIstring\fR
|
\fB\-select\fR \fIstring\fR
|
||||||
.
|
.
|
||||||
.IP "" 4
|
.IP "" 4
|
||||||
|
|
|
@ -3,12 +3,10 @@
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param input Pointer to the user-input string.
|
|
||||||
*
|
|
||||||
* dmenu dialog.
|
* dmenu dialog.
|
||||||
*
|
*
|
||||||
* @returns TRUE if script was successful.
|
* @returns TRUE if script was successful.
|
||||||
*/
|
*/
|
||||||
int dmenu_switcher_dialog ( char **input );
|
int dmenu_switcher_dialog ( void );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -232,6 +232,8 @@ typedef struct _Settings
|
||||||
int monitor;
|
int monitor;
|
||||||
/** Line margin */
|
/** Line margin */
|
||||||
unsigned int line_margin;
|
unsigned int line_margin;
|
||||||
|
/** filter */
|
||||||
|
char *filter;
|
||||||
} Settings;
|
} Settings;
|
||||||
|
|
||||||
/** Global Settings structure. */
|
/** Global Settings structure. */
|
||||||
|
|
|
@ -178,8 +178,9 @@ static void dmenu_output_formatted_line ( const char *format, const char *string
|
||||||
fflush ( stdout );
|
fflush ( stdout );
|
||||||
}
|
}
|
||||||
|
|
||||||
int dmenu_switcher_dialog ( char **input )
|
int dmenu_switcher_dialog ( void )
|
||||||
{
|
{
|
||||||
|
char *input = NULL;
|
||||||
char *dmenu_prompt = "dmenu ";
|
char *dmenu_prompt = "dmenu ";
|
||||||
int selected_line = -1;
|
int selected_line = -1;
|
||||||
int retv = FALSE;
|
int retv = FALSE;
|
||||||
|
@ -218,7 +219,8 @@ int dmenu_switcher_dialog ( char **input )
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
find_arg_str_alloc ( "-filter", input );
|
/* copy filter string */
|
||||||
|
input = g_strdup ( config.filter );
|
||||||
|
|
||||||
char *select = NULL;
|
char *select = NULL;
|
||||||
find_arg_str ( "-select", &select );
|
find_arg_str ( "-select", &select );
|
||||||
|
@ -251,7 +253,7 @@ int dmenu_switcher_dialog ( char **input )
|
||||||
|
|
||||||
do {
|
do {
|
||||||
int next_pos = selected_line;
|
int next_pos = selected_line;
|
||||||
int mretv = menu ( list, length, input, dmenu_prompt,
|
int mretv = menu ( list, length, &input, dmenu_prompt,
|
||||||
token_match, NULL, &selected_line, config.levenshtein_sort, get_display_data, list, &next_pos, message );
|
token_match, NULL, &selected_line, config.levenshtein_sort, get_display_data, list, &next_pos, message );
|
||||||
// Special behavior.
|
// Special behavior.
|
||||||
// TODO clean this up!
|
// TODO clean this up!
|
||||||
|
@ -261,7 +263,7 @@ int dmenu_switcher_dialog ( char **input )
|
||||||
*/
|
*/
|
||||||
restart = 1;
|
restart = 1;
|
||||||
if ( ( mretv & ( MENU_OK | MENU_QUICK_SWITCH ) ) && list[selected_line] != NULL ) {
|
if ( ( mretv & ( MENU_OK | MENU_QUICK_SWITCH ) ) && list[selected_line] != NULL ) {
|
||||||
dmenu_output_formatted_line ( format, list[selected_line], selected_line, *input );
|
dmenu_output_formatted_line ( format, list[selected_line], selected_line, input );
|
||||||
retv = TRUE;
|
retv = TRUE;
|
||||||
if ( ( mretv & MENU_QUICK_SWITCH ) ) {
|
if ( ( mretv & MENU_QUICK_SWITCH ) ) {
|
||||||
retv = 10 + ( mretv & MENU_LOWER_MASK );
|
retv = 10 + ( mretv & MENU_LOWER_MASK );
|
||||||
|
@ -279,7 +281,7 @@ int dmenu_switcher_dialog ( char **input )
|
||||||
restart = FALSE;
|
restart = FALSE;
|
||||||
// Normal mode
|
// Normal mode
|
||||||
if ( ( mretv & MENU_OK ) && list[selected_line] != NULL ) {
|
if ( ( mretv & MENU_OK ) && list[selected_line] != NULL ) {
|
||||||
dmenu_output_formatted_line ( format, list[selected_line], selected_line, *input );
|
dmenu_output_formatted_line ( format, list[selected_line], selected_line, input );
|
||||||
if ( ( mretv & MENU_SHIFT ) ) {
|
if ( ( mretv & MENU_SHIFT ) ) {
|
||||||
restart = TRUE;
|
restart = TRUE;
|
||||||
// Move to next line.
|
// Move to next line.
|
||||||
|
@ -289,7 +291,7 @@ int dmenu_switcher_dialog ( char **input )
|
||||||
}
|
}
|
||||||
// Custom input
|
// Custom input
|
||||||
else if ( ( mretv & ( MENU_CUSTOM_INPUT ) ) ) {
|
else if ( ( mretv & ( MENU_CUSTOM_INPUT ) ) ) {
|
||||||
dmenu_output_formatted_line ( format, *input, -1, *input );
|
dmenu_output_formatted_line ( format, input, -1, input );
|
||||||
if ( ( mretv & MENU_SHIFT ) ) {
|
if ( ( mretv & MENU_SHIFT ) ) {
|
||||||
restart = TRUE;
|
restart = TRUE;
|
||||||
// Move to next line.
|
// Move to next line.
|
||||||
|
@ -300,14 +302,14 @@ int dmenu_switcher_dialog ( char **input )
|
||||||
}
|
}
|
||||||
// Quick switch with entry selected.
|
// Quick switch with entry selected.
|
||||||
else if ( ( mretv & MENU_QUICK_SWITCH ) && selected_line >= 0 ) {
|
else if ( ( mretv & MENU_QUICK_SWITCH ) && selected_line >= 0 ) {
|
||||||
dmenu_output_formatted_line ( format, list[selected_line], selected_line, *input );
|
dmenu_output_formatted_line ( format, list[selected_line], selected_line, input );
|
||||||
|
|
||||||
restart = FALSE;
|
restart = FALSE;
|
||||||
retv = 10 + ( mretv & MENU_LOWER_MASK );
|
retv = 10 + ( mretv & MENU_LOWER_MASK );
|
||||||
}
|
}
|
||||||
// Quick switch without entry selected.
|
// Quick switch without entry selected.
|
||||||
else if ( ( mretv & MENU_QUICK_SWITCH ) && selected_line == -1 ) {
|
else if ( ( mretv & MENU_QUICK_SWITCH ) && selected_line == -1 ) {
|
||||||
dmenu_output_formatted_line ( format, *input, -1, *input );
|
dmenu_output_formatted_line ( format, input, -1, input );
|
||||||
|
|
||||||
restart = FALSE;
|
restart = FALSE;
|
||||||
retv = 10 + ( mretv & MENU_LOWER_MASK );
|
retv = 10 + ( mretv & MENU_LOWER_MASK );
|
||||||
|
@ -318,6 +320,8 @@ int dmenu_switcher_dialog ( char **input )
|
||||||
g_free ( urgent_list );
|
g_free ( urgent_list );
|
||||||
g_free ( active_list );
|
g_free ( active_list );
|
||||||
|
|
||||||
|
g_free ( input );
|
||||||
|
|
||||||
return retv;
|
return retv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1502,17 +1502,15 @@ static void teardown ( int pfd )
|
||||||
*/
|
*/
|
||||||
static int run_dmenu ()
|
static int run_dmenu ()
|
||||||
{
|
{
|
||||||
char *input = NULL;
|
int ret_state = EXIT_FAILURE;
|
||||||
int ret_state = EXIT_FAILURE;
|
int pfd = setup ();
|
||||||
int pfd = setup ();
|
|
||||||
if ( pfd < 0 ) {
|
if ( pfd < 0 ) {
|
||||||
return ret_state;
|
return ret_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dmenu modi has a return state.
|
// Dmenu modi has a return state.
|
||||||
ret_state = dmenu_switcher_dialog ( &input );
|
ret_state = dmenu_switcher_dialog ();
|
||||||
|
|
||||||
g_free ( input );
|
|
||||||
teardown ( pfd );
|
teardown ( pfd );
|
||||||
return ret_state;
|
return ret_state;
|
||||||
}
|
}
|
||||||
|
@ -1524,7 +1522,7 @@ static void run_switcher ( SwitcherMode mode )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Otherwise check if requested mode is enabled.
|
// Otherwise check if requested mode is enabled.
|
||||||
char *input = NULL;
|
char *input = g_strdup ( config.filter );
|
||||||
for ( unsigned int i = 0; i < num_switchers; i++ ) {
|
for ( unsigned int i = 0; i < num_switchers; i++ ) {
|
||||||
switchers[i]->init ( switchers[i] );
|
switchers[i]->init ( switchers[i] );
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,8 @@ static XrmOption xrmOptions[] = {
|
||||||
{ xrm_Number, "monitor", { .snum = &config.monitor }, NULL },
|
{ xrm_Number, "monitor", { .snum = &config.monitor }, NULL },
|
||||||
/* Alias for dmenu compatibility. */
|
/* Alias for dmenu compatibility. */
|
||||||
{ xrm_SNumber, "m", { .snum = &config.monitor }, NULL },
|
{ xrm_SNumber, "m", { .snum = &config.monitor }, NULL },
|
||||||
{ xrm_Number, "line-margin", { .num = &config.line_margin }, NULL }
|
{ xrm_Number, "line-margin", { .num = &config.line_margin }, NULL },
|
||||||
|
{ xrm_String, "filter", { .str = &config.filter }, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Dynamic options.
|
// Dynamic options.
|
||||||
|
|
Loading…
Reference in a new issue