Get rid of the |sc_| substitution rules

This commit is contained in:
Kovid Goyal 2018-06-05 08:13:28 +05:30
parent b5e452942e
commit 065a2b37c7
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
6 changed files with 57 additions and 73 deletions

View File

@ -9,30 +9,12 @@
import os
import re
import subprocess
from collections import defaultdict
from functools import partial
from docutils import nodes
from docutils.parsers.rst.roles import set_classes
from sphinx import addnodes
def create_shortcut_defs():
defns = defaultdict(list)
for line in open('../kitty/kitty.conf'):
if line.startswith('map '):
_, sc, name = line.split(maxsplit=2)
sc = sc.replace('kitty_mod', 'ctrl+shift')
name = name.rstrip().replace(' ', '_').replace('-', '_').replace('+',
'plus').replace('.', '_').replace('___', '_').replace('__', '_').strip('_')
defns[name].append(':kbd:`' + sc.replace('>', '') + '`')
defns = [
'.. |sc_{}| replace:: {}'.format(name, ' or '.join(defns[name]))
for name in sorted(defns)
]
return '\n'.join(defns)
from sphinx.util.logging import getLogger
# -- Project information -----------------------------------------------------
@ -45,6 +27,7 @@ author = 'Kovid Goyal'
version = ''
# The full version, including alpha/beta/rc tags
release = ''
logger = getLogger(__name__)
# -- General configuration ---------------------------------------------------
@ -100,7 +83,7 @@ rst_prolog = '''
.. role:: title
.. role:: env
''' + create_shortcut_defs()
'''
# -- Options for HTML output -------------------------------------------------
@ -455,7 +438,10 @@ def process_shortcut_link(env, refnode, has_explicit_title, title, target):
if not slug:
conf_name, slug = 'kitty', conf_name
full_name = conf_name + '.' + slug
target, title = shortcut_slugs[full_name]
try:
target, title = shortcut_slugs[full_name]
except KeyError:
logger.warning('Unknown shortcut: {}'.format(target), location=refnode)
return title, target

View File

@ -9,7 +9,7 @@ Configuring kitty
frames-per-second. See below for an overview of all customization
possibilities.
You can open the config file within kitty by pressing |sc_edit_config_file|.
You can open the config file within kitty by pressing :sc:`edit_config_file`.
You can also display the current configuration by running ``kitty
--debug-config``.

View File

@ -107,12 +107,12 @@ Scrolling
======================== =======================
Action Shortcut
======================== =======================
Scroll line up |sc_scroll_line_up|
Scroll line down |sc_scroll_line_down|
Scroll page up |sc_scroll_page_up|
Scroll page down |sc_scroll_page_down|
Scroll to top |sc_scroll_home|
Scroll to bottom |sc_scroll_end|
Scroll line up :sc:`scroll_line_up`
Scroll line down :sc:`scroll_line_down`
Scroll page up :sc:`scroll_page_up`
Scroll page down :sc:`scroll_page_down`
Scroll to top :sc:`scroll_home`
Scroll to bottom :sc:`scroll_end`
======================== =======================
Tabs
@ -121,14 +121,14 @@ Tabs
======================== =======================
Action Shortcut
======================== =======================
New tab |sc_new_tab|
Close tab |sc_close_tab|
Next tab |sc_next_tab|
Previous tab |sc_previous_tab|
Next layout |sc_next_layout|
Move tab forward |sc_move_tab_forward|
Move tab backward |sc_move_tab_backward|
Set tab title |sc_set_tab_title|
New tab :sc:`new_tab`
Close tab :sc:`close_tab`
Next tab :sc:`next_tab`
Previous tab :sc:`previous_tab`
Next layout :sc:`next_layout`
Move tab forward :sc:`move_tab_forward`
Move tab backward :sc:`move_tab_backward`
Set tab title :sc:`set_tab_title`
======================== =======================
@ -138,15 +138,15 @@ Windows
======================== =======================
Action Shortcut
======================== =======================
New window |sc_new_window|
New OS window |sc_new_os_window|
Close window |sc_close_window|
Next window |sc_next_window|
Previous window |sc_previous_window|
Move window forward |sc_move_window_forward|
Move window backward |sc_move_window_backward|
Move window to top |sc_move_window_to_top|
Focus specific window |sc_first_window|, |sc_second_window| ... |sc_tenth_window|
New window :sc:`new_window`
New OS window :sc:`new_os_window`
Close window :sc:`close_window`
Next window :sc:`next_window`
Previous window :sc:`previous_window`
Move window forward :sc:`move_window_forward`
Move window backward :sc:`move_window_backward`
Move window to top :sc:`move_window_to_top`
Focus specific window :sc:`first_window`, :sc:`second_window` ... :sc:`tenth_window`
(clockwise from the top-left)
======================== =======================
@ -157,22 +157,22 @@ Other keyboard shortcuts
================================== =======================
Action Shortcut
================================== =======================
Copy to clipboard |sc_copy_to_clipboard|
Paste from clipboard |sc_paste_from_clipboard|
Paste from selection |sc_paste_from_selection|
Increase font size |sc_change_font_size_all_plus2_0|
Decrease font size |sc_change_font_size_all_2_0|
Restore font size |sc_change_font_size_all_0|
Toggle fullscreen |sc_toggle_fullscreen|
Input unicode character |sc_input_unicode_character|
Click URL using the keyboard |sc_kitten_hints|
Pass current selection to program |sc_pass_selection_to_program|
Edit |kitty| config file |sc_edit_config_file|
Open a |kitty| shell |sc_kitty_shell_window|
Increase background opacity |sc_set_background_opacity_plus0_1|
Decrease background opacity |sc_set_background_opacity_0_1|
Full background opacity |sc_set_background_opacity_1|
Reset background opacity |sc_set_background_opacity_default|
Copy to clipboard :sc:`copy_to_clipboard`
Paste from clipboard :sc:`paste_from_clipboard`
Paste from selection :sc:`paste_from_selection`
Increase font size :sc:`increase_font_size`
Decrease font size :sc:`decrease_font_size`
Restore font size :sc:`reset_font_size`
Toggle fullscreen :sc:`toggle_fullscreen`
Input unicode character :sc:`input_unicode_character`
Click URL using the keyboard :sc:`open_url`
Pass current selection to program :sc:`pass_selection_to_program`
Edit |kitty| config file :sc:`edit_config_file`
Open a |kitty| shell :sc:`kitty_shell`
Increase background opacity :sc:`increase_background_opacity`
Decrease background opacity :sc:`decrease_background_opacity`
Full background opacity :sc:`full_background_opacity`
Reset background opacity :sc:`reset_background_opacity`
================================== =======================
@ -190,11 +190,11 @@ Currently, there are five layouts available,
* **Horizontal** -- All windows are shown side-by-side
* **Vertical** -- All windows are shown one below the other
You can switch between layouts using the |sc_next_layout| key combination. You can
You can switch between layouts using the :sc:`next_layout` key combination. You can
also create shortcuts to select particular layouts, and choose which layouts
you want to enable/disable, see |kitty.conf| for examples.
You can resize windows inside layouts. Press |sc_start_resizing_window| to
You can resize windows inside layouts. Press :sc:`start_resizing_window` to
enter resizing mode and follow the on-screen instructions. In a given window
layout only some operations may be possible for a particular window. For
example, in the Tall layout you can make the first window wider/narrower, but
@ -314,7 +314,7 @@ can use either keyboard shortcuts or the mouse scroll wheel to do so. However,
|kitty| has an extra, neat feature. Sometimes you need to explore the
scrollback buffer in more detail, maybe search for some text or refer to it
side-by-side while typing in a follow-up command. |kitty| allows you to do this
by pressing the |sc_show_scrollback| key-combination, which will open the
by pressing the :sc:`show_scrollback` key-combination, which will open the
scrollback buffer in your favorite pager program (which is ``less`` by default).
Colors and text formatting are preserved. You can explore the scrollback buffer
comfortably within the pager.

View File

@ -2,7 +2,7 @@ Hints
==========
|kitty| has a *hints mode* to select and act on arbitrary text snippets currently
visible on the screen. For example, you can press |sc_kitten_hints|
visible on the screen. For example, you can press :sc:`open_url`
to choose any URL visible on the screen and then open it using your system
browser.
@ -13,7 +13,7 @@ browser.
URL hints mode
Similarly, you can press |sc_kitten_hints_type_path_program| to
Similarly, you can press :sc:`insert_selected_path` to
select anything that looks like a path or filename and then insert it into the
terminal, very useful for picking files from the output of a ``git`` or ``ls`` command and
adding them to the command line for the next command.

View File

@ -115,9 +115,8 @@ shell. Run ``kitty @`` with no arguments and you will be dropped into the |kitty
shell with completion for |kitty| command names and options.
You can even open the |kitty| shell inside a running |kitty| using a simple
keyboard shortcut (|sc_kitty_shell_window| by default). This has the added
keyboard shortcut (:sc:`kitty_shell` by default). This has the added
advantage that you dont need to use ``allow_remote_control`` to make it work.
.. include:: generated/cli-kitty-at.rst

View File

@ -760,7 +760,6 @@ k('open_url', 'kitty_mod+e', 'kitten hints', _('Open URL'), _('''
Open a currently visible URL using the keyboard. The program used to open the
URL is specified in :opt:`open_url_with`.'''))
k('insert_selected_path', 'kitty_mod+p>f', 'kitten hints --type path --program -', _('Insert selected path'), long_text=_('''
Select a path/filename and insert it into the terminal. Useful, for instance to
run git commands on a filename output from a previous git command.'''))
@ -787,10 +786,10 @@ k('input_unicode_character', 'kitty_mod+u', 'input_unicode_character', _('Unicod
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('increase_background_opacity', 'kitty_mod+a>m', 'set_background_opacity +0.1', _('Increase background opacity'))
k('decrease_background_opacity', 'kitty_mod+a>l', 'set_background_opacity -0.1', _('Decrease background opacity'))
k('full_background_opacity', 'kitty_mod+a>1', 'set_background_opacity 1', _('Make background fully opaque'))
k('reset_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