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
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
# Plan: a better delta (change) format
|
|
2
|
+
|
|
3
|
+
## Today (checked 2026-11-21)
|
|
4
|
+
|
|
5
|
+
Every text change is a delta array `[pos, op, len, text]`. It's applied by
|
|
6
|
+
`Buffer#run_delta` (`buffer.rb:841`), mirrored to GTK by `GtkView#handle_deltas`
|
|
7
|
+
(`gui_sourceview.rb:749`), and grouped for undo in `@edit_history`.
|
|
8
|
+
|
|
9
|
+
Problems:
|
|
10
|
+
- **Magic numbers and indexes:** `INSERT = 2` and `DELETE = 3001` (`constants.rb`).
|
|
11
|
+
`d[1] == DELETE` and similar checks appear in 9 places, and comments explain what
|
|
12
|
+
`d[3]` is.
|
|
13
|
+
- **Redundant or inconsistent length:** an insert carries both `len` and `text`, and
|
|
14
|
+
undo creates `[pos, INSERT, 0, text]` with length 0.
|
|
15
|
+
- **Mutated in place:** a delete's text is filled in afterwards
|
|
16
|
+
(`delta[3] = slice!`), and `add_delta` clamps `delta[2]`. The same delta means
|
|
17
|
+
different things before and after it runs.
|
|
18
|
+
- **Ad-hoc extensions:** the LSP code clones a delta and adds `[4]` and `[5]` (line and
|
|
19
|
+
column). The experimental btree converts it to a separate `Delta` class.
|
|
20
|
+
- **A replace is two deltas:** a delete plus an insert. That means two GTK updates,
|
|
21
|
+
two LSP change events, and two undo steps that have to be grouped.
|
|
22
|
+
- **Hard to extend:** a new kind (FORMAT for `doc/wysiwyg_plan.md`) needs every `case`
|
|
23
|
+
changed.
|
|
24
|
+
- **Every position-based structure is shifted by its own code in `run_delta`:** marks,
|
|
25
|
+
`edit_pos_history`, highlights (`update_highlights`), line ends, fold anchors and the
|
|
26
|
+
cursor.
|
|
27
|
+
|
|
28
|
+
Deltas aren't saved anywhere except in debug dumps, so the format can change
|
|
29
|
+
without migrating any data. There are 18 `add_delta([...])` call sites.
|
|
30
|
+
|
|
31
|
+
## Options
|
|
32
|
+
|
|
33
|
+
### 1. Named fields with a Struct (smallest step)
|
|
34
|
+
|
|
35
|
+
```ruby
|
|
36
|
+
Delta = Struct.new(:pos, :op, :len, :text) do # op: :insert / :delete
|
|
37
|
+
def self.insert(pos, text) = new(pos, :insert, text.size, text)
|
|
38
|
+
def self.delete(pos, len) = new(pos, :delete, len, nil)
|
|
39
|
+
def end_pos = pos + len
|
|
40
|
+
end
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
- A Struct still answers `d[0]`, so the old indexed code keeps working while it's
|
|
44
|
+
migrated file by file.
|
|
45
|
+
- Symbols replace the magic numbers, and the constructors derive `len`.
|
|
46
|
+
- *Cons:* only the syntax gets better. Mutation, the two-delta replace and the `case`
|
|
47
|
+
statements stay.
|
|
48
|
+
|
|
49
|
+
### 2. One replace edit
|
|
50
|
+
|
|
51
|
+
Every change is "at `pos`, replace `removed` with `inserted`":
|
|
52
|
+
|
|
53
|
+
```ruby
|
|
54
|
+
Edit = Data.define(:pos, :removed, :inserted, :attrs) do # immutable (Ruby 3.2+)
|
|
55
|
+
def self.insert(pos, text) = new(pos, "", text, nil)
|
|
56
|
+
def self.delete(pos, text) = new(pos, text, "", nil)
|
|
57
|
+
def self.replace(pos, old, new_) = new(pos, old, new_, nil)
|
|
58
|
+
def inverse = with(removed: inserted, inserted: removed)
|
|
59
|
+
def delta_len = inserted.size - removed.size # for shifting positions
|
|
60
|
+
end
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
- **Insert, delete and replace have one shape.** `replace_range`, the case transforms
|
|
64
|
+
and `:s` become one edit, so one GTK update and one undo step.
|
|
65
|
+
- **Undo is `inverse`.** That replaces `apply_inverse_delta`.
|
|
66
|
+
- **It matches LSP directly:** a change event is "replace this range with this text".
|
|
67
|
+
The `[4]` and `[5]` hack goes away, and line and column are computed where they're
|
|
68
|
+
needed.
|
|
69
|
+
- **It's immutable.** `run_delta` reads the text to be removed before it creates the
|
|
70
|
+
edit, so nothing is filled in afterwards.
|
|
71
|
+
- **`attrs` makes room for WYSIWYG formatting.** Inserted text can carry its spans,
|
|
72
|
+
and a delete carries the spans it removed, so undo restores them.
|
|
73
|
+
- *Cons:* touches the 18 `add_delta` call sites and the 9 op checks. Each change is
|
|
74
|
+
mechanical.
|
|
75
|
+
|
|
76
|
+
### 3. Polymorphic edit classes
|
|
77
|
+
|
|
78
|
+
```ruby
|
|
79
|
+
class Edit::Insert < Edit; def apply(buf) …; def inverse = Edit::Delete.new(pos, text); def shift(p) …; def to_gtk(view) …; end
|
|
80
|
+
class Edit::Delete < Edit; …; end
|
|
81
|
+
class Edit::Format < Edit; …; end # WYSIWYG
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
- Each kind knows how to apply itself, invert itself, move a position past itself
|
|
85
|
+
(marks, highlights, fold anchors) and update GTK. New kinds don't touch any `case`.
|
|
86
|
+
- *Cons:* more classes and indirection for what is mostly two operations. The logic for
|
|
87
|
+
one consumer (GTK, LSP) gets spread over several classes.
|
|
88
|
+
- Can be combined with option 2: a replace edit plus a separate `Format` class.
|
|
89
|
+
|
|
90
|
+
### 4. Changesets (OT-style, like CodeMirror and Quill) — chosen
|
|
91
|
+
|
|
92
|
+
A changeset describes one change to the whole document, as a walk from start to
|
|
93
|
+
end with three operations:
|
|
94
|
+
- `retain(n)`: keep the next `n` characters unchanged
|
|
95
|
+
- `delete(n)`: remove the next `n` characters
|
|
96
|
+
- `insert(text)`: add `text` here
|
|
97
|
+
|
|
98
|
+
The retains and deletes together cover the whole old document.
|
|
99
|
+
|
|
100
|
+
Example. `hello world` → `hello there!`:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
retain(6) delete(5) insert("there!")
|
|
104
|
+
└ "hello " ┘└ "world" ┘
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
The old length is 6 + 5 = 11, and the new length is 6 + 6 = 12. An insert of `X` at
|
|
108
|
+
position 3 is `retain(3) insert("X") retain(8)`.
|
|
109
|
+
|
|
110
|
+
The delta array describes *one* change at one position. A changeset describes *what
|
|
111
|
+
happened to every part* of the document. That makes these operations possible:
|
|
112
|
+
|
|
113
|
+
1. **Compose:** `a.compose(b)` is one changeset with the effect of a and then b. An
|
|
114
|
+
undo group (`i … esc`), a macro run or a `:s` over the file becomes a single
|
|
115
|
+
change for GTK, LSP and undo.
|
|
116
|
+
2. **Invert:** swaps the inserts and deletes (the deleted text is stored). Undo is
|
|
117
|
+
applying the inverse.
|
|
118
|
+
3. **Map positions:** `cs.map_pos(p)` gives where old position `p` ends up. A side
|
|
119
|
+
argument decides whether an insert at exactly `p` goes before or after it.
|
|
120
|
+
|
|
121
|
+
This one function replaces the separate shifting code for marks,
|
|
122
|
+
`edit_pos_history`, highlights, line ends, fold anchors, the cursor and the WYSIWYG
|
|
123
|
+
spans.
|
|
124
|
+
4. **Transform:** `transform(a, b)` rewrites b, which was made against the same old
|
|
125
|
+
document as a, so that it applies after a with the same intent. For example, if a
|
|
126
|
+
inserts at 2 and b deletes at 8, then b′ deletes at 8 + the length of a's insert.
|
|
127
|
+
|
|
128
|
+
This is the basis of collaborative editing. Locally it serves multiple cursors, and
|
|
129
|
+
external changes that arrive while editing: a file reload, or LSP edits computed
|
|
130
|
+
against an older version.
|
|
131
|
+
5. **Attributes (rich text, Quill's Delta format):** operations carry formatting.
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
retain(6) retain(5, bold: true) # make "world" bold
|
|
135
|
+
insert("new", italic: true) # insert italic text
|
|
136
|
+
retain(3, bold: nil) # remove bold
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Text and formatting changes then share one mechanism: undo, compose and position
|
|
140
|
+
mapping work for formatting too.
|
|
141
|
+
|
|
142
|
+
Sketch:
|
|
143
|
+
|
|
144
|
+
```ruby
|
|
145
|
+
buf.change { |c| c.retain(6).delete(5).insert("there!") } # one undo step
|
|
146
|
+
buf.apply(ChangeSet.replace(6, "world", "there!"))
|
|
147
|
+
mark.pos = cs.map_pos(mark.pos)
|
|
148
|
+
undo_group = undo_group.compose(cs)
|
|
149
|
+
buf.apply(undo_group.invert) # undo
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**The document length never needs to be passed by callers:**
|
|
153
|
+
- **The trailing retain is implicit.** A changeset ends with "keep the rest", and
|
|
154
|
+
`apply` fills that in from the document's actual length. CodeMirror and Quill both
|
|
155
|
+
work this way.
|
|
156
|
+
- **Position constructors cover the common case:** `ChangeSet.insert(pos, text)`,
|
|
157
|
+
`ChangeSet.replace(pos, old, new)`.
|
|
158
|
+
- **Built from the buffer:** `buf.changeset` / `buf.change { |c| … }` fill in the
|
|
159
|
+
length and the buffer's `@version`.
|
|
160
|
+
- **The version, not the length, detects a stale changeset.** One built against an
|
|
161
|
+
older text (an LSP reply, a background thread) is refused on `apply`. A length check
|
|
162
|
+
catches that only when the size happened to change.
|
|
163
|
+
- Compose and transform get the lengths from the changesets themselves.
|
|
164
|
+
|
|
165
|
+
Costs:
|
|
166
|
+
- **Every change site changes.** The 18 `add_delta` calls and the code that reads
|
|
167
|
+
deltas would have to build or consume changesets.
|
|
168
|
+
- **Compose and transform are hard to get right** for every combination of retain,
|
|
169
|
+
insert and delete, with attributes too. They need property tests, such as random
|
|
170
|
+
changesets checked with `apply(compose(a, b)) == apply(b, apply(a))`.
|
|
171
|
+
- **Size:** a changeset spanning a big file must be stored compactly. Merge runs and
|
|
172
|
+
leave the trailing retain implicit. CodeMirror uses a flat array of lengths.
|
|
173
|
+
- **Most of the gain is in features Vimamsa doesn't have yet:** multiple cursors,
|
|
174
|
+
collaboration, merging outside edits.
|
|
175
|
+
|
|
176
|
+
## Decision: changesets (option 4)
|
|
177
|
+
|
|
178
|
+
Changesets are the change format (decided 2026-11-21). Options 1–3 are kept above
|
|
179
|
+
for the record.
|
|
180
|
+
|
|
181
|
+
Why:
|
|
182
|
+
- **Position mapping:** one `map_pos` replaces the separate shifting code for marks,
|
|
183
|
+
highlights, line ends, fold anchors, the edit history and the cursor.
|
|
184
|
+
- **Formatting:** attributes on operations give `doc/wysiwyg_plan.md` text and
|
|
185
|
+
formatting changes, undo and position mapping through one mechanism. No separate
|
|
186
|
+
FORMAT delta is needed.
|
|
187
|
+
- **Grouping:** composing turns undo groups, macro runs and `:s` into one change for
|
|
188
|
+
GTK, LSP and undo.
|
|
189
|
+
- **Future features:** multiple cursors, merging outside changes (reload, LSP edits
|
|
190
|
+
against an older version) and possibly collaboration need `transform`. It can be
|
|
191
|
+
added later on the same format.
|
|
192
|
+
|
|
193
|
+
The single-edit convenience of option 2 is kept as constructors:
|
|
194
|
+
`ChangeSet.insert(pos, text)`, `ChangeSet.delete(pos, text)` and
|
|
195
|
+
`ChangeSet.replace(pos, old, new)`. Most call sites need nothing more.
|
|
196
|
+
|
|
197
|
+
## Design
|
|
198
|
+
|
|
199
|
+
### Format
|
|
200
|
+
|
|
201
|
+
```ruby
|
|
202
|
+
# lib/vimamsa/changeset.rb
|
|
203
|
+
cs = ChangeSet.new # trailing retain implicit
|
|
204
|
+
.retain(6)
|
|
205
|
+
.delete("world") # deleted text is stored, for invert
|
|
206
|
+
.insert("there!", bold: true) # optional attributes
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
- Operations are stored compactly: neighbors of the same kind are merged, and the
|
|
210
|
+
trailing retain is implicit. A flat array of `[op, value, attrs]` is enough at first.
|
|
211
|
+
- **Deletes store the removed text** (and its attributes), so `invert` needs no
|
|
212
|
+
document. The text is read from the buffer when the changeset is applied, if the
|
|
213
|
+
caller gave only a length. After that, the changeset is frozen.
|
|
214
|
+
- **Version:** `buf.changeset` / `buf.change { |c| … }` record the buffer's
|
|
215
|
+
`@version`. `apply` refuses a changeset built for another version, unless it is
|
|
216
|
+
first transformed (later) or explicitly rebased.
|
|
217
|
+
|
|
218
|
+
### Operations
|
|
219
|
+
|
|
220
|
+
| Method | Purpose | Needed for |
|
|
221
|
+
|---|---|---|
|
|
222
|
+
| `apply(buf)` | change the text, then notify GTK, LSP, the position mappers and undo | step 2 |
|
|
223
|
+
| `invert` | undo | step 2 |
|
|
224
|
+
| `map_pos(p, assoc: :before/:after)` | where an old position ends up | step 3 |
|
|
225
|
+
| `compose(other)` | one changeset with the effect of both | step 4 |
|
|
226
|
+
| `each_edit` | the changes as `(pos, removed, inserted, attrs)` in new-document positions, front to back | GTK, LSP |
|
|
227
|
+
| `transform(other)` | concurrent changes | later |
|
|
228
|
+
|
|
229
|
+
### Consumers
|
|
230
|
+
|
|
231
|
+
- **Buffer text:** `run_delta` becomes `apply_changeset`. It walks the operations
|
|
232
|
+
front to back, keeps a running offset, and uses `String#[]=` per edit. That's cheap,
|
|
233
|
+
because changesets from typing have one or two edits.
|
|
234
|
+
- **GTK** (`handle_deltas`): one `delete` / `insert` per `each_edit`, inside a
|
|
235
|
+
`begin_user_action` block, so GTK sees one change. Then apply the attribute tags
|
|
236
|
+
(WYSIWYG).
|
|
237
|
+
- **LSP:** incremental sync takes an array of content changes, applied in order. Send
|
|
238
|
+
one per `each_edit`. Line and column are computed from the document as it is at
|
|
239
|
+
that point in the sequence, so the `[4]` / `[5]` clone goes. Fall back to full
|
|
240
|
+
sync for very large changesets.
|
|
241
|
+
- **Undo:** an undo group is one composed changeset. Undo applies `invert`, and redo
|
|
242
|
+
applies the changeset again. Grouping (`new_undo_group`) stays as it is and only
|
|
243
|
+
composes instead of appending.
|
|
244
|
+
- **Position-based data:** everything that holds positions registers with the buffer
|
|
245
|
+
and is updated through `map_pos` after each apply. That covers marks,
|
|
246
|
+
`edit_pos_history`, highlights, line ends, fold anchors, the cursor and the WYSIWYG
|
|
247
|
+
spans. Line ends may stay specialized for speed, but are checked against `map_pos`
|
|
248
|
+
in tests.
|
|
249
|
+
- **Macros** record actions, not deltas, so they don't change.
|
|
250
|
+
|
|
251
|
+
### Migration
|
|
252
|
+
|
|
253
|
+
Keep the old interface as an adapter while the call sites move:
|
|
254
|
+
`add_delta([pos, INSERT, len, text])` builds `ChangeSet.insert(pos, text)`, and the
|
|
255
|
+
delete form builds `ChangeSet.delete(pos, len)`. Everything inside the buffer works
|
|
256
|
+
on changesets from step 2. The 18 call sites then move over one file at a time, and
|
|
257
|
+
the adapter is removed at the end.
|
|
258
|
+
|
|
259
|
+
## Tests
|
|
260
|
+
|
|
261
|
+
Property tests with random documents and random changesets (in the style of
|
|
262
|
+
`test_random_edit`):
|
|
263
|
+
- `apply(invert(a), apply(a, doc)) == doc`
|
|
264
|
+
- `apply(compose(a, b), doc) == apply(b, apply(a, doc))`
|
|
265
|
+
- `map_pos` agrees with where a marker character placed at `p` ends up
|
|
266
|
+
- `each_edit` applied one by one gives the same text as `apply`
|
|
267
|
+
- After random edits, the GTK buffer text equals the `Buffer` string, and the LSP
|
|
268
|
+
document rebuilt from the sent changes equals it too.
|
|
269
|
+
- A changeset built for an older `@version` is refused.
|
|
270
|
+
|
|
271
|
+
Plus examples: `hello world` → `hello there!`, an insert at 0 and at the end, a
|
|
272
|
+
delete of everything, a replace over a line break, and merging neighbors of the same
|
|
273
|
+
kind.
|
|
274
|
+
|
|
275
|
+
## Order
|
|
276
|
+
|
|
277
|
+
1. `ChangeSet` with the constructors, `apply` to a plain string, `invert`, `each_edit`,
|
|
278
|
+
and the property tests. No editor integration yet.
|
|
279
|
+
2. The buffer applies changesets: `run_delta` → `apply_changeset`, with `add_delta` as an
|
|
280
|
+
adapter. GTK uses `each_edit`. Undo groups hold changesets (append for now). LSP is
|
|
281
|
+
sent one change per `each_edit`.
|
|
282
|
+
3. `map_pos`, and moving the position updates from `run_delta` onto it, one structure
|
|
283
|
+
at a time: marks, edit history, highlights, fold anchors, cursor. Keep line ends
|
|
284
|
+
specialized if faster, but tested.
|
|
285
|
+
4. `compose`: undo groups become one changeset. `replace_range`, the case transforms
|
|
286
|
+
and `:s` become one changeset each.
|
|
287
|
+
5. Convert the 18 call sites to the constructors. Remove the adapter, the `INSERT` /
|
|
288
|
+
`DELETE` constants and the experimental btree `Delta` class.
|
|
289
|
+
6. Attributes on operations, for `doc/wysiwyg_plan.md` (replaces its FORMAT delta).
|
|
290
|
+
7. Later: `transform`, for multiple cursors and outside changes.
|
|
291
|
+
|
|
292
|
+
Run the full suite in the VM after each step. `test_random_edit` covers undo and
|
|
293
|
+
redo.
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
# Plan: recording demos, and a form input mode
|
|
2
|
+
|
|
3
|
+
TODO: steps 1, 2, 4, 5 and 6 done (`3415ded`..`b5b01c9`). Act next on step 7 of "Implementation order" (step 3 is for later).
|
|
4
|
+
|
|
5
|
+
## Context
|
|
6
|
+
|
|
7
|
+
Demos (Help ▸ Demos, `lib/vimamsa/demo_player.rb`) are step files written by
|
|
8
|
+
hand: `keys`, `type`, `wait`, `delay`, `target` (format in the header of
|
|
9
|
+
`scripts/demo/demo_steps.txt`). Recording one, the way a macro is recorded,
|
|
10
|
+
would make new demos much quicker to write.
|
|
11
|
+
|
|
12
|
+
The player feeds each key to `KeyBindingTree#match_key_conf`, as if typed. A
|
|
13
|
+
recorder can capture keys at the same place. But some input never reaches the
|
|
14
|
+
key bindings. Forms (`PopupFormGenerator`, e.g. `, r r` search and replace)
|
|
15
|
+
use `Gtk::Entry` widgets that handle their own keys, so typing in them can't be
|
|
16
|
+
recorded and the player can't type into them.
|
|
17
|
+
|
|
18
|
+
The direction (2026-11-21): all text input goes through the key bindings,
|
|
19
|
+
including editing form fields. So this plan has two parts:
|
|
20
|
+
|
|
21
|
+
1. **Form input mode.** Form fields stay normal GTK input widgets, each backed
|
|
22
|
+
by a vimamsa `Buffer`. Key handling in the form window is overridden: keys
|
|
23
|
+
go to the key bindings, in a mode for form input.
|
|
24
|
+
2. **Demo recorder.** It captures keys in `match_key_conf` and writes the
|
|
25
|
+
existing step format. Thanks to part 1 it needs no special case for forms.
|
|
26
|
+
|
|
27
|
+
## Part 1: form input mode
|
|
28
|
+
|
|
29
|
+
### Design
|
|
30
|
+
|
|
31
|
+
**The GTK widget is the view, a `Buffer` is the model.** Each field of a form
|
|
32
|
+
(`Gtk::Entry` for one line; a `Gtk::TextView` later for several) gets a
|
|
33
|
+
vimamsa `Buffer` holding its text and cursor position. The widget only shows
|
|
34
|
+
it:
|
|
35
|
+
|
|
36
|
+
- After each key action, the widget's text and cursor (and selection) are set
|
|
37
|
+
from the buffer: `entry.text = fb.to_s.chomp`, `entry.position = fb.pos`.
|
|
38
|
+
- The widget never edits its own text. When something else changes it (a
|
|
39
|
+
middle-click paste, a drop), the `changed` signal copies the new text into
|
|
40
|
+
the buffer as one edit, so the buffer stays the source of truth.
|
|
41
|
+
- A mouse click in a field moves the buffer's cursor (`notify::cursor-position`
|
|
42
|
+
→ `fb.set_pos`) and makes that field current.
|
|
43
|
+
|
|
44
|
+
**Overriding the key handling.** The form window gets an
|
|
45
|
+
`EventControllerKey` in the capture phase, like the main window
|
|
46
|
+
(`VMAgui#reset_controllers`). It translates each key to the editor's key name
|
|
47
|
+
and calls `vma.kbd.match_key_conf`, then returns true so the GTK widget never
|
|
48
|
+
sees the key.
|
|
49
|
+
|
|
50
|
+
- The key name translation is now inside `VSourceView#handle_key_event`. Move
|
|
51
|
+
it to one function, e.g. `gui_key_name(keyval, keystr, modifiers)`, used by
|
|
52
|
+
both windows. Then the form window gets the same names (`ctrl-r`, `ctrl!`,
|
|
53
|
+
`space` ...) and the same modifier handling (the `modifiers` signal).
|
|
54
|
+
- `@entry_has_focus` / `notify_entry_focus` (the calculator module's way of
|
|
55
|
+
letting a GTK entry take the keys) is the opposite of this direction.
|
|
56
|
+
Migrate it in step 7 and remove it afterwards.
|
|
57
|
+
|
|
58
|
+
**The mode.** A new mode for form input, e.g. `vma.kbd.add_mode("F", :form)`,
|
|
59
|
+
active while a form has the focus:
|
|
60
|
+
|
|
61
|
+
- Very basic bindings, like a GTK entry works now (decided 2026-11-21):
|
|
62
|
+
typing edits the current field (`F <char>` → `form.insert.char`),
|
|
63
|
+
`backspace`, `delete`, `left` / `right`, `home` / `end`, and the clipboard
|
|
64
|
+
keys `ctrl-a` (select the whole field), `ctrl-c` (copy the selection),
|
|
65
|
+
`ctrl-x` (cut it), `ctrl-v` (paste at the cursor, over the selection). A
|
|
66
|
+
field's selection is set by `ctrl-a` or by selecting with the mouse in the
|
|
67
|
+
widget (mirrored into the buffer); typing or deleting replaces it. Copy and
|
|
68
|
+
paste use the system clipboard (`Clipboard`), not the registers. Plus the
|
|
69
|
+
form keys:
|
|
70
|
+
`tab` / `shift-tab` next and previous field, `enter` submit (or press the
|
|
71
|
+
focused button), `esc` cancel. Nothing modal inside a field.
|
|
72
|
+
- Vim-style editing in fields comes later, if at all: a form command sub-mode
|
|
73
|
+
(a minor mode of `:form`: `h l w b e x d w`, `i a`), with `esc` going to it
|
|
74
|
+
and a second `esc` cancelling.
|
|
75
|
+
- The mode badge shows FORM. The key log and key hint show form keys like any
|
|
76
|
+
others.
|
|
77
|
+
- When the form closes, the mode before it comes back (the mode stack).
|
|
78
|
+
|
|
79
|
+
**Which buffer actions edit.** Edit actions use `buf` / `vma.buf`. While a
|
|
80
|
+
form is current, they must edit the field's buffer:
|
|
81
|
+
|
|
82
|
+
- `vma.form` holds the current form: its fields, the current field, and its
|
|
83
|
+
buffer `vma.form.buf`.
|
|
84
|
+
- Form actions (`form.*`) edit `vma.form.buf` directly. That is all the basic
|
|
85
|
+
bindings need.
|
|
86
|
+
- Only for the later vim-style editing: let `buf` resolve to `vma.form.buf`
|
|
87
|
+
while form mode is active, to reuse the normal edit and motion actions. That
|
|
88
|
+
needs care: code that expects `buf.view`, highlighting, autosave, the buffer
|
|
89
|
+
list.
|
|
90
|
+
- Field buffers are not in the buffer list or the file history, have no file,
|
|
91
|
+
and need no `VSourceView`. `Buffer` today always creates a GTK view
|
|
92
|
+
(`gui_create_buffer` in `Buffer#initialize`), so it needs a way to be
|
|
93
|
+
created without one, e.g. `Buffer.new(text, nil, prefix, view: false)`.
|
|
94
|
+
`$minibuffer = Buffer.new(">", "")` is a precedent of a buffer outside the
|
|
95
|
+
list.
|
|
96
|
+
|
|
97
|
+
**Input methods.** Keys taken in the capture phase bypass GTK input methods
|
|
98
|
+
(compose, dead keys, CJK input). The main editor already works this way, so
|
|
99
|
+
forms get the same behaviour, no worse than the editor. A later improvement
|
|
100
|
+
for both is to take committed text from a `Gtk::IMContext`.
|
|
101
|
+
|
|
102
|
+
### The command line: its own mode
|
|
103
|
+
|
|
104
|
+
Forms stay simpler than the command line (decided 2026-11-21). The command
|
|
105
|
+
line (`gui_command_line.rb`, a `Gtk::Entry`) gets its own mode, e.g.
|
|
106
|
+
`cmdline`, not form mode. It uses the same field machinery: a GTK widget as
|
|
107
|
+
the view, a field `Buffer` as the model, keys overridden to go to the key
|
|
108
|
+
bindings.
|
|
109
|
+
|
|
110
|
+
- The basic field editing keys are bound in both modes from one shared
|
|
111
|
+
definition (a helper that binds `<char>`, `backspace`, `delete`, `left` /
|
|
112
|
+
`right`, `home` / `end`, `ctrl-a` / `ctrl-c` / `ctrl-x` / `ctrl-v` to a
|
|
113
|
+
given mode). So both edit the same way, without
|
|
114
|
+
form mode growing.
|
|
115
|
+
- On top of that, only the command line has history (`up` / `down`), tab
|
|
116
|
+
completion of `a.` action ids, `enter` to run and `esc` to close.
|
|
117
|
+
- Form mode keeps only what forms need: the basic keys, `tab` / `shift-tab`
|
|
118
|
+
between fields, `enter` submit, `esc` cancel.
|
|
119
|
+
- The existing `M` / `:minibuffer` mode (`key_bindings_vimlike.rb`, marked
|
|
120
|
+
"TODO: needed?") could become the command line's mode, or be removed. Check
|
|
121
|
+
what still uses it before step 7.
|
|
122
|
+
|
|
123
|
+
### What moves to form mode
|
|
124
|
+
|
|
125
|
+
1. `PopupFormGenerator` (`gui_form_generator.rb`): search and replace
|
|
126
|
+
(`, r r`), confirmations (`Gui.confirm`, e.g. "Install demo files?"), other
|
|
127
|
+
generated forms.
|
|
128
|
+
2. The calculator module's entry (`@entry_has_focus`).
|
|
129
|
+
3. Later: the Settings dialog fields, the select windows (`gui_select_window.rb`)
|
|
130
|
+
if they take text. The GTK file chooser stays native, or is replaced by
|
|
131
|
+
the file explorer.
|
|
132
|
+
|
|
133
|
+
## Part 2: demo recorder
|
|
134
|
+
|
|
135
|
+
### Recording
|
|
136
|
+
|
|
137
|
+
- `help.demo.record` toggles recording, like macro recording, as Help ▸ Demos
|
|
138
|
+
▸ Record demo. A status indicator shows "● REC" while recording
|
|
139
|
+
(`VMAgui#set_status_indicator`). The key that stops recording isn't
|
|
140
|
+
recorded.
|
|
141
|
+
- The capture point is `KeyBindingTree#match_key_conf(c, translated_c,
|
|
142
|
+
event_type)`, the one entry point for keys, which is also where
|
|
143
|
+
`DemoPlayer#press` feeds them. For each key it records the time (monotonic
|
|
144
|
+
clock), the key name, the mode before the key, and the action it ran (from
|
|
145
|
+
`:key_action`).
|
|
146
|
+
- **Bare modifiers:** `ctrl` is recorded only when its release (`ctrl!`) comes
|
|
147
|
+
with no other key in between. That is what `ctrl!` means, and what
|
|
148
|
+
`press("ctrl")` replays. Otherwise `ctrl-r` would replay as a mode switch
|
|
149
|
+
plus `ctrl-r`. The same goes for `alt` and `shift`.
|
|
150
|
+
- **Starting state:** at the start, the current file's text is saved as the
|
|
151
|
+
demo's start file, and the cursor goes to the top (the player starts there),
|
|
152
|
+
or its position is saved.
|
|
153
|
+
- **Mouse:** clicks and scrolling aren't recorded (the format has no mouse
|
|
154
|
+
steps). If a click moves the cursor or changes the buffer while recording,
|
|
155
|
+
show a warning in the status line.
|
|
156
|
+
- Input that still bypasses the key bindings (dialogs not yet in form mode)
|
|
157
|
+
also gets a warning when it opens during recording.
|
|
158
|
+
|
|
159
|
+
### Turning the keys into steps
|
|
160
|
+
|
|
161
|
+
- `delay`: the median gap between keys, rounded to 0.05 s, clamped to
|
|
162
|
+
0.2–0.8 s.
|
|
163
|
+
- `wait`: a gap clearly longer than the delay (over 2 × delay), minus the
|
|
164
|
+
delay, rounded to 0.1 s and capped at 3 s, so the recorder's hesitation
|
|
165
|
+
doesn't bore the viewer.
|
|
166
|
+
- `type`: runs of plain characters typed in Insert mode (or in a form field).
|
|
167
|
+
Other keys go into `keys` lines, split at waits.
|
|
168
|
+
- **Easy jump:** labels depend on the window size, so recorded label keys
|
|
169
|
+
wouldn't replay in another window. After a `jump.easy` action, the label
|
|
170
|
+
keys are replaced with `target line N` (the line the cursor ended on) and
|
|
171
|
+
`keys @JUMP_LABEL@`, as in `demo_easyjump_steps.txt`.
|
|
172
|
+
- **Comments:** each group of keys gets the action description from the key
|
|
173
|
+
log (`# Jump to the start of the next word`), so the file reads like the
|
|
174
|
+
hand-written ones and is easy to edit.
|
|
175
|
+
- **Forms:** with part 1 done, keys typed into a form are ordinary keys in
|
|
176
|
+
form mode, recorded and replayed like any others. Opening a form can be
|
|
177
|
+
asynchronous (`PopupFormGenerator` queues popups), so the player must not
|
|
178
|
+
type into the editor before the form is up. The recorder writes the mode at
|
|
179
|
+
points where it changed because of a window (`mode form`), and the player
|
|
180
|
+
waits there, up to a timeout, until that mode is active.
|
|
181
|
+
|
|
182
|
+
### Saving and playing
|
|
183
|
+
|
|
184
|
+
- A recorded demo is saved in the user dir:
|
|
185
|
+
`<user dir>/demos/<name>/steps.txt` plus its start files.
|
|
186
|
+
- The step format gets header commands: `title TEXT`, `desc TEXT`, `file NAME`
|
|
187
|
+
(start files, in the demo's folder). Built-in demos can use them too, in
|
|
188
|
+
place of the `title:` / `desc:` / `files:` in `DemoPlayer::DEMOS`.
|
|
189
|
+
- `DemoPlayer` lists user demos after the built-in ones: Help ▸ Demos, the
|
|
190
|
+
demo dropdown above the key log, and (optionally) the introduction page.
|
|
191
|
+
- Recording asks for a name when it stops (a form, so in form mode).
|
|
192
|
+
|
|
193
|
+
### Things that can make playback differ
|
|
194
|
+
|
|
195
|
+
- **Undo grouping by time** (`cnf.undo.group_threshold`): played back at
|
|
196
|
+
another speed, the same keys may form different undo steps, so `u` undoes a
|
|
197
|
+
different amount. The player could close an undo group after each step, or
|
|
198
|
+
the recorder could note undo boundaries.
|
|
199
|
+
- The keymap scheme: record and play in the same one (write it in the header,
|
|
200
|
+
`scheme vimlike`, and refuse or warn on a mismatch).
|
|
201
|
+
- Buffer history order, for demos that switch files (the files demo depends
|
|
202
|
+
on it).
|
|
203
|
+
- Settings that change what keys do (e.g. `cnf.undo.insert_one_step`).
|
|
204
|
+
|
|
205
|
+
## Implementation order
|
|
206
|
+
|
|
207
|
+
1. Move key name translation out of `VSourceView#handle_key_event` into one
|
|
208
|
+
function used by the main window. No behaviour change. Tests: the existing
|
|
209
|
+
suite, plus a few key names (`ctrl-r`, `ctrl!`, `space`, shifted
|
|
210
|
+
characters).
|
|
211
|
+
2. Form mode for `PopupFormGenerator`: field buffers (`Buffer` without a
|
|
212
|
+
view), the capture controller on the form window, mode `F` with insert,
|
|
213
|
+
delete, cursor keys, tab, enter, esc, and syncing the widgets from the
|
|
214
|
+
buffers (and back for clicks and pastes). Tests: open the search and
|
|
215
|
+
replace form, type with `keys`, tab, type, enter; the buffer text is
|
|
216
|
+
replaced. Mouse paste into a field reaches its buffer. Esc cancels.
|
|
217
|
+
3. (Later, not part of this plan's first round) Vim-style editing in fields:
|
|
218
|
+
a form command sub-mode, with `buf` resolving to the field buffer while in
|
|
219
|
+
form mode.
|
|
220
|
+
4. Recorder core: start/stop action and menu item, capture in
|
|
221
|
+
`match_key_conf`, the bare-modifier rule, saving raw keys plus the start
|
|
222
|
+
file. Tests: feed keys with `keys` and fake times, check the recorded list.
|
|
223
|
+
5. Converting to steps: `delay`, `wait`, `type`, comments, easy jump targets,
|
|
224
|
+
`mode` sync points. Tests: generated text for known key sequences; record,
|
|
225
|
+
play back, same final buffer text (including `, r r` once step 2 is done).
|
|
226
|
+
6. User demos in `DemoPlayer`: header commands, the user `demos` folder,
|
|
227
|
+
listing in the menu and the dropdown, naming on stop.
|
|
228
|
+
7. The command line in its own mode (shared basic editing keys, plus
|
|
229
|
+
history, completion, run, close), and the calculator entry in form mode;
|
|
230
|
+
remove `@entry_has_focus`.
|
|
231
|
+
|
|
232
|
+
Run the suite in the test VM after each step (`./run_tests_vm.rb`).
|
|
233
|
+
|
|
234
|
+
## Open questions
|
|
235
|
+
|
|
236
|
+
- Mode letters and names: `F` / `:form` (`F` is free today); the command
|
|
237
|
+
line's mode (a new one, or the existing `M` / `:minibuffer`).
|
|
238
|
+
- Should recorded demos be shareable as a single file (steps plus start file
|
|
239
|
+
inlined), for sending to someone?
|
|
240
|
+
|
|
241
|
+
## DONE
|
|
242
|
+
|
|
243
|
+
- Step 1 (2026-11-21, `3415ded`): `gui_key_name` and `gui_set_modifiers` in
|
|
244
|
+
`lib/vimamsa/key_names.rb`, used by `VSourceView#handle_key_event` and the main
|
|
245
|
+
window's `modifiers` handler.
|
|
246
|
+
- Step 2 (2026-11-21, `a38c55f`): `lib/vimamsa/form_input.rb`.
|
|
247
|
+
- `FormField`: a `Gtk::Entry` showing a hidden-view `Buffer`. It reads the
|
|
248
|
+
widget's own changes on `changed`, and the mouse cursor and selection before
|
|
249
|
+
each key.
|
|
250
|
+
- `FormInput`: the form's fields and buttons, the window's capture-phase key
|
|
251
|
+
controller, and mode `F` (editor scope, mode stack restored on close).
|
|
252
|
+
- `form.*` actions and keys from `form_input_setup` (called in `Editor#start`
|
|
253
|
+
after the keymap, and by `--help`). `bind_form_field_keys(mode)` is the shared
|
|
254
|
+
helper for the command line later.
|
|
255
|
+
- `PopupFormGenerator` uses it (search and replace, `Gui.confirm`).
|
|
256
|
+
- The key log groups form typing like Insert-mode typing.
|
|
257
|
+
- Tests: `tests/test_form_input.rb` (11). Not covered: real key events through
|
|
258
|
+
the form window (no e2e test).
|
|
259
|
+
- Steps 4–6 (2026-11-21, `b5b01c9`): `lib/vimamsa/demo_recorder.rb`.
|
|
260
|
+
- Recording: Help ▸ Demos ▸ Record demo (`help.demo.record`), the "● REC demo"
|
|
261
|
+
status indicator. Keys come from the new `:key_input` event of
|
|
262
|
+
`match_key_conf`, emitted before the override callback so easy jump labels
|
|
263
|
+
are captured. Each key has its time, mode, action and cursor line. Bare
|
|
264
|
+
ctrl/alt/shift count only when released alone. The stop command's own keys
|
|
265
|
+
are dropped.
|
|
266
|
+
- Recording starts in Command mode with the cursor at the top, as playback
|
|
267
|
+
does.
|
|
268
|
+
- Conversion (`DemoRecorder.steps`):
|
|
269
|
+
- `delay` is the median gap; `wait` is the pause minus the delay, capped at
|
|
270
|
+
3 s.
|
|
271
|
+
- `type` covers Insert-mode and form typing; leading spaces go in a keys
|
|
272
|
+
line.
|
|
273
|
+
- Each keys group gets a comment with its actions' descriptions.
|
|
274
|
+
- An easy jump label becomes `target line N` + `keys @JUMP_LABEL@`, and
|
|
275
|
+
`#` goes last on a keys line.
|
|
276
|
+
- Saving: on stop, a name form (form mode), then `<user dir>/demos/<slug>/`
|
|
277
|
+
with `steps.txt` (header `title`, `file`) and the start file.
|
|
278
|
+
- Playing: `DemoPlayer.demos` = `DEMOS` + `user_demos`, each with a
|
|
279
|
+
`help.demo.user.<slug>` action and its own source folder (`src:`).
|
|
280
|
+
- The menu lists the recorded demos that exist at startup.
|
|
281
|
+
- Help ▸ Demos ▸ Play the last recorded demo (`help.demo.recorded.last`)
|
|
282
|
+
plays the newest one.
|
|
283
|
+
- The demo dropdown above the key log refreshes its list.
|
|
284
|
+
- Tests: `tests/test_demo_recorder.rb` (7), including record → save through
|
|
285
|
+
the form → play back to the same text, with `, r r` typed into the form.
|
|
286
|
+
- Not done: the `mode form` sync points and the `scheme` header (playback
|
|
287
|
+
feeds keys synchronously and popups open synchronously, so not needed so
|
|
288
|
+
far); undo grouping by time can still differ at another speed.
|
data/doc/design_goals.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Design goals
|
|
2
|
+
|
|
3
|
+
## Goals
|
|
4
|
+
(TODO: no need to number these)
|
|
5
|
+
0. Minimize amount keypresses. Minimize movement betweeen keyboard and mouse.
|
|
6
|
+
1. **Separate key bindings from actions.** Every command is a named action, and a
|
|
7
|
+
binding only points to one (unlike Vim, where `dw` *is* the command). Any action
|
|
8
|
+
can then be bound in any keymap, rebound in `custom.rb`, and found in the menu
|
|
9
|
+
or in Search for Actions. Composite commands are built from parts defined as data
|
|
10
|
+
(operator × motion), not hardcoded per key combination.
|
|
11
|
+
2. **Modularity.** Optional features, and those that need external tools (LSP,
|
|
12
|
+
ack, dictation, terminal, …), are modules that can be turned on and off. The core
|
|
13
|
+
works without them.
|
|
14
|
+
3. **A reusable key binding system.** `KeyBindingTree` knows about keys, modes and
|
|
15
|
+
actions, not buffers, so other software could use it.
|
|
16
|
+
4. **Vim compatibility for popular features:** motions, operators with counts, text
|
|
17
|
+
objects, visual mode, registers, `.`, search.
|
|
18
|
+
5. **Ruby as the extension language.** Configuration is plain Ruby (`custom.rb`).
|
|
19
|
+
- Don't rely too much on GTK gui. Gui may change, or there may be support for another gui. First version was implemented for QT. There could be a gui abstraction layer to ease the move to another gui framework or console.
|
|
20
|
+
- At some point goal is to support WYSIWYG style editing (like Word). Open questions are the file format and which component to use for rendering.
|
|
21
|
+
- Allow using easy jump for almost everywhere (selecting files, items from gui lists etc.)
|
|
22
|
+
|
|
23
|
+
## Non-goals
|
|
24
|
+
|
|
25
|
+
- Vimscript and Vim plugins.
|
|
26
|
+
- Vim's full Ex command language. Only common `:` commands (`:w`, `:wq`, `:s`).
|
|
27
|
+
- Vim regex syntax. Searches use Ruby regex.
|