Add ctrl-space to set selected item as input.

This commit is contained in:
QC 2014-09-03 19:40:24 +02:00
parent 0462811800
commit 20dca49a22
4 changed files with 54 additions and 5 deletions

View File

@ -312,6 +312,7 @@ Rofi supports the following keybindings:
* `Ctrl-Page Up`: Go to the previous column * `Ctrl-Page Up`: Go to the previous column
* `Ctrl-Page Down`: Go to the next column * `Ctrl-Page Down`: Go to the next column
* `?`: Switch to the next modi. The list can be customized with the `-switchers` argument. * `?`: Switch to the next modi. The list can be customized with the `-switchers` argument.
* `Ctrl-space`: Set selected item as input text.
## WEBSITE ## WEBSITE

View File

@ -8,8 +8,9 @@ rofi \- A window switcher, run dialog and dmenu replacement
[ \-bg \fIcolor\fP ] [ \-hlfg \fIcolor\fP ] [ \-hlbg \fIcolor\fP ] [ \-key \fIcombo\fP ] [ \-dkey \fIcomdo\fP ] [ \-rkey \fIcomdo\fP ] [ \-bg \fIcolor\fP ] [ \-hlfg \fIcolor\fP ] [ \-hlbg \fIcolor\fP ] [ \-key \fIcombo\fP ] [ \-dkey \fIcomdo\fP ] [ \-rkey \fIcomdo\fP ]
[ \-terminal \fIterminal\fP ] [ \-location \fIposition\fP ] [ \-hmode ] [ \-fixed\-num\-lines ] [ \-padding \fIpadding\fP ] [ \-terminal \fIterminal\fP ] [ \-location \fIposition\fP ] [ \-hmode ] [ \-fixed\-num\-lines ] [ \-padding \fIpadding\fP ]
[ \-opacity \fIopacity%\fP ] [ \-display \fIdisplay\fP ] [ \-bc \fIcolor\fP ] [ \-bw \fIwidth\fP ] [ \-dmenu [ \-p \fIprompt\fP ] ] [ \-opacity \fIopacity%\fP ] [ \-display \fIdisplay\fP ] [ \-bc \fIcolor\fP ] [ \-bw \fIwidth\fP ] [ \-dmenu [ \-p \fIprompt\fP ] ]
[ \-ssh\-set\-title \fItrue|false\fP ] [ \-now ] [ \-rnow ] [ \-snow ] [ \-version ] [ \-help] [ \-dump\-xresources ] [ \-ssh\-client \fIclient\fP ] [ \-ssh\-command \fIcommand\fP ] [ \-now ] [ \-rnow ] [ \-snow ] [ \-version ]
[ \-disable\-history ] [ \-levenshtein\-sort ] [ \-show \fImode\fP ] [ \-switcher \fImode1,mode2\fP ] [ \-e \fImessage\fP] [ \-help] [ \-dump\-xresources ] [ \-disable\-history ] [ \-levenshtein\-sort ] [ \-show \fImode\fP ] [ \-switcher
\fImode1,mode2\fP ] [ \-e \fImessage\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.
@ -281,6 +282,26 @@ Dump the current active configuration in xresources format to the command\-line.
SSH dialogs tries to set 'ssh hostname' of the spawned terminal. SSH dialogs tries to set 'ssh hostname' of the spawned terminal.
Not all terminals support this. Not all terminals support this.
Default value is true. Default value is true.
.IP
\fIThis command has been deprecated for the ssh\-command string\fP
.PP
\fB\fC\-ssh\-command\fR \fIcmd\fP
.IP
Set the command to execute when starting a ssh session.
.PP
\fB\fC\-run\-command\fR \fIcmd\fP
.IP
Set the command to execute when running an application.
See \fIPATTERN\fP\&.
.PP
\fB\fC\-run\-shell\-command\fR \fIcmd\fP
.IP
Set the command to execute when running an application in a shell.
See \fIPATTERN\fP\&.
.PP
\fB\fC\-ssh\-client\fR \fIclient\fP
.IP
Override the used ssh client. Default is \fB\fCssh\fR\&.
.PP .PP
\fB\fC\-disable\-history\fR \fB\fC\-disable\-history\fR
.IP .IP
@ -341,6 +362,20 @@ So to have a mode 'Workspaces' using the \fB\fCi3_switch_workspace.sh\fR script
Popup a message dialog (used internally for showing errors) with *message*. Popup a message dialog (used internally for showing errors) with *message*.
.fi .fi
.RE .RE
.SH Pattern
.PP
To launch commands (e.g. when using the ssh dialog) the user can enter the used commandline,
the following keys can be used that will be replaced at runtime:
.RS
.IP \(bu 2
\fB\fC{host}\fR: The host to connect to.
.IP \(bu 2
\fB\fC{terminal}\fR: The configured terminal (See \-terminal\-emulator)
.IP \(bu 2
\fB\fC{ssh\-client}\fR: The configured ssh client (See \-ssh\-client)
.IP \(bu 2
\fB\fC{cmd}\fR: The command to execute.
.RE
.SH Keybindings .SH Keybindings
.PP .PP
Rofi supports the following keybindings: Rofi supports the following keybindings:
@ -379,6 +414,8 @@ Rofi supports the following keybindings:
\fB\fCCtrl\-Page Down\fR: Go to the next column \fB\fCCtrl\-Page Down\fR: Go to the next column
.IP \(bu 2 .IP \(bu 2
\fB\fC?\fR: Switch to the next modi. The list can be customized with the \fB\fC\-switchers\fR argument. \fB\fC?\fR: Switch to the next modi. The list can be customized with the \fB\fC\-switchers\fR argument.
.IP \(bu 2
\fB\fCCtrl\-space\fR: Set selected item as input text.
.RE .RE
.SH WEBSITE .SH WEBSITE
.PP .PP

View File

@ -930,6 +930,7 @@ typedef struct MenuState
// Return state // Return state
int *selected_line; int *selected_line;
MenuReturn retv; MenuReturn retv;
char **lines;
}MenuState; }MenuState;
/** /**
@ -1184,6 +1185,15 @@ static void menu_keyboard_navigation ( MenuState *state, KeySym key, unsigned in
state->selected = state->filtered_lines - 1; state->selected = state->filtered_lines - 1;
state->update = TRUE; state->update = TRUE;
} }
else if ( key == XK_space && (modstate & ControlMask ) == ControlMask ) {
// If a valid item is selected, return that..
if ( state->selected < state->filtered_lines && state->filtered[state->selected] != NULL ) {
textbox_text( state->text, state->lines[state->line_map[state->selected]] );
textbox_cursor_end( state->text );
state->update = TRUE;
state->refilter = TRUE;
}
}
state->prev_key = key; state->prev_key = key;
} }
@ -1415,7 +1425,8 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
.max_elements = 0, .max_elements = 0,
// We want to filter on the first run. // We want to filter on the first run.
.refilter = TRUE, .refilter = TRUE,
.update = FALSE .update = FALSE,
.lines = lines
}; };
unsigned int i; unsigned int i;
workarea mon; workarea mon;

View File

@ -34,11 +34,11 @@ textbox_test_SOURCES=\
textbox-test.c textbox-test.c
helper_test_SOURCES=\ helper_test_SOURCES=\
helper-test.c\
../config/config.c\ ../config/config.c\
../include/rofi.h\ ../include/rofi.h\
../source/helper.c\ ../source/helper.c\
../include/helper.h ../include/helper.h\
helper-test.c
.PHONY: test .PHONY: test
test: ${bin_PROGRAMS} test: ${bin_PROGRAMS}