omni-ai-cli 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +615 -2
- package/bin/ai.js +84 -0
- package/docs/README.en.md +615 -0
- package/docs/README.es.md +618 -0
- package/docs/README.fr.md +630 -0
- package/omni_ai/__init__.py +1 -0
- package/omni_ai/__main__.py +6 -0
- package/omni_ai/chat.py +1458 -0
- package/omni_ai/cli.py +991 -0
- package/omni_ai/config.py +531 -0
- package/omni_ai/deepseek.py +57 -0
- package/omni_ai/grok.py +111 -0
- package/omni_ai/onboarding.py +196 -0
- package/omni_ai/openrouter.py +335 -0
- package/omni_ai/osutils.py +86 -0
- package/omni_ai/pii.py +281 -0
- package/omni_ai/profiles.json +69 -0
- package/omni_ai/skills.py +124 -0
- package/omni_ai/sync.py +199 -0
- package/omni_ai/tools.py +75 -0
- package/omni_ai/ui.py +595 -0
- package/omni_ai/usage.py +305 -0
- package/omni_ai/vendor/prompt_toolkit/LICENSE +27 -0
- package/omni_ai/vendor/prompt_toolkit/__init__.py +52 -0
- package/omni_ai/vendor/prompt_toolkit/application/__init__.py +32 -0
- package/omni_ai/vendor/prompt_toolkit/application/application.py +1626 -0
- package/omni_ai/vendor/prompt_toolkit/application/current.py +195 -0
- package/omni_ai/vendor/prompt_toolkit/application/dummy.py +55 -0
- package/omni_ai/vendor/prompt_toolkit/application/run_in_terminal.py +114 -0
- package/omni_ai/vendor/prompt_toolkit/auto_suggest.py +177 -0
- package/omni_ai/vendor/prompt_toolkit/buffer.py +2029 -0
- package/omni_ai/vendor/prompt_toolkit/cache.py +127 -0
- package/omni_ai/vendor/prompt_toolkit/clipboard/__init__.py +17 -0
- package/omni_ai/vendor/prompt_toolkit/clipboard/base.py +109 -0
- package/omni_ai/vendor/prompt_toolkit/clipboard/in_memory.py +44 -0
- package/omni_ai/vendor/prompt_toolkit/clipboard/pyperclip.py +42 -0
- package/omni_ai/vendor/prompt_toolkit/completion/__init__.py +43 -0
- package/omni_ai/vendor/prompt_toolkit/completion/base.py +438 -0
- package/omni_ai/vendor/prompt_toolkit/completion/deduplicate.py +45 -0
- package/omni_ai/vendor/prompt_toolkit/completion/filesystem.py +118 -0
- package/omni_ai/vendor/prompt_toolkit/completion/fuzzy_completer.py +213 -0
- package/omni_ai/vendor/prompt_toolkit/completion/nested.py +109 -0
- package/omni_ai/vendor/prompt_toolkit/completion/word_completer.py +94 -0
- package/omni_ai/vendor/prompt_toolkit/contrib/__init__.py +0 -0
- package/omni_ai/vendor/prompt_toolkit/contrib/completers/__init__.py +5 -0
- package/omni_ai/vendor/prompt_toolkit/contrib/completers/system.py +64 -0
- package/omni_ai/vendor/prompt_toolkit/contrib/regular_languages/__init__.py +80 -0
- package/omni_ai/vendor/prompt_toolkit/contrib/regular_languages/compiler.py +579 -0
- package/omni_ai/vendor/prompt_toolkit/contrib/regular_languages/completion.py +100 -0
- package/omni_ai/vendor/prompt_toolkit/contrib/regular_languages/lexer.py +94 -0
- package/omni_ai/vendor/prompt_toolkit/contrib/regular_languages/regex_parser.py +279 -0
- package/omni_ai/vendor/prompt_toolkit/contrib/regular_languages/validation.py +60 -0
- package/omni_ai/vendor/prompt_toolkit/contrib/ssh/__init__.py +8 -0
- package/omni_ai/vendor/prompt_toolkit/contrib/ssh/server.py +178 -0
- package/omni_ai/vendor/prompt_toolkit/contrib/telnet/__init__.py +7 -0
- package/omni_ai/vendor/prompt_toolkit/contrib/telnet/log.py +13 -0
- package/omni_ai/vendor/prompt_toolkit/contrib/telnet/protocol.py +209 -0
- package/omni_ai/vendor/prompt_toolkit/contrib/telnet/server.py +428 -0
- package/omni_ai/vendor/prompt_toolkit/cursor_shapes.py +117 -0
- package/omni_ai/vendor/prompt_toolkit/data_structures.py +18 -0
- package/omni_ai/vendor/prompt_toolkit/document.py +1182 -0
- package/omni_ai/vendor/prompt_toolkit/enums.py +19 -0
- package/omni_ai/vendor/prompt_toolkit/eventloop/__init__.py +31 -0
- package/omni_ai/vendor/prompt_toolkit/eventloop/async_generator.py +125 -0
- package/omni_ai/vendor/prompt_toolkit/eventloop/inputhook.py +191 -0
- package/omni_ai/vendor/prompt_toolkit/eventloop/utils.py +101 -0
- package/omni_ai/vendor/prompt_toolkit/eventloop/win32.py +72 -0
- package/omni_ai/vendor/prompt_toolkit/filters/__init__.py +71 -0
- package/omni_ai/vendor/prompt_toolkit/filters/app.py +419 -0
- package/omni_ai/vendor/prompt_toolkit/filters/base.py +261 -0
- package/omni_ai/vendor/prompt_toolkit/filters/cli.py +65 -0
- package/omni_ai/vendor/prompt_toolkit/filters/utils.py +41 -0
- package/omni_ai/vendor/prompt_toolkit/formatted_text/__init__.py +59 -0
- package/omni_ai/vendor/prompt_toolkit/formatted_text/ansi.py +297 -0
- package/omni_ai/vendor/prompt_toolkit/formatted_text/base.py +179 -0
- package/omni_ai/vendor/prompt_toolkit/formatted_text/html.py +145 -0
- package/omni_ai/vendor/prompt_toolkit/formatted_text/pygments.py +32 -0
- package/omni_ai/vendor/prompt_toolkit/formatted_text/utils.py +103 -0
- package/omni_ai/vendor/prompt_toolkit/history.py +306 -0
- package/omni_ai/vendor/prompt_toolkit/input/__init__.py +14 -0
- package/omni_ai/vendor/prompt_toolkit/input/ansi_escape_sequences.py +344 -0
- package/omni_ai/vendor/prompt_toolkit/input/base.py +153 -0
- package/omni_ai/vendor/prompt_toolkit/input/defaults.py +79 -0
- package/omni_ai/vendor/prompt_toolkit/input/posix_pipe.py +118 -0
- package/omni_ai/vendor/prompt_toolkit/input/posix_utils.py +97 -0
- package/omni_ai/vendor/prompt_toolkit/input/typeahead.py +78 -0
- package/omni_ai/vendor/prompt_toolkit/input/vt100.py +309 -0
- package/omni_ai/vendor/prompt_toolkit/input/vt100_parser.py +250 -0
- package/omni_ai/vendor/prompt_toolkit/input/win32.py +749 -0
- package/omni_ai/vendor/prompt_toolkit/input/win32_pipe.py +156 -0
- package/omni_ai/vendor/prompt_toolkit/key_binding/__init__.py +22 -0
- package/omni_ai/vendor/prompt_toolkit/key_binding/bindings/__init__.py +0 -0
- package/omni_ai/vendor/prompt_toolkit/key_binding/bindings/auto_suggest.py +66 -0
- package/omni_ai/vendor/prompt_toolkit/key_binding/bindings/basic.py +257 -0
- package/omni_ai/vendor/prompt_toolkit/key_binding/bindings/completion.py +206 -0
- package/omni_ai/vendor/prompt_toolkit/key_binding/bindings/cpr.py +30 -0
- package/omni_ai/vendor/prompt_toolkit/key_binding/bindings/emacs.py +563 -0
- package/omni_ai/vendor/prompt_toolkit/key_binding/bindings/focus.py +26 -0
- package/omni_ai/vendor/prompt_toolkit/key_binding/bindings/mouse.py +348 -0
- package/omni_ai/vendor/prompt_toolkit/key_binding/bindings/named_commands.py +691 -0
- package/omni_ai/vendor/prompt_toolkit/key_binding/bindings/open_in_editor.py +52 -0
- package/omni_ai/vendor/prompt_toolkit/key_binding/bindings/page_navigation.py +85 -0
- package/omni_ai/vendor/prompt_toolkit/key_binding/bindings/scroll.py +190 -0
- package/omni_ai/vendor/prompt_toolkit/key_binding/bindings/search.py +96 -0
- package/omni_ai/vendor/prompt_toolkit/key_binding/bindings/vi.py +2233 -0
- package/omni_ai/vendor/prompt_toolkit/key_binding/defaults.py +63 -0
- package/omni_ai/vendor/prompt_toolkit/key_binding/digraphs.py +1378 -0
- package/omni_ai/vendor/prompt_toolkit/key_binding/emacs_state.py +36 -0
- package/omni_ai/vendor/prompt_toolkit/key_binding/key_bindings.py +670 -0
- package/omni_ai/vendor/prompt_toolkit/key_binding/key_processor.py +526 -0
- package/omni_ai/vendor/prompt_toolkit/key_binding/vi_state.py +107 -0
- package/omni_ai/vendor/prompt_toolkit/keys.py +222 -0
- package/omni_ai/vendor/prompt_toolkit/layout/__init__.py +147 -0
- package/omni_ai/vendor/prompt_toolkit/layout/containers.py +2738 -0
- package/omni_ai/vendor/prompt_toolkit/layout/controls.py +945 -0
- package/omni_ai/vendor/prompt_toolkit/layout/dimension.py +220 -0
- package/omni_ai/vendor/prompt_toolkit/layout/dummy.py +40 -0
- package/omni_ai/vendor/prompt_toolkit/layout/layout.py +412 -0
- package/omni_ai/vendor/prompt_toolkit/layout/margins.py +304 -0
- package/omni_ai/vendor/prompt_toolkit/layout/menus.py +748 -0
- package/omni_ai/vendor/prompt_toolkit/layout/mouse_handlers.py +56 -0
- package/omni_ai/vendor/prompt_toolkit/layout/processors.py +1010 -0
- package/omni_ai/vendor/prompt_toolkit/layout/screen.py +323 -0
- package/omni_ai/vendor/prompt_toolkit/layout/scrollable_pane.py +494 -0
- package/omni_ai/vendor/prompt_toolkit/layout/utils.py +80 -0
- package/omni_ai/vendor/prompt_toolkit/lexers/__init__.py +21 -0
- package/omni_ai/vendor/prompt_toolkit/lexers/base.py +85 -0
- package/omni_ai/vendor/prompt_toolkit/lexers/pygments.py +328 -0
- package/omni_ai/vendor/prompt_toolkit/log.py +13 -0
- package/omni_ai/vendor/prompt_toolkit/mouse_events.py +85 -0
- package/omni_ai/vendor/prompt_toolkit/output/__init__.py +15 -0
- package/omni_ai/vendor/prompt_toolkit/output/base.py +332 -0
- package/omni_ai/vendor/prompt_toolkit/output/color_depth.py +64 -0
- package/omni_ai/vendor/prompt_toolkit/output/conemu.py +65 -0
- package/omni_ai/vendor/prompt_toolkit/output/defaults.py +106 -0
- package/omni_ai/vendor/prompt_toolkit/output/flush_stdout.py +87 -0
- package/omni_ai/vendor/prompt_toolkit/output/plain_text.py +143 -0
- package/omni_ai/vendor/prompt_toolkit/output/vt100.py +748 -0
- package/omni_ai/vendor/prompt_toolkit/output/win32.py +683 -0
- package/omni_ai/vendor/prompt_toolkit/output/windows10.py +128 -0
- package/omni_ai/vendor/prompt_toolkit/patch_stdout.py +297 -0
- package/omni_ai/vendor/prompt_toolkit/py.typed +0 -0
- package/omni_ai/vendor/prompt_toolkit/renderer.py +814 -0
- package/omni_ai/vendor/prompt_toolkit/search.py +226 -0
- package/omni_ai/vendor/prompt_toolkit/selection.py +58 -0
- package/omni_ai/vendor/prompt_toolkit/shortcuts/__init__.py +46 -0
- package/omni_ai/vendor/prompt_toolkit/shortcuts/dialogs.py +330 -0
- package/omni_ai/vendor/prompt_toolkit/shortcuts/progress_bar/__init__.py +33 -0
- package/omni_ai/vendor/prompt_toolkit/shortcuts/progress_bar/base.py +449 -0
- package/omni_ai/vendor/prompt_toolkit/shortcuts/progress_bar/formatters.py +431 -0
- package/omni_ai/vendor/prompt_toolkit/shortcuts/prompt.py +1513 -0
- package/omni_ai/vendor/prompt_toolkit/shortcuts/utils.py +239 -0
- package/omni_ai/vendor/prompt_toolkit/styles/__init__.py +67 -0
- package/omni_ai/vendor/prompt_toolkit/styles/base.py +184 -0
- package/omni_ai/vendor/prompt_toolkit/styles/defaults.py +236 -0
- package/omni_ai/vendor/prompt_toolkit/styles/named_colors.py +162 -0
- package/omni_ai/vendor/prompt_toolkit/styles/pygments.py +70 -0
- package/omni_ai/vendor/prompt_toolkit/styles/style.py +401 -0
- package/omni_ai/vendor/prompt_toolkit/styles/style_transformation.py +374 -0
- package/omni_ai/vendor/prompt_toolkit/token.py +9 -0
- package/omni_ai/vendor/prompt_toolkit/utils.py +327 -0
- package/omni_ai/vendor/prompt_toolkit/validation.py +192 -0
- package/omni_ai/vendor/prompt_toolkit/widgets/__init__.py +63 -0
- package/omni_ai/vendor/prompt_toolkit/widgets/base.py +995 -0
- package/omni_ai/vendor/prompt_toolkit/widgets/dialogs.py +108 -0
- package/omni_ai/vendor/prompt_toolkit/widgets/menus.py +374 -0
- package/omni_ai/vendor/prompt_toolkit/widgets/toolbars.py +370 -0
- package/omni_ai/vendor/prompt_toolkit/win32_types.py +229 -0
- package/omni_ai/vendor/wcwidth/LICENSE +27 -0
- package/omni_ai/vendor/wcwidth/__init__.py +29 -0
- package/omni_ai/vendor/wcwidth/table_vs16.py +125 -0
- package/omni_ai/vendor/wcwidth/table_wide.py +1493 -0
- package/omni_ai/vendor/wcwidth/table_zero.py +4843 -0
- package/omni_ai/vendor/wcwidth/unicode_versions.py +38 -0
- package/omni_ai/vendor/wcwidth/wcwidth.py +345 -0
- package/package.json +40 -4
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from enum import Enum
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"Keys",
|
|
7
|
+
"ALL_KEYS",
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Keys(str, Enum):
|
|
12
|
+
"""
|
|
13
|
+
List of keys for use in key bindings.
|
|
14
|
+
|
|
15
|
+
Note that this is an "StrEnum", all values can be compared against
|
|
16
|
+
strings.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
value: str
|
|
20
|
+
|
|
21
|
+
Escape = "escape" # Also Control-[
|
|
22
|
+
ShiftEscape = "s-escape"
|
|
23
|
+
|
|
24
|
+
ControlAt = "c-@" # Also Control-Space.
|
|
25
|
+
|
|
26
|
+
ControlA = "c-a"
|
|
27
|
+
ControlB = "c-b"
|
|
28
|
+
ControlC = "c-c"
|
|
29
|
+
ControlD = "c-d"
|
|
30
|
+
ControlE = "c-e"
|
|
31
|
+
ControlF = "c-f"
|
|
32
|
+
ControlG = "c-g"
|
|
33
|
+
ControlH = "c-h"
|
|
34
|
+
ControlI = "c-i" # Tab
|
|
35
|
+
ControlJ = "c-j" # Newline
|
|
36
|
+
ControlK = "c-k"
|
|
37
|
+
ControlL = "c-l"
|
|
38
|
+
ControlM = "c-m" # Carriage return
|
|
39
|
+
ControlN = "c-n"
|
|
40
|
+
ControlO = "c-o"
|
|
41
|
+
ControlP = "c-p"
|
|
42
|
+
ControlQ = "c-q"
|
|
43
|
+
ControlR = "c-r"
|
|
44
|
+
ControlS = "c-s"
|
|
45
|
+
ControlT = "c-t"
|
|
46
|
+
ControlU = "c-u"
|
|
47
|
+
ControlV = "c-v"
|
|
48
|
+
ControlW = "c-w"
|
|
49
|
+
ControlX = "c-x"
|
|
50
|
+
ControlY = "c-y"
|
|
51
|
+
ControlZ = "c-z"
|
|
52
|
+
|
|
53
|
+
Control1 = "c-1"
|
|
54
|
+
Control2 = "c-2"
|
|
55
|
+
Control3 = "c-3"
|
|
56
|
+
Control4 = "c-4"
|
|
57
|
+
Control5 = "c-5"
|
|
58
|
+
Control6 = "c-6"
|
|
59
|
+
Control7 = "c-7"
|
|
60
|
+
Control8 = "c-8"
|
|
61
|
+
Control9 = "c-9"
|
|
62
|
+
Control0 = "c-0"
|
|
63
|
+
|
|
64
|
+
ControlShift1 = "c-s-1"
|
|
65
|
+
ControlShift2 = "c-s-2"
|
|
66
|
+
ControlShift3 = "c-s-3"
|
|
67
|
+
ControlShift4 = "c-s-4"
|
|
68
|
+
ControlShift5 = "c-s-5"
|
|
69
|
+
ControlShift6 = "c-s-6"
|
|
70
|
+
ControlShift7 = "c-s-7"
|
|
71
|
+
ControlShift8 = "c-s-8"
|
|
72
|
+
ControlShift9 = "c-s-9"
|
|
73
|
+
ControlShift0 = "c-s-0"
|
|
74
|
+
|
|
75
|
+
ControlBackslash = "c-\\"
|
|
76
|
+
ControlSquareClose = "c-]"
|
|
77
|
+
ControlCircumflex = "c-^"
|
|
78
|
+
ControlUnderscore = "c-_"
|
|
79
|
+
|
|
80
|
+
Left = "left"
|
|
81
|
+
Right = "right"
|
|
82
|
+
Up = "up"
|
|
83
|
+
Down = "down"
|
|
84
|
+
Home = "home"
|
|
85
|
+
End = "end"
|
|
86
|
+
Insert = "insert"
|
|
87
|
+
Delete = "delete"
|
|
88
|
+
PageUp = "pageup"
|
|
89
|
+
PageDown = "pagedown"
|
|
90
|
+
|
|
91
|
+
ControlLeft = "c-left"
|
|
92
|
+
ControlRight = "c-right"
|
|
93
|
+
ControlUp = "c-up"
|
|
94
|
+
ControlDown = "c-down"
|
|
95
|
+
ControlHome = "c-home"
|
|
96
|
+
ControlEnd = "c-end"
|
|
97
|
+
ControlInsert = "c-insert"
|
|
98
|
+
ControlDelete = "c-delete"
|
|
99
|
+
ControlPageUp = "c-pageup"
|
|
100
|
+
ControlPageDown = "c-pagedown"
|
|
101
|
+
|
|
102
|
+
ShiftLeft = "s-left"
|
|
103
|
+
ShiftRight = "s-right"
|
|
104
|
+
ShiftUp = "s-up"
|
|
105
|
+
ShiftDown = "s-down"
|
|
106
|
+
ShiftHome = "s-home"
|
|
107
|
+
ShiftEnd = "s-end"
|
|
108
|
+
ShiftInsert = "s-insert"
|
|
109
|
+
ShiftDelete = "s-delete"
|
|
110
|
+
ShiftPageUp = "s-pageup"
|
|
111
|
+
ShiftPageDown = "s-pagedown"
|
|
112
|
+
|
|
113
|
+
ControlShiftLeft = "c-s-left"
|
|
114
|
+
ControlShiftRight = "c-s-right"
|
|
115
|
+
ControlShiftUp = "c-s-up"
|
|
116
|
+
ControlShiftDown = "c-s-down"
|
|
117
|
+
ControlShiftHome = "c-s-home"
|
|
118
|
+
ControlShiftEnd = "c-s-end"
|
|
119
|
+
ControlShiftInsert = "c-s-insert"
|
|
120
|
+
ControlShiftDelete = "c-s-delete"
|
|
121
|
+
ControlShiftPageUp = "c-s-pageup"
|
|
122
|
+
ControlShiftPageDown = "c-s-pagedown"
|
|
123
|
+
|
|
124
|
+
BackTab = "s-tab" # shift + tab
|
|
125
|
+
|
|
126
|
+
F1 = "f1"
|
|
127
|
+
F2 = "f2"
|
|
128
|
+
F3 = "f3"
|
|
129
|
+
F4 = "f4"
|
|
130
|
+
F5 = "f5"
|
|
131
|
+
F6 = "f6"
|
|
132
|
+
F7 = "f7"
|
|
133
|
+
F8 = "f8"
|
|
134
|
+
F9 = "f9"
|
|
135
|
+
F10 = "f10"
|
|
136
|
+
F11 = "f11"
|
|
137
|
+
F12 = "f12"
|
|
138
|
+
F13 = "f13"
|
|
139
|
+
F14 = "f14"
|
|
140
|
+
F15 = "f15"
|
|
141
|
+
F16 = "f16"
|
|
142
|
+
F17 = "f17"
|
|
143
|
+
F18 = "f18"
|
|
144
|
+
F19 = "f19"
|
|
145
|
+
F20 = "f20"
|
|
146
|
+
F21 = "f21"
|
|
147
|
+
F22 = "f22"
|
|
148
|
+
F23 = "f23"
|
|
149
|
+
F24 = "f24"
|
|
150
|
+
|
|
151
|
+
ControlF1 = "c-f1"
|
|
152
|
+
ControlF2 = "c-f2"
|
|
153
|
+
ControlF3 = "c-f3"
|
|
154
|
+
ControlF4 = "c-f4"
|
|
155
|
+
ControlF5 = "c-f5"
|
|
156
|
+
ControlF6 = "c-f6"
|
|
157
|
+
ControlF7 = "c-f7"
|
|
158
|
+
ControlF8 = "c-f8"
|
|
159
|
+
ControlF9 = "c-f9"
|
|
160
|
+
ControlF10 = "c-f10"
|
|
161
|
+
ControlF11 = "c-f11"
|
|
162
|
+
ControlF12 = "c-f12"
|
|
163
|
+
ControlF13 = "c-f13"
|
|
164
|
+
ControlF14 = "c-f14"
|
|
165
|
+
ControlF15 = "c-f15"
|
|
166
|
+
ControlF16 = "c-f16"
|
|
167
|
+
ControlF17 = "c-f17"
|
|
168
|
+
ControlF18 = "c-f18"
|
|
169
|
+
ControlF19 = "c-f19"
|
|
170
|
+
ControlF20 = "c-f20"
|
|
171
|
+
ControlF21 = "c-f21"
|
|
172
|
+
ControlF22 = "c-f22"
|
|
173
|
+
ControlF23 = "c-f23"
|
|
174
|
+
ControlF24 = "c-f24"
|
|
175
|
+
|
|
176
|
+
# Matches any key.
|
|
177
|
+
Any = "<any>"
|
|
178
|
+
|
|
179
|
+
# Special.
|
|
180
|
+
ScrollUp = "<scroll-up>"
|
|
181
|
+
ScrollDown = "<scroll-down>"
|
|
182
|
+
|
|
183
|
+
CPRResponse = "<cursor-position-response>"
|
|
184
|
+
Vt100MouseEvent = "<vt100-mouse-event>"
|
|
185
|
+
WindowsMouseEvent = "<windows-mouse-event>"
|
|
186
|
+
BracketedPaste = "<bracketed-paste>"
|
|
187
|
+
|
|
188
|
+
SIGINT = "<sigint>"
|
|
189
|
+
|
|
190
|
+
# For internal use: key which is ignored.
|
|
191
|
+
# (The key binding for this key should not do anything.)
|
|
192
|
+
Ignore = "<ignore>"
|
|
193
|
+
|
|
194
|
+
# Some 'Key' aliases (for backwards-compatibility).
|
|
195
|
+
ControlSpace = ControlAt
|
|
196
|
+
Tab = ControlI
|
|
197
|
+
Enter = ControlM
|
|
198
|
+
Backspace = ControlH
|
|
199
|
+
|
|
200
|
+
# ShiftControl was renamed to ControlShift in
|
|
201
|
+
# 888fcb6fa4efea0de8333177e1bbc792f3ff3c24 (20 Feb 2020).
|
|
202
|
+
ShiftControlLeft = ControlShiftLeft
|
|
203
|
+
ShiftControlRight = ControlShiftRight
|
|
204
|
+
ShiftControlHome = ControlShiftHome
|
|
205
|
+
ShiftControlEnd = ControlShiftEnd
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
ALL_KEYS: list[str] = [k.value for k in Keys]
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
# Aliases.
|
|
212
|
+
KEY_ALIASES: dict[str, str] = {
|
|
213
|
+
"backspace": "c-h",
|
|
214
|
+
"c-space": "c-@",
|
|
215
|
+
"enter": "c-m",
|
|
216
|
+
"tab": "c-i",
|
|
217
|
+
# ShiftControl was renamed to ControlShift.
|
|
218
|
+
"s-c-left": "c-s-left",
|
|
219
|
+
"s-c-right": "c-s-right",
|
|
220
|
+
"s-c-home": "c-s-home",
|
|
221
|
+
"s-c-end": "c-s-end",
|
|
222
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Command line layout definitions
|
|
3
|
+
-------------------------------
|
|
4
|
+
|
|
5
|
+
The layout of a command line interface is defined by a Container instance.
|
|
6
|
+
There are two main groups of classes here. Containers and controls:
|
|
7
|
+
|
|
8
|
+
- A container can contain other containers or controls, it can have multiple
|
|
9
|
+
children and it decides about the dimensions.
|
|
10
|
+
- A control is responsible for rendering the actual content to a screen.
|
|
11
|
+
A control can propose some dimensions, but it's the container who decides
|
|
12
|
+
about the dimensions -- or when the control consumes more space -- which part
|
|
13
|
+
of the control will be visible.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
Container classes::
|
|
17
|
+
|
|
18
|
+
- Container (Abstract base class)
|
|
19
|
+
|- HSplit (Horizontal split)
|
|
20
|
+
|- VSplit (Vertical split)
|
|
21
|
+
|- FloatContainer (Container which can also contain menus and other floats)
|
|
22
|
+
`- Window (Container which contains one actual control
|
|
23
|
+
|
|
24
|
+
Control classes::
|
|
25
|
+
|
|
26
|
+
- UIControl (Abstract base class)
|
|
27
|
+
|- FormattedTextControl (Renders formatted text, or a simple list of text fragments)
|
|
28
|
+
`- BufferControl (Renders an input buffer.)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
Usually, you end up wrapping every control inside a `Window` object, because
|
|
32
|
+
that's the only way to render it in a layout.
|
|
33
|
+
|
|
34
|
+
There are some prepared toolbars which are ready to use::
|
|
35
|
+
|
|
36
|
+
- SystemToolbar (Shows the 'system' input buffer, for entering system commands.)
|
|
37
|
+
- ArgToolbar (Shows the input 'arg', for repetition of input commands.)
|
|
38
|
+
- SearchToolbar (Shows the 'search' input buffer, for incremental search.)
|
|
39
|
+
- CompletionsToolbar (Shows the completions of the current buffer.)
|
|
40
|
+
- ValidationToolbar (Shows validation errors of the current buffer.)
|
|
41
|
+
|
|
42
|
+
And one prepared menu:
|
|
43
|
+
|
|
44
|
+
- CompletionsMenu
|
|
45
|
+
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
from __future__ import annotations
|
|
49
|
+
|
|
50
|
+
from .containers import (
|
|
51
|
+
AnyContainer,
|
|
52
|
+
ColorColumn,
|
|
53
|
+
ConditionalContainer,
|
|
54
|
+
Container,
|
|
55
|
+
DynamicContainer,
|
|
56
|
+
Float,
|
|
57
|
+
FloatContainer,
|
|
58
|
+
HorizontalAlign,
|
|
59
|
+
HSplit,
|
|
60
|
+
ScrollOffsets,
|
|
61
|
+
VerticalAlign,
|
|
62
|
+
VSplit,
|
|
63
|
+
Window,
|
|
64
|
+
WindowAlign,
|
|
65
|
+
WindowRenderInfo,
|
|
66
|
+
is_container,
|
|
67
|
+
to_container,
|
|
68
|
+
to_window,
|
|
69
|
+
)
|
|
70
|
+
from .controls import (
|
|
71
|
+
BufferControl,
|
|
72
|
+
DummyControl,
|
|
73
|
+
FormattedTextControl,
|
|
74
|
+
SearchBufferControl,
|
|
75
|
+
UIContent,
|
|
76
|
+
UIControl,
|
|
77
|
+
)
|
|
78
|
+
from .dimension import (
|
|
79
|
+
AnyDimension,
|
|
80
|
+
D,
|
|
81
|
+
Dimension,
|
|
82
|
+
is_dimension,
|
|
83
|
+
max_layout_dimensions,
|
|
84
|
+
sum_layout_dimensions,
|
|
85
|
+
to_dimension,
|
|
86
|
+
)
|
|
87
|
+
from .layout import InvalidLayoutError, Layout, walk
|
|
88
|
+
from .margins import (
|
|
89
|
+
ConditionalMargin,
|
|
90
|
+
Margin,
|
|
91
|
+
NumberedMargin,
|
|
92
|
+
PromptMargin,
|
|
93
|
+
ScrollbarMargin,
|
|
94
|
+
)
|
|
95
|
+
from .menus import CompletionsMenu, MultiColumnCompletionsMenu
|
|
96
|
+
from .scrollable_pane import ScrollablePane
|
|
97
|
+
|
|
98
|
+
__all__ = [
|
|
99
|
+
# Layout.
|
|
100
|
+
"Layout",
|
|
101
|
+
"InvalidLayoutError",
|
|
102
|
+
"walk",
|
|
103
|
+
# Dimensions.
|
|
104
|
+
"AnyDimension",
|
|
105
|
+
"Dimension",
|
|
106
|
+
"D",
|
|
107
|
+
"sum_layout_dimensions",
|
|
108
|
+
"max_layout_dimensions",
|
|
109
|
+
"to_dimension",
|
|
110
|
+
"is_dimension",
|
|
111
|
+
# Containers.
|
|
112
|
+
"AnyContainer",
|
|
113
|
+
"Container",
|
|
114
|
+
"HorizontalAlign",
|
|
115
|
+
"VerticalAlign",
|
|
116
|
+
"HSplit",
|
|
117
|
+
"VSplit",
|
|
118
|
+
"FloatContainer",
|
|
119
|
+
"Float",
|
|
120
|
+
"WindowAlign",
|
|
121
|
+
"Window",
|
|
122
|
+
"WindowRenderInfo",
|
|
123
|
+
"ConditionalContainer",
|
|
124
|
+
"ScrollOffsets",
|
|
125
|
+
"ColorColumn",
|
|
126
|
+
"to_container",
|
|
127
|
+
"to_window",
|
|
128
|
+
"is_container",
|
|
129
|
+
"DynamicContainer",
|
|
130
|
+
"ScrollablePane",
|
|
131
|
+
# Controls.
|
|
132
|
+
"BufferControl",
|
|
133
|
+
"SearchBufferControl",
|
|
134
|
+
"DummyControl",
|
|
135
|
+
"FormattedTextControl",
|
|
136
|
+
"UIControl",
|
|
137
|
+
"UIContent",
|
|
138
|
+
# Margins.
|
|
139
|
+
"Margin",
|
|
140
|
+
"NumberedMargin",
|
|
141
|
+
"ScrollbarMargin",
|
|
142
|
+
"ConditionalMargin",
|
|
143
|
+
"PromptMargin",
|
|
144
|
+
# Menus.
|
|
145
|
+
"CompletionsMenu",
|
|
146
|
+
"MultiColumnCompletionsMenu",
|
|
147
|
+
]
|