mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -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 = -1,
|
||||
.line_margin = 3,
|
||||
.filter = NULL,
|
||||
};
|
||||
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
[ -display *display* ]
|
||||
[ -bc *color* ]
|
||||
[ -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-command *command* ]
|
||||
[ -disable-history ]
|
||||
|
@ -197,6 +198,10 @@ Below is a list of the most important options:
|
|||
|
||||
Enable experimental fuzzy matching.
|
||||
|
||||
`-filter` *filter*
|
||||
|
||||
Preset user filter to *filter* in the entry box and pre-filter the list.
|
||||
|
||||
|
||||
### Theming
|
||||
|
||||
|
@ -560,10 +565,6 @@ The following options are further explained in the theming section:
|
|||
|
||||
Default: 's'
|
||||
|
||||
`-filter` *filter*
|
||||
|
||||
Preset user filter to *filter* in the entry box and pre-filter the list.
|
||||
|
||||
`-select` *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
|
||||
.
|
||||
.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"
|
||||
\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
|
||||
.
|
||||
.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"
|
||||
\fB\-bg\fR
|
||||
.
|
||||
|
@ -741,11 +754,11 @@ When one entry is left, automatically select this\.
|
|||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.P
|
||||
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
|
||||
.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)\.
|
||||
|
||||
Default: *\-1*
|
||||
.
|
||||
.fi
|
||||
.
|
||||
|
@ -1021,19 +1034,6 @@ Default: \'s\'
|
|||
.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
|
||||
.
|
||||
.P
|
||||
\fB\-select\fR \fIstring\fR
|
||||
.
|
||||
.IP "" 4
|
||||
|
|
|
@ -3,12 +3,10 @@
|
|||
|
||||
|
||||
/**
|
||||
* @param input Pointer to the user-input string.
|
||||
*
|
||||
* dmenu dialog.
|
||||
*
|
||||
* @returns TRUE if script was successful.
|
||||
*/
|
||||
int dmenu_switcher_dialog ( char **input );
|
||||
int dmenu_switcher_dialog ( void );
|
||||
|
||||
#endif
|
||||
|
|
|
@ -232,6 +232,8 @@ typedef struct _Settings
|
|||
int monitor;
|
||||
/** Line margin */
|
||||
unsigned int line_margin;
|
||||
/** filter */
|
||||
char *filter;
|
||||
} Settings;
|
||||
|
||||
/** Global Settings structure. */
|
||||
|
|
|
@ -178,8 +178,9 @@ static void dmenu_output_formatted_line ( const char *format, const char *string
|
|||
fflush ( stdout );
|
||||
}
|
||||
|
||||
int dmenu_switcher_dialog ( char **input )
|
||||
int dmenu_switcher_dialog ( void )
|
||||
{
|
||||
char *input = NULL;
|
||||
char *dmenu_prompt = "dmenu ";
|
||||
int selected_line = -1;
|
||||
int retv = FALSE;
|
||||
|
@ -218,7 +219,8 @@ int dmenu_switcher_dialog ( char **input )
|
|||
return TRUE;
|
||||
}
|
||||
}
|
||||
find_arg_str_alloc ( "-filter", input );
|
||||
/* copy filter string */
|
||||
input = g_strdup ( config.filter );
|
||||
|
||||
char *select = NULL;
|
||||
find_arg_str ( "-select", &select );
|
||||
|
@ -251,7 +253,7 @@ int dmenu_switcher_dialog ( char **input )
|
|||
|
||||
do {
|
||||
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 );
|
||||
// Special behavior.
|
||||
// TODO clean this up!
|
||||
|
@ -261,7 +263,7 @@ int dmenu_switcher_dialog ( char **input )
|
|||
*/
|
||||
restart = 1;
|
||||
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;
|
||||
if ( ( mretv & MENU_QUICK_SWITCH ) ) {
|
||||
retv = 10 + ( mretv & MENU_LOWER_MASK );
|
||||
|
@ -279,7 +281,7 @@ int dmenu_switcher_dialog ( char **input )
|
|||
restart = FALSE;
|
||||
// Normal mode
|
||||
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 ) ) {
|
||||
restart = TRUE;
|
||||
// Move to next line.
|
||||
|
@ -289,7 +291,7 @@ int dmenu_switcher_dialog ( char **input )
|
|||
}
|
||||
// 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 ) ) {
|
||||
restart = TRUE;
|
||||
// Move to next line.
|
||||
|
@ -300,14 +302,14 @@ int dmenu_switcher_dialog ( char **input )
|
|||
}
|
||||
// Quick switch with entry selected.
|
||||
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;
|
||||
retv = 10 + ( mretv & MENU_LOWER_MASK );
|
||||
}
|
||||
// Quick switch without entry selected.
|
||||
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;
|
||||
retv = 10 + ( mretv & MENU_LOWER_MASK );
|
||||
|
@ -318,6 +320,8 @@ int dmenu_switcher_dialog ( char **input )
|
|||
g_free ( urgent_list );
|
||||
g_free ( active_list );
|
||||
|
||||
g_free ( input );
|
||||
|
||||
return retv;
|
||||
}
|
||||
|
||||
|
|
|
@ -1502,17 +1502,15 @@ static void teardown ( int pfd )
|
|||
*/
|
||||
static int run_dmenu ()
|
||||
{
|
||||
char *input = NULL;
|
||||
int ret_state = EXIT_FAILURE;
|
||||
int pfd = setup ();
|
||||
int ret_state = EXIT_FAILURE;
|
||||
int pfd = setup ();
|
||||
if ( pfd < 0 ) {
|
||||
return ret_state;
|
||||
}
|
||||
|
||||
// Dmenu modi has a return state.
|
||||
ret_state = dmenu_switcher_dialog ( &input );
|
||||
ret_state = dmenu_switcher_dialog ();
|
||||
|
||||
g_free ( input );
|
||||
teardown ( pfd );
|
||||
return ret_state;
|
||||
}
|
||||
|
@ -1524,7 +1522,7 @@ static void run_switcher ( SwitcherMode mode )
|
|||
return;
|
||||
}
|
||||
// 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++ ) {
|
||||
switchers[i]->init ( switchers[i] );
|
||||
}
|
||||
|
|
|
@ -127,7 +127,8 @@ static XrmOption xrmOptions[] = {
|
|||
{ xrm_Number, "monitor", { .snum = &config.monitor }, NULL },
|
||||
/* Alias for dmenu compatibility. */
|
||||
{ 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.
|
||||
|
|
Loading…
Reference in a new issue