evcc: 0.131.4 -> 0.131.5
[NixPkgs.git] / pkgs / by-name / xk / xkeysnail / browser-emacs-bindings.py
blob347ac17d33fce2e56fd1d3b24981b80d478aadc0
1 # -*- coding: utf-8 -*-
2 import re
3 from xkeysnail.transform import *
5 aa = False
6 def aa_setvar(v):
7 def _aa_setvar():
8 transform._mark_set = False
9 global aa; aa = v
10 return _aa_setvar
11 def aa_ifvar():
12 def _aa_ifvar():
13 transform._mark_set = False
14 global aa
15 if aa: aa = False; return K("esc")
16 return K("enter")
17 return _aa_ifvar
18 def aa_flipmark():
19 def _aa_flipmark():
20 transform._mark_set = not transform._mark_set;
21 return _aa_flipmark
23 define_keymap(re.compile("Google-chrome|Chromium-browser|firefox"), {
24 K("C-b"): with_mark(K("left")),
25 K("C-f"): with_mark(K("right")),
26 K("C-p"): with_mark(K("up")),
27 K("C-n"): with_mark(K("down")),
28 K("M-b"): with_mark(K("C-left")),
29 K("M-f"): with_mark(K("C-right")),
30 K("C-a"): with_mark(K("home")),
31 K("C-e"): with_mark(K("end")),
33 K("C-w"): [K("C-x"), set_mark(False)],
34 K("M-w"): [K("C-c"), K("right"), set_mark(False)],
35 K("C-y"): [K("C-v"), set_mark(False)],
36 K("C-k"): [K("Shift-end"), K("C-x"), set_mark(False)],
37 K("C-d"): [K("delete"), set_mark(False)],
38 K("M-d"): [K("C-delete"), set_mark(False)],
39 K("M-backspace"): [K("C-backspace"), set_mark(False)],
41 K("C-slash"): [K("C-z"), set_mark(False)],
42 K("C-space"): aa_flipmark(),
43 K("C-M-space"): with_or_set_mark(K("C-right")),
45 # K("C-s"): K("F3"),
46 # K("C-r"): K("Shift-F3"),
47 # K("C-g"): [K("esc"), set_mark(False)]
49 K("C-s"): [K("F3"), aa_setvar(True)],
50 K("C-r"): [K("Shift-F3"), aa_setvar(True)],
51 K("C-g"): [K("esc"), aa_setvar(False)],
52 K("enter"): aa_ifvar()