vimamsa 0.1.27 → 0.1.28
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.
- checksums.yaml +4 -4
- data/README.md +139 -89
- data/custom_example.rb +18 -6
- data/doc/TODO.md +327 -110
- data/doc/action_names_plan.md +442 -0
- data/doc/bundling_plan.md +2 -1
- data/doc/delta_syntax_plan.md +293 -0
- data/doc/demo_recording_plan.md +288 -0
- data/doc/design_goals.md +27 -0
- data/doc/intro_page_plan.md +266 -0
- data/doc/key_bindings_report_plan.md +45 -0
- data/doc/line_tree_plan.md +89 -0
- data/doc/missing_vim_bindings.md +34 -44
- data/doc/modules_settings_plan.md +1 -1
- data/doc/registries_plan.md +202 -0
- data/doc/startup_speed_plan.md +97 -0
- data/doc/treap_visualizer.html +585 -0
- data/doc/vim_compatibility_plan.md +186 -31
- data/doc/vimlike_vim_conflicts.md +236 -228
- data/doc/vm_snapshots_plan.md +4 -4
- data/doc/wysiwyg_plan.md +231 -0
- data/exe/run_tests.rb +8 -1
- data/exe/vimamsa +49 -6
- data/help/intro.txt +30 -0
- data/help/vim_intro.txt +31 -0
- data/img/demo.gif +0 -0
- data/img/demo.mp4 +0 -0
- data/lang/hyperplaintext.lang +1 -1
- data/lib/vimamsa/ack.rb +2 -0
- data/lib/vimamsa/actions.rb +381 -36
- data/lib/vimamsa/bookmarks.rb +8 -8
- data/lib/vimamsa/buffer.rb +83 -37
- data/lib/vimamsa/buffer_changetext.rb +58 -36
- data/lib/vimamsa/buffer_list.rb +2 -2
- data/lib/vimamsa/buffer_manager.rb +6 -6
- data/lib/vimamsa/cli_help.rb +75 -0
- data/lib/vimamsa/clipboard.rb +6 -3
- data/lib/vimamsa/conf.rb +9 -0
- data/lib/vimamsa/crash_handler.rb +2 -2
- data/lib/vimamsa/debug.rb +2 -2
- data/lib/vimamsa/demo_player.rb +458 -0
- data/lib/vimamsa/demo_recorder.rb +277 -0
- data/lib/vimamsa/diff_buffer.rb +1 -1
- data/lib/vimamsa/dot_repeat.rb +104 -0
- data/lib/vimamsa/easy_jump.rb +54 -3
- data/lib/vimamsa/editor.rb +89 -46
- data/lib/vimamsa/file_history.rb +1 -1
- data/lib/vimamsa/file_manager.rb +23 -23
- data/lib/vimamsa/form_input.rb +388 -0
- data/lib/vimamsa/gui.rb +83 -13
- data/lib/vimamsa/gui_command_line.rb +44 -5
- data/lib/vimamsa/gui_form_generator.rb +17 -6
- data/lib/vimamsa/gui_key_hint.rb +165 -0
- data/lib/vimamsa/gui_keylog_panel.rb +164 -2
- data/lib/vimamsa/gui_menu.rb +69 -50
- data/lib/vimamsa/gui_select_window.rb +77 -43
- data/lib/vimamsa/gui_settings.rb +9 -5
- data/lib/vimamsa/gui_sourceview.rb +15 -81
- data/lib/vimamsa/gui_theme.rb +11 -2
- data/lib/vimamsa/hook.rb +2 -0
- data/lib/vimamsa/intro_page.rb +368 -0
- data/lib/vimamsa/key_actions.rb +315 -225
- data/lib/vimamsa/key_binding_tree.rb +228 -61
- data/lib/vimamsa/key_bindings_notepad.rb +18 -16
- data/lib/vimamsa/key_bindings_report.rb +290 -67
- data/lib/vimamsa/key_bindings_vim.rb +47 -297
- data/lib/vimamsa/key_bindings_vimlike.rb +347 -339
- data/lib/vimamsa/key_names.rb +80 -0
- data/lib/vimamsa/line_tree.rb +367 -0
- data/lib/vimamsa/macro.rb +20 -3
- data/lib/vimamsa/rbvma.rb +15 -0
- data/lib/vimamsa/registers.rb +125 -0
- data/lib/vimamsa/run_ruby.rb +64 -0
- data/lib/vimamsa/search_replace.rb +4 -4
- data/lib/vimamsa/string_util.rb +17 -3
- data/lib/vimamsa/tests.rb +8 -8
- data/lib/vimamsa/text_objects.rb +11 -54
- data/lib/vimamsa/text_transforms.rb +4 -0
- data/lib/vimamsa/tmp_user_dir.rb +39 -0
- data/lib/vimamsa/user_dirs.rb +83 -0
- data/lib/vimamsa/version.rb +1 -1
- data/lib/vimamsa/vim_core.rb +355 -0
- data/lib/vimamsa/vim_operators.rb +365 -0
- data/modules/calculator/calculator.rb +5 -5
- data/modules/color_highlight/color_highlight.rb +3 -3
- data/modules/dictation/dictation.rb +32 -32
- data/modules/ollama/ollama.rb +5 -5
- data/modules/terminal/terminal.rb +5 -5
- data/modules/tts/tts.rb +10 -10
- data/run_e2e_vm.sh +3 -3
- data/run_tests_vm.rb +138 -0
- data/scripts/demo/demo_easyjump_steps.txt +60 -0
- data/scripts/demo/demo_files_steps.txt +52 -0
- data/scripts/demo/demo_steps.txt +9 -1
- data/scripts/demo/notes.txt +6 -0
- data/scripts/demo/record_demo.rb +60 -81
- data/scripts/demo/report.rb +7 -0
- data/scripts/demo/shapes.rb +1 -0
- data/scripts/demo/square/shapes.rb +29 -0
- data/scripts/demo/square/steps.txt +185 -0
- data/scripts/lib/perf_startup.rb +138 -0
- data/scripts/lib/script_helpers.rb +53 -0
- data/scripts/perf_compare.rb +34 -0
- data/scripts/profile_startup.rb +72 -0
- data/tests/test_action_ids.rb +232 -0
- data/tests/test_auto_format.rb +2 -2
- data/tests/test_autocomplete.rb +1 -1
- data/tests/test_basic_editing.rb +18 -18
- data/tests/test_bookmarks.rb +6 -6
- data/tests/test_bracket_match.rb +3 -0
- data/tests/test_cli_help.rb +64 -0
- data/tests/test_color_highlight.rb +2 -2
- data/tests/test_command_line.rb +1 -1
- data/tests/test_context_menu_file.rb +18 -0
- data/tests/test_copy_paste.rb +33 -33
- data/tests/test_custom_two_phase.rb +1 -1
- data/tests/test_demo_player.rb +301 -0
- data/tests/test_demo_recorder.rb +202 -0
- data/tests/test_dictation.rb +16 -16
- data/tests/test_dot_repeat.rb +88 -0
- data/tests/test_easy_jump.rb +93 -0
- data/tests/test_extract_file_links.rb +3 -3
- data/tests/test_file_panel.rb +2 -2
- data/tests/test_flash.rb +1 -1
- data/tests/test_fold.rb +1 -1
- data/tests/test_form_input.rb +203 -0
- data/tests/test_func_panel.rb +2 -2
- data/tests/test_gtk_sync.rb +7 -7
- data/tests/test_intro_page.rb +437 -0
- data/tests/test_key_categories.rb +163 -0
- data/tests/test_keylog_panel.rb +163 -3
- data/tests/test_line_ends.rb +51 -0
- data/tests/test_line_tree.rb +86 -0
- data/tests/test_lsp_clangd.rb +2 -2
- data/tests/test_macro.rb +2 -2
- data/tests/test_module_interface.rb +9 -9
- data/tests/test_notepad_bindings.rb +5 -5
- data/tests/test_perf_startup.rb +28 -0
- data/tests/test_random_edit.rb +27 -27
- data/tests/test_registers.rb +122 -0
- data/tests/test_run_ruby.rb +77 -0
- data/tests/test_startup_file.rb +1 -1
- data/tests/test_text_objects.rb +1 -1
- data/tests/test_text_transforms.rb +12 -0
- data/tests/test_tmp_user_dir.rb +79 -0
- data/tests/test_tts.rb +10 -10
- data/tests/test_undo.rb +34 -34
- data/tests/test_user_dirs.rb +122 -0
- data/tests/test_vim_bindings.rb +107 -6
- data/tests/test_vim_conflicts.rb +41 -4
- data/tests/test_vim_operators.rb +116 -0
- data/tests/test_window_layout.rb +83 -0
- data/vimamsa.gemspec +1 -1
- data/vm_guest_run.sh +22 -2
- metadata +58 -3
- data/run_tests_vm.sh +0 -130
data/doc/wysiwyg_plan.md
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# Plan: WYSIWYG editing (rich text with hidden markup)
|
|
2
|
+
|
|
3
|
+
## Goal
|
|
4
|
+
|
|
5
|
+
Edit formatted text as it looks: bold looks bold, and there are no markers on screen.
|
|
6
|
+
The formatting is stored in an underlying text format in the file. The user sees that
|
|
7
|
+
format **only when they ask for it** ("Show markup"), never because the cursor
|
|
8
|
+
moves onto it.
|
|
9
|
+
|
|
10
|
+
First prototype: **bold, italic and font size**. It renders with the existing
|
|
11
|
+
GtkSourceView (a `GtkTextView`), with no HTML or WebKit.
|
|
12
|
+
|
|
13
|
+
## Today (checked 2026-11-21)
|
|
14
|
+
|
|
15
|
+
- Hyperplaintext styles are visible marker characters in the text: `⦁bold⦁`,
|
|
16
|
+
`╱italic╱`, `❙title❙`, `⟦link⟧`, and `◼` for headings. `apply_style_markers`
|
|
17
|
+
(`buffer.rb`) inserts them. `lang/hyperplaintext.lang` colors them. Visual
|
|
18
|
+
`, t b`, `, t i` and `, t c` and `C , t 1`… are bound to `style.*`.
|
|
19
|
+
- `Buffer < String` holds the text. Every change is a delta
|
|
20
|
+
`[pos, INSERT|DELETE, len, text]`, applied by `Buffer#run_delta` (`buffer.rb:841`).
|
|
21
|
+
`run_delta` already updates position-based data on each change
|
|
22
|
+
(`update_highlights`, `update_line_ends`). `GtkView#handle_deltas`
|
|
23
|
+
(`gui_sourceview.rb:749`) applies the same deltas to the GTK buffer.
|
|
24
|
+
- **There's a precedent for buffer text that differs from the file:** closed folds
|
|
25
|
+
(`fold.rb`) are taken out of the buffer string, and `content_for_disk` puts them
|
|
26
|
+
back on save and autosave.
|
|
27
|
+
|
|
28
|
+
## Design
|
|
29
|
+
|
|
30
|
+
### 1. The visible text is the buffer
|
|
31
|
+
|
|
32
|
+
`Buffer` (the String) holds only the text the user sees, with no markers. So the
|
|
33
|
+
cursor can't land inside markup, and everything that works on text keeps working
|
|
34
|
+
unchanged: motions, counts, search, undo of text changes, `j`/`k` columns, macros,
|
|
35
|
+
autocomplete.
|
|
36
|
+
|
|
37
|
+
The formatting lives beside it in a **span model**, and the file format exists only
|
|
38
|
+
on disk:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
file (markup) ──parse──▶ visible text (Buffer) + spans (RichText)
|
|
42
|
+
◀─serialize─ │ │
|
|
43
|
+
└──── GTK buffer + tags (view)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 2. Span model (`lib/vimamsa/rich_text.rb`)
|
|
47
|
+
|
|
48
|
+
A `RichText` object per buffer (`buf.rich`, nil for normal buffers) holds attribute
|
|
49
|
+
runs over the visible text:
|
|
50
|
+
|
|
51
|
+
```ruby
|
|
52
|
+
# half-open ranges over Buffer positions; overlapping runs are allowed
|
|
53
|
+
[ { range: 0...5, attr: :bold },
|
|
54
|
+
{ range: 3...9, attr: :italic },
|
|
55
|
+
{ range: 12...20, attr: [:size, 1.5] } ]
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Interface (so the storage can be swapped later):
|
|
59
|
+
- `attrs_at(pos)`: the attributes in effect at `pos`
|
|
60
|
+
- `runs_in(range)`: the runs that overlap `range`, clipped to it
|
|
61
|
+
- `apply(range, attr)` / `remove(range, attr)`: merges with neighbors, splits as needed
|
|
62
|
+
- `on_insert(pos, len, attrs)`: shifts later runs, extends the run being typed in, and
|
|
63
|
+
adds `attrs` for the new text
|
|
64
|
+
- `on_delete(pos, len)`: shrinks or drops runs, and returns the removed pieces for
|
|
65
|
+
undo
|
|
66
|
+
|
|
67
|
+
**Storage, in steps:**
|
|
68
|
+
1. **Prototype:** one sorted array per attribute, of non-overlapping `[start, end, value]`.
|
|
69
|
+
Overlaps between *different* attributes are then free. Each edit costs O(runs),
|
|
70
|
+
which is fine up to tens of thousands of runs.
|
|
71
|
+
2. **If profiling asks for it:** a balanced binary tree (or a rope) whose nodes store
|
|
72
|
+
their subtree's length. Finding the runs at a position and shifting them after an
|
|
73
|
+
edit are then O(log n). Only `RichText` changes, because callers use the interface.
|
|
74
|
+
|
|
75
|
+
The GTK side needs no extra structure. `GtkTextBuffer` is already a B-tree whose
|
|
76
|
+
tags move with the text.
|
|
77
|
+
|
|
78
|
+
### 3. Keeping things in sync
|
|
79
|
+
|
|
80
|
+
- **The Ruby spans are the source of truth. The GTK tags only mirror them.**
|
|
81
|
+
- `run_delta` calls `rich.on_insert` / `rich.on_delete`, next to `update_highlights`.
|
|
82
|
+
- `handle_deltas` applies the tags after each insert: `apply_tag` over the inserted
|
|
83
|
+
range, for the attributes `rich.attrs_at` gives. A plain GTK insert has no tags, so
|
|
84
|
+
the result is deterministic. A delete needs no tag work.
|
|
85
|
+
- Changes are changesets (`doc/delta_syntax_plan.md`). Formatting changes are
|
|
86
|
+
`retain` operations with attributes (`retain(5, bold: true)`), and inserted text can
|
|
87
|
+
carry its attributes. Undo, redo, position mapping and the GTK update then use the
|
|
88
|
+
same path as text changes. `RichText` updates its runs through the changeset's
|
|
89
|
+
`map_pos` and attributes, instead of separate `on_insert` / `on_delete` hooks, once
|
|
90
|
+
step 3 of that plan exists.
|
|
91
|
+
- A test compares the GTK tag ranges with the `RichText` runs after random edits, in
|
|
92
|
+
the style of `test_random_edit`.
|
|
93
|
+
|
|
94
|
+
### 4. Typing and editing rules
|
|
95
|
+
|
|
96
|
+
- **Typing extends the style of the character before the cursor:** at the end of a
|
|
97
|
+
bold word the text stays bold, and at the start it doesn't. This is like word
|
|
98
|
+
processors.
|
|
99
|
+
- **Typing style:** toggling bold with no selection (Insert mode) sets the style for
|
|
100
|
+
the next characters typed. It's shown in the status area (**B** *I* 150%) and
|
|
101
|
+
cleared when the cursor moves.
|
|
102
|
+
- **Undo:** a changeset's delete operations store the removed text with its
|
|
103
|
+
attributes, so `invert` puts the spans back. Formatting changes invert like text
|
|
104
|
+
changes. One Insert-mode session stays one undo step (one composed changeset).
|
|
105
|
+
- **Registers (prototype):** yank and put copy plain text, and pasted text gets the
|
|
106
|
+
typing style. Later, internal registers keep the spans, and the system clipboard
|
|
107
|
+
gets plain text.
|
|
108
|
+
- **Vim operators** work on the visible text. `d`, `c` and `x` drop the spans of what
|
|
109
|
+
they delete, through `on_delete`. Nothing needs to know about formatting.
|
|
110
|
+
|
|
111
|
+
### 5. Rendering (GtkTextView)
|
|
112
|
+
|
|
113
|
+
- Tags made once per buffer:
|
|
114
|
+
- `rich-bold`: `weight = 700`
|
|
115
|
+
- `rich-italic`: `style = ITALIC`
|
|
116
|
+
- `rich-size-<n>`: `scale = n`, from a small fixed list such as 0.8, 1.2, 1.5 and 2.0,
|
|
117
|
+
so the tags stay few
|
|
118
|
+
- Rich tags get a higher priority than syntax-highlighting tags. In a rich buffer,
|
|
119
|
+
turn the hyperplaintext language off, or use a variant without the marker rules,
|
|
120
|
+
because there are no markers left to color.
|
|
121
|
+
- Things to check with larger text:
|
|
122
|
+
- cursor drawing (`pos_to_coord`)
|
|
123
|
+
- easy-jump label placement
|
|
124
|
+
- line-height assumptions (in the file panel, scrolling and `view.center`)
|
|
125
|
+
- italic in the user's font (some monospace fonts have no italic and get a slanted
|
|
126
|
+
fallback)
|
|
127
|
+
|
|
128
|
+
### 6. The file format (hidden)
|
|
129
|
+
|
|
130
|
+
The format is a serializer behind an interface: `parse(markup) → [text, runs]` and
|
|
131
|
+
`serialize(text, runs) → markup`. Several can exist.
|
|
132
|
+
|
|
133
|
+
**For the prototype, use the hyperplaintext markers.** Files then stay readable and
|
|
134
|
+
diffable, and existing hpt files open in rich mode:
|
|
135
|
+
- bold `⦁…⦁` and italic `╱…╱`, as today
|
|
136
|
+
- size: a new marker, for example `⸨150%|…⸩`
|
|
137
|
+
|
|
138
|
+
Decide the exact characters before step 2. They must be rare in normal text and
|
|
139
|
+
easy to type in "Show markup".
|
|
140
|
+
- **Escaping:** a literal marker character in the text is written doubled, or with a
|
|
141
|
+
backslash. The test is that `parse(serialize(x)) == x` for random text and runs.
|
|
142
|
+
|
|
143
|
+
Later serializers: Markdown (`**`, `*`, `#` headings for size) and an HTML subset
|
|
144
|
+
(`<b>`, `<i>`, `<span style="font-size:150%">`) for export. The second serializer is
|
|
145
|
+
also the test that the model doesn't depend on the format.
|
|
146
|
+
|
|
147
|
+
Save and autosave go through `content_for_disk`, as folds do. The serializer runs
|
|
148
|
+
there, after the folds are put back.
|
|
149
|
+
|
|
150
|
+
### 7. "Show markup"
|
|
151
|
+
|
|
152
|
+
- **Prototype:** `rich.markup.show` opens the serialized text in a separate, read-only
|
|
153
|
+
buffer, with the cursor at the matching position.
|
|
154
|
+
- **Later:** editable markup. You edit that buffer and apply it back with
|
|
155
|
+
`rich.markup.apply`: parse, then replace the text and runs as one undo step.
|
|
156
|
+
Alternatively, switch the same buffer between rich and markup mode in place.
|
|
157
|
+
- `rich.toggle` turns rich mode on or off for a buffer. Turning it off converts to
|
|
158
|
+
the plain hpt buffer with visible markers (today's behavior).
|
|
159
|
+
|
|
160
|
+
### 8. Which buffers are rich
|
|
161
|
+
|
|
162
|
+
- Rich mode is off by default. Turn it on with `cnf.rich.enabled = true` and a list
|
|
163
|
+
of languages (`cnf.rich.langs = ["hyperplaintext"]`), or per buffer with
|
|
164
|
+
`rich.toggle`.
|
|
165
|
+
- Not rich: buffers with LSP. Positions sent to the language server would be wrong,
|
|
166
|
+
because the file holds markup the buffer doesn't.
|
|
167
|
+
- Search and grep across files (`grep.files`) search the file contents, so they see
|
|
168
|
+
the markup. That's acceptable for now. "Jump to match" maps the position from the
|
|
169
|
+
markup to the visible text, using the parse result.
|
|
170
|
+
|
|
171
|
+
### 9. Actions and keys
|
|
172
|
+
|
|
173
|
+
The naming follows `doc/action_names_plan.md`:
|
|
174
|
+
- `rich.bold.toggle`, `rich.italic.toggle`, `rich.size.up`, `rich.size.down`,
|
|
175
|
+
`rich.size.reset`
|
|
176
|
+
- `rich.markup.show`, `rich.toggle`
|
|
177
|
+
|
|
178
|
+
Keys: in rich buffers, the existing `style.*` bindings (Visual `, t b`, `, t i`,
|
|
179
|
+
`, t c`) call the rich actions instead of inserting markers. Size gets `, t +`,
|
|
180
|
+
`, t -` and `, t 0`. No new ctrl or alt chords. Insert mode needs a way to set the
|
|
181
|
+
typing style without leaving Insert mode. Decide that after trying the prototype.
|
|
182
|
+
|
|
183
|
+
## Prototype scope
|
|
184
|
+
|
|
185
|
+
In:
|
|
186
|
+
- `RichText` with arrays
|
|
187
|
+
- the hpt serializer for bold, italic and size, with escaping
|
|
188
|
+
- GTK tags
|
|
189
|
+
- typing rules, and undo of text and format changes
|
|
190
|
+
- `rich.markup.show` (read-only)
|
|
191
|
+
- `rich.toggle`
|
|
192
|
+
- the actions above
|
|
193
|
+
|
|
194
|
+
Out, for later:
|
|
195
|
+
- editable markup view
|
|
196
|
+
- formatted registers and clipboard
|
|
197
|
+
- Markdown and HTML serializers
|
|
198
|
+
- links, headings as line styles, images, lists
|
|
199
|
+
- the tree storage
|
|
200
|
+
- rich buffers in two-column mode
|
|
201
|
+
|
|
202
|
+
## Tests
|
|
203
|
+
|
|
204
|
+
- `RichText` unit cases: insert and delete at, inside and around runs; merging and
|
|
205
|
+
splitting; overlapping attributes.
|
|
206
|
+
- Serializer round trip: random text and runs go through serialize and parse and come
|
|
207
|
+
back the same. Marker characters in the text are escaped.
|
|
208
|
+
- GTK sync: after random inserts, deletes and format toggles, the GTK tag ranges
|
|
209
|
+
equal the `RichText` runs.
|
|
210
|
+
- Editing: `d w` over half a bold word, `x` at a run edge, and typing after a bold
|
|
211
|
+
word extends it. Undo and redo restore both the text and the formatting.
|
|
212
|
+
- Save and reload give the same text and runs. The file holds markup, and autosave
|
|
213
|
+
writes the same thing.
|
|
214
|
+
- "Show markup" shows the serialized text and the right cursor position.
|
|
215
|
+
|
|
216
|
+
## Order
|
|
217
|
+
|
|
218
|
+
1. `RichText` (arrays) and its unit tests. No GUI yet.
|
|
219
|
+
2. The hpt serializer (bold, italic, size), round-trip tests, and the choice of the
|
|
220
|
+
size marker.
|
|
221
|
+
3. Hook it into `run_delta`, `handle_deltas`, load and `content_for_disk`. Add the GTK
|
|
222
|
+
tags and the sync test.
|
|
223
|
+
4. Attributes on changeset operations (step 6 of `doc/delta_syntax_plan.md`), undo
|
|
224
|
+
and redo of formatting, and the typing rules.
|
|
225
|
+
5. Actions and keys, the typing style in the status area, and `rich.markup.show`.
|
|
226
|
+
6. Try it on real notes. Decide the Insert-mode keys, and whether the array storage is
|
|
227
|
+
fast enough.
|
|
228
|
+
7. Later: editable markup, formatted registers, the Markdown and HTML serializers, and
|
|
229
|
+
more attributes.
|
|
230
|
+
|
|
231
|
+
Run the full suite in the VM after each step.
|
data/exe/run_tests.rb
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
# run_tests.rb tests/test_foo.rb TestFooClass # specific class from specific file
|
|
7
7
|
# run_tests.rb foo,bar,baz # run tests/test_foo.rb, test_bar.rb, test_baz.rb
|
|
8
8
|
# run_tests.rb test_random_edit duration=60 # pass duration option to stress test
|
|
9
|
+
# run_tests.rb perf_startup ref=HEAD~10 runs=7 # startup time vs an older commit
|
|
9
10
|
# run_tests.rb --headless # invisible window (xvfb-run, or Broadway if
|
|
10
11
|
# # xvfb not installed); does not disturb
|
|
11
12
|
# # normal use; e2e kbd tests skip
|
|
@@ -46,6 +47,8 @@ if raw_args.delete("--headless")
|
|
|
46
47
|
# and not the real Wayland session. xvfb-run exits with our exit code.
|
|
47
48
|
ENV["GDK_BACKEND"] = "x11"
|
|
48
49
|
ENV.delete("WAYLAND_DISPLAY")
|
|
50
|
+
# No window manager there: tests that need one skip (VMA_HEADLESS)
|
|
51
|
+
ENV["VMA_HEADLESS"] = "xvfb"
|
|
49
52
|
exec("xvfb-run", "-a", "-s", "-screen 0 1600x1000x24",
|
|
50
53
|
RbConfig.ruby, File.expand_path(selfpath), *(ARGV - ["--headless"]))
|
|
51
54
|
end
|
|
@@ -76,6 +79,7 @@ if raw_args.delete("--headless")
|
|
|
76
79
|
end
|
|
77
80
|
ENV["GDK_BACKEND"] = "broadway"
|
|
78
81
|
ENV["BROADWAY_DISPLAY"] = ":9"
|
|
82
|
+
ENV["VMA_HEADLESS"] = "broadway"
|
|
79
83
|
end
|
|
80
84
|
|
|
81
85
|
test_files = raw_args.select { |a| a.end_with?(".rb") && File.file?(a) }
|
|
@@ -84,6 +88,8 @@ class_filter = raw_args.select { |a| a.match?(/\A[A-Z]/) }
|
|
|
84
88
|
# Parse key=value options (e.g. duration=60)
|
|
85
89
|
raw_args.each do |a|
|
|
86
90
|
$vma_test_duration = $1.to_i if a =~ /\Aduration=(\d+)\z/
|
|
91
|
+
$vma_test_ref = $1 if a =~ /\Aref=(\S+)\z/ # test_perf_startup
|
|
92
|
+
$vma_test_runs = $1.to_i if a =~ /\Aruns=(\d+)\z/
|
|
87
93
|
end
|
|
88
94
|
|
|
89
95
|
# Expand comma-separated shorthand: "foo,bar" -> tests/test_foo.rb, tests/test_bar.rb
|
|
@@ -103,7 +109,8 @@ if test_files.empty?
|
|
|
103
109
|
# test_notepad_bindings / test_vim_bindings: load alternative keybinding
|
|
104
110
|
# schemes, which would corrupt bindings for later test files in the
|
|
105
111
|
# shared process.
|
|
106
|
-
|
|
112
|
+
# test_perf_startup: starts the editor a dozen times (about a minute).
|
|
113
|
+
excluded = ["test_random_edit.rb", "test_notepad_bindings.rb", "test_vim_bindings.rb", "test_perf_startup.rb"]
|
|
107
114
|
test_files.reject! { |f| excluded.include?(File.basename(f)) }
|
|
108
115
|
end
|
|
109
116
|
|
data/exe/vimamsa
CHANGED
|
@@ -8,8 +8,12 @@ selfpath = __FILE__
|
|
|
8
8
|
selfpath = File.readlink(selfpath) if File.lstat(selfpath).symlink?
|
|
9
9
|
scriptdir = File.expand_path(File.dirname(selfpath) + "/..")
|
|
10
10
|
|
|
11
|
-
#
|
|
12
|
-
#
|
|
11
|
+
# Config and data dirs (user_dirs.rb): ~/.config/vimamsa and
|
|
12
|
+
# ~/.local/share/vimamsa by default (the XDG dirs)
|
|
13
|
+
require File.join(scriptdir, "lib/vimamsa/user_dirs")
|
|
14
|
+
|
|
15
|
+
# --user-dir PATH (or --user-dir=PATH): use PATH as the config and data
|
|
16
|
+
# directory instead of those two. Consumed here (and removed from ARGV) so it is
|
|
13
17
|
# available before anything reads the user dir, including the listen check below.
|
|
14
18
|
if (i = ARGV.index("--user-dir"))
|
|
15
19
|
$vma_user_dir = File.expand_path(ARGV[i + 1]) if ARGV[i + 1]
|
|
@@ -18,11 +22,36 @@ elsif (arg = ARGV.find { |a| a.start_with?("--user-dir=") })
|
|
|
18
22
|
$vma_user_dir = File.expand_path(arg.split("=", 2)[1])
|
|
19
23
|
ARGV.delete(arg)
|
|
20
24
|
end
|
|
21
|
-
$vma_user_dir ||=
|
|
25
|
+
$vma_user_dir ||= Vimamsa::UserDirs.default_config_dir
|
|
26
|
+
|
|
27
|
+
# --intro: show the introduction page at start (intro_page.rb), whatever the
|
|
28
|
+
# settings say. Removed from ARGV so it isn't taken for a file name.
|
|
29
|
+
$vma_show_intro = !ARGV.delete("--intro").nil?
|
|
30
|
+
|
|
31
|
+
# --help / -h: the options and the actions (cli_help.rb), then exit
|
|
32
|
+
$vma_cli_help = [ARGV.delete("--help"), ARGV.delete("-h")].any?
|
|
33
|
+
|
|
34
|
+
# --tmp-user-dir: a new, empty user dir in the system temp dir, deleted on
|
|
35
|
+
# quit (tmp_user_dir.rb). After an editor restart the dir comes in the
|
|
36
|
+
# environment instead, so the new process keeps using (and deletes) it.
|
|
37
|
+
require File.join(scriptdir, "lib/vimamsa/tmp_user_dir")
|
|
38
|
+
tmp_requested = !ARGV.delete("--tmp-user-dir").nil?
|
|
39
|
+
if Vimamsa::TmpUserDir.ours?(ENV[Vimamsa::TmpUserDir::ENV_KEY]) && File.directory?(ENV[Vimamsa::TmpUserDir::ENV_KEY])
|
|
40
|
+
$vma_tmp_user_dir = ENV.delete(Vimamsa::TmpUserDir::ENV_KEY)
|
|
41
|
+
elsif tmp_requested && !$vma_cli_help
|
|
42
|
+
$vma_tmp_user_dir = Vimamsa::TmpUserDir.create
|
|
43
|
+
puts "Temporary user dir (deleted on quit): #{$vma_tmp_user_dir}"
|
|
44
|
+
end
|
|
45
|
+
ENV.delete(Vimamsa::TmpUserDir::ENV_KEY) # not for programs the editor starts
|
|
46
|
+
if $vma_tmp_user_dir
|
|
47
|
+
$vma_user_dir = $vma_tmp_user_dir
|
|
48
|
+
# Not run on exec (restart_editor), which keeps the dir
|
|
49
|
+
at_exit { Vimamsa::TmpUserDir.delete($vma_tmp_user_dir) }
|
|
50
|
+
end
|
|
22
51
|
|
|
23
52
|
# If process is already running, open the parameter file in the running process and exit.
|
|
24
|
-
listen_dir = File.join($vma_user_dir, "listen")
|
|
25
|
-
if File.exist?(listen_dir) and !ARGV[0].nil?
|
|
53
|
+
listen_dir = File.join(Vimamsa::UserDirs.data_dir_for($vma_user_dir), "listen")
|
|
54
|
+
if File.exist?(listen_dir) and !ARGV[0].nil? and !$vma_cli_help
|
|
26
55
|
tmpf = Tempfile.new("vmarun", listen_dir)
|
|
27
56
|
fp = tmpf.path
|
|
28
57
|
paramfn = File.expand_path(ARGV[0])
|
|
@@ -46,13 +75,27 @@ end
|
|
|
46
75
|
$LOAD_PATH.unshift(File.join(scriptdir, "lib"))
|
|
47
76
|
$LOAD_PATH.unshift(File.join(scriptdir, "ext"))
|
|
48
77
|
|
|
78
|
+
if $vma_cli_help
|
|
79
|
+
require "vimamsa/cli_help"
|
|
80
|
+
Vimamsa.print_cli_usage # before loading the rest (GTK takes a while)
|
|
81
|
+
end
|
|
82
|
+
|
|
49
83
|
require "vimamsa"
|
|
50
84
|
include Vimamsa
|
|
51
85
|
|
|
86
|
+
if $vma_cli_help
|
|
87
|
+
Vimamsa.print_cli_actions
|
|
88
|
+
exit(0)
|
|
89
|
+
end
|
|
90
|
+
|
|
52
91
|
# Persist crash/segfault debug info (native stderr dump + structured reports)
|
|
53
|
-
# to ~/.
|
|
92
|
+
# to the crash dir in the data dir (~/.local/share/vimamsa/crash/).
|
|
54
93
|
Vimamsa::CrashHandler.setup
|
|
55
94
|
|
|
95
|
+
# kill / ctrl-c: quit as from the menu (session saved, a --tmp-user-dir
|
|
96
|
+
# deleted). The trap only sets a flag; VMAgui#monitor quits on the main loop.
|
|
97
|
+
%w[TERM INT].each { |sig| Signal.trap(sig) { $vma_quit_requested = true } }
|
|
98
|
+
|
|
56
99
|
# Ilib:ext
|
|
57
100
|
# r rbvma -e "puts VMA.new.run"
|
|
58
101
|
$vmag = Vimamsa::VMAgui.new()
|
data/help/intro.txt
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
❙Welcome to Vimamsa❙
|
|
2
|
+
A Vim-inspired text editor. This page is always in Help ▸ Introduction.
|
|
3
|
+
|
|
4
|
+
◼ Modes
|
|
5
|
+
Command mode: keys move the cursor and edit. The badge at the bottom right shows the mode.
|
|
6
|
+
Insert mode: keys type text. Enter it with {key:C:mode.insert}, leave it with {key:I:mode.prev}.
|
|
7
|
+
Visual mode: select text, {key:C:mode.visual}.
|
|
8
|
+
(ctrl! = press and release ctrl alone, with no other key)
|
|
9
|
+
|
|
10
|
+
◼ Watch a demo
|
|
11
|
+
Each demo plays in its own buffer. The key log on the right shows every key and
|
|
12
|
+
what it did; the controls above it pause, change the speed or switch the demo.
|
|
13
|
+
{demos}
|
|
14
|
+
|
|
15
|
+
◼ The essentials
|
|
16
|
+
Open a file {key:file.open}
|
|
17
|
+
Find a file {key:file.finder}
|
|
18
|
+
Save {key:buf.save}
|
|
19
|
+
Search {key:search.buf}
|
|
20
|
+
Undo {key:undo.last}
|
|
21
|
+
Command line {key:mode.cmdline}
|
|
22
|
+
|
|
23
|
+
◼ Coming from Vim?
|
|
24
|
+
⟦run:help.vim_intro|Vim differences⟧ the main differences, in one screen
|
|
25
|
+
|
|
26
|
+
◼ Learn more
|
|
27
|
+
⟦run:help.keys|Key bindings⟧ all key bindings
|
|
28
|
+
⟦run:app.demo|Install demo files⟧ text and images to try
|
|
29
|
+
|
|
30
|
+
⟦run:help.intro.startup.toggle|Show at startup: on / off⟧
|
data/help/vim_intro.txt
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
❙Vimamsa for Vim users❙
|
|
2
|
+
The differences you meet first. Back: ⟦help:intro⟧
|
|
3
|
+
|
|
4
|
+
◼ The command line (:) is very limited
|
|
5
|
+
It understands only :w, :q, :wq, :e <file>, :<line number>, :!<shell command>
|
|
6
|
+
(the output goes to a buffer) and :reg. Anything else is run as Ruby, so there is
|
|
7
|
+
no :s///, :g, :set, ranges or :help. Search with {key:search.buf}; search and
|
|
8
|
+
replace is in the Search menu; settings are in Settings.
|
|
9
|
+
|
|
10
|
+
◼ ctrl alone switches modes
|
|
11
|
+
Press and release ctrl with no other key: in Command mode it enters Insert mode,
|
|
12
|
+
in Insert and Visual mode it leaves them. esc works too, but it doesn't move the
|
|
13
|
+
cursor one character left as Vim's does.
|
|
14
|
+
|
|
15
|
+
◼ Keys that do something else
|
|
16
|
+
{vim_key_table}
|
|
17
|
+
, starts many of Vimamsa's own commands (see ⟦help:keybindings⟧).
|
|
18
|
+
|
|
19
|
+
◼ Not there yet
|
|
20
|
+
Line-wise and block visual mode (V, ctrl-v); ge, { }, %; = and gq;
|
|
21
|
+
ctrl-e / ctrl-y; gv and gi.
|
|
22
|
+
|
|
23
|
+
◼ The same as in Vim
|
|
24
|
+
Operators with motions and text objects (d c y gU gu g~ > <, dw, ci(, yap ...),
|
|
25
|
+
counts, registers ("a-"z, "+), . (repeat), macros (q, @) and marks.
|
|
26
|
+
|
|
27
|
+
◼ Prefer Vim's keys?
|
|
28
|
+
Settings ▸ Keybinding scheme ▸ vim (needs a restart).
|
|
29
|
+
|
|
30
|
+
◼ All the differences
|
|
31
|
+
⟦help:vim_conflicts⟧ every key that differs (generated from the keymaps)
|
data/img/demo.gif
CHANGED
|
Binary file
|
data/img/demo.mp4
ADDED
|
Binary file
|
data/lang/hyperplaintext.lang
CHANGED
data/lib/vimamsa/ack.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
|
|
2
|
+
#TODO: separate this into its own module. Could ack be included in appimage? If yes, enable by default (if appimage).
|
|
2
3
|
module Vimamsa
|
|
3
4
|
# Interface for ack! https://beyondgrep.com/
|
|
4
5
|
|
|
@@ -83,6 +84,7 @@ class FileContentSearch
|
|
|
83
84
|
end
|
|
84
85
|
end
|
|
85
86
|
|
|
87
|
+
#TODO: avoid global functions. put into own module or class.
|
|
86
88
|
def gui_ack()
|
|
87
89
|
search_paths = vma.get_content_search_paths.join("<br/>")
|
|
88
90
|
|