vimamsa 0.1.26 → 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.
Files changed (229) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/appimage.yml +93 -0
  3. data/.gitignore +4 -1
  4. data/Dockerfile +7 -4
  5. data/README.md +195 -99
  6. data/custom_example.rb +59 -17
  7. data/doc/TODO.md +678 -0
  8. data/doc/action_names_plan.md +442 -0
  9. data/doc/bundling_plan.md +570 -0
  10. data/doc/delta_syntax_plan.md +293 -0
  11. data/doc/demo_recording_plan.md +288 -0
  12. data/doc/design_goals.md +27 -0
  13. data/doc/intro_page_plan.md +266 -0
  14. data/doc/key_bindings_report_plan.md +213 -0
  15. data/doc/line_tree_plan.md +89 -0
  16. data/doc/missing_vim_bindings.md +61 -0
  17. data/doc/modules_settings_plan.md +433 -0
  18. data/doc/refactor_dedup_plan.md +117 -0
  19. data/doc/registries_plan.md +202 -0
  20. data/doc/startup_speed_plan.md +97 -0
  21. data/doc/treap_visualizer.html +585 -0
  22. data/doc/unused_code_plan.md +120 -0
  23. data/doc/vim_compatibility_plan.md +451 -0
  24. data/doc/vimlike_vim_conflicts.md +262 -0
  25. data/doc/vm_snapshots_plan.md +146 -0
  26. data/doc/wysiwyg_plan.md +231 -0
  27. data/exe/run_tests.rb +124 -3
  28. data/exe/vimamsa +68 -5
  29. data/fonts/OFL-Oxanium.txt +93 -0
  30. data/fonts/Oxanium[wght].ttf +0 -0
  31. data/help/intro.txt +30 -0
  32. data/help/vim_intro.txt +31 -0
  33. data/icon.png +0 -0
  34. data/img/demo.gif +0 -0
  35. data/img/demo.mp4 +0 -0
  36. data/lang/hyperplaintext.lang +7 -1
  37. data/lib/vimamsa/ack.rb +13 -1
  38. data/lib/vimamsa/actions.rb +385 -37
  39. data/lib/vimamsa/appimage_env.rb +35 -0
  40. data/lib/vimamsa/audio.rb +2 -5
  41. data/lib/vimamsa/bookmarks.rb +302 -0
  42. data/lib/vimamsa/buffer.rb +675 -118
  43. data/lib/vimamsa/buffer_changetext.rb +150 -68
  44. data/lib/vimamsa/buffer_cursor.rb +7 -0
  45. data/lib/vimamsa/buffer_list.rb +6 -2
  46. data/lib/vimamsa/buffer_manager.rb +10 -7
  47. data/lib/vimamsa/bundled_fonts.rb +32 -0
  48. data/lib/vimamsa/cli_help.rb +75 -0
  49. data/lib/vimamsa/clipboard.rb +9 -3
  50. data/lib/vimamsa/conf.rb +68 -3
  51. data/lib/vimamsa/constants.rb +3 -0
  52. data/lib/vimamsa/crash_handler.rb +149 -0
  53. data/lib/vimamsa/debug.rb +6 -3
  54. data/lib/vimamsa/demo_player.rb +458 -0
  55. data/lib/vimamsa/demo_recorder.rb +277 -0
  56. data/lib/vimamsa/desktop_install.rb +96 -0
  57. data/lib/vimamsa/diff_buffer.rb +40 -11
  58. data/lib/vimamsa/dot_repeat.rb +104 -0
  59. data/lib/vimamsa/easy_jump.rb +57 -3
  60. data/lib/vimamsa/editor.rb +327 -78
  61. data/lib/vimamsa/encrypt.rb +78 -29
  62. data/lib/vimamsa/file_finder.rb +4 -19
  63. data/lib/vimamsa/file_history.rb +4 -1
  64. data/lib/vimamsa/file_manager.rb +46 -31
  65. data/lib/vimamsa/fold.rb +226 -0
  66. data/lib/vimamsa/form_input.rb +388 -0
  67. data/lib/vimamsa/gui.rb +603 -119
  68. data/lib/vimamsa/gui_command_line.rb +247 -0
  69. data/lib/vimamsa/gui_dialog.rb +94 -42
  70. data/lib/vimamsa/gui_file_panel.rb +356 -25
  71. data/lib/vimamsa/gui_form_generator.rb +75 -40
  72. data/lib/vimamsa/gui_func_panel.rb +67 -22
  73. data/lib/vimamsa/gui_image.rb +3 -0
  74. data/lib/vimamsa/gui_key_hint.rb +165 -0
  75. data/lib/vimamsa/gui_keylog_panel.rb +408 -0
  76. data/lib/vimamsa/gui_menu.rb +84 -53
  77. data/lib/vimamsa/gui_select_window.rb +80 -75
  78. data/lib/vimamsa/gui_settings.rb +86 -41
  79. data/lib/vimamsa/gui_sourceview.rb +280 -92
  80. data/lib/vimamsa/gui_sourceview_autocomplete.rb +319 -90
  81. data/lib/vimamsa/gui_text.rb +63 -2
  82. data/lib/vimamsa/gui_theme.rb +615 -0
  83. data/lib/vimamsa/hook.rb +5 -0
  84. data/lib/vimamsa/hyper_plain_text.rb +3 -0
  85. data/lib/vimamsa/intro_page.rb +368 -0
  86. data/lib/vimamsa/key_actions.rb +382 -193
  87. data/lib/vimamsa/key_binding_tree.rb +467 -273
  88. data/lib/vimamsa/key_bindings_notepad.rb +45 -0
  89. data/lib/vimamsa/key_bindings_report.rb +484 -0
  90. data/lib/vimamsa/key_bindings_vim.rb +104 -0
  91. data/lib/vimamsa/key_bindings_vimlike.rb +353 -289
  92. data/lib/vimamsa/key_names.rb +80 -0
  93. data/lib/vimamsa/langservp.rb +271 -54
  94. data/lib/vimamsa/line_tree.rb +367 -0
  95. data/lib/vimamsa/macro.rb +23 -3
  96. data/lib/vimamsa/main.rb +14 -8
  97. data/lib/vimamsa/rbvma.rb +41 -1
  98. data/lib/vimamsa/registers.rb +125 -0
  99. data/lib/vimamsa/run_ruby.rb +64 -0
  100. data/lib/vimamsa/search.rb +3 -0
  101. data/lib/vimamsa/search_replace.rb +15 -14
  102. data/lib/vimamsa/string_util.rb +134 -40
  103. data/lib/vimamsa/terminal.rb +3 -0
  104. data/lib/vimamsa/test_framework.rb +28 -2
  105. data/lib/vimamsa/tests.rb +11 -8
  106. data/lib/vimamsa/text_objects.rb +310 -0
  107. data/lib/vimamsa/text_transforms.rb +18 -0
  108. data/lib/vimamsa/tmp_user_dir.rb +39 -0
  109. data/lib/vimamsa/user_dirs.rb +83 -0
  110. data/lib/vimamsa/util.rb +46 -7
  111. data/lib/vimamsa/version.rb +1 -1
  112. data/lib/vimamsa/vim_core.rb +355 -0
  113. data/lib/vimamsa/vim_operators.rb +365 -0
  114. data/lib/vimamsa.rb +0 -1
  115. data/modules/calculator/calculator.rb +5 -5
  116. data/modules/color_highlight/color_highlight.rb +118 -0
  117. data/modules/color_highlight/color_highlight_info.rb +3 -0
  118. data/modules/dictation/dictation.rb +1054 -0
  119. data/modules/dictation/dictation_info.rb +3 -0
  120. data/modules/dictation/whisper_worker.py +273 -0
  121. data/modules/ollama/ollama.rb +107 -0
  122. data/modules/ollama/ollama_info.rb +3 -0
  123. data/modules/terminal/terminal.rb +5 -5
  124. data/modules/tts/tts.rb +119 -0
  125. data/modules/tts/tts_info.rb +3 -0
  126. data/run_e2e_vm.sh +28 -0
  127. data/run_tests_vm.rb +138 -0
  128. data/scripts/appimage/AppRun +54 -0
  129. data/scripts/appimage/Dockerfile +18 -0
  130. data/scripts/appimage/build.sh +19 -0
  131. data/scripts/appimage/build_in_container.sh +192 -0
  132. data/scripts/appimage/smoke_test.sh +27 -0
  133. data/scripts/demo/demo_easyjump_steps.txt +60 -0
  134. data/scripts/demo/demo_files_steps.txt +52 -0
  135. data/scripts/demo/demo_steps.txt +67 -0
  136. data/scripts/demo/notes.txt +6 -0
  137. data/scripts/demo/record_demo.rb +156 -0
  138. data/scripts/demo/report.rb +7 -0
  139. data/scripts/demo/shapes.rb +29 -0
  140. data/scripts/demo/square/shapes.rb +29 -0
  141. data/scripts/demo/square/steps.txt +185 -0
  142. data/scripts/lib/perf_startup.rb +138 -0
  143. data/scripts/lib/script_helpers.rb +53 -0
  144. data/scripts/perf_compare.rb +34 -0
  145. data/scripts/profile_startup.rb +72 -0
  146. data/styles/134272-molokai.xml +3 -0
  147. data/styles/molokai_cyber.xml +48 -0
  148. data/styles/molokai_edit.xml +1 -0
  149. data/tests/support/virtual_keyboard.rb +254 -0
  150. data/tests/support/virtual_mic.rb +67 -0
  151. data/tests/test_ack.rb +22 -0
  152. data/tests/test_action_ids.rb +232 -0
  153. data/tests/test_auto_format.rb +122 -0
  154. data/tests/test_autocomplete.rb +211 -0
  155. data/tests/test_autosave.rb +145 -0
  156. data/tests/test_basic_editing.rb +46 -16
  157. data/tests/test_bookmarks.rb +206 -0
  158. data/tests/test_bracket_match.rb +88 -0
  159. data/tests/test_bundling.rb +92 -0
  160. data/tests/test_cli_help.rb +64 -0
  161. data/tests/test_color_highlight.rb +92 -0
  162. data/tests/test_command_line.rb +79 -0
  163. data/tests/test_command_line_file.rb +27 -0
  164. data/tests/test_context_menu_file.rb +147 -0
  165. data/tests/test_copy_paste.rb +106 -26
  166. data/tests/test_crash_handler.rb +39 -0
  167. data/tests/test_custom_two_phase.rb +92 -0
  168. data/tests/test_demo_player.rb +301 -0
  169. data/tests/test_demo_recorder.rb +202 -0
  170. data/tests/test_dialog_callback_errors.rb +44 -0
  171. data/tests/test_dictation.rb +294 -0
  172. data/tests/test_diff_buffer_name.rb +51 -0
  173. data/tests/test_dot_repeat.rb +88 -0
  174. data/tests/test_double_click.rb +41 -0
  175. data/tests/test_drag_selection.rb +125 -0
  176. data/tests/test_e2e_cmdline.rb +116 -0
  177. data/tests/test_e2e_dictation.rb +98 -0
  178. data/tests/test_e2e_replace_char.rb +58 -0
  179. data/tests/test_easy_jump.rb +93 -0
  180. data/tests/test_extract_file_links.rb +55 -0
  181. data/tests/test_file_format.rb +217 -0
  182. data/tests/test_file_manager.rb +72 -0
  183. data/tests/test_file_panel.rb +269 -0
  184. data/tests/test_flash.rb +78 -0
  185. data/tests/test_fold.rb +111 -0
  186. data/tests/test_font_refresh.rb +56 -0
  187. data/tests/test_form_input.rb +203 -0
  188. data/tests/test_func_panel.rb +68 -0
  189. data/tests/test_grep_apply.rb +46 -0
  190. data/tests/test_gtk_sync.rb +126 -0
  191. data/tests/test_hpt_highlight_visible.rb +75 -0
  192. data/tests/test_hpt_link_highlight.rb +82 -0
  193. data/tests/test_intro_page.rb +437 -0
  194. data/tests/test_jump_to_file.rb +41 -0
  195. data/tests/test_key_bindings.rb +208 -0
  196. data/tests/test_key_categories.rb +163 -0
  197. data/tests/test_keylog_panel.rb +261 -0
  198. data/tests/test_line_ends.rb +51 -0
  199. data/tests/test_line_tree.rb +86 -0
  200. data/tests/test_lsp_clangd.rb +281 -0
  201. data/tests/test_lsp_jump.rb +87 -0
  202. data/tests/test_lsp_position_encoding.rb +49 -0
  203. data/tests/test_lsp_symbols.rb +68 -0
  204. data/tests/test_macro.rb +137 -0
  205. data/tests/test_markdown_highlight.rb +57 -0
  206. data/tests/test_mode_badge.rb +41 -0
  207. data/tests/test_module_interface.rb +9 -9
  208. data/tests/test_notepad_bindings.rb +67 -0
  209. data/tests/test_perf_startup.rb +28 -0
  210. data/tests/test_popup_queue.rb +51 -0
  211. data/tests/test_random_edit.rb +109 -0
  212. data/tests/test_registers.rb +122 -0
  213. data/tests/test_revert.rb +127 -0
  214. data/tests/test_run_ruby.rb +77 -0
  215. data/tests/test_startup_file.rb +58 -0
  216. data/tests/test_status_area.rb +50 -0
  217. data/tests/test_text_objects.rb +163 -0
  218. data/tests/test_text_transforms.rb +341 -0
  219. data/tests/test_tmp_user_dir.rb +79 -0
  220. data/tests/test_tts.rb +68 -0
  221. data/tests/test_undo.rb +34 -34
  222. data/tests/test_user_dirs.rb +122 -0
  223. data/tests/test_vim_bindings.rb +353 -0
  224. data/tests/test_vim_conflicts.rb +100 -0
  225. data/tests/test_vim_operators.rb +116 -0
  226. data/tests/test_window_layout.rb +302 -0
  227. data/vimamsa.gemspec +3 -1
  228. data/vm_guest_run.sh +129 -0
  229. metadata +167 -10
data/doc/TODO.md ADDED
@@ -0,0 +1,678 @@
1
+ # TODO
2
+
3
+ Generic list of future actions. Larger efforts get their own plan in `doc/*_plan.md`
4
+ and are linked from here.
5
+
6
+ When an item is finished, move it to **DONE**. Add a short summary of what was done and
7
+ the git ref(s), as a short commit hash or a range.
8
+
9
+ ## Open
10
+
11
+ ### Record demos; form input through the key bindings
12
+
13
+ Record a demo like a macro, into the demo step format, by capturing keys in
14
+ `match_key_conf`. First, form fields get a form input mode: GTK widgets as the
15
+ view, a vimamsa `Buffer` per field as the model, and the form window's keys going
16
+ to the key bindings. Then typing in forms (e.g. `, r r`) records and replays too.
17
+ Plan: `doc/demo_recording_plan.md`.
18
+
19
+ ### Faster startup
20
+
21
+ About 0.9 s of a 2.6–3.0 s startup can be saved. The biggest item: the red-colors gem,
22
+ which cairo requires, builds every colormap when loaded (0.6–0.8 s); it can be loaded
23
+ only when it is used. Plan: `doc/startup_speed_plan.md`.
24
+
25
+ ### Easy jump: line-start labels in the gutter
26
+
27
+ Easy jump labels are opaque black boxes with bold red text, drawn over the first
28
+ characters of words and lines (`easy_jump.rb`, `VMAgui#overlay_draw_text`). While
29
+ they're shown, the code under them can't be read: `AA` covers `# E`, `DD` covers `def`
30
+ (seen in the easy jump demo, 2026-11-21).
31
+
32
+ - Draw the line-start labels in the gutter, next to the line numbers, so they cover
33
+ no code.
34
+ - Word-start labels stay in the text. Possibly make them see-through, with brighter
35
+ text.
36
+ - `DemoPlayer#jump_label` and its test look labels up by position
37
+ (`@easy_jump_wsmarks`), so they should still work.
38
+
39
+ ### Descriptive names for key bindings that lack one
40
+
41
+ Mostly done: every binding now runs a named action (the dotted action ids, see
42
+ "Consistent, hierarchical action names"), and the key bindings page, key log and
43
+ toolbar show its description. Left: seven actions are registered with an empty
44
+ description, so they show as bare ids: `bmark.select`, `bmark.delete`, `bmgr.select`,
45
+ `bmgr.close`, `fexp.select`, `buf.history.prev` and `buf.diff`
46
+ (`grep -rn 'reg_act(.*, "")' lib modules`).
47
+
48
+ ### More Vim bindings: counts after operators, missing operator + motion combinations
49
+
50
+ The full design is step 1 of `doc/vim_compatibility_plan.md` (a generic operator +
51
+ motion layer). The gap list is in `doc/missing_vim_bindings.md`. This item tracks the
52
+ concrete bindings, ordered by usefulness and cost.
53
+
54
+ State (2026-11-19):
55
+ - A count *before* the command (`3dw`) works, because the key tree repeats the action
56
+ (`key_binding_tree.rb:888`).
57
+ - A count *after* the operator works only where a `<num>` binding was written out.
58
+ The only one is `"C d <num> e"` (`key_bindings_vimlike.rb:229`, handled by
59
+ `KeyBindingTree#match_num_key`).
60
+
61
+ 1. **Counts after the operator for bindings that already exist** (quick win, can come
62
+ before the operator layer):
63
+ - `d <num> w`, `d <num> d` (= `3dd`), `d <num> f x`, `d <num> F x`
64
+ - `y <num> w`, `y <num> e`, `y <num> y`
65
+ - `g U <num> w`, `g u <num> w`, `g ~ <num> w`
66
+ - vim scheme: `c <num> w`, `c <num> e`, `c <num> c`
67
+ - text objects: `d 2 i (` (today only `2 d i (` works)
68
+
69
+ Rather than writing every `<num>` binding by hand, let `match_num_key` accept digits
70
+ after any registered operator prefix (`C d`, `C y`, `C c`, `C g U`, `C g u`,
71
+ `C g ~`), so current and future operator bindings all get counts. Caveat: `c …`
72
+ must not just repeat its action (three insert-mode entries), so the change bindings
73
+ need actions that apply the count themselves (`method_handles_repeat`). Check
74
+ `delete_line` / `copy_cur_line` the same way.
75
+ 2. **Missing operator + motion combinations** (both schemes unless noted):
76
+ - `d b`, `c b`, `y b`
77
+ - `d t x`, `c t x`, `d T x`, `y t x`
78
+ - `d j`, `d k`: missing in both; in vimlike they're commented-out TODOs at
79
+ `key_bindings_vimlike.rb:222-223`
80
+ - `d G`, `d g g`; `d }`, `d {`, `y }`; `d %`; `d ^`, `y ^`
81
+ - vimlike now has `c w`, `c e`, `c c`, `c $`, `S` from the shared vim table
82
+ (2026-11-20); `C` and `s` stay vimlike's own. See `doc/vimlike_vim_conflicts.md`.
83
+ 3. **Missing motions** (they then also work after operators):
84
+ - `W` / `E` / `ge` (`B` is commented out in vimlike)
85
+ - `T x`, and `,` (`;` exists)
86
+ - `%`, `{` / `}`, `(` / `)`
87
+ - `H` / `L` (`M` is taken in vimlike), `#`
88
+ 4. **Doubled operators / other count commands**:
89
+ - `>>` / `<<` with counts (Visual `>` / `<` are now in vimlike too)
90
+ - `ctrl-x` (`ctrl-a` is now in vimlike, from the shared vim table)
91
+ - check that `3 r x`, `3 p` and `J` / `gJ` with counts apply the count correctly
92
+ 5. **Larger, already planned**: line-wise `V`, block `ctrl-v`, `o` / `gv` in Visual
93
+ mode, named registers (`"a`). See plan steps 4–5.
94
+
95
+ Groups 2–3 should be done through the operator layer (plan step 1), not as about 100
96
+ hand-written bindings. Where there's a choice, new vimlike bindings avoid alt-/ctrl-
97
+ chords. Each group needs tests (`keys("d 3 w")` + `assert_buf`), and the real-Vim differential
98
+ check where available.
99
+
100
+ ### Organize the "Show key bindings" page
101
+
102
+ Bindings like `[C] d i <char> : buf.text_object_op(:delete, <char>, :i)` land in
103
+ **Others**. With the vim or notepad scheme almost everything does, because the report's
104
+ sections are hardcoded to vimlike keywords. Plan: `doc/key_bindings_report_plan.md`.
105
+ It covers:
106
+ - structured binding records
107
+ - a fixed category list via `cat:` keywords, plus automatic categories for minor
108
+ modes and modules
109
+ - splitting vimlike's 205-binding `core` block
110
+ - grouping by mode in definition order
111
+ - a text-object table
112
+ - readable conditions
113
+ - a test that fails on uncategorized bindings
114
+
115
+ Depends on the "Descriptive names for key bindings" item above for the description
116
+ column.
117
+
118
+ ### Function panel shows nothing on the key bindings help page
119
+
120
+ The key bindings page (`show_key_bindings`) is a hyperplaintext buffer with `❙…❙` /
121
+ `◼ …` headings, which the function panel can outline (`FuncPanel#hyperplaintext_outline_entries`).
122
+ On this page it shows "(no file)" instead. Three causes (found 2026-11-19):
123
+
124
+ 1. **The `fname` guard runs first.** `FuncPanel#refresh` (`gui_func_panel.rb:50-53`)
125
+ returns "(no file)" for any buffer without a file name before it checks for
126
+ hyperplaintext. Generated buffers (`create_new_buffer`) have `fname = nil`.
127
+ 2. **The language is only set on the GTK side.** The report calls
128
+ `gui_set_file_lang(b.id, "hyperplaintext")` (`key_bindings_report.rb:15,70`), which
129
+ sets the GtkSource buffer's language but not `Buffer#lang`. So
130
+ `hyperplaintext_buffer?` (`buf.lang == "hyperplaintext" || fname.end_with?(".txt")`)
131
+ is false even without the guard. `Buffer#set_language` (`buffer.rb:195`) sets both.
132
+ 3. **Refresh runs too early.** `create_new_buffer` (`editor.rb:622-629`) makes the
133
+ buffer current, which triggers `func_panel_refresh` from `buffer_list.rb:133`,
134
+ *before* `set_content` and before the caller sets the language. Nothing refreshes
135
+ the panel afterwards (the only other triggers are a buffer switch and the manual
136
+ `:refresh_func_panel`).
137
+
138
+ The same problem affects the other generated buffers that use `gui_set_file_lang`:
139
+ - the free-bindings report (`key_bindings_report.rb:15`)
140
+ - the vim-conflicts report (markdown, `:259`)
141
+ - diff buffers (`diff_buffer.rb:110,184,210`)
142
+
143
+ Fix:
144
+ 1. In `refresh`, check for hyperplaintext before the `fname` guard (it only needs the
145
+ text), and keep "(no file)" just for the LSP path.
146
+ 2. Make the report and other generated-buffer callers use `buf.set_language(...)`
147
+ instead of `gui_set_file_lang`. Or make `gui_set_file_lang` also update
148
+ `Buffer#lang`, which fixes every caller at once.
149
+ 3. Refresh the panel when a buffer's language changes (in `set_language`), and after
150
+ `create_new_buffer` has set the content. A debounced refresh on text change
151
+ (like `file_panel_marks_changed`) would also keep the outline current while editing
152
+ `.txt` files.
153
+ 4. Optional: outline markdown (`#` headings) the same way, so the vim-conflicts
154
+ report, README.md and the `doc/*.md` files get an outline without LSP. This fits
155
+ with the markdown highlighting item.
156
+ 5. Test (`tests/test_func_panel.rb`): with the panel shown, run `:show_key_bindings`
157
+ and assert that the panel's store has a row for the "Key bindings" title and the
158
+ `◼` sections, and does not show "(no file)".
159
+
160
+ ### Single downloadable app (AppImage, later Flatpak)
161
+
162
+ Plan: `doc/bundling_plan.md`. AppImage is recommended: one file, and no sandbox, so
163
+ external tools keep working. It has to bundle relocatable Ruby, the gems, the GI
164
+ typelibs and the GTK/GStreamer/VTE libs, built on Ubuntu 24.04 (to match the tested GTK 4.14; see "GTK version differences"). Code fixes needed
165
+ first:
166
+ - `exe/vimamsa` puts CWD-relative `lib`/`ext` on the load path
167
+ - the dead `ext/stridx` path
168
+ - `Exec=` in `desktop_install.rb` has to point at `$APPIMAGE`
169
+ - `ruby-lsp` stays bundled for now; AppRun exposes a `ruby-lsp` binstub on `PATH`
170
+ Before the AppImage helps non-Ubuntu users (see "Running on non-Ubuntu distros" in the plan):
171
+ - a `cnf.terminal.command` setting with auto-detection, to replace the hardcoded `gnome-terminal`
172
+ - modules page install commands per distro (read from `/etc/os-release`)
173
+
174
+ ### Resettable test VM: occasional fresh-install runs
175
+
176
+ The test VM (`$VM_NAME`) isn't blank any more. It was provisioned once and has collected state from
177
+ every run since, so a fresh install is never tested. Plan:
178
+ `doc/vm_snapshots_plan.md`.
179
+ - two VirtualBox snapshots: `clean` (fresh 24.04 + Guest Additions) and
180
+ `provisioned`
181
+ - `run_tests_vm.rb` restores `provisioned` before every run
182
+ - it automatically does a fresh run from `clean` when install inputs change or
183
+ weekly, and then retakes `provisioned`
184
+
185
+ The `clean` baseline needs a newly installed VM (one-time, manual).
186
+
187
+ ### Start in insert mode (command stays the base), new buffers inherit the mode, esc toggle
188
+
189
+ Goal: easier for new users without giving up modal editing. Command mode stays the
190
+ **base** of the mode stack, so `to_previous_mode` (`key_binding_tree.rb:156`) and
191
+ Visual → command keep working. Only the mode a buffer *starts* in changes.
192
+
193
+ **Rule for a new buffer's start mode** (decided 2026-11-19):
194
+ - A new buffer starts in **the most recent of command/insert in the previous buffer**,
195
+ i.e. the buffer that was current when the new one was created. Use the topmost
196
+ `:command` or `:insert` in its mode stack, and skip transient modes (Visual,
197
+ replace, minor modes) above it. Examples:
198
+ - `[command, visual]` → command
199
+ - `[command, insert]` → insert
200
+ - `[command, insert, visual]` → insert (Visual entered from insert, e.g.
201
+ shift-arrows)
202
+ - `[command]` → command
203
+ - Read the live stack (`vma.kbd.default_mode_stack`), not the buffer's saved
204
+ `mode_stack`. The saved copy is only updated on a buffer switch
205
+ (`buffer_list.rb:116`) and on mode changes with buffer scope (`editor.rb:111`), so
206
+ it can be stale.
207
+ - Start in insert → the new buffer's stack is `[command, insert]`, so esc returns to
208
+ command as usual. Start in command → `[command]`.
209
+ - **Fallbacks:**
210
+ - The previous buffer is a special-mode buffer (grep, bookmarks, file manager,
211
+ buffer list: `@buf.default_mode = :grep/:bmark/:file_exp/:buf_mgr`, so its stack
212
+ has no command/insert), or the keyboard is in an editor-scope mode
213
+ (`get_scope == :editor`): use the mode of the most recently used *regular*
214
+ buffer.
215
+ - The first buffer at startup, or no regular buffer yet: the **remembered last
216
+ mode** (see below). Only when nothing is remembered yet (first run ever, or the
217
+ state file is missing) use `cnf.start_in_insert`. It defaults to on for new
218
+ installs and is written as off into existing installs' `settings.rb` on first
219
+ start after the upgrade, so current users see no change.
220
+ - Session restore: all restored buffers get the startup mode, and the buffer that
221
+ becomes current decides what comes next.
222
+ - **Remembered across restarts** (decided 2026-11-19): the last command/insert mode
223
+ (the same "topmost command or insert" value the inheritance rule uses, taken from
224
+ the last *regular* buffer) is saved and used as the start mode at the next startup.
225
+ - Store it in the **data dir** (`get_data_path`, `editor.rb:776`), like the window
226
+ layout. `marshal_save` / `save_var_to_file` (`editor.rb:345-364`) currently write
227
+ to `get_dot_path` (the config dir), so either give them a data-dir variant or put
228
+ the value into the same state file as the layout.
229
+ - Save it in `Editor#save_state` / `shutdown` (`editor.rb:388-391`, next to
230
+ `save_window_layout`) **and** when the command/insert value changes, so it
231
+ survives a crash. Saving only on change keeps writes rare: one per mode toggle,
232
+ not per key.
233
+ - Ignore transient and special modes when saving. Leaving the editor in Visual
234
+ mode or with the grep buffer current stores the underlying command/insert of the
235
+ last regular buffer.
236
+ - One global value, not per file. (Per-buffer modes for session-restored buffers
237
+ could come later through `session.txt`.)
238
+ - Test mode (`vma_test_mode?`) neither reads nor writes it, as with the layout. A
239
+ corrupt or unknown value is ignored and falls back to `cnf.start_in_insert`.
240
+ - **Exempt buffers** keep their own mode: generated pages (key bindings help,
241
+ free-bindings and vim-conflicts reports, diffs, shell-command output,
242
+ `filelinks`) start in command, so a stray key can't edit them and `enter` still
243
+ follows links. Special-mode buffers keep their `default_mode`. Mark them with a
244
+ `create_new_buffer(..., start_mode: :command)` argument, or by the callers that
245
+ set `default_mode`.
246
+ - **Switching** to an existing buffer restores its own saved mode, as now. The
247
+ inheritance rule applies to *new* buffers only. Opening an already-open file is a
248
+ switch, not a new buffer.
249
+ - Implementation point: `Buffer#initialize` sets `@mode_stack = [@default_mode]`
250
+ (`buffer.rb:31-32`). Compute the start stack there (or in `create_new_buffer` /
251
+ the open-file path) through a helper such as `vma.kbd.inherited_start_mode`, and
252
+ apply it when the buffer becomes current.
253
+
254
+ **Esc toggles command → insert** (`cnf.esc_toggles_insert`):
255
+ - In Vim, esc in normal mode only cancels a pending command or count, and otherwise
256
+ does nothing (at most a beep). `C esc` is unbound in vimlike and vim today.
257
+ Vimlike already has the same toggle on a ctrl tap (`"C ctrl!" => :insert_mode`,
258
+ `"I esc || I ctrl!" => :prev_mode`, `key_bindings_vimlike.rb:78,83`).
259
+ - **The second esc in a row does nothing**, so `esc esc` (Vim users' "make sure I'm
260
+ in command mode") always ends in command mode. It's a deterministic rule, not a
261
+ timeout.
262
+ - Esc with a pending count (`3 esc`) only clears the count. Esc mid-sequence
263
+ (`, esc`) only cancels, as now (no matching child → back to root,
264
+ `key_binding_tree.rb:592-606`).
265
+ - On in vimlike (and notepad, where it's moot). **Never in the `vim` scheme**, which
266
+ must behave like Vim.
267
+ - The current mode must be clearly visible (cursor shape/color *and* a mode label).
268
+ Check that the label is prominent enough once modes toggle.
269
+
270
+ **Tests:**
271
+ - The harness forces command mode before each test (`test_framework.rb:124`), so
272
+ existing tests are unaffected.
273
+ - New tests:
274
+ - inheritance from `[command]`, `[command, insert]`, `[command, visual]` and
275
+ `[command, insert, visual]`
276
+ - fallback from a special-mode buffer
277
+ - generated pages start in command
278
+ - switching restores the saved mode
279
+ - `esc` toggles, `esc esc` ends in command, `3 esc` clears the count
280
+ - Visual → esc → esc
281
+ - in the vim scheme `esc` does nothing
282
+ - `cnf.start_in_insert` off reproduces today's behavior
283
+ - the remembered mode round-trips: save insert → "restart" (reload the state) →
284
+ first buffer starts in insert. A remembered value wins over
285
+ `cnf.start_in_insert`. A missing or corrupt file falls back to the setting.
286
+ Visual/special modes at shutdown store the underlying command/insert.
287
+
288
+ ### Help panel: the ~20 most important key bindings, shown by default for new users
289
+
290
+ A small side panel that lists the essential bindings for the **active scheme**. It
291
+ opens by default for new users and closes with a click (× button). The full list
292
+ stays on Help ▸ Show key bindings, which today is bound to `C , ; s k`. That's hard to
293
+ find, which is part of why this panel is needed.
294
+
295
+ Comments / design decisions:
296
+ - **Content is derived, not hardcoded.** Use a curated list of ~20 action symbols
297
+ (the same `BASIC_ACTIONS` list proposed in `doc/key_bindings_report_plan.md`, so the
298
+ panel and the "Basics" section of the full page agree). Look up their keys in the
299
+ live tree (`KeyBindingTree#act_bindings[mode][action]`, `key_binding_tree.rb:89,799`).
300
+ That way the panel is right for vimlike, vim and notepad, and for rebinds in
301
+ `custom.rb`. Actions with no binding in the active scheme are left out.
302
+ - List for vimlike, grouped (revised 2026-11-19):
303
+ - **Modes**: **`ctrl` (tap: press and release alone)**, the main way to switch:
304
+ command → insert (`"C ctrl!" => :insert_mode`), insert → command
305
+ (`"I ctrl!"`, `:prev_mode`), visual → command (`"V ctrl!"`). Then `esc`
306
+ command, `v` visual. (`i` is not listed: ctrl covers entering insert mode.) Show `ctrl` first and explain "tap" in the label,
307
+ since `ctrl!` notation means nothing to new users.
308
+ - **Moving** (command/visual): `h` `j` `k` `l` left / down / up / right, `w` next
309
+ word, `b` previous word
310
+ - **Files**: `ctrl-s` save, `ctrl-w` close, `, n b` new. File finding (`, f`,
311
+ `, h`, `, b`) is left out: menus and the file panel cover it, and the full page
312
+ lists it.
313
+ - **Editing** (command): `u` undo, `ctrl-r` redo, `x` delete char, `d d` delete
314
+ line, `y y` copy line, `p` paste
315
+ - **Selection** (visual): `d` delete, `y` copy
316
+ - **Search**: `/` find, `s` easy-jump
317
+ - **Help**: `, , s` search actions, `, ; s k` all key bindings
318
+ - **Quit**: `Q`
319
+
320
+ That's about 25 keys in about 20 rows: `h j k l` is one row, `w b` one row, and
321
+ the three `ctrl` tap directions one row.
322
+ - `l` was bound to a Ruby string (`buf.move(FORWARD_CHAR)`), which the
323
+ action-symbol lookup can't find. Fixed 2026-11-19 (`374cca1`): `"VC l"` now uses the existing
324
+ `:e_move_forward_char` in vimlike and vim. All the moving keys (`h j k l w b`) are
325
+ named actions now.
326
+
327
+ Labels come from the action descriptions (see the "Descriptive names" item), with
328
+ the keys shown as keycaps.
329
+ - **Mode-aware.** The top line shows the current mode in large text ("INSERT — type
330
+ normally, esc for commands" / "COMMAND — keys run commands, i to type"). The
331
+ group for the current mode is highlighted, and it updates on mode change. That
332
+ makes the panel the prominent mode indicator the start-in-insert / esc-toggle
333
+ item asks for.
334
+ - **Rows are clickable** and run the action (`call_action`). That helps new users
335
+ and means the panel is useful even before they learn the keys. The panel must
336
+ **not take keyboard focus** (`focusable = false` on its widgets), so typing always
337
+ goes to the editor. The e2e tests depend on that too.
338
+ - **Placement**: a right-side panel built like the key log panel, which wraps
339
+ `@minibuf_vpane` at the grid level, independent of the file/func panel and
340
+ two-column nesting (`gui.rb:1264-1300`). Narrow, about 220 px, and scrollable.
341
+ Not an overlay on the text, which would cover code. If both are open, the key log
342
+ panel and the help panel share the right side (stack them, or let showing one
343
+ hide the other).
344
+ - **Open by default only for new users.** Shown when there's no saved state (new
345
+ install). Closing it saves `help_panel_closed` once, globally (not per screen
346
+ resolution), together with the window/view layout state in the data dir
347
+ (`save_window_layout`), and it stays closed from then on. Existing installs get it
348
+ closed by default, using the same settings migration as `cnf.start_in_insert`.
349
+ Option: show it again once after a major version upgrade that changes bindings.
350
+ - **Reopening** must be easy to find: Help ▸ "Show help panel", a View-menu toggle
351
+ next to the other panels, and an action for Search for Actions. Add a vimlike
352
+ binding in the `, ;` help prefix without modifier chords, e.g. `, ; h`; check it's
353
+ free with Show free key bindings. The panel's footer says "Reopen: Help ▸ Show help
354
+ panel".
355
+ - Footer link: "All key bindings…" opens the full page (`show_key_bindings`).
356
+ - Test mode (`vma_test_mode?`) never auto-opens it, like the other panels.
357
+
358
+ Tests:
359
+ - In each scheme, the panel's rows resolve to non-empty keys and descriptions. No
360
+ raw Ruby is shown.
361
+ - Closing persists (reload the state → stays closed). A new state shows it.
362
+ - Clicking a row runs its action. Typing after a click still goes to the buffer.
363
+ - The mode header follows `esc` / `i`.
364
+
365
+ Depends on / ties in with:
366
+ - "Descriptive names for key bindings" (labels)
367
+ - "Organize the Show key bindings page" (`BASIC_ACTIONS`)
368
+ - "Start in insert mode" (mode indicator)
369
+ - the layout persistence in DONE
370
+
371
+ ### Modules page and module extraction
372
+
373
+ See `doc/modules_settings_plan.md`.
374
+
375
+ ### Consistent, hierarchical action names
376
+
377
+ Action ids are ad hoc. They mix verb-first and noun-first names, use implementation
378
+ prefixes (`gui_`, `vim_`, `e_`, `V_`), contain duplicates (`undo` / `edit_undo`,
379
+ `move_next_line` / `forward_line`, …) and use inconsistent words (forward / next,
380
+ buf / buffer). Plan: `doc/action_names_plan.md`.
381
+ - dotted ids, from general to specific: `move.word.next`, `buf.close`, `sel.copy`
382
+ - an `a` proxy like `cnf`: `bindkey "C w", a.move.word.next`, and `a.buf.save!` runs an action
383
+ - namespaces map onto the key bindings report categories
384
+ - `ACTION_ALIASES` keep the old ids working in `custom.rb` and in saved macros
385
+ - `Action#path` replaces the unused `:group` option
386
+
387
+ ### Tab completes file names on the command line
388
+
389
+ `:!cat /proc/cpu<tab>` should complete to `:!cat /proc/cpuinfo`. Today the command
390
+ line (`lib/vimamsa/gui_command_line.rb`) handles only Escape, Up and Down. Tab
391
+ does nothing useful.
392
+ - Complete the word before the cursor as a path: absolute, `~/…`, or relative to the
393
+ current buffer's directory (or the working directory for unsaved buffers).
394
+ - A single match is completed in place, with `/` added for a directory. Several
395
+ matches complete to their longest common prefix. A second Tab lists them, in the
396
+ message area or a small popup.
397
+ - Works for `:!cmd` and `:e`, and anywhere a word looks like a path. Escape spaces,
398
+ or quote the path, as the shell needs.
399
+ - Later: complete command names after `:!` from `$PATH`, and action ids after
400
+ `:a.` (`doc/action_names_plan.md`).
401
+ - Test: in a temp directory with `foo_one`, `foo_two` and `bar/`, `:e ba<tab>` gives
402
+ `bar/`, and `:e fo<tab>` gives `foo_`.
403
+
404
+ ### Keymap syntax that isn't Ruby code (`map` strings and keymap files)
405
+
406
+ Declare keymaps in a plain text format, one binding per line, instead of Ruby hashes:
407
+
408
+ ```
409
+ # today (key_bindings_vimlike.rb)
410
+ "C z " => "mode.browse",
411
+
412
+ # keymap file
413
+ C z mode.browse
414
+ VC l move.char.next
415
+ C d <num> e edit.delete.word_end
416
+ ```
417
+
418
+ The last token is the action id; everything before it is the mode and the keys, in
419
+ the notation used today. This depends on the dotted ids from
420
+ `doc/action_names_plan.md`: an id always contains a `.`, so it can't be mistaken for
421
+ a key name.
422
+ - The same syntax works in two places:
423
+ - **In Ruby, as a multiline string passed to `map`**, so it can sit in the scheme
424
+ files, in modules and in `custom.rb`:
425
+
426
+ ```ruby
427
+ map <<~KEYS
428
+ [motion]
429
+ VC h move.char.prev
430
+ VC l move.char.next
431
+ C z mode.browse
432
+ KEYS
433
+ ```
434
+ - **In separate files** (optional), such as `keymaps/vimlike.keys`, or a user file in
435
+ the config dir that is loaded after the scheme. This lets users rebind keys without
436
+ writing Ruby. Loading a file is just `map(File.read(path))`, with the file name
437
+ used in error messages.
438
+ - Lines starting with `#` are comments. A section line such as `[motion]` sets the
439
+ category for the lines below it (`doc/key_bindings_report_plan.md`).
440
+ - Conditions (today `I tab(vma.buf.view.autocp_active)`) become named conditions
441
+ defined in Ruby: `I tab edit.complete.next when completion_open`.
442
+ - Key sets for operators and motions (`doc/vim_compatibility_plan.md`, step 1) need a
443
+ block syntax, e.g. `set op` … `end`, plus template lines like `C <op> <motion>
444
+ operator.motion`.
445
+ - No Ruby code in the keymap syntax. The Ruby-string bindings get named actions first (the
446
+ "Descriptive names for key bindings" item).
447
+ - The parser reports errors with file and line: an unknown action, an unknown key
448
+ name, a mode that doesn't exist. For a `map` string, the line is the calling
449
+ file's line plus the offset inside the string (`caller_locations`).
450
+ - Parse into the same `add_keys` / `bindkey` calls, so the tree, the conflict
451
+ report and the tests don't change. A test checks that the `map` version of a
452
+ scheme gives the same tree as the `add_keys` hashes it replaces.
453
+
454
+ ### Git functions as a separate module
455
+
456
+ Move the git features into `modules/git/`: "Show git diff" of the current file
457
+ (`buf.diff.git`, `git_diff_buffer`) and of the whole repo (`file.diff.repo`, `git_diff_w`).
458
+ Both are in `lib/vimamsa/diff_buffer.rb` today.
459
+
460
+ Stays in core:
461
+ - the diff view: the `diffview` minor mode, `DiffLineMapper`, jump to source, and the
462
+ unsaved-changes diff (`buf.diff`, which uses plain `diff`)
463
+ - project-root detection by a `.git` directory (`editor.rb:823`). It only looks for a
464
+ marker and doesn't run git.
465
+
466
+ Changes needed in the module interface (checked 2026-11-20):
467
+ - **Default on.** Modules are off unless `cnf.modules.<name>.enabled` is set. Only
468
+ `color_highlight` gets a default, hardcoded in core (`conf.rb:165`). Git diff is an
469
+ existing feature, so add `default_enabled: true` to `_info` and drop the hardcoded
470
+ default.
471
+ - **Menu entries anywhere.** `gui_menu.rb:57-58` hardcodes the git items under
472
+ Actions ▸ experimental. Modules can only add items to the top-level Modules menu
473
+ (`add_module_action`). Let a module add items to any menu path, and remove them in
474
+ `<name>_disable`.
475
+ - **Core code that knows about git.** `Buffer#git_root` and `resolve_diff_path`, which
476
+ runs `git rev-parse` itself, are git-specific. Replace them with a generic
477
+ `diff_base_dir` (the directory that relative `a/` and `b/` paths in a diff are
478
+ relative to). The module sets it when it creates the diff buffer.
479
+ - **A public diff view API.** The module has to open a diff buffer in diff view
480
+ without copying core code. Something like `open_diff_buffer(text, name, base_dir:)`,
481
+ which does what `create_new_buffer` + `gui_set_file_lang("diff")` + `diffview` do
482
+ today.
483
+ - **Actions of a disabled module.** Today they give "Unknown action". Instead, say
484
+ "enable the git module (Settings ▸ Modules)". For this, `_info` lists the module's
485
+ action ids (`actions: ["git.diff.buf", "git.diff.repo"]`). This also lets the
486
+ `ACTION_ALIASES` entries (`git_diff_buffer` → …) point to module actions. The alias
487
+ test then allows an alias whose target belongs to a module.
488
+ - **Requirements.** The `git` executable, through the `requirements:` key from
489
+ `doc/modules_settings_plan.md`. Check it with `which git`.
490
+ - **Tests.** `tests/test_diff_buffer_name.rb` calls `git_diff_buffer` directly. Add a
491
+ test helper that loads and initializes a module for one test (`with_module(:git)`),
492
+ so module tests don't depend on the user's settings.
493
+
494
+ Renames (with aliases): `buf.diff.git` → `git.diff.buf`, `file.diff.repo` →
495
+ `git.diff.repo`. Later candidates for the module: blame, log of the current file,
496
+ stage the current file.
497
+
498
+ ### Open links in Markdown files, as with hpt `⟦…⟧` links
499
+
500
+ Enter (`handle_line_action`) on a link in a `.md` file should open it, as it does
501
+ for hyperplaintext links `⟦file⟧`. For example `[vimlike_vim_conflicts.md]` or
502
+ `[the report](vimlike_vim_conflicts.md)` in `doc/vim_compatibility_plan.md`.
503
+
504
+ Why it fails today (`Buffer#get_cur_nonwhitespace_word`, `buffer.rb:1514`):
505
+ - The word under the cursor is cut at white space, so it keeps the brackets:
506
+ `[vimlike_vim_conflicts.md](vimlike_vim_conflicts.md)`. That's not an existing
507
+ file, a URL, a `file:line` pointer or a `⟦…⟧` link.
508
+ - A relative path resolves against `bufs.last_dir`, not the directory of the file
509
+ that contains the link. `hpt_check_cur_word` does use the buffer's directory.
510
+ - In `[link text](target)`, the cursor is often on the link text, which may contain
511
+ spaces, so the target isn't in the "word" at all.
512
+
513
+ To do:
514
+ - Recognize the Markdown link forms around the cursor on the current line (not by
515
+ white-space word):
516
+ - `[text](target)` and `[text](target "title")`, with the cursor anywhere on it
517
+ - `<https://…>` autolinks
518
+ - `[text][ref]` and `[ref]` with a `[ref]: target` definition in the file
519
+ - a bracketed file name `[name.md]` that exists next to the file, as in the
520
+ example above
521
+ - Resolve relative targets against the file's directory, like `hpt_check_cur_word`.
522
+ - `target#anchor`: open the file and jump to the heading whose GitHub-style slug
523
+ matches.
524
+ - Then dispatch as now: text file → open it, URL → browser, other file →
525
+ default program (`handle_word`). Also offer it in the context menu.
526
+ - Maybe share this with `file_path_at` (`buffer.rb:1561`), which already strips
527
+ surrounding brackets and punctuation for the hover/open-file check.
528
+ - Tests: Enter on each form in a temp `.md` file opens the right file and line.
529
+
530
+ ### WYSIWYG editing: rich text with hidden markup
531
+
532
+ Bold, italic and font size shown as formatting, with the markup hidden in the file
533
+ and shown only on request ("Show markup"). The buffer holds only the visible text,
534
+ the formatting is a separate span model mirrored to GtkTextView tags, and the hpt
535
+ markers are the file format. Plan: `doc/wysiwyg_plan.md`.
536
+
537
+ ### Changesets as the change format
538
+
539
+ Replace the `[pos, op, len, text]` delta arrays with OT-style changesets (`retain` /
540
+ `delete` / `insert`, with optional attributes), as in CodeMirror and Quill. They give
541
+ one `map_pos` for every position-based structure, composed undo groups, formatting
542
+ changes for WYSIWYG, and later `transform` for multiple cursors. Decided 2026-11-21.
543
+ Plan: `doc/delta_syntax_plan.md`.
544
+
545
+ ### Performance: line ends and UTF-8 indexing in large files
546
+
547
+ Measured 2026-11-21 in plain Ruby 3.4, ~55-character lines. Fixed already:
548
+ `scan_indexes` (O(n^2) on non-ASCII text: 13 s → about 0.1 s for 5.5 MB) and
549
+ `get_line_end` (`select` → `bsearch`). See DONE.
550
+
551
+ Still open:
552
+ - **`update_line_ends` shifted every later line end on each edit.** Done: `@line_ends`
553
+ is now a treap of lines (`LineTree`, see DONE and `doc/line_tree_plan.md`).
554
+ Follow-up: loops over all lines (`fold.rb`'s fold search) call `[i]` per line,
555
+ which is now O(log n) each. Walk the tree in order there if it shows up in
556
+ profiles.
557
+ - **UTF-8 character indexing.** Ruby strings have no character index. Once a buffer
558
+ contains one non-ASCII character, every `self[pos]`, `insert` and `slice!` scans from
559
+ the start. That's 0.5 ms each at 5.5 MB, versus 0.002 ms for ASCII-only text. Motions
560
+ and syntax checks make many such calls per keystroke.
561
+ - First profile typing and moving around in a large non-ASCII file in the real editor
562
+ (`perf`, or `ruby-prof`) to see whether this dominates.
563
+ - If it does, the options are:
564
+ - a checkpoint index: character → byte offset every ~4 KB, updated through a
565
+ Fenwick tree, used for `byteslice` access
566
+ - a rope: a balanced tree of chunks with character counts per node. This changes
567
+ the `Buffer < String` model, so it's a last resort.
568
+ - The GTK side needs nothing: `GtkTextBuffer` is already a B-tree.
569
+
570
+ ### Replace complicated shell scripts with Ruby scripts
571
+
572
+ The longer scripts have outgrown bash: env-var parsing, error handling, quoting,
573
+ retries and many steps. Port them to Ruby. Ruby is already the project language,
574
+ so testing and sharing helpers between scripts gets easier.
575
+
576
+ Candidates (lines as of 2026-11-20):
577
+ - ~~`run_tests_vm.sh` (130): host side~~: done, now `run_tests_vm.rb` (see DONE).
578
+ - `vm_guest_run.sh` (120): guest side; provisioning, gem build, test run
579
+ - `scripts/appimage/build_in_container.sh` (192): the AppImage build
580
+
581
+ Keep as shell:
582
+ - small wrappers: `run_e2e_vm.sh`, `scripts/appimage/build.sh`,
583
+ `scripts/appimage/smoke_test.sh`, `install.sh`, `docker_cmd.sh`
584
+
585
+ Constraints:
586
+ - **Bootstrap without Ruby.** A clean VM (the `clean` snapshot) has no Ruby, and
587
+ `vm_guest_run.sh` is what installs it (`apt-get install ruby ruby-dev …`). So
588
+ keep a few lines of shell that install Ruby if it's missing and then `exec`
589
+ the `.rb` script.
590
+ - Same for the AppImage container: the Dockerfile installs no system Ruby, and the
591
+ script builds the bundled Ruby itself. Either add `ruby` to the Dockerfile for the
592
+ build script only (it must not leak into the AppDir), or keep the steps before
593
+ the Ruby build in shell.
594
+ - Use only the standard library (`open3`, `fileutils`, `optparse`); no gems,
595
+ because they aren't installed yet when the script runs.
596
+ - Keep the same interface: env vars (`VM_NAME`, `VM_USER`, `VM_PASS`, `VM_DISPLAY`,
597
+ `FORCE_PROVISION`, `VMA_TEST_ARGS`, `VMA_REF`, `RUBY_VERSION`), the arguments, and the exit codes
598
+ (the suite's 0/1, 2 for missing variables). Never print `VM_PASS`.
599
+ - Shared helpers (run a command and echo `>>` steps, fail with a message) go in
600
+ `scripts/lib/`.
601
+ - Update the references in `CLAUDE.md`, `doc/vm_snapshots_plan.md` and
602
+ `doc/bundling_plan.md`.
603
+ - Check each port with a full VM run (`run_tests_vm.rb`) or an AppImage build plus its smoke test.
604
+
605
+ ## DONE
606
+
607
+ Format: `- **Item title** (2026-MM-DD, `abc1234`[..`def5678`]): one or two lines on what was changed.`
608
+
609
+ - **XDG dirs instead of `~/.vimamsa`** (2026-11-22, uncommitted): generated files
610
+ (session, buffer list, command and file history, file index, recorded macros,
611
+ backups, crash reports, listen dir) go in `~/.local/share/vimamsa`; config stays in
612
+ `~/.config/vimamsa` (`$XDG_DATA_HOME` / `$XDG_CONFIG_HOME` honored). `--user-dir`
613
+ keeps both in one dir. The old files move once at start (`user_dirs.rb`). Tests in
614
+ `tests/test_user_dirs.rb`, one of which fails on any fixed `~/.vimamsa` path.
615
+
616
+ - **Introduction page for first-time users** (2026-11-21, `6448bb9`): shown on
617
+ the first start, from Help ▸ Introduction, with `:intro` or with `--intro`. It has
618
+ inline buttons that start the demos, key names taken from the bindings, and a
619
+ one-screen "Vimamsa for Vim users" page, plus a demo dropdown above the key log.
620
+ `doc/intro_page_plan.md`.
621
+
622
+ - **Switching files demo** (2026-11-21, `9399229`): Help ▸ Demos ▸ Switching files
623
+ (`scripts/demo/demo_files_steps.txt`, on shapes.rb, report.rb and notes.txt): tab,
624
+ browse mode h / l, and the file explorer (`, f`, then k / j and l). Demos can have
625
+ several files, and a demo folder of their own.
626
+ - **Easy jump label feedback** (2026-11-21, `2125c34`): after the first key, matching
627
+ labels show it bright yellow and bold, and the others are dimmed. The chosen label
628
+ stays 0.15 s after the others go. `cnf.easy_jump.glow` (off: without a GPU it made
629
+ easy jump about 60% slower). Tests in `tests/test_easy_jump.rb`.
630
+ - **Key hint below the row** (2026-11-21, `fef2d63`): `cnf.key_hint.y_offset` px
631
+ below the cursor's row (above it if no room), right of the text it covers.
632
+
633
+ - **Demo player: loop, pause, speed, demos menu** (2026-11-21, `19e528c`): Help ▸
634
+ Demos ▸ Basic editing / Easy jump (`scripts/demo/demo_easyjump_steps.txt`: moves
635
+ `to_s` with v + easy jump, x, P). A demo loops, with the file restored, until
636
+ stopped. Buttons above the key log (Pause/Continue, −, +), ✕ closes the key log
637
+ (stopping the demo); actions `help.demo.pause` / `.faster` / `.slower` / `.stop` /
638
+ `.easyjump`. Tests in `tests/test_demo_player.rb`.
639
+ - **Key hint next to the cursor** (2026-11-21, `19e528c`): while the key log is
640
+ shown, a see-through bubble with a dashed border, right of the end of the cursor's
641
+ line, shows the current mode (badge colors), the last key and action, then fades
642
+ (`gui_key_hint.rb`). The key log is cleared at the start of each demo round. Easy
643
+ jump labels are logged too (`log_jump_label`). Tests in `tests/test_keylog_panel.rb`.
644
+
645
+ - **`run_tests_vm.sh` ported to Ruby** (2026-11-21, `ac4251a`): `run_tests_vm.rb`, same env
646
+ vars, arguments, steps and exit codes, standard library only; shared helpers in
647
+ `scripts/lib/script_helpers.rb`. `run_e2e_vm.sh` and the docs point to it.
648
+
649
+ - **Resized window after maximize restored** (2026-11-21, `36c04d3`): GNOME's auto-maximize
650
+ maximized a restored window that covers most of the screen, which was then saved
651
+ as maximized. `VMAgui#undo_auto_maximize` unmaximizes it to the saved size.
652
+ Test: `test_resized_after_maximize_restored` in `tests/test_window_layout.rb`.
653
+
654
+ - **Line ends in a treap** (2026-11-21, `96234a8`): `@line_ends` is a
655
+ `LineTree` (`lib/vimamsa/line_tree.rb`), an implicit treap with one node per line
656
+ (length, random priority, subtree line and character counts). It answers the Array
657
+ methods the code used (`size`, `[i]`, `bsearch_index`, `bsearch`), so no call site
658
+ changed. An edit costs about 0.005 ms at 100k lines, down from 6.3 ms, and lookups
659
+ about 0.004 ms. Plan: `doc/line_tree_plan.md`. Tests: `tests/test_line_tree.rb`.
660
+
661
+ - **Fast line ends for non-ASCII text** (2026-11-21, `57d3030`): `scan_indexes`
662
+ (`string_util.rb`) counts characters only between consecutive matches, using byte
663
+ offsets, instead of calling `MatchData#begin`, which counts from the start of the
664
+ file each time. Loading the line ends of a 5.5 MB file with one non-ASCII character
665
+ went from 13 s to about 0.1 s. `get_line_end` uses `bsearch` instead of `select`.
666
+ Tests: `tests/test_line_ends.rb`.
667
+
668
+ - **Restore window geometry and view layout on startup** (2026-11-18, `99cd484`): window
669
+ size/maximized, file/func/keylog panels with widths, two-column split and file, and
670
+ minibuffer history height are saved per screen resolution (last 5) in the data dir
671
+ and fitted to the current monitor on start. `idle_set_size` replaced by one
672
+ `set_default_size` before show. Off in test mode or with `cnf.restore_layout = false`.
673
+ Not yet checked in the VM: switching the guest resolution between runs.
674
+ - **Markdown (`.md`) syntax highlighting shows almost nothing with the bundled schemes**
675
+ (2026-11-19, `7a92079`): `markup_overlay_styles` (`gui_settings.rb`) adds `def:heading`,
676
+ `def:inline-code`, `def:link-text`, … to the generated overlay where the base scheme
677
+ lacks them, colored from its keyword/string/comment/hyperlink styles. Optional step 2
678
+ (hand-picked colors in `molokai_edit.xml`) not done.