Script to add shortcut definitions to readme

This commit is contained in:
Kovid Goyal 2016-12-08 10:35:11 +05:30
parent b8d206cc67
commit 57a0dc7f07
2 changed files with 62 additions and 2 deletions

View File

@ -1,6 +1,36 @@
= kitty - A terminal emulator
:toc:
:toc-placement!:
// START_SHORTCUT_BLOCK
:sc_paste_from_clipboard: `ctrl+shift+v`
:sc_paste_from_selection: `ctrl+shift+s`
:sc_copy_to_clipboard: `ctrl+shift+c`
:sc_scroll_line_up: `ctrl+shift+up`
:sc_scroll_line_down: `ctrl+shift+down`
:sc_scroll_page_up: `ctrl+shift+page_up`
:sc_scroll_page_down: `ctrl+shift+page_down`
:sc_scroll_home: `ctrl+shift+home`
:sc_scroll_end: `ctrl+shift+end`
:sc_new_window: `ctrl+shift+enter`
:sc_next_window: `ctrl+shift+]`
:sc_previous_window: `ctrl+shift+[`
:sc_close_window: `ctrl+shift+w`
:sc_next_layout: `ctrl+shift+l`
:sc_first_window: `ctrl+shift+1`
:sc_second_window: `ctrl+shift+2`
:sc_third_window: `ctrl+shift+3`
:sc_fourth_window: `ctrl+shift+4`
:sc_fifth_window: `ctrl+shift+5`
:sc_sixth_window: `ctrl+shift+6`
:sc_seventh_window: `ctrl+shift+7`
:sc_eighth_window: `ctrl+shift+8`
:sc_ninth_window: `ctrl+shift+9`
:sc_tenth_window: `ctrl+shift+0`
:sc_next_tab: `ctrl+shift+right`
:sc_previous_tab: `ctrl+shift+left`
:sc_new_tab: `ctrl+shift+t`
:sc_close_tab: `ctrl+shift+q`
// END_SHORTCUT_BLOCK
image::https://travis-ci.org/kovidgoyal/kitty.svg?branch=master[Build status, link=https://travis-ci.org/kovidgoyal/kitty]
@ -90,8 +120,11 @@ windows are:
|===
|Action |Shortcut
|New tab |`new_tab`
|Close tab |`close_tab`
|New tab | {sc_new_tab}
|Close tab | {sc_close_tab}
|===
== Configuration

27
preprocess-readme.py Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env python3
# vim:fileencoding=utf-8
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
import os
import re
base = os.path.dirname(os.path.abspath(__file__))
os.chdir(base)
defns = []
for line in open('kitty/kitty.conf'):
if line.startswith('map '):
_, sc, name = line.split(maxsplit=3)
defns.append(':sc_{}: `{}`'.format(name, sc))
defns = '\n'.join(defns)
raw = open('README.asciidoc').read()
pat = re.compile(r'^// START_SHORTCUT_BLOCK$.+?^// END_SHORTCUT_BLOCK$', re.M | re.DOTALL)
nraw = pat.sub('// START_SHORTCUT_BLOCK\n' +
defns + '\n// END_SHORTCUT_BLOCK', raw)
if raw != nraw:
print('Updating shortcuts block')
open('README.asciidoc', 'w').write(nraw)