mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Introduce lazy-refilter mode for long lists.
This commit is contained in:
parent
7e6241226e
commit
661b65dd2a
6 changed files with 62 additions and 16 deletions
|
@ -108,6 +108,8 @@ Settings config = {
|
||||||
/** Height of an element in #chars */
|
/** Height of an element in #chars */
|
||||||
.element_height = 1,
|
.element_height = 1,
|
||||||
/** Sidebar mode, show the switchers */
|
/** Sidebar mode, show the switchers */
|
||||||
.sidebar_mode = FALSE
|
.sidebar_mode = FALSE,
|
||||||
|
/** Lazy mode setting */
|
||||||
|
.lazy_filter_limit = 5000
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ rofi - A window switcher, run dialog and dmenu replacement
|
||||||
*command* ] [ -now ] [ -rnow ] [ -snow ] [ -version ] [ -help] [ -dump-xresources ] [
|
*command* ] [ -now ] [ -rnow ] [ -snow ] [ -version ] [ -help] [ -dump-xresources ] [
|
||||||
-disable-history ] [ -levenshtein-sort ] [ -case-sensitive ] [ -show *mode* ] [ -switcher *mode1,
|
-disable-history ] [ -levenshtein-sort ] [ -case-sensitive ] [ -show *mode* ] [ -switcher *mode1,
|
||||||
mode2* ] [ -e *message*] [ -sep *separator* ] [ -eh *element height* ] [ -l *selected line* ] [
|
mode2* ] [ -e *message*] [ -sep *separator* ] [ -eh *element height* ] [ -l *selected line* ] [
|
||||||
-run-list-command *cmd* ]
|
-run-list-command *cmd* ] [ -lazy-filter-limit *limit* ]
|
||||||
|
|
||||||
## DESCRIPTION
|
## DESCRIPTION
|
||||||
|
|
||||||
|
@ -252,6 +252,12 @@ The default key combinations are:
|
||||||
|
|
||||||
rofi -rnow -sidebar-mode -lines 0
|
rofi -rnow -sidebar-mode -lines 0
|
||||||
|
|
||||||
|
`-lazy-filter-limit` *limit*
|
||||||
|
|
||||||
|
The number of entries required for Rofi to go into lazy filter mode.
|
||||||
|
In lazy filter mode, it won't refilter the list on each keypress, but only after rofi been idle
|
||||||
|
for 250ms. Default is 5000 lines, set to 0 to always enable.
|
||||||
|
|
||||||
### Pattern setting
|
### Pattern setting
|
||||||
|
|
||||||
`-terminal`
|
`-terminal`
|
||||||
|
|
20
doc/rofi.1
20
doc/rofi.1
|
@ -12,7 +12,7 @@ rofi \- A window switcher, run dialog and dmenu replacement
|
||||||
\fIcommand\fP ] [ \-now ] [ \-rnow ] [ \-snow ] [ \-version ] [ \-help] [ \-dump\-xresources ] [
|
\fIcommand\fP ] [ \-now ] [ \-rnow ] [ \-snow ] [ \-version ] [ \-help] [ \-dump\-xresources ] [
|
||||||
\-disable\-history ] [ \-levenshtein\-sort ] [ \-case\-sensitive ] [ \-show \fImode\fP ] [ \-switcher \fImode1,
|
\-disable\-history ] [ \-levenshtein\-sort ] [ \-case\-sensitive ] [ \-show \fImode\fP ] [ \-switcher \fImode1,
|
||||||
mode2\fP ] [ \-e \fImessage\fP] [ \-sep \fIseparator\fP ] [ \-eh \fIelement height\fP ] [ \-l \fIselected line\fP ] [
|
mode2\fP ] [ \-e \fImessage\fP] [ \-sep \fIseparator\fP ] [ \-eh \fIelement height\fP ] [ \-l \fIselected line\fP ] [
|
||||||
\-run\-list\-command \fIcmd\fP ]
|
\-run\-list\-command \fIcmd\fP ] [ \-lazy\-filter\-limit \fIlimit\fP ]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.PP
|
.PP
|
||||||
\fBrofi\fP is an X11 popup window switcher. A list is displayed center\-screen showing open window titles, WM_CLASS, and desktop number.
|
\fBrofi\fP is an X11 popup window switcher. A list is displayed center\-screen showing open window titles, WM_CLASS, and desktop number.
|
||||||
|
@ -332,6 +332,12 @@ To show sidebar use:
|
||||||
rofi \-rnow \-sidebar\-mode \-lines 0
|
rofi \-rnow \-sidebar\-mode \-lines 0
|
||||||
.fi
|
.fi
|
||||||
.RE
|
.RE
|
||||||
|
.PP
|
||||||
|
\fB\fC\-lazy\-filter\-limit\fR \fIlimit\fP
|
||||||
|
.PP
|
||||||
|
The number of entries required for Rofi to go into lazy filter mode.
|
||||||
|
In lazy filter mode, it won't refilter the list on each keypress, but only after rofi been idle
|
||||||
|
for 250ms. Default is 5000 lines, set to 0 to always enable.
|
||||||
.SS Pattern setting
|
.SS Pattern setting
|
||||||
.PP
|
.PP
|
||||||
\fB\fC\-terminal\fR
|
\fB\fC\-terminal\fR
|
||||||
|
@ -539,14 +545,18 @@ Check quotes used on the commandline: e.g. used “ instead of ".
|
||||||
.SH WEBSITE
|
.SH WEBSITE
|
||||||
.PP
|
.PP
|
||||||
\fBrofi\fP website can be found at here
|
\fBrofi\fP website can be found at here
|
||||||
\[la]https://davedavenport.github.io/rofi/\[ra]
|
.UR https://davedavenport.github.io/rofi/
|
||||||
|
.UE
|
||||||
.PP
|
.PP
|
||||||
\fBrofi\fP bugtracker can be found here
|
\fBrofi\fP bugtracker can be found here
|
||||||
\[la]https://github.com/DaveDavenport/rofi/issues\[ra]
|
.UR https://github.com/DaveDavenport/rofi/issues
|
||||||
|
.UE
|
||||||
.SH AUTHOR
|
.SH AUTHOR
|
||||||
.PP
|
.PP
|
||||||
Qball Cow
|
Qball Cow
|
||||||
\[la]qball@gmpclient.org\[ra]
|
.MT qball@gmpclient.org
|
||||||
|
.ME
|
||||||
.PP
|
.PP
|
||||||
Original code based on work by: Sean Pringle
|
Original code based on work by: Sean Pringle
|
||||||
\[la]sean.pringle@gmail.com\[ra]
|
.MT sean.pringle@gmail.com
|
||||||
|
.ME
|
||||||
|
|
|
@ -205,6 +205,8 @@ typedef struct _Settings
|
||||||
int element_height;
|
int element_height;
|
||||||
/** Sidebar mode, show the switchers */
|
/** Sidebar mode, show the switchers */
|
||||||
int sidebar_mode;
|
int sidebar_mode;
|
||||||
|
/** Lazy filter limit. */
|
||||||
|
unsigned int lazy_filter_limit;
|
||||||
} Settings;
|
} Settings;
|
||||||
|
|
||||||
/** Global Settings structure. */
|
/** Global Settings structure. */
|
||||||
|
|
|
@ -1659,11 +1659,10 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
|
||||||
}
|
}
|
||||||
|
|
||||||
state.quit = FALSE;
|
state.quit = FALSE;
|
||||||
|
menu_refilter ( &state, lines, mmc, mmc_data, sorting, config.case_sensitive );
|
||||||
|
|
||||||
|
int x11_fd = ConnectionNumber ( display );
|
||||||
while ( !state.quit ) {
|
while ( !state.quit ) {
|
||||||
// If something changed, refilter the list. (paste or text entered)
|
|
||||||
if ( state.refilter ) {
|
|
||||||
menu_refilter ( &state, lines, mmc, mmc_data, sorting, config.case_sensitive );
|
|
||||||
}
|
|
||||||
// Update if requested.
|
// Update if requested.
|
||||||
if ( state.update ) {
|
if ( state.update ) {
|
||||||
menu_update ( &state );
|
menu_update ( &state );
|
||||||
|
@ -1671,6 +1670,34 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
|
||||||
|
|
||||||
// Wait for event.
|
// Wait for event.
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
// Only use lazy mode above 5000 lines.
|
||||||
|
if ( state.num_lines > config.lazy_filter_limit ) {
|
||||||
|
// No message waiting, update been set, do timeout trick.
|
||||||
|
if ( state.refilter && !XPending ( display ) ) {
|
||||||
|
// This implements a lazy re-filtering.
|
||||||
|
struct timeval tv;
|
||||||
|
fd_set in_fds;
|
||||||
|
// Create a File Description Set containing x11_fd
|
||||||
|
FD_ZERO ( &in_fds );
|
||||||
|
FD_SET ( x11_fd, &in_fds );
|
||||||
|
|
||||||
|
// Set our timer. 200ms is a decent delay
|
||||||
|
tv.tv_usec = 200000;
|
||||||
|
tv.tv_sec = 0;
|
||||||
|
// Wait for X Event or a Timer
|
||||||
|
if ( select ( x11_fd + 1, &in_fds, 0, 0, &tv ) == 0 ) {
|
||||||
|
// Timer expired, update.
|
||||||
|
menu_refilter ( &state, lines, mmc, mmc_data, sorting, config.case_sensitive );
|
||||||
|
menu_update ( &state );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( state.refilter ) {
|
||||||
|
menu_refilter ( &state, lines, mmc, mmc_data, sorting, config.case_sensitive );
|
||||||
|
menu_update ( &state );
|
||||||
|
}
|
||||||
|
}
|
||||||
XNextEvent ( display, &ev );
|
XNextEvent ( display, &ev );
|
||||||
|
|
||||||
// Handle event.
|
// Handle event.
|
||||||
|
@ -1697,10 +1724,6 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
|
||||||
// Key press event.
|
// Key press event.
|
||||||
else if ( ev.type == KeyPress ) {
|
else if ( ev.type == KeyPress ) {
|
||||||
do {
|
do {
|
||||||
// while ( XCheckTypedEvent ( display, KeyPress, &ev ) ) {
|
|
||||||
// ;
|
|
||||||
// }
|
|
||||||
|
|
||||||
if ( time ) {
|
if ( time ) {
|
||||||
*time = ev.xkey.time;
|
*time = ev.xkey.time;
|
||||||
}
|
}
|
||||||
|
@ -2365,6 +2388,8 @@ static void parse_cmd_options ( int argc, char ** argv )
|
||||||
|
|
||||||
find_arg_int ( argc, argv, "-eh", &( config.element_height ) );
|
find_arg_int ( argc, argv, "-eh", &( config.element_height ) );
|
||||||
|
|
||||||
|
find_arg_int ( argc, argv, "-lazy-filter-limit", &( config.lazy_filter_limit ) );
|
||||||
|
|
||||||
if ( find_arg ( argc, argv, "-sidebar-mode" ) >= 0 ) {
|
if ( find_arg ( argc, argv, "-sidebar-mode" ) >= 0 ) {
|
||||||
config.sidebar_mode = TRUE;
|
config.sidebar_mode = TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,8 @@ static XrmOption xrmOptions[] = {
|
||||||
{ xrm_String, "key", { .str = &config.window_key }, NULL },
|
{ xrm_String, "key", { .str = &config.window_key }, NULL },
|
||||||
{ xrm_String, "rkey", { .str = &config.run_key }, NULL },
|
{ xrm_String, "rkey", { .str = &config.run_key }, NULL },
|
||||||
{ xrm_String, "skey", { .str = &config.ssh_key }, NULL },
|
{ xrm_String, "skey", { .str = &config.ssh_key }, NULL },
|
||||||
{ xrm_Boolean, "sidebar-mode", { .num = &config.sidebar_mode }, NULL }
|
{ xrm_Boolean, "sidebar-mode", { .num = &config.sidebar_mode }, NULL },
|
||||||
|
{ xrm_Number, "lazy-filter-limit", { .num = &config.lazy_filter_limit }, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue