19 |
""" |
""" |
20 |
Default bindings for the Gzz client. |
Default bindings for the Gzz client. |
21 |
|
|
22 |
Note: These bindings are only used with the PythonBinder, |
Note: These bindings are only used with the PotionFallbackBinder, |
23 |
not with gzz.view.DefaultBinder. |
not with gzz.view.DefaultBinder. |
24 |
""" |
""" |
25 |
|
|
26 |
from gzz.client.actions import * |
import gzz, java |
27 |
|
|
28 |
edit_mode = {} |
from gzz.potion.potions import * |
29 |
search_mode = {} |
from gzz.modules.email import * |
|
|
|
|
normal_mode = { |
|
|
|
|
|
# "Meta-binding:" |
|
|
# Clearing the pending directional operation |
|
|
|
|
|
'Backspace': ClearPendingOp(), |
|
30 |
|
|
31 |
|
def call(list, type=None): |
32 |
|
if type is None: type = gzz.potion.CommandCall |
33 |
|
if list is None: return None |
34 |
|
if isinstance(list, gzz.potion.Expression): return list |
35 |
|
#print list |
36 |
|
head = list[0] |
37 |
|
params = [call(l, gzz.potion.FunctionCall) for l in list[1:]] |
38 |
|
return type(head(), params) |
39 |
|
|
40 |
|
def action(list, win=1): |
41 |
|
return gzz.client.PotionFallbackBinder.Action(call(list), win) |
42 |
|
|
43 |
|
arr = gzz.client.PotionFallbackBinder.Arrow |
44 |
|
def map(dict): |
45 |
|
m = java.util.HashMap() |
46 |
|
for k,v in dict.items(): m.put(k, v) |
47 |
|
return m |
48 |
|
|
49 |
|
def fn(fn): |
50 |
|
return call(fn, gzz.potion.FunctionCall) |
51 |
|
|
52 |
# Mode switching bindings |
def const(i): |
53 |
|
return ConstantExpression(i, str(i)) |
|
'Tab': EditMode(1), |
|
|
'Shift-Tab': EditMode(0), |
|
|
'Ctrl-F': SearchMode(), |
|
|
|
|
|
|
|
|
|
|
|
# Bindings to invoke external editor |
|
|
|
|
|
'Ctrl-E': CallExternalEditor(1), |
|
|
'Ctrl-Shift-E': CallExternalEditor(0), |
|
54 |
|
|
55 |
|
|
56 |
|
search_mode = {} |
57 |
|
|
58 |
# Left arrowset |
normal_mode = { |
59 |
|
'Up': arr(1,1,-1), 'i': arr(1,1,-1), 'e': arr(0,1,-1), |
60 |
|
'Down': arr(1,1,1), ',': arr(1,1,1), 'c': arr(0,1,1), |
61 |
|
'Left': arr(1,0,-1), 'j': arr(1,0,-1), 's': arr(0,1,-1), |
62 |
|
'Right': arr(1,0,1), 'l': arr(1,0,1), 'f': arr(0,0,1), |
63 |
|
'k': arr(1,2,1), 'K': arr(1,2,-1), |
64 |
|
'd': arr(0,2,1), 'D': arr(0,2,-1), |
65 |
|
'n': action([NewCell, None]), |
66 |
|
'-': action([Connect, [PrefixOrOther], None]), |
67 |
|
'h': action([Hop2, None]), |
68 |
|
'p': action([Put,[ThisWindow], [PrefixOrOther]], 1), |
69 |
|
'P': action([Put,[ThisWindow], [PrefixOrOther]], 0), |
70 |
|
'g': action([Go, [PrefixOrOther]], 1), |
71 |
|
'G': action([Go, [PrefixOrOther]], 0), |
72 |
|
't': action([Clone,[PrefixOrRight], None]), |
73 |
|
'T': action([Clone,[PrefixOrLeft], None]), |
74 |
|
'm': action([ToggleMark, [ThisWindow]], 1), |
75 |
|
'M': action([ToggleMark, [ThisWindow]], 0), |
76 |
|
'Alt-M': action([MarkHalfRank, [PrefixOrThis], None]), |
77 |
|
'q': action(call([Quit])), |
78 |
|
'Q': action(call([Quit])), |
79 |
|
'x': action(call([ChangeDim, const(0), const(1)]), 1), |
80 |
|
'y': action(call([ChangeDim, const(1), const(1)]), 1), |
81 |
|
'z': action(call([ChangeDim, const(2), const(1)]), 1), |
82 |
|
'X': action(call([ChangeDim, const(0), const(1)]), 0), |
83 |
|
'Y': action(call([ChangeDim, const(1), const(1)]), 0), |
84 |
|
'Z': action(call([ChangeDim, const(2), const(1)]), 0), |
85 |
|
'Alt-X': action(call([ChangeDim, const(0), const(-1)]), 1), |
86 |
|
'Alt-Y': action(call([ChangeDim, const(1), const(-1)]), 1), |
87 |
|
'Alt-Z': action(call([ChangeDim, const(2), const(-1)]), 1), |
88 |
|
'Alt-Shift-X': action(call([ChangeDim, const(0), const(-1)]), 0), |
89 |
|
'Alt-Shift-Y': action(call([ChangeDim, const(1), const(-1)]), 0), |
90 |
|
'Alt-Shift-Z': action(call([ChangeDim, const(2), const(-1)]), 0), |
91 |
|
'v': action(call([ChangeView, const(1)])), |
92 |
|
'Alt-V': action(call([ChangeView, const(-1)])), |
93 |
|
'b': action(call([Break, None])), |
94 |
|
'B': action(call([Break, None])), |
95 |
|
'Delete': action(call([Delete, [PrefixOrThis]])), |
96 |
|
'Alt-Backspace': action(call([Delete, [PrefixOrThis]])), |
97 |
|
'Shift-Delete': action(call([Delete, [PrefixOrThis]])), |
98 |
|
'Alt-Shift-Backspace': action(call([Delete, [PrefixOrThis]])), |
99 |
|
'o': action(call([Go, [RootClone, [ThisWindow]]]), 1), |
100 |
|
'O': action(call([Go, [RootClone, [ThisWindow]]]), 0), |
101 |
|
'Tab': action(call([SwitchToTextMode])), |
102 |
|
'Tabulator': action(call([SwitchToTextMode])), |
103 |
|
'Ctrl-E': action(call([ExtEdit, [PrefixOrThis]]), 1), |
104 |
|
'Ctrl-Shift-E': action(call([ExtEdit, [PrefixOrThis]]), 0), |
105 |
|
'Ctrl-V': action(call([ViewContainedText, [PrefixOrThis]]), 1), |
106 |
|
'Ctrl-Shift-V': action(call([ViewContainedText, [PrefixOrThis]]), 0), |
107 |
|
'Ctrl-9': action(call([ChangeCellView, const(1)])), |
108 |
|
|
109 |
's': Arrow(0, 0, -1), |
'Ctrl-A': fn([AllEmailsThat, None]), |
110 |
'S': Arrow(0, 0, -1), |
'Ctrl-F': fn([FromFilterFn, None]), |
111 |
'f': Arrow(0, 0, 1), |
'Ctrl-T': fn([ToFilterFn, None]), |
112 |
'F': Arrow(0, 0, 1), |
'Ctrl-O': fn([OlderFilterFn, None]), |
113 |
'e': Arrow(0, 1, -1), |
'Ctrl-Alt-O': fn([NewerFilterFn, None]), |
114 |
'E': Arrow(0, 1, -1), |
'Alt-S': fn([SubjectFilterFn, None]), |
115 |
'c': Arrow(0, 1, 1), |
'&': fn([AndFilterFn, None, None]), |
116 |
'C': Arrow(0, 1, 1), |
'|': fn([OrFilterFn, None, None]), |
117 |
'd': Arrow(0, 2, -1), |
} |
|
'D': Arrow(0, 2, 1), |
|
|
|
|
|
|
|
|
|
|
|
# Right arrowset |
|
|
|
|
|
'j': Arrow(1, 0, -1), |
|
|
'J': Arrow(1, 0, -1), |
|
|
'l': Arrow(1, 0, 1), |
|
|
'L': Arrow(1, 0, 1), |
|
|
'i': Arrow(1, 1, -1), |
|
|
'I': Arrow(1, 1, -1), |
|
|
',': Arrow(1, 1, 1), |
|
|
'k': Arrow(1, 2, -1), |
|
|
'K': Arrow(1, 2, 1), |
|
|
|
|
|
'Left': Arrow(1, 0, -1), |
|
|
'Right': Arrow(1, 0, 1), |
|
|
'Up': Arrow(1, 1, -1), |
|
|
'Down': Arrow(1, 1, 1), |
|
|
|
|
|
|
|
|
|
|
|
# Directional operations (DirOps) |
|
|
|
|
|
'n': NewAndEdit(), |
|
|
'N': New(), |
|
|
'-': Connect(), |
|
|
'b': Break(), |
|
|
'B': Break(), |
|
|
'h': Hop(), |
|
|
'H': Hop(), |
|
|
't': Clone(1), |
|
|
'T': Clone(0), |
|
118 |
|
|
119 |
|
edit_mode = { |
120 |
|
gzz.client.PotionFallbackBinder.CHAR_KEY: |
121 |
|
action(call([InsertChar, [EventKey]])), |
122 |
|
|
123 |
|
'Left': action(call([TextCursorLeft])), |
124 |
# Non-directional operations |
'Right': action(call([TextCursorRight])), |
125 |
|
'Tab': action(call([SwitchToNormalMode])), |
126 |
'm': ToggleMark(1), |
'Tabulator': action(call([SwitchToNormalMode])), |
127 |
'M': ToggleMark(0), |
'Backspace': action(call([DeleteChar])), |
|
'v': ChangeView(1, 1), |
|
|
'V': ChangeView(0, 1), |
|
|
'o': Rootclone(1), |
|
|
'O': Rootclone(0), |
|
|
'g': GoTo(1), |
|
|
'G': GoTo(0), |
|
|
|
|
|
'Delete': Delete(1), |
|
|
'Ctrl-Backspace': Delete(1), # Macs have no "Delete" key |
|
|
|
|
|
|
|
|
|
|
|
# Saving and quitting |
|
|
|
|
|
'Ctrl-S': Save(), |
|
|
'q': Quit(), |
|
|
'Q': Quit(), |
|
|
|
|
|
|
|
|
|
|
|
# Rotating dimensions |
|
|
|
|
|
'x': Rotate(1, 0, 1), |
|
|
'y': Rotate(1, 1, 1), |
|
|
'z': Rotate(1, 2, 1), |
|
|
|
|
|
'X': Rotate(0, 0, 1), |
|
|
'Y': Rotate(0, 1, 1), |
|
|
'Z': Rotate(0, 2, 1), |
|
|
|
|
|
'Alt-X': Rotate(1, 0, -1), |
|
|
'Alt-Y': Rotate(1, 1, -1), |
|
|
'Alt-Z': Rotate(1, 2, -1), |
|
|
|
|
|
'Alt-Shift-X': Rotate(0, 0, -1), |
|
|
'Alt-Shift-Y': Rotate(0, 1, -1), |
|
|
'Alt-Shift-Z': Rotate(0, 2, -1), |
|
|
|
|
|
'r': ResetDims(1), |
|
|
'R': ResetDims(0), |
|
|
|
|
|
|
|
|
|
|
|
# Window and arrowset operations |
|
|
|
|
|
'Alt-A': ReassignArrowset(), |
|
|
'Alt-F': Fork(), |
|
|
'Alt-N': NewWindow(), |
|
|
|
|
|
|
|
|
|
|
|
# Misc |
|
|
|
|
|
'Ctrl-L': MakeLink(1), |
|
|
'Alt-L': MakeLink(-1), |
|
|
|
|
|
# totally temporary! |
|
|
'Ctrl-0': CreatePageSpan(), |
|
128 |
} |
} |
129 |
|
|
130 |
|
bindingsByMode = java.util.HashMap() |
131 |
|
bindingsByMode.put(gzz.client.PotionFallbackBinder.NORMAL_MODE, |
132 |
|
map(normal_mode)) |
133 |
|
bindingsByMode.put("text mode", map(text_mode)) |