mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-27 18:51:41 +02:00
DRYer
This commit is contained in:
@@ -289,12 +289,7 @@ def shortcut_matches(s, mods, key, scancode):
|
|||||||
return s[0] & 0b1111 == mods & 0b1111 and s[2] == q
|
return s[0] & 0b1111 == mods & 0b1111 and s[2] == q
|
||||||
|
|
||||||
|
|
||||||
def generate_key_table():
|
def generate_key_table_impl(w):
|
||||||
# To run this, use: python3 . +runpy "from kitty.keys import *; generate_key_table()"
|
|
||||||
import os
|
|
||||||
from functools import partial
|
|
||||||
f = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'keys.h'), 'w')
|
|
||||||
w = partial(print, file=f)
|
|
||||||
w('// auto-generated from keys.py, do not edit!')
|
w('// auto-generated from keys.py, do not edit!')
|
||||||
w('#pragma once')
|
w('#pragma once')
|
||||||
w('#include <stddef.h>')
|
w('#include <stddef.h>')
|
||||||
@@ -389,3 +384,12 @@ def generate_key_table():
|
|||||||
ind('return NULL;')
|
ind('return NULL;')
|
||||||
i -= 1
|
i -= 1
|
||||||
w('}')
|
w('}')
|
||||||
|
|
||||||
|
|
||||||
|
def generate_key_table():
|
||||||
|
# To run this, use: python3 . +runpy "from kitty.keys import *; generate_key_table()"
|
||||||
|
import os
|
||||||
|
from functools import partial
|
||||||
|
with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'keys.h'), 'w') as f:
|
||||||
|
w = partial(print, file=f)
|
||||||
|
generate_key_table_impl(w)
|
||||||
|
|||||||
Reference in New Issue
Block a user