Switch to stop cycling feature (#407)

* Added 'cycle' option to switch list navigation wrapping

* Replaced tabs with spaces

* Updating the expected rofi properties with 'cycle' option

* Updating documentation with the 'cycle' option
This commit is contained in:
Yaroslav 2016-05-25 14:40:23 -04:00 committed by Dave Davenport
parent 17e9398699
commit f901494c6a
7 changed files with 28 additions and 7 deletions

View File

@ -94,6 +94,8 @@ Settings config = {
.levenshtein_sort = FALSE, .levenshtein_sort = FALSE,
/** Case sensitivity of the search */ /** Case sensitivity of the search */
.case_sensitive = FALSE, .case_sensitive = FALSE,
/** Cycle through in the element list */
.cycle = TRUE,
/** 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 */

View File

@ -26,6 +26,7 @@
[ -disable-history ] [ -disable-history ]
[ -levenshtein-sort ] [ -levenshtein-sort ]
[ -case-sensitive ] [ -case-sensitive ]
[ -cycle ]
[ -show *mode* ] [ -show *mode* ]
[ -modi *mode1,mode2* ] [ -modi *mode1,mode2* ]
[ -eh *element height* ] [ -eh *element height* ]
@ -185,6 +186,10 @@ Example: Have a mode 'Workspaces' using the `i3_switch_workspace.sh` script:
Start in case sensitive mode. Start in case sensitive mode.
`-cycle`
Cycle through the results list. Default is 'true'.
`-fuzzy` `-fuzzy`
Enable experimental fuzzy matching. Enable experimental fuzzy matching.

View File

@ -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 ] [ \-terminal \fIterminal\fR ] [ \-location \fIposition\fR ] [ \-fixed\-num\-lines ] [ \-padding \fIpadding\fR ] [ \-opacity \fIopacity%\fR ] [ \-display \fIdisplay\fR ] [ \-bw \fIwidth\fR ] [ \-dmenu [ \-p \fIprompt\fR ] [ \-sep \fIseparator\fR ] [ \-l \fIselected line\fR ] [ \-mesg ] [ \-select ] [ \-input \fIinput\fR ] ] [ \-filter \fIfilter\fR ] [ \-ssh\-client \fIclient\fR ] [ \-ssh\-command \fIcommand\fR ] [ \-window\-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 ] [ \-dump\-xresources\-theme ] [ \-auto\-select ] [ \-parse\-hosts ] [ \-no\-parse\-known\-hosts ] [ \-combi\-modi \fImode1,mode2\fR ] [ \-normal\-window ] [ \-fake\-transparency ] [ \-glob ] [ \-regex ] [ \-tokenize ] [ \-threads \fInum\fR ] [ \-config \fIfilename\fR ] \fBrofi\fR [ \-width \fIpct_scr\fR ] [ \-lines \fIlines\fR ] [ \-columns \fIcolumns\fR ] [ \-font \fIpangofont\fR ] [ \-terminal \fIterminal\fR ] [ \-location \fIposition\fR ] [ \-fixed\-num\-lines ] [ \-padding \fIpadding\fR ] [ \-opacity \fIopacity%\fR ] [ \-display \fIdisplay\fR ] [ \-bw \fIwidth\fR ] [ \-dmenu [ \-p \fIprompt\fR ] [ \-sep \fIseparator\fR ] [ \-l \fIselected line\fR ] [ \-mesg ] [ \-select ] [ \-input \fIinput\fR ] ] [ \-filter \fIfilter\fR ] [ \-ssh\-client \fIclient\fR ] [ \-ssh\-command \fIcommand\fR ] [ \-window\-command \fIcommand\fR ] [ \-disable\-history ] [ \-levenshtein\-sort ] [ \-case\-sensitive ] [ \-cycle ] [ \-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 ] [ \-dump\-xresources\-theme ] [ \-auto\-select ] [ \-parse\-hosts ] [ \-no\-parse\-known\-hosts ] [ \-combi\-modi \fImode1,mode2\fR ] [ \-normal\-window ] [ \-fake\-transparency ] [ \-glob ] [ \-regex ] [ \-tokenize ] [ \-threads \fInum\fR ] [ \-config \fIfilename\fR ]
. .
.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\.
@ -268,6 +268,12 @@ rofi \-modi "window,run,ssh,Workspaces:i3_switch_workspaces\.sh" \-show Workspac
Start in case sensitive mode\. Start in case sensitive mode\.
. .
.P .P
\fB\-cycle\fR
.
.P
Cycle through the results list\. Default is 'true'\.
.
.P
\fB\-fuzzy\fR \fB\-fuzzy\fR
. .
.P .P

View File

@ -50,6 +50,8 @@ rofi.disable-history: false
rofi.levenshtein-sort: false rofi.levenshtein-sort: false
! Set case-sensitivity ! Set case-sensitivity
rofi.case-sensitive: false rofi.case-sensitive: false
! Cycle through the results list
rofi.cycle: true
! Enable sidebar-mode ! Enable sidebar-mode
rofi.sidebar-mode: false rofi.sidebar-mode: false
! Row height (in chars) ! Row height (in chars)

View File

@ -90,6 +90,8 @@ typedef struct
unsigned int levenshtein_sort; unsigned int levenshtein_sort;
/** Search case sensitivity */ /** Search case sensitivity */
unsigned int case_sensitive; unsigned int case_sensitive;
/** Cycle through in the element list */
unsigned int cycle;
/** 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 */

View File

@ -798,14 +798,16 @@ inline static void rofi_view_nav_left ( RofiViewState *state )
*/ */
inline static void rofi_view_nav_up ( RofiViewState *state ) inline static void rofi_view_nav_up ( RofiViewState *state )
{ {
// If no lines or don't cycle, do nothing.
if ( state->filtered_lines == 0 || ( state->selected == 0 && !config.cycle ) ) {
return;
}
// Wrap around. // Wrap around.
if ( state->selected == 0 ) { if ( state->selected == 0 ) {
state->selected = state->filtered_lines; state->selected = state->filtered_lines;
} }
state->selected--;
if ( state->selected > 0 ) {
state->selected--;
}
state->update = TRUE; state->update = TRUE;
} }
@ -817,8 +819,8 @@ inline static void rofi_view_nav_up ( RofiViewState *state )
*/ */
inline static void rofi_view_nav_down ( RofiViewState *state ) inline static void rofi_view_nav_down ( RofiViewState *state )
{ {
// If no lines, do nothing. // If no lines or don't cycle, do nothing.
if ( state->filtered_lines == 0 ) { if ( state->filtered_lines == 0 || ( state->selected == state->filtered_lines - 1 && !config.cycle ) ) {
return; return;
} }
state->selected = state->selected < state->filtered_lines - 1 ? MIN ( state->filtered_lines - 1, state->selected + 1 ) : 0; state->selected = state->selected < state->filtered_lines - 1 ? MIN ( state->filtered_lines - 1, state->selected + 1 ) : 0;

View File

@ -125,6 +125,8 @@ static XrmOption xrmOptions[] = {
"Use levenshtein sorting" }, "Use levenshtein sorting" },
{ xrm_Boolean, "case-sensitive", { .num = &config.case_sensitive }, NULL, { xrm_Boolean, "case-sensitive", { .num = &config.case_sensitive }, NULL,
"Set case-sensitivity" }, "Set case-sensitivity" },
{ xrm_Boolean, "cycle", { .num = &config.cycle }, NULL,
"Cycle through the results list" },
{ xrm_Boolean, "sidebar-mode", { .num = &config.sidebar_mode }, NULL, { xrm_Boolean, "sidebar-mode", { .num = &config.sidebar_mode }, NULL,
"Enable sidebar-mode" }, "Enable sidebar-mode" },
{ xrm_SNumber, "eh", { .snum = &config.element_height }, NULL, { xrm_SNumber, "eh", { .snum = &config.element_height }, NULL,