Finish adding shortcuts to docs

This commit is contained in:
Kovid Goyal
2018-06-04 23:16:52 +05:30
parent 429efd70ff
commit 4fa8cb562a
3 changed files with 45 additions and 5 deletions

View File

@@ -418,11 +418,14 @@ def render_conf(conf_name, all_options):
handle_group(sc.group, True)
sc_text = f'{conf_name}.{sc.short_text}'
a('.. shortcut:: ' + sc_text)
a('.. parsed-literal::')
a('')
shortcuts = [s for s in shortcuts if s.add_to_default]
shortcut_slugs[f'{conf_name}.{sc.name}'] = (sc_text, sc.key.replace('kitty_mod', kitty_mod))
for x in shortcuts:
a(' map :green:`{}` {}'.format(x.key.replace('kitty_mod', kitty_mod), x.action_def))
if shortcuts:
a('.. parsed-literal::')
a('')
for x in shortcuts:
if x.add_to_default:
a(' map :green:`{}` {}'.format(x.key.replace('kitty_mod', kitty_mod), x.action_def))
a('')
if sc.long_text:
a(expand_opt_references(conf_name, sc.long_text))

View File

@@ -163,7 +163,8 @@ def as_conf_file(all_options):
def handle_shortcut(shortcuts):
handle_group(shortcuts[0].group, True)
for sc in shortcuts:
a('map {} {}'.format(sc.key, sc.action_def))
if sc.add_to_default:
a('map {} {}'.format(sc.key, sc.action_def))
if sc.long_text:
a(''), a(render_block(sc.long_text.strip())), a('')

View File

@@ -110,6 +110,7 @@ For example::
],
'shortcuts.clipboard': [_('Clipboard')],
'shortcuts.scrolling': [_('Scrolling')],
'shortcuts.misc': [_('Miscellaneous')],
'shortcuts.window': [_('Window management')],
'shortcuts.tab': [
_('Tab management'), '',
@@ -774,6 +775,41 @@ output of things like: ls -1'''))
k('insert_selected_word', 'kitty_mod+p>w', 'kitten hints --type word --program -', _('Insert selected word'), long_text=_('''
Select words and insert into terminal.'''))
# }}}
g('shortcuts.misc') # {{{
k('toggle_fullscreen', 'kitty_mod+f11', 'toggle_fullscreen', _('Toggle fullscreen'))
k('input_unicode_character', 'kitty_mod+u', 'input_unicode_character', _('Unicode input'))
k('edit_config_file', 'kitty_mod+f2', 'edit_config_file', _('Edit config file'))
k('kitty_shell', 'kitty_mod+escape', 'kitty_shell window', _('Open the kitty command shell'), long_text=_('''
# Open the kitty shell in a new window/tab/overlay/os_window to control kitty using commands.'''))
k('set_background_opacity', 'kitty_mod+a>m', 'set_background_opacity +0.1', _('Increase background opacity'))
k('set_background_opacity', 'kitty_mod+a>l', 'set_background_opacity -0.1', _('Decrease background opacity'))
k('set_background_opacity', 'kitty_mod+a>1', 'set_background_opacity 1', _('Make background fully opaque'))
k('set_background_opacity', 'kitty_mod+a>d', 'set_background_opacity default', _('Reset background opacity'))
k('send_text', 'ctrl+shift+alt+h', 'send_text all Hello World', _('Send arbitrary text on key presses'),
add_to_default=False, long_text=_('''
You can tell kitty to send arbitrary (UTF-8) encoded text to
the client program when pressing specified shortcut keys. For example::
map ctrl+alt+a send_text all Special text
This will send "Special text" when you press the :kbd:`ctrl+alt+a` key
combination. The text to be sent is a python string literal so you can use
escapes like :code:`\\x1b` to send control codes or :code:`\\u21fb` to send
unicode characters (or you can just input the unicode characters directly as
UTF-8 text). The first argument to :code:`send_text` is the keyboard modes in which to
activate the shortcut. The possible values are :code:`normal` or :code:`application` or :code:`kitty`
or a comma separated combination of them. The special keyword :code:`all` means all
modes. The modes :code:`normal` and :code:`application` refer to the DECCKM cursor key mode for
terminals, and :code:`kitty` refers to the special kitty extended keyboard protocol.
Another example, that outputs a word and then moves the cursor to the start of
the line (same as pressing the Home key)::
map ctrl+alt+a send_text normal Word\\x1b[H
map ctrl+alt+a send_text application Word\\x1bOH
'''))
# }}}
# }}}