diff --git a/doc/rofi-manpage.markdown b/doc/rofi-manpage.markdown index aad9be47..ac545869 100644 --- a/doc/rofi-manpage.markdown +++ b/doc/rofi-manpage.markdown @@ -253,6 +253,25 @@ the `-switchers` argument. **rofi** website can be found at [here](https://davedavenport.github.io/rofi/) +## Keybinding + +* `Ctrl-v, Insert`: Paste clipboard +* `Ctrl-Shift-v, Shift-Insert`: Paste primary selection +* `Ctrl-u`: Clear the line +* `Ctrl-a`: Beginning of line +* `Ctrl-e`: End of line +* `Ctrl-f, Right`: Forward one character +* `Ctrl-b, Left`: Back one character +* `Ctrl-d, Delete`: Delete character +* `Ctrl-h, Backspace`: Backspace (delete previous character) +* `Ctrl-j,Ctrl-m,Enter`: Accept entry +* `Ctrl-n,Down`: Select next entry +* `Ctrl-p,Up`: Select previous entry +* `Page Up`: Go to the previous page +* `Page Down`: Go to the next page +* `Ctrl-Page Up`: Go to the previous column +* `Ctrl-Page Down`: Go to the next column + ## AUTHOR Qball Cow diff --git a/doc/rofi.1 b/doc/rofi.1 index b43626d1..8960bced 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -321,6 +321,41 @@ the \fB\fC\-switchers\fR argument. \fBrofi\fP website can be found at here .UR https://davedavenport.github.io/rofi/ .UE +.SH Keybinding +.RS +.IP \(bu 2 +\fB\fCCtrl\-v, Insert\fR: Paste clipboard +.IP \(bu 2 +\fB\fCCtrl\-Shift\-v, Shift\-Insert\fR: Paste primary selection +.IP \(bu 2 +\fB\fCCtrl\-u\fR: Clear the line +.IP \(bu 2 +\fB\fCCtrl\-a\fR: Beginning of line +.IP \(bu 2 +\fB\fCCtrl\-e\fR: End of line +.IP \(bu 2 +\fB\fCCtrl\-f, Right\fR: Forward one character +.IP \(bu 2 +\fB\fCCtrl\-b, Left\fR: Back one character +.IP \(bu 2 +\fB\fCCtrl\-d, Delete\fR: Delete character +.IP \(bu 2 +\fB\fCCtrl\-h, Backspace\fR: Backspace (delete previous character) +.IP \(bu 2 +\fB\fCCtrl\-j,Ctrl\-m,Enter\fR: Accept entry +.IP \(bu 2 +\fB\fCCtrl\-n,Down\fR: Select next entry +.IP \(bu 2 +\fB\fCCtrl\-p,Up\fR: Select previous entry +.IP \(bu 2 +\fB\fCPage Up\fR: Go to the previous page +.IP \(bu 2 +\fB\fCPage Down\fR: Go to the next page +.IP \(bu 2 +\fB\fCCtrl\-Page Up\fR: Go to the previous column +.IP \(bu 2 +\fB\fCCtrl\-Page Down\fR: Go to the next column +.RE .SH AUTHOR .PP Qball Cow diff --git a/source/rofi.c b/source/rofi.c index 573db1ce..07959c4e 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -1428,9 +1428,9 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom break; } else{ - // Up or Shift-Tab + // Up, Ctrl-p or Shift-Tab if ( key == XK_Up || ( key == XK_Tab && ev.xkey.state & ShiftMask ) || - ( key == XK_k && ev.xkey.state & ControlMask ) ) { + ( key == XK_p && ev.xkey.state & ControlMask ) ) { if ( selected == 0 ) { selected = filtered_lines; } @@ -1440,11 +1440,28 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom } update = TRUE; } + // Down, Ctrl-n else if ( key == XK_Down || - ( key == XK_j && ev.xkey.state & ControlMask ) ) { + ( key == XK_n && ev.xkey.state & ControlMask ) ) { selected = selected < filtered_lines - 1 ? MIN ( filtered_lines - 1, selected + 1 ) : 0; update = TRUE; } + else if ( key == XK_Page_Up && ev.xkey.state & ControlMask ) { + if ( selected < max_rows ) { + selected = 0; + } + else{ + selected -= max_rows; + } + update = TRUE; + } + else if ( key == XK_Page_Down && ev.xkey.state & ControlMask ) { + selected += max_rows; + if ( selected >= filtered_lines ) { + selected = filtered_lines - 1; + } + update = TRUE; + } else if ( key == XK_Page_Up ) { if ( selected < max_elements ) { selected = 0; @@ -1462,22 +1479,6 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom } update = TRUE; } - else if ( key == XK_h && ev.xkey.state & ControlMask ) { - if ( selected < max_rows ) { - selected = 0; - } - else{ - selected -= max_rows; - } - update = TRUE; - } - else if ( key == XK_l && ev.xkey.state & ControlMask ) { - selected += max_rows; - if ( selected >= filtered_lines ) { - selected = filtered_lines - 1; - } - update = TRUE; - } else if ( key == XK_Home || key == XK_KP_Home ) { selected = 0; update = TRUE; diff --git a/source/textbox.c b/source/textbox.c index 20afc606..43c4f530 100644 --- a/source/textbox.c +++ b/source/textbox.c @@ -368,30 +368,48 @@ int textbox_keypress ( textbox *tb, XEvent *ev ) len = Xutf8LookupString ( tb->xic, &ev->xkey, pad, sizeof ( pad ), &key, &stat ); pad[len] = 0; - if ( key == XK_Left ) { - textbox_cursor_dec ( tb ); + // Left or Ctrl-b + if ( key == XK_Left || + (( ev->xkey.state&ControlMask) && key == XK_b) ) { + textbox_cursor_dec ( tb ); return 1; } - else if ( key == XK_Right ) { + // Right or Ctrl-F + else if ( key == XK_Right || + (( ev->xkey.state&ControlMask) && key == XK_f) ) { textbox_cursor_inc ( tb ); return 1; - } /*else if ( key == XK_Home ) { - - textbox_cursor_home( tb ); - return 1; - } else if ( key == XK_End ) { - textbox_cursor_end( tb ); - return 1; - } */ - else if ( key == XK_Delete ) { + } + // Delete or Ctrl-D + else if ( key == XK_Delete || + (( ev->xkey.state&ControlMask) && key == XK_d) ) { textbox_cursor_del ( tb ); return 1; } - else if ( key == XK_BackSpace ) { + // Ctrl-U: Kill from the beginning to the end of the line. + else if ( ( ev->xkey.state&ControlMask) && key == XK_u) { + textbox_text( tb, ""); + return 1; + } + // Ctrl-A + else if ( ( ev->xkey.state&ControlMask) && key == XK_a) { + textbox_cursor ( tb, 0 ); + return 1; + } + // Ctrl-E + else if ( ( ev->xkey.state&ControlMask) && key == XK_e) { + textbox_cursor_end ( tb ); + return 1; + } + // BackSpace, Ctrl-h + else if ( key == XK_BackSpace || + (( ev->xkey.state&ControlMask) && key == XK_h) ) { textbox_cursor_bkspc ( tb ); return 1; } - else if ( key == XK_Return || key == XK_KP_Enter ) { + else if ( key == XK_Return || key == XK_KP_Enter || + ((ev->xkey.state&ControlMask) && key == XK_j) || + ((ev->xkey.state&ControlMask) && key == XK_m)) { return -1; } else if ( !iscntrl ( *pad ) ) {