From 57a0dc7f0759eebbb99178dd4ae04b29bd6155a1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 8 Dec 2016 10:35:11 +0530 Subject: [PATCH] Script to add shortcut definitions to readme --- README.asciidoc | 37 +++++++++++++++++++++++++++++++++++-- preprocess-readme.py | 27 +++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-) create mode 100755 preprocess-readme.py diff --git a/README.asciidoc b/README.asciidoc index 75429b7e1..28024a931 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -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 diff --git a/preprocess-readme.py b/preprocess-readme.py new file mode 100755 index 000000000..b96637217 --- /dev/null +++ b/preprocess-readme.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +# vim:fileencoding=utf-8 +# License: GPL v3 Copyright: 2016, Kovid Goyal + +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)