From 64183b5a26fe3288976dfabe6a312563069efd45 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 8 Sep 2014 16:53:33 +0200 Subject: [PATCH] Start moving keybindings --- qutebrowser/config/configdata.py | 650 ++++++++++++++++++++----------- 1 file changed, 425 insertions(+), 225 deletions(-) diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 263c6cb8e..5fca0394e 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -80,61 +80,6 @@ SECTION_DESC = { "bang-syntax, e.g. `:open qutebrowser !google`. The string `{}` will " "be replaced by the search term, use `{{` and `}}` for literal " "`{`/`}` signs."), - 'keybind': ( - "Bindings from a key(chain) to a command.\n" - "For special keys (can't be part of a keychain), enclose them in " - "`<`...`>`. For modifiers, you can use either `-` or `+` as " - "delimiters, and these names:\n\n" - " * Control: `Control`, `Ctrl`\n" - " * Meta: `Meta`, `Windows`, `Mod4`\n" - " * Alt: `Alt`, `Mod1`\n" - " * Shift: `Shift`\n\n" - "For simple keys (no `<>`-signs), a capital letter means the key is " - "pressed with Shift. For special keys (with `<>`-signs), you need " - "to explicitely add `Shift-` to match a key pressed with shift. " - "You can bind multiple commands by separating them with `;;`."), - 'keybind.insert': ( - "Keybindings for insert mode.\n" - "Since normal keypresses are passed through, only special keys are " - "supported in this mode.\n" - "Useful hidden commands to map in this section:\n\n" - " * `open-editor`: Open a texteditor with the focused field.\n" - " * `leave-mode`: Leave the command mode."), - 'keybind.hint': ( - "Keybindings for hint mode.\n" - "Since normal keypresses are passed through, only special keys are " - "supported in this mode.\n" - "Useful hidden commands to map in this section:\n\n" - " * `follow-hint`: Follow the currently selected hint.\n" - " * `leave-mode`: Leave the command mode."), - 'keybind.passthrough': ( - "Keybindings for passthrough mode.\n" - "Since normal keypresses are passed through, only special keys are " - "supported in this mode.\n" - "Useful hidden commands to map in this section:\n\n" - " * `leave-mode`: Leave the passthrough mode."), - 'keybind.command': ( - "Keybindings for command mode.\n" - "Since normal keypresses are passed through, only special keys are " - "supported in this mode.\n" - "Useful hidden commands to map in this section:\n\n" - " * `command-history-prev`: Switch to previous command in history.\n" - " * `command-history-next`: Switch to next command in history.\n" - " * `completion-item-prev`: Select previous item in completion.\n" - " * `completion-item-next`: Select next item in completion.\n" - " * `command-accept`: Execute the command currently in the " - "commandline.\n" - " * `leave-mode`: Leave the command mode."), - 'keybind.prompt': ( - "Keybindings for prompts in the status line.\n" - "You can bind normal keys in this mode, but they will be only active " - "when a yes/no-prompt is asked. For other prompt modes, you can only " - "bind special keys.\n" - "Useful hidden commands to map in this section:\n\n" - " * `prompt-accept`: Confirm the entered value.\n" - " * `prompt-yes`: Answer yes to a yes/no question.\n" - " * `prompt-no`: Answer no to a yes/no question.\n" - " * `leave-mode`: Leave the prompt mode."), 'aliases': ( "Aliases for commands.\n" "By default, no aliases are defined. Example which adds a new command " @@ -581,176 +526,6 @@ DATA = collections.OrderedDict([ ('wiki', '${wikipedia}'), )), - ('keybind', sect.ValueList( - typ.KeyBindingName(), typ.KeyBinding(), - ('o', 'set-cmd-text ":open "'), - ('go', 'set-cmd-text ":open {url}"'), - ('O', 'set-cmd-text ":open -t "'), - ('gO', 'set-cmd-text ":open -t {url}"'), - ('xo', 'set-cmd-text ":open -b "'), - ('xO', 'set-cmd-text ":open -b {url}"'), - ('ga', 'open -t about:blank'), - ('d', 'tab-close'), - ('co', 'tab-only'), - ('T', 'tab-focus'), - ('gm', 'tab-move'), - ('gl', 'tab-move -'), - ('gr', 'tab-move +'), - ('J', 'tab-next'), - ('K', 'tab-prev'), - ('r', 'reload'), - ('H', 'back'), - ('L', 'forward'), - ('f', 'hint'), - ('F', 'hint all tab'), - (';b', 'hint all tab-bg'), - (';i', 'hint images'), - (';I', 'hint images tab'), - ('.i', 'hint images tab-bg'), - (';o', 'hint links fill ":open {hint-url}"'), - (';O', 'hint links fill ":open -t {hint-url}"'), - ('.o', 'hint links fill ":open -b {hint-url}"'), - (';y', 'hint links yank'), - (';Y', 'hint links yank-primary'), - (';r', 'hint links rapid'), - (';d', 'hint links download'), - ('h', 'scroll -50 0'), - ('j', 'scroll 0 50'), - ('k', 'scroll 0 -50'), - ('l', 'scroll 50 0'), - ('u', 'undo'), - ('gg', 'scroll-perc 0'), - ('G', 'scroll-perc'), - ('n', 'search-next'), - ('N', 'search-prev'), - ('i', 'enter-mode insert'), - ('yy', 'yank'), - ('yY', 'yank -s'), - ('yt', 'yank -t'), - ('yT', 'yank -ts'), - ('pp', 'paste'), - ('pP', 'paste -s'), - ('Pp', 'paste -t'), - ('PP', 'paste -ts'), - ('m', 'quickmark-save'), - ('b', 'set-cmd-text ":quickmark-load "'), - ('B', 'set-cmd-text ":quickmark-load -t "'), - ('sf', 'save'), - ('ss', 'set-cmd-text ":set "'), - ('sl', 'set-cmd-text ":set -t "'), - ('sk', 'set-cmd-text ":set keybind "'), - ('-', 'zoom-out'), - ('+', 'zoom-in'), - ('=', 'zoom'), - ('[[', 'prev-page'), - (']]', 'next-page'), - ('{{', 'prev-page -t'), - ('}}', 'next-page -t'), - ('wi', 'inspector'), - ('gd', 'download-page'), - ('ad', 'cancel-download'), - ('', 'tab-focus last'), - ('', 'enter-mode passthrough'), - ('', 'quit'), - ('', 'undo'), - ('', 'tab-close'), - ('', 'open -t about:blank'), - ('', 'scroll-page 0 1'), - ('', 'scroll-page 0 -1'), - ('', 'scroll-page 0 0.5'), - ('', 'scroll-page 0 -0.5'), - ('', 'tab-focus 1'), - ('', 'tab-focus 2'), - ('', 'tab-focus 3'), - ('', 'tab-focus 4'), - ('', 'tab-focus 5'), - ('', 'tab-focus 6'), - ('', 'tab-focus 7'), - ('', 'tab-focus 8'), - ('', 'tab-focus 9'), - ('', 'back'), - ('', 'home'), - ('', 'stop'), - ('', 'print'), - )), - - ('keybind.insert', sect.ValueList( - typ.KeyBindingName(), typ.KeyBinding(), - ('', 'leave-mode'), - ('', 'leave-mode'), - ('', 'open-editor'), - ('', '${}'), - )), - - ('keybind.hint', sect.ValueList( - typ.KeyBindingName(), typ.KeyBinding(), - ('', 'follow-hint'), - ('', 'leave-mode'), - ('', 'leave-mode'), - ('', '${}'), - )), - - ('keybind.passthrough', sect.ValueList( - typ.KeyBindingName(), typ.KeyBinding(), - ('', 'leave-mode'), - ('', '${}'), - )), - - # FIXME we should probably have a common section for input modes with a - # text field. - - ('keybind.command', sect.ValueList( - typ.KeyBindingName(), typ.KeyBinding(), - ('', 'leave-mode'), - ('', 'command-history-prev'), - ('', 'command-history-next'), - ('', 'completion-item-prev'), - ('', 'completion-item-prev'), - ('', 'completion-item-next'), - ('', 'completion-item-next'), - ('', 'command-accept'), - ('', 'command-accept'), - ('', 'rl-backward-char'), - ('', 'rl-forward-char'), - ('', 'rl-backward-word'), - ('', 'rl-forward-word'), - ('', 'rl-beginning-of-line'), - ('', 'rl-end-of-line'), - ('', 'rl-unix-line-discard'), - ('', 'rl-kill-line'), - ('', 'rl-kill-word'), - ('', 'rl-unix-word-rubout'), - ('', 'rl-yank'), - ('', 'rl-delete-char'), - ('', 'rl-backward-delete-char'), - ('', '${}'), - ('', '${}'), - )), - - ('keybind.prompt', sect.ValueList( - typ.KeyBindingName(), typ.KeyBinding(), - ('', 'leave-mode'), - ('', 'prompt-accept'), - ('', 'prompt-accept'), - ('y', 'prompt-yes'), - ('n', 'prompt-no'), - ('', 'rl-backward-char'), - ('', 'rl-forward-char'), - ('', 'rl-backward-word'), - ('', 'rl-forward-word'), - ('', 'rl-beginning-of-line'), - ('', 'rl-end-of-line'), - ('', 'rl-unix-line-discard'), - ('', 'rl-kill-line'), - ('', 'rl-kill-word'), - ('', 'rl-unix-word-rubout'), - ('', 'rl-yank'), - ('', 'rl-delete-char'), - ('', 'rl-backward-delete-char'), - ('', '${}'), - ('', '${}'), - )), - ('aliases', sect.ValueList( typ.String(forbidden=' '), typ.Command(), )), @@ -1004,3 +779,428 @@ DATA = collections.OrderedDict([ "The default font size for fixed-pitch text."), )), ]) + +KEYBINDINGS = """ +# Bindings from a key(chain) to a command. +# +# For special keys (can't be part of a keychain), enclose them in `<`...`>`. +# For modifiers, you can use either `-` or `+` as delimiters, and these names: +# +# * Control: `Control`, `Ctrl` +# * Meta: `Meta`, `Windows`, `Mod4` +# * Alt: `Alt`, `Mod1` +# * Shift: `Shift` +# +# For simple keys (no `<>`-signs), a capital letter means the key is pressed +# with Shift. For special keys (with `<>`-signs), you need to explicitely add +# `Shift-` to match a key pressed with shift. You can bind multiple commands +# by separating them with `;;`. + +[normal] + +set-cmd-text ":open " + o + +set-cmd-text ":open {url}" + go + +set-cmd-text ":open -t " + O + +set-cmd-text ":open -t {url}" + gO + +set-cmd-text ":open -b " + xo + +set-cmd-text ":open -b {url}" + xO + +open -t about:blank + ga + +tab-close + d + +tab-only + co + +tab-focus + T + +tab-move + gm + +tab-move - + gl + +tab-move + + gr + +tab-next + J + +tab-prev + K + +reload + r + +back + H + +forward + L + +hint + f + +hint all tab + F + +hint all tab-bg + ;b + +hint images + ;i + +hint images tab + ;I + +hint images tab-bg + .i + +hint links fill ":open {hint-url}" + ;o + +hint links fill ":open -t {hint-url}" + ;O + +hint links fill ":open -b {hint-url}" + .o + +hint links yank + ;y + +hint links yank-primary + ;Y + +hint links rapid + ;r + +hint links download + ;d + +scroll -50 0 + h + +scroll 0 50 + j + +scroll 0 -50 + k + +scroll 50 0 + l + +undo + u + +scroll-perc 0 + gg + +scroll-perc + G + +search-next + n + +search-prev + N + +enter-mode insert + i + +yank + yy + +yank -s + yY + +yank -t + yt + +yank -ts + yT + +paste + pp + +paste -s + pP + +paste -t + Pp + +paste -ts + PP + +quickmark-save + m + +set-cmd-text ":quickmark-load " + b + +set-cmd-text ":quickmark-load -t " + B + +save + sf + +set-cmd-text ":set " + ss + +set-cmd-text ":set -t " + sl + +set-cmd-text ":set keybind " + sk + +zoom-out + - + +zoom-in + + + +zoom + = + +prev-page + [[ + +next-page + ]] + +prev-page -t + {{ + +next-page -t + }} + +inspector + wi + +download-page + gd + +cancel-download + ad + +tab-focus last + + +enter-mode passthrough + + +quit + + +undo + + +tab-close + + +open -t about:blank + + +scroll-page 0 1 + + +scroll-page 0 -1 + + +scroll-page 0 0.5 + + +scroll-page 0 -0.5 + + +tab-focus 1 + + +tab-focus 2 + + +tab-focus 3 + + +tab-focus 4 + + +tab-focus 5 + + +tab-focus 6 + + +tab-focus 7 + + +tab-focus 8 + + +tab-focus 9 + + +back + + +home + + +stop + + +print + + +[insert,hint,passthrough,command,prompt] + +leave-mode + + + + +[passthrough] +# Keybindings for passthrough mode. +# +# Since normal keypresses are passed through, only special keys are supported +# in this section. + +[insert] + +# Since normal keypresses are passed through, only special keys are supported +# in this section. +# +# Useful hidden commands to map in this section: +# * `open-editor`: Open a texteditor with the focused field. + +open-editor + + +[hint] + +# Since normal keypresses are passed through, only special keys are supported +# in this section. +# +# Useful hidden commands to map in this section: +# +# * `follow-hint`: Follow the currently selected hint. + +follow-hint + + +[command,prompt] + +rl-backward-char + + +rl-forward-char + + +rl-backward-word + + +rl-forward-word + + +rl-beginning-of-line + + +rl-end-of-line + + +rl-unix-line-discard + + +rl-kill-line + + +rl-kill-word + + +rl-unix-word-rubout + + +rl-yank + + +rl-delete-char + + +rl-backward-delete-char + + + +[command] + +# Since normal keypresses are passed through, only special keys are +# supported in this mode. + +# Useful hidden commands to map in this section: +# +# * `command-history-prev`: Switch to previous command in history. +# * `command-history-next`: Switch to next command in history. +# * `completion-item-prev`: Select previous item in completion. +# * `completion-item-next`: Select next item in completion. +# * `command-accept`: Execute the command currently in the commandline. +# * `leave-mode`: Leave the command mode. + +command-history-prev + + +command-history-next + + +completion-item-prev + + +completion-item-prev + + +completion-item-next + + +completion-item-next + + +command-accept + + + + +[prompt] + +# You can bind normal keys in this mode, but they will be only active when a +# yes/no-prompt is asked. For other prompt modes, you can only bind special +# keys. + +# Useful hidden commands to map in this section: +# +# * `prompt-accept`: Confirm the entered value. +# * `prompt-yes`: Answer yes to a yes/no question. +# * `prompt-no`: Answer no to a yes/no question. +# * `leave-mode`: Leave the prompt mode. + +prompt-accept + + + + +prompt-yes + y + +prompt-no + n +"""