vimamsa 0.1.26 → 0.1.27

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 (170) 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 +62 -16
  6. data/custom_example.rb +43 -13
  7. data/doc/TODO.md +461 -0
  8. data/doc/bundling_plan.md +569 -0
  9. data/doc/key_bindings_report_plan.md +168 -0
  10. data/doc/missing_vim_bindings.md +71 -0
  11. data/doc/modules_settings_plan.md +433 -0
  12. data/doc/refactor_dedup_plan.md +117 -0
  13. data/doc/unused_code_plan.md +120 -0
  14. data/doc/vim_compatibility_plan.md +296 -0
  15. data/doc/vimlike_vim_conflicts.md +254 -0
  16. data/doc/vm_snapshots_plan.md +146 -0
  17. data/exe/run_tests.rb +117 -3
  18. data/exe/vimamsa +24 -4
  19. data/fonts/OFL-Oxanium.txt +93 -0
  20. data/fonts/Oxanium[wght].ttf +0 -0
  21. data/icon.png +0 -0
  22. data/img/demo.gif +0 -0
  23. data/lang/hyperplaintext.lang +6 -0
  24. data/lib/vimamsa/ack.rb +11 -1
  25. data/lib/vimamsa/actions.rb +4 -1
  26. data/lib/vimamsa/appimage_env.rb +35 -0
  27. data/lib/vimamsa/audio.rb +2 -5
  28. data/lib/vimamsa/bookmarks.rb +302 -0
  29. data/lib/vimamsa/buffer.rb +593 -82
  30. data/lib/vimamsa/buffer_changetext.rb +102 -42
  31. data/lib/vimamsa/buffer_cursor.rb +7 -0
  32. data/lib/vimamsa/buffer_list.rb +4 -0
  33. data/lib/vimamsa/buffer_manager.rb +4 -1
  34. data/lib/vimamsa/bundled_fonts.rb +32 -0
  35. data/lib/vimamsa/clipboard.rb +3 -0
  36. data/lib/vimamsa/conf.rb +59 -3
  37. data/lib/vimamsa/constants.rb +3 -0
  38. data/lib/vimamsa/crash_handler.rb +149 -0
  39. data/lib/vimamsa/debug.rb +4 -1
  40. data/lib/vimamsa/desktop_install.rb +96 -0
  41. data/lib/vimamsa/diff_buffer.rb +39 -10
  42. data/lib/vimamsa/easy_jump.rb +3 -0
  43. data/lib/vimamsa/editor.rb +263 -57
  44. data/lib/vimamsa/encrypt.rb +78 -29
  45. data/lib/vimamsa/file_finder.rb +4 -19
  46. data/lib/vimamsa/file_history.rb +3 -0
  47. data/lib/vimamsa/file_manager.rb +30 -15
  48. data/lib/vimamsa/fold.rb +226 -0
  49. data/lib/vimamsa/gui.rb +520 -106
  50. data/lib/vimamsa/gui_command_line.rb +208 -0
  51. data/lib/vimamsa/gui_dialog.rb +94 -42
  52. data/lib/vimamsa/gui_file_panel.rb +356 -25
  53. data/lib/vimamsa/gui_form_generator.rb +59 -35
  54. data/lib/vimamsa/gui_func_panel.rb +67 -22
  55. data/lib/vimamsa/gui_image.rb +3 -0
  56. data/lib/vimamsa/gui_keylog_panel.rb +246 -0
  57. data/lib/vimamsa/gui_menu.rb +23 -11
  58. data/lib/vimamsa/gui_select_window.rb +19 -48
  59. data/lib/vimamsa/gui_settings.rb +78 -37
  60. data/lib/vimamsa/gui_sourceview.rb +273 -19
  61. data/lib/vimamsa/gui_sourceview_autocomplete.rb +319 -90
  62. data/lib/vimamsa/gui_text.rb +63 -2
  63. data/lib/vimamsa/gui_theme.rb +606 -0
  64. data/lib/vimamsa/hook.rb +3 -0
  65. data/lib/vimamsa/hyper_plain_text.rb +3 -0
  66. data/lib/vimamsa/key_actions.rb +112 -13
  67. data/lib/vimamsa/key_binding_tree.rb +242 -215
  68. data/lib/vimamsa/key_bindings_notepad.rb +43 -0
  69. data/lib/vimamsa/key_bindings_report.rb +261 -0
  70. data/lib/vimamsa/key_bindings_vim.rb +354 -0
  71. data/lib/vimamsa/key_bindings_vimlike.rb +65 -9
  72. data/lib/vimamsa/langservp.rb +271 -54
  73. data/lib/vimamsa/macro.rb +3 -0
  74. data/lib/vimamsa/main.rb +14 -8
  75. data/lib/vimamsa/rbvma.rb +26 -1
  76. data/lib/vimamsa/search.rb +3 -0
  77. data/lib/vimamsa/search_replace.rb +11 -10
  78. data/lib/vimamsa/string_util.rb +120 -40
  79. data/lib/vimamsa/terminal.rb +3 -0
  80. data/lib/vimamsa/test_framework.rb +28 -2
  81. data/lib/vimamsa/tests.rb +3 -0
  82. data/lib/vimamsa/text_objects.rb +353 -0
  83. data/lib/vimamsa/text_transforms.rb +14 -0
  84. data/lib/vimamsa/util.rb +46 -7
  85. data/lib/vimamsa/version.rb +1 -1
  86. data/lib/vimamsa.rb +0 -1
  87. data/modules/color_highlight/color_highlight.rb +118 -0
  88. data/modules/color_highlight/color_highlight_info.rb +3 -0
  89. data/modules/dictation/dictation.rb +1054 -0
  90. data/modules/dictation/dictation_info.rb +3 -0
  91. data/modules/dictation/whisper_worker.py +273 -0
  92. data/modules/ollama/ollama.rb +107 -0
  93. data/modules/ollama/ollama_info.rb +3 -0
  94. data/modules/tts/tts.rb +119 -0
  95. data/modules/tts/tts_info.rb +3 -0
  96. data/run_e2e_vm.sh +28 -0
  97. data/run_tests_vm.sh +130 -0
  98. data/scripts/appimage/AppRun +54 -0
  99. data/scripts/appimage/Dockerfile +18 -0
  100. data/scripts/appimage/build.sh +19 -0
  101. data/scripts/appimage/build_in_container.sh +192 -0
  102. data/scripts/appimage/smoke_test.sh +27 -0
  103. data/scripts/demo/demo_steps.txt +59 -0
  104. data/scripts/demo/record_demo.rb +177 -0
  105. data/scripts/demo/shapes.rb +28 -0
  106. data/styles/134272-molokai.xml +3 -0
  107. data/styles/molokai_cyber.xml +48 -0
  108. data/styles/molokai_edit.xml +1 -0
  109. data/tests/support/virtual_keyboard.rb +254 -0
  110. data/tests/support/virtual_mic.rb +67 -0
  111. data/tests/test_ack.rb +22 -0
  112. data/tests/test_auto_format.rb +122 -0
  113. data/tests/test_autocomplete.rb +211 -0
  114. data/tests/test_autosave.rb +145 -0
  115. data/tests/test_basic_editing.rb +33 -3
  116. data/tests/test_bookmarks.rb +206 -0
  117. data/tests/test_bracket_match.rb +85 -0
  118. data/tests/test_bundling.rb +92 -0
  119. data/tests/test_color_highlight.rb +92 -0
  120. data/tests/test_command_line.rb +79 -0
  121. data/tests/test_command_line_file.rb +27 -0
  122. data/tests/test_context_menu_file.rb +129 -0
  123. data/tests/test_copy_paste.rb +80 -0
  124. data/tests/test_crash_handler.rb +39 -0
  125. data/tests/test_custom_two_phase.rb +92 -0
  126. data/tests/test_dialog_callback_errors.rb +44 -0
  127. data/tests/test_dictation.rb +294 -0
  128. data/tests/test_diff_buffer_name.rb +51 -0
  129. data/tests/test_double_click.rb +41 -0
  130. data/tests/test_drag_selection.rb +125 -0
  131. data/tests/test_e2e_cmdline.rb +116 -0
  132. data/tests/test_e2e_dictation.rb +98 -0
  133. data/tests/test_e2e_replace_char.rb +58 -0
  134. data/tests/test_extract_file_links.rb +55 -0
  135. data/tests/test_file_format.rb +217 -0
  136. data/tests/test_file_manager.rb +72 -0
  137. data/tests/test_file_panel.rb +269 -0
  138. data/tests/test_flash.rb +78 -0
  139. data/tests/test_fold.rb +111 -0
  140. data/tests/test_font_refresh.rb +56 -0
  141. data/tests/test_func_panel.rb +68 -0
  142. data/tests/test_grep_apply.rb +46 -0
  143. data/tests/test_gtk_sync.rb +126 -0
  144. data/tests/test_hpt_highlight_visible.rb +75 -0
  145. data/tests/test_hpt_link_highlight.rb +82 -0
  146. data/tests/test_jump_to_file.rb +41 -0
  147. data/tests/test_key_bindings.rb +208 -0
  148. data/tests/test_keylog_panel.rb +101 -0
  149. data/tests/test_lsp_clangd.rb +281 -0
  150. data/tests/test_lsp_jump.rb +87 -0
  151. data/tests/test_lsp_position_encoding.rb +49 -0
  152. data/tests/test_lsp_symbols.rb +68 -0
  153. data/tests/test_macro.rb +137 -0
  154. data/tests/test_markdown_highlight.rb +57 -0
  155. data/tests/test_mode_badge.rb +41 -0
  156. data/tests/test_notepad_bindings.rb +67 -0
  157. data/tests/test_popup_queue.rb +51 -0
  158. data/tests/test_random_edit.rb +109 -0
  159. data/tests/test_revert.rb +127 -0
  160. data/tests/test_startup_file.rb +58 -0
  161. data/tests/test_status_area.rb +50 -0
  162. data/tests/test_text_objects.rb +163 -0
  163. data/tests/test_text_transforms.rb +329 -0
  164. data/tests/test_tts.rb +68 -0
  165. data/tests/test_vim_bindings.rb +252 -0
  166. data/tests/test_vim_conflicts.rb +63 -0
  167. data/tests/test_window_layout.rb +219 -0
  168. data/vimamsa.gemspec +3 -1
  169. data/vm_guest_run.sh +109 -0
  170. metadata +112 -10
@@ -0,0 +1,254 @@
1
+ # Vim keymap vs vimlike keymap
2
+
3
+ Generated by `vim_binding_conflicts_report` (lib/vimamsa/key_bindings_report.rb)
4
+ from `key_bindings_vim.rb` and `key_bindings_vimlike.rb`. Don't edit by hand:
5
+ run `VMA_UPDATE_DOC=1 ruby exe/run_tests.rb --headless vim_conflicts`.
6
+
7
+ Bindings that modules and `custom.rb` add at startup are not included.
8
+
9
+ | | Count |
10
+ |---|---|
11
+ | Conflicts (the vim binding can't be used in vimlike) | 20 |
12
+ | Missing from vimlike (no conflict, could be added) | 19 |
13
+ | Shared (same keys, same action) | 187 |
14
+
15
+ ## Conflicts
16
+
17
+ | Mode | Vim keys | Vim action | vimlike | Reason |
18
+ |---|---|---|---|---|
19
+ | C | <code>@ @</code> | <code>vma.macro.run_last_macro</code> | <code>@ &lt;char&gt;</code> <code>vma.macro.run_macro(&lt;char&gt;)</code> | a vimlike <char> binding takes the key |
20
+ | C | <code>C</code> | <code>:vim_change_to_eol</code> | <code>FileContentSearch.start_gui</code> | same keys, other action |
21
+ | C | <code>O</code> | <code>:vim_open_line_above</code> | <code>buf.jump(END_OF_LINE)</code> | same keys, other action |
22
+ | C | <code>X</code> | <code>:vim_delete_char_backward</code> | <code>buf.jump(END_OF_LINE);buf.insert_txt("\n");</code> | same keys, other action |
23
+ | C | <code>^</code> | <code>buf.jump(FIRST_NON_WHITESPACE)</code> | <code>buf.jump(BEGINNING_OF_LINE)</code> | same keys, other action |
24
+ | C | <code>backspace</code> | <code>buf.move(BACKWARD_CHAR)</code> | <code>buf.selection_active? ? buf.delete(SELECTION) : buf.delet...</code> | same keys, other action |
25
+ | C | <code>ctrl-o</code> | <code>buf.jump_to_last_edit</code> | <code>:open_file_dialog</code> | same keys, other action |
26
+ | C | <code>d $</code> | <code>:vim_delete_to_eol</code> | <code>buf.delete2(:to_line_end)</code> | same keys, other action |
27
+ | C | <code>s</code> | <code>:vim_substitute_char</code> | <code>EasyJump.start</code> | same keys, other action |
28
+ | C | <code>space</code> | <code>buf.move(FORWARD_CHAR)</code> | <code>2 longer bindings</code> | vimlike uses these keys as a prefix |
29
+ | C | <code>x</code> | <code>:vim_delete_char</code> | <code>buf.delete(CURRENT_CHAR_FORWARD)</code> | same keys, other action |
30
+ | C | <code>z z</code> | <code>:center_on_current_line</code> | <code>z</code> <code>:start_browse_mode</code> | a shorter vimlike binding runs first |
31
+ | I | <code>ctrl-c</code> | <code>vma.kbd.to_previous_mode</code> | <code>buf.copy_active_selection</code> | same keys, other action |
32
+ | I | <code>ctrl-h</code> | <code>buf.selection_active? ? buf.delete(SELECTION) : buf.delet...</code> | <code>buf.view.autocp_manual_trigger</code> | same keys, other action |
33
+ | I | <code>ctrl-j</code> | <code>buf.insert_new_line()</code> | <code>buf.view.hide_completions</code> | same keys, other action |
34
+ | I | <code>ctrl-n</code> | <code>buf.view.autocp_manual_trigger</code> | <code>buf.move(FORWARD_LINE)</code> | same keys, other action |
35
+ | I | <code>ctrl-p</code> | <code>buf.view.autocp_manual_trigger</code> | <code>buf.move(BACKWARD_LINE)</code> | same keys, other action |
36
+ | V | <code>^</code> | <code>buf.jump(FIRST_NON_WHITESPACE)</code> | <code>buf.jump(BEGINNING_OF_LINE)</code> | same keys, other action |
37
+ | V | <code>ctrl-c</code> | <code>buf.end_visual_mode</code> | <code>buf.comment_selection</code> | same keys, other action |
38
+ | V | <code>s</code> | <code>:vim_change_selection</code> | <code>EasyJump.start</code> | same keys, other action |
39
+
40
+ ## Missing from vimlike
41
+
42
+ | Mode | Vim keys | Vim action |
43
+ |---|---|---|
44
+ | C | <code>.</code> | <code>repeat_last_action()</code> |
45
+ | C | <code>D</code> | <code>:vim_delete_to_eol</code> |
46
+ | C | <code>S</code> | <code>:vim_change_line</code> |
47
+ | C | <code>Y</code> | <code>buf.copy_line</code> |
48
+ | C | <code>` &lt;char&gt;</code> | <code>buf.jump_to_mark(&lt;char&gt;)</code> |
49
+ | C | <code>c $</code> | <code>:vim_change_to_eol</code> |
50
+ | C | <code>c c</code> | <code>:vim_change_line</code> |
51
+ | C | <code>c e</code> | <code>:vim_change_word</code> |
52
+ | C | <code>c w</code> | <code>:vim_change_word</code> |
53
+ | C | <code>ctrl-a</code> | <code>buf.increment_current_word</code> |
54
+ | C | <code>ctrl-b</code> | <code>vma.gui.page_up</code> |
55
+ | C | <code>ctrl-d</code> | <code>buf.move(:forward_page)</code> |
56
+ | C | <code>ctrl-f</code> | <code>vma.gui.page_down</code> |
57
+ | C | <code>ctrl-u</code> | <code>buf.move(:backward_page)</code> |
58
+ | C | <code>y $</code> | <code>buf.copy(:to_line_end)</code> |
59
+ | C | <code>y w</code> | <code>buf.copy(:to_next_word)</code> |
60
+ | V | <code>&lt;</code> | <code>buf.unindent_selection</code> |
61
+ | V | <code>&gt;</code> | <code>buf.indent_selection</code> |
62
+ | V | <code>c</code> | <code>:vim_change_selection</code> |
63
+
64
+ ## Shared
65
+
66
+ | Mode | Keys | Action |
67
+ |---|---|---|
68
+ | B | <code>;</code> | <code>buf.jump_to_last_edit</code> |
69
+ | B | <code>c</code> | <code>bufs.close_current_buffer(true)</code> |
70
+ | B | <code>ctrl!</code> | <code>:exit_browse_mode</code> |
71
+ | B | <code>d</code> | <code>vma.gui.page_down</code> |
72
+ | B | <code>e</code> | <code>vma.gui.page_up(multip: 0.25)</code> |
73
+ | B | <code>enter</code> | <code>:exit_browse_mode</code> |
74
+ | B | <code>esc</code> | <code>:exit_browse_mode</code> |
75
+ | B | <code>h</code> | <code>bufs.history_switch(-1)</code> |
76
+ | B | <code>i</code> | <code>buf.jump(START_OF_BUFFER)</code> |
77
+ | B | <code>j</code> | <code>:exit_browse_mode</code> |
78
+ | B | <code>l</code> | <code>bufs.history_switch(+1)</code> |
79
+ | B | <code>m</code> | <code>vma.macro.run_last_macro</code> |
80
+ | B | <code>n</code> | <code>vma.gui.file_panel_select_adjacent(1)</code> |
81
+ | B | <code>o</code> | <code>buf.jump(END_OF_BUFFER)</code> |
82
+ | B | <code>p</code> | <code>vma.gui.file_panel_select_adjacent(-1)</code> |
83
+ | B | <code>q</code> | <code>buf.jump_to_last_edit</code> |
84
+ | B | <code>r</code> | <code>vma.gui.page_down(multip: 0.25)</code> |
85
+ | B | <code>return</code> | <code>:exit_browse_mode</code> |
86
+ | B | <code>s</code> | <code>vma.gui.page_up</code> |
87
+ | B | <code>w</code> | <code>:jump_to_next_edit</code> |
88
+ | B | <code>z</code> | <code>center_on_current_line();call_action(:exit_browse_mode)</code> |
89
+ | C | <code>$</code> | <code>buf.jump(END_OF_LINE)</code> |
90
+ | C | <code>' &lt;char&gt;</code> | <code>buf.jump_to_mark(&lt;char&gt;)</code> |
91
+ | C | <code>*</code> | <code>buf.jump_to_next_instance_of_word</code> |
92
+ | C | <code>/</code> | <code>invoke_search</code> |
93
+ | C | <code>/[1-9]/</code> | <code>vma.kbd.set_next_command_count(&lt;char&gt;)</code> |
94
+ | C | <code>0(vma.kbd.next_command_count!=nil)</code> | <code>vma.kbd.set_next_command_count(&lt;char&gt;)</code> |
95
+ | C | <code>0(vma.kbd.next_command_count==nil)</code> | <code>buf.jump(BEGINNING_OF_LINE)</code> |
96
+ | C | <code>:</code> | <code>vma.gui.cmd_line.start</code> |
97
+ | C | <code>;</code> | <code>repeat_last_find</code> |
98
+ | C | <code>@ &lt;char&gt;</code> | <code>vma.macro.run_macro(&lt;char&gt;)</code> |
99
+ | C | <code>A</code> | <code>buf.jump(END_OF_LINE);vma.kbd.set_mode(:insert)</code> |
100
+ | C | <code>F &lt;char&gt;</code> | <code>buf.jump_to_next_instance_of_char(&lt;char&gt;,BACKWARD)</code> |
101
+ | C | <code>F space</code> | <code>buf.jump_to_next_instance_of_char(' ',BACKWARD)</code> |
102
+ | C | <code>G</code> | <code>buf.jump(END_OF_BUFFER)</code> |
103
+ | C | <code>G(vma.kbd.next_command_count!=nil)</code> | <code>buf.jump_to_line()</code> |
104
+ | C | <code>I</code> | <code>buf.jump(FIRST_NON_WHITESPACE);vma.kbd.set_mode(:insert)</code> |
105
+ | C | <code>J</code> | <code>buf.join_lines()</code> |
106
+ | C | <code>N</code> | <code>$search.jump_to_previous()</code> |
107
+ | C | <code>P</code> | <code>buf.paste(BEFORE)</code> |
108
+ | C | <code>R</code> | <code>vma.kbd.set_mode(:replace)</code> |
109
+ | C | <code>a</code> | <code>buf.move(FORWARD_CHAR);vma.kbd.set_mode(:insert)</code> |
110
+ | C | <code>alt-h</code> | <code>vma.gui.file_panel_select_adjacent(-1)</code> |
111
+ | C | <code>alt-l</code> | <code>vma.gui.file_panel_select_adjacent(1)</code> |
112
+ | C | <code>b</code> | <code>buf.jump_word(BACKWARD, WORD_START)</code> |
113
+ | C | <code>c a &lt;char&gt;</code> | <code>buf.text_object_op(:change, &lt;char&gt;, :a)</code> |
114
+ | C | <code>c i &lt;char&gt;</code> | <code>buf.text_object_op(:change, &lt;char&gt;, :i)</code> |
115
+ | C | <code>ctrl-r</code> | <code>buf.redo()</code> |
116
+ | C | <code>d ' &lt;char&gt;</code> | <code>buf.delete2(:to_mark,&lt;char&gt;)</code> |
117
+ | C | <code>d 0</code> | <code>buf.delete2(:to_line_start)</code> |
118
+ | C | <code>d F &lt;char&gt;</code> | <code>buf.delete2(:to_char_backward,&lt;char&gt;)</code> |
119
+ | C | <code>d F space</code> | <code>buf.delete2(:to_char_backward,' ')</code> |
120
+ | C | <code>d a &lt;char&gt;</code> | <code>buf.text_object_op(:delete, &lt;char&gt;, :a)</code> |
121
+ | C | <code>d d</code> | <code>buf.delete_line</code> |
122
+ | C | <code>d e</code> | <code>buf.delete2(:to_word_end)</code> |
123
+ | C | <code>d f &lt;char&gt;</code> | <code>buf.delete2(:to_char,&lt;char&gt;)</code> |
124
+ | C | <code>d f space</code> | <code>buf.delete2(:to_char,' ')</code> |
125
+ | C | <code>d i &lt;char&gt;</code> | <code>buf.text_object_op(:delete, &lt;char&gt;, :i)</code> |
126
+ | C | <code>d w</code> | <code>buf.delete2(:to_next_word)</code> |
127
+ | C | <code>down</code> | <code>buf.move(FORWARD_LINE)</code> |
128
+ | C | <code>e</code> | <code>buf.jump_word(FORWARD, WORD_END)</code> |
129
+ | C | <code>enter</code> | <code>buf.handle_line_action()</code> |
130
+ | C | <code>f &lt;char&gt;</code> | <code>buf.jump_to_next_instance_of_char(&lt;char&gt;)</code> |
131
+ | C | <code>f space</code> | <code>buf.jump_to_next_instance_of_char(' ')</code> |
132
+ | C | <code>g ;</code> | <code>buf.jump_to_last_edit</code> |
133
+ | C | <code>g U U</code> | <code>buf.transform_range(:line, :upcase)</code> |
134
+ | C | <code>g U a &lt;char&gt;</code> | <code>buf.text_object_op(:upcase, &lt;char&gt;, :a)</code> |
135
+ | C | <code>g U i &lt;char&gt;</code> | <code>buf.text_object_op(:upcase, &lt;char&gt;, :i)</code> |
136
+ | C | <code>g U w</code> | <code>buf.transform_range(:to_next_word, :upcase)</code> |
137
+ | C | <code>g g</code> | <code>buf.jump(START_OF_BUFFER)</code> |
138
+ | C | <code>g u a &lt;char&gt;</code> | <code>buf.text_object_op(:downcase, &lt;char&gt;, :a)</code> |
139
+ | C | <code>g u i &lt;char&gt;</code> | <code>buf.text_object_op(:downcase, &lt;char&gt;, :i)</code> |
140
+ | C | <code>g u u</code> | <code>buf.transform_range(:line, :downcase)</code> |
141
+ | C | <code>g u w</code> | <code>buf.transform_range(:to_next_word, :downcase)</code> |
142
+ | C | <code>g ~ a &lt;char&gt;</code> | <code>buf.text_object_op(:swapcase, &lt;char&gt;, :a)</code> |
143
+ | C | <code>g ~ i &lt;char&gt;</code> | <code>buf.text_object_op(:swapcase, &lt;char&gt;, :i)</code> |
144
+ | C | <code>g ~ w</code> | <code>buf.transform_range(:to_next_word, :swapcase)</code> |
145
+ | C | <code>g ~ ~</code> | <code>buf.transform_range(:line, :swapcase)</code> |
146
+ | C | <code>h</code> | <code>:e_move_backward_char</code> |
147
+ | C | <code>i</code> | <code>vma.kbd.set_mode(:insert)</code> |
148
+ | C | <code>j</code> | <code>buf.move(FORWARD_LINE)</code> |
149
+ | C | <code>k</code> | <code>buf.move(BACKWARD_LINE)</code> |
150
+ | C | <code>l</code> | <code>:e_move_forward_char</code> |
151
+ | C | <code>left</code> | <code>buf.move(BACKWARD_CHAR)</code> |
152
+ | C | <code>m &lt;char&gt;</code> | <code>buf.mark_current_position(&lt;char&gt;)</code> |
153
+ | C | <code>n</code> | <code>$search.jump_to_next()</code> |
154
+ | C | <code>o</code> | <code>buf.jump(END_OF_LINE);buf.insert_txt("\n");vma.kbd.set_mo...</code> |
155
+ | C | <code>p</code> | <code>buf.paste(AFTER)</code> |
156
+ | C | <code>pagedown</code> | <code>vma.gui.page_down</code> |
157
+ | C | <code>pageup</code> | <code>vma.gui.page_up</code> |
158
+ | C | <code>q &lt;char&gt;</code> | <code>vma.kbd.set_mode(:macro);vma.macro.start_recording(&lt;char&gt;)</code> |
159
+ | C | <code>r &lt;char&gt;</code> | <code>buf.replace_with_char(&lt;char&gt;)</code> |
160
+ | C | <code>r space</code> | <code>buf.replace_with_char(' ')</code> |
161
+ | C | <code>return</code> | <code>buf.handle_line_action()</code> |
162
+ | C | <code>right</code> | <code>buf.move(FORWARD_CHAR)</code> |
163
+ | C | <code>tab</code> | <code>bufs.switch_to_last_buf</code> |
164
+ | C | <code>u</code> | <code>buf.undo()</code> |
165
+ | C | <code>up</code> | <code>buf.move(BACKWARD_LINE)</code> |
166
+ | C | <code>v</code> | <code>buf.start_selection; vma.kbd.set_mode(:visual)</code> |
167
+ | C | <code>w</code> | <code>buf.jump_word(FORWARD, WORD_START)</code> |
168
+ | C | <code>y ' &lt;char&gt;</code> | <code>buf.copy(:to_mark,&lt;char&gt;)</code> |
169
+ | C | <code>y 0</code> | <code>buf.copy(:to_line_start)</code> |
170
+ | C | <code>y a &lt;char&gt;</code> | <code>buf.text_object_op(:yank, &lt;char&gt;, :a)</code> |
171
+ | C | <code>y e</code> | <code>buf.copy(:to_word_end)</code> |
172
+ | C | <code>y i &lt;char&gt;</code> | <code>buf.text_object_op(:yank, &lt;char&gt;, :i)</code> |
173
+ | C | <code>y y</code> | <code>buf.copy_line</code> |
174
+ | C | <code>~</code> | <code>:vim_toggle_case</code> |
175
+ | I | <code>&lt;char&gt;</code> | <code>buf.insert_txt(&lt;char&gt;)</code> |
176
+ | I | <code>backspace</code> | <code>buf.selection_active? ? buf.delete(SELECTION) : buf.delet...</code> |
177
+ | I | <code>ctrl-space</code> | <code>buf.view.autocp_manual_trigger</code> |
178
+ | I | <code>down</code> | <code>insert_move(FORWARD_LINE)</code> |
179
+ | I | <code>enter</code> | <code>buf.insert_new_line()</code> |
180
+ | I | <code>esc</code> | <code>vma.kbd.to_previous_mode</code> |
181
+ | I | <code>left</code> | <code>insert_move(BACKWARD_CHAR)</code> |
182
+ | I | <code>pagedown</code> | <code>insert_move(:pagedown)</code> |
183
+ | I | <code>pageup</code> | <code>insert_move(:pageup)</code> |
184
+ | I | <code>right</code> | <code>insert_move(FORWARD_CHAR)</code> |
185
+ | I | <code>shift!(vma.buf.view.autocp_active)</code> | <code>buf.view.autocp_select</code> |
186
+ | I | <code>shift-down</code> | <code>insert_select_move(FORWARD_LINE)</code> |
187
+ | I | <code>shift-left</code> | <code>insert_select_move(BACKWARD_CHAR)</code> |
188
+ | I | <code>shift-pagedown</code> | <code>insert_select_move(:pagedown)</code> |
189
+ | I | <code>shift-pageup</code> | <code>insert_select_move(:pageup)</code> |
190
+ | I | <code>shift-right</code> | <code>insert_select_move(FORWARD_CHAR)</code> |
191
+ | I | <code>shift-tab</code> | <code>buf.unindent</code> |
192
+ | I | <code>shift-tab(vma.buf.view.autocp_active)</code> | <code>buf.view.autocp_select_previous</code> |
193
+ | I | <code>shift-up</code> | <code>insert_select_move(BACKWARD_LINE)</code> |
194
+ | I | <code>space</code> | <code>buf.insert_txt(" ")</code> |
195
+ | I | <code>tab</code> | <code>buf.insert_tab</code> |
196
+ | I | <code>tab(vma.buf.view.autocp_active)</code> | <code>buf.view.autocp_select_next</code> |
197
+ | I | <code>up</code> | <code>insert_move(BACKWARD_LINE)</code> |
198
+ | R | <code>&lt;char&gt;</code> | <code>readchar_new_char(&lt;char&gt;)</code> |
199
+ | V | <code>$</code> | <code>buf.jump(END_OF_LINE)</code> |
200
+ | V | <code>' &lt;char&gt;</code> | <code>buf.jump_to_mark(&lt;char&gt;)</code> |
201
+ | V | <code>*</code> | <code>buf.jump_to_next_instance_of_word</code> |
202
+ | V | <code>/</code> | <code>invoke_search</code> |
203
+ | V | <code>/[1-9]/</code> | <code>vma.kbd.set_next_command_count(&lt;char&gt;)</code> |
204
+ | V | <code>0(vma.kbd.next_command_count!=nil)</code> | <code>vma.kbd.set_next_command_count(&lt;char&gt;)</code> |
205
+ | V | <code>0(vma.kbd.next_command_count==nil)</code> | <code>buf.jump(BEGINNING_OF_LINE)</code> |
206
+ | V | <code>;</code> | <code>repeat_last_find</code> |
207
+ | V | <code>F &lt;char&gt;</code> | <code>buf.jump_to_next_instance_of_char(&lt;char&gt;,BACKWARD)</code> |
208
+ | V | <code>F space</code> | <code>buf.jump_to_next_instance_of_char(' ',BACKWARD)</code> |
209
+ | V | <code>G</code> | <code>buf.jump(END_OF_BUFFER)</code> |
210
+ | V | <code>G(vma.kbd.next_command_count!=nil)</code> | <code>buf.jump_to_line()</code> |
211
+ | V | <code>J</code> | <code>buf.convert_selected_text(:joinlines)</code> |
212
+ | V | <code>U</code> | <code>buf.transform_selection(:upcase)</code> |
213
+ | V | <code>a &lt;char&gt;</code> | <code>buf.text_object_op(:select, &lt;char&gt;, :a)</code> |
214
+ | V | <code>b</code> | <code>buf.jump_word(BACKWARD, WORD_START)</code> |
215
+ | V | <code>d</code> | <code>buf.delete(SELECTION)</code> |
216
+ | V | <code>down</code> | <code>buf.move(FORWARD_LINE)</code> |
217
+ | V | <code>e</code> | <code>buf.jump_word(FORWARD, WORD_END)</code> |
218
+ | V | <code>esc</code> | <code>buf.end_visual_mode</code> |
219
+ | V | <code>f &lt;char&gt;</code> | <code>buf.jump_to_next_instance_of_char(&lt;char&gt;)</code> |
220
+ | V | <code>f space</code> | <code>buf.jump_to_next_instance_of_char(' ')</code> |
221
+ | V | <code>g ;</code> | <code>buf.jump_to_last_edit</code> |
222
+ | V | <code>g U</code> | <code>buf.transform_selection(:upcase)</code> |
223
+ | V | <code>g g</code> | <code>buf.jump(START_OF_BUFFER)</code> |
224
+ | V | <code>g u</code> | <code>buf.transform_selection(:downcase)</code> |
225
+ | V | <code>h</code> | <code>:e_move_backward_char</code> |
226
+ | V | <code>i &lt;char&gt;</code> | <code>buf.text_object_op(:select, &lt;char&gt;, :i)</code> |
227
+ | V | <code>j</code> | <code>buf.move(FORWARD_LINE)</code> |
228
+ | V | <code>k</code> | <code>buf.move(BACKWARD_LINE)</code> |
229
+ | V | <code>l</code> | <code>:e_move_forward_char</code> |
230
+ | V | <code>left</code> | <code>buf.move(BACKWARD_CHAR)</code> |
231
+ | V | <code>m &lt;char&gt;</code> | <code>buf.mark_current_position(&lt;char&gt;)</code> |
232
+ | V | <code>pagedown</code> | <code>vma.gui.page_down</code> |
233
+ | V | <code>pageup</code> | <code>vma.gui.page_up</code> |
234
+ | V | <code>q &lt;char&gt;</code> | <code>vma.kbd.set_mode(:macro);vma.macro.start_recording(&lt;char&gt;)</code> |
235
+ | V | <code>right</code> | <code>buf.move(FORWARD_CHAR)</code> |
236
+ | V | <code>u</code> | <code>buf.transform_selection(:downcase)</code> |
237
+ | V | <code>up</code> | <code>buf.move(BACKWARD_LINE)</code> |
238
+ | V | <code>w</code> | <code>buf.jump_word(FORWARD, WORD_START)</code> |
239
+ | V | <code>x</code> | <code>buf.delete(SELECTION)</code> |
240
+ | V | <code>y</code> | <code>buf.copy_active_selection()</code> |
241
+ | V | <code>~</code> | <code>buf.transform_selection(:swapcase)</code> |
242
+ | X | <code>&lt;char&gt;</code> | <code>buf.replace_with_char(&lt;char&gt;);buf.move(FORWARD_CHAR)</code> |
243
+ | X | <code>down</code> | <code>buf.move(FORWARD_LINE)</code> |
244
+ | X | <code>esc</code> | <code>vma.kbd.to_previous_mode</code> |
245
+ | X | <code>left</code> | <code>buf.move(BACKWARD_CHAR)</code> |
246
+ | X | <code>right</code> | <code>buf.move(FORWARD_CHAR)</code> |
247
+ | X | <code>up</code> | <code>buf.move(BACKWARD_LINE)</code> |
248
+ | audio | <code>esc</code> | <code>vma.kbd.to_previous_mode</code> |
249
+ | audio | <code>f</code> | <code>Audio.seek_forward</code> |
250
+ | audio | <code>left</code> | <code>Audio.seek_forward(-5.0)</code> |
251
+ | audio | <code>q</code> | <code>vma.kbd.to_previous_mode</code> |
252
+ | audio | <code>right</code> | <code>Audio.seek_forward</code> |
253
+ | audio | <code>space</code> | <code>Audio.stop</code> |
254
+ | macro | <code>q</code> | <code>vma.kbd.to_previous_mode; vma.macro.end_recording</code> |
@@ -0,0 +1,146 @@
1
+ # Plan: resettable test VM ("blank" the VM to simulate a fresh install)
2
+
3
+ ## Context
4
+
5
+ `run_tests_vm.sh` (host) + `vm_guest_run.sh` (guest) run the suite in the test
6
+ VirtualBox VM named by `$VM_NAME`. The VM isn't blank any more:
7
+ - Provisioning runs once and is then skipped forever because of the marker
8
+ `~/.vimamsa_vm_provisioned`.
9
+ - Every run leaves state behind: gems, `~/.config/vimamsa-test`, apt updates and
10
+ whatever earlier runs installed.
11
+
12
+ So "does it install and run on a fresh Ubuntu?" isn't being tested any more. It will
13
+ matter more for the AppImage (`doc/bundling_plan.md`), which has to run on a machine
14
+ with *no* `-dev` packages, Ruby or gems at all.
15
+
16
+ Current state (checked 2026-11-19):
17
+ - VirtualBox 7.0
18
+ - the test VM has one disk and **no snapshots**
19
+
20
+ ## Approach: VirtualBox snapshots
21
+
22
+ A snapshot freezes the disk (and, if it's taken while the VM is running, its RAM). Later
23
+ writes go to a differencing image. Restoring a snapshot throws all changes away in
24
+ seconds.
25
+
26
+ Two snapshots:
27
+
28
+ | Snapshot | Contents | Used for |
29
+ |---|---|---|
30
+ | `clean` | fresh Ubuntu 24.04 desktop install + Guest Additions + the test user (`$VM_USER`) logged in on `$VM_DISPLAY`. **No** build tools, Ruby gems or GTK `-dev` packages. | "blank" runs: the full install path from scratch (`gem install`), and later the AppImage on a clean system |
31
+ | `provisioned` | `clean` + `vm_guest_run.sh` provisioning (apt `-dev` packages, gems) | normal test runs: fast, and every run starts from the same known state instead of piling up leftovers |
32
+
33
+ Take both **while the VM is running with the desktop logged in** (`--live`). Restoring
34
+ then resumes straight into the logged-in session on `:0`, which `guestcontrol` and the
35
+ GUI tests need. No autologin or boot wait is needed. Guest Additions resync the guest
36
+ clock after resume.
37
+
38
+ ### Commands (VBoxManage 7.0)
39
+
40
+ ```sh
41
+ # take (VM running, desktop logged in)
42
+ VBoxManage snapshot "$VM_NAME" take clean --live --description "Ubuntu 24.04 + GA, no vimamsa deps"
43
+ # restore (VM must be powered off first)
44
+ VBoxManage controlvm "$VM_NAME" poweroff
45
+ VBoxManage snapshot "$VM_NAME" restore clean # or: restore provisioned
46
+ VBoxManage startvm "$VM_NAME" --type gui # resumes the saved session
47
+ # replace an outdated snapshot
48
+ VBoxManage snapshot "$VM_NAME" delete provisioned
49
+ VBoxManage snapshot "$VM_NAME" take provisioned --live
50
+ ```
51
+
52
+ ## Creating the `clean` baseline (one-time, manual)
53
+
54
+ The current test VM is already provisioned, so it can't become `clean`. Removing
55
+ `-dev` packages and gems by hand would never be truly clean. Instead:
56
+
57
+ 1. Snapshot the **current** state as `provisioned` right away. This is a quick win:
58
+ normal runs become reproducible today.
59
+ 2. Create a fresh VM for the clean baseline. Either:
60
+ - `VBoxManage unattended install <vm> --iso=ubuntu-24.04.x-desktop-amd64.iso --user="$VM_USER" --password-file=… --install-additions --start-vm=gui`
61
+ Check that VirtualBox 7.0's unattended install handles the 24.04 desktop ISO
62
+ (its subiquity installer). If not, install by hand.
63
+ - or install by hand from the ISO: user `$VM_USER`, Guest Additions, autologin on.
64
+
65
+ Then make sure `VBoxManage guestcontrol … run /bin/true` works, and take `clean`
66
+ (`--live`).
67
+ 3. Run `FORCE_PROVISION=1 ./run_tests_vm.sh` against it. If it passes, take
68
+ `provisioned` on the new VM. Then retire the old VM, or point `VM_NAME` (set in the
69
+ user's shell profile) at the new one.
70
+
71
+ Record the ISO version (e.g. 24.04.3) in the snapshot description.
72
+
73
+ ## Script changes
74
+
75
+ `run_tests_vm.sh` gets a reset step before "Ensure the VM is running":
76
+
77
+ - `VM_RESET=provisioned` (**new default**): power off, restore `provisioned`, start.
78
+ Each run starts identical, so no leftovers between runs. This costs about 10–30 s
79
+ for poweroff, restore and resume.
80
+ - `VM_RESET=clean` (or a `--fresh` flag): restore `clean`. `vm_guest_run.sh` then
81
+ provisions from zero. This is the "fresh install" simulation. **If the suite
82
+ passes, retake `provisioned` from the result** (delete the old one, take the new
83
+ one). That way dependency changes in `vm_guest_run.sh` or the gemspec carry into
84
+ normal runs without manual steps.
85
+ - `VM_RESET=none`: the current behavior (keep state). Useful for debugging a failure
86
+ inside the VM.
87
+ - If the snapshot doesn't exist, fall back to `none` with a warning, so the script
88
+ keeps working on a VM without snapshots.
89
+ - The `~/.vimamsa_vm_provisioned` marker and `FORCE_PROVISION` stay: `clean` has no
90
+ marker, so it provisions. `provisioned` has it, so it skips.
91
+
92
+ ### "Occasionally": when a fresh run happens
93
+
94
+ Automatically, in `run_tests_vm.sh`, so nobody has to remember:
95
+ - the host keeps a state file (e.g. `~/.local/share/vimamsa/vm_fresh_state`, in line
96
+ with the XDG item in `doc/TODO.md`) with the date of the last *passing* fresh run
97
+ and a hash of the install inputs: `vimamsa.gemspec`, `Gemfile`/`Gemfile.lock`,
98
+ `vm_guest_run.sh`, `ext/vmaext/extconf.rb`
99
+ - a run becomes a fresh run (`VM_RESET=clean`) when:
100
+ - the hash changed (new dependency or provisioning step), **or**
101
+ - the last fresh run is older than **7 days**, **or**
102
+ - it's explicitly asked for (`--fresh` / `VM_RESET=clean`)
103
+ - it prints which mode it chose and why, e.g.
104
+ `>> Fresh-install run: vimamsa.gemspec changed since last fresh run`
105
+ - `VM_RESET=provisioned` explicitly skips the automatic choice for a quick run.
106
+
107
+ Fresh runs are slow: apt plus compiling the Ruby-GNOME gems takes several minutes.
108
+ That's why they're occasional rather than every run.
109
+
110
+ ### Keeping `clean` from going stale
111
+
112
+ `clean` is frozen at its install date. That's realistic: users install from an ISO
113
+ and then update. But apt update downloads grow over time. Every few months (or
114
+ with a new Ubuntu point release), rebuild `clean` from a newer ISO, or restore it, run
115
+ `apt full-upgrade`, and retake it. Note the date in the snapshot description.
116
+
117
+ ## AppImage testing (later)
118
+
119
+ Once the AppImage exists, add `VM_RESET=clean` runs that **don't provision**. They
120
+ copy in only the AppImage and run the smoke test (`doc/bundling_plan.md`, "Testing the
121
+ bundle"). This is the real check that nothing is missing from the bundle, because
122
+ `clean` has no GTK `-dev` packages or Ruby. Other distros (Fedora, KDE) would be more
123
+ VMs with the same `clean` snapshot scheme.
124
+
125
+ ## Disk and safety
126
+
127
+ - Snapshots grow as differencing images. Expect a few GB for `provisioned` and a few
128
+ more per run until the next restore. Restoring throws the run's growth away, so
129
+ steady-state use stays at about `clean` + `provisioned`. Check that the VM
130
+ folder's disk has room for that.
131
+ - Snapshot *restore* destroys the VM's current state. That's intended for a
132
+ test-only VM, but the script should only reset VMs that have a `clean` or
133
+ `provisioned` snapshot. Never reset a VM that has none, so pointing `VM_NAME` at
134
+ the wrong VM (some other VirtualBox VM) can't wipe it.
135
+ - The guest password stays out of the repo, as now (`VM_PASS` + chmod-600 password
136
+ file).
137
+
138
+ ## Order
139
+
140
+ 1. Take `provisioned` of the current VM now. Add `VM_RESET` with the `provisioned` /
141
+ `none` modes.
142
+ 2. Build a fresh 24.04 VM and take `clean`. Add the `clean` mode, plus retaking
143
+ `provisioned` after a passing fresh run.
144
+ 3. Automatic fresh-run trigger (hash + 7 days) with the state file.
145
+ 4. Update the VM section of CLAUDE.md.
146
+ 5. Later: AppImage-only runs on `clean`, and more distro VMs.
data/exe/run_tests.rb CHANGED
@@ -1,4 +1,15 @@
1
1
  #!/usr/bin/ruby
2
+ # Usage:
3
+ # run_tests.rb # run all tests in tests/
4
+ # run_tests.rb tests/test_foo.rb # run specific file
5
+ # run_tests.rb TestFooClass # run specific class (all files)
6
+ # run_tests.rb tests/test_foo.rb TestFooClass # specific class from specific file
7
+ # run_tests.rb foo,bar,baz # run tests/test_foo.rb, test_bar.rb, test_baz.rb
8
+ # run_tests.rb test_random_edit duration=60 # pass duration option to stress test
9
+ # run_tests.rb --headless # invisible window (xvfb-run, or Broadway if
10
+ # # xvfb not installed); does not disturb
11
+ # # normal use; e2e kbd tests skip
12
+
2
13
  require "ripl/multi_line"
3
14
  require "tempfile"
4
15
  require "pathname"
@@ -9,15 +20,118 @@ selfpath = __FILE__
9
20
  selfpath = File.readlink(selfpath) if File.lstat(selfpath).symlink?
10
21
  scriptdir = File.expand_path(File.dirname(selfpath) + "/..")
11
22
 
12
- $LOAD_PATH.unshift(File.expand_path("lib"))
13
- $LOAD_PATH.unshift(File.expand_path("ext"))
23
+ # Relative to this script, not the current directory: started from elsewhere
24
+ # (or from an AppImage) a "./lib" there must not be picked up.
25
+ $LOAD_PATH.unshift(File.join(scriptdir, "lib"))
26
+ $LOAD_PATH.unshift(File.join(scriptdir, "ext"))
14
27
  begin
15
28
  gem_spec = Gem::Specification.find_by_name("vimamsa")
16
29
  $LOAD_PATH.unshift(File.join(gem_spec.gem_dir, "ext", "vmaext")) if gem_spec
17
30
  rescue Gem::MissingSpecError
18
31
  end
19
32
 
33
+ raw_args = ARGV.dup.reject { |a| a == "--test" }
34
+
35
+ # --headless: run on an invisible display instead of the desktop. No window
36
+ # appears and focus is not touched, so tests can run in the background during
37
+ # normal use. E2E virtual-keyboard tests detect this and skip (uinput events
38
+ # go to the real seat, not to a headless display).
39
+ #
40
+ # Preferred backend: xvfb-run (private X server per run, auto display
41
+ # allocation and teardown). Fallback: GTK's Broadway backend (no extra
42
+ # packages, but a fixed shared display :9).
43
+ if raw_args.delete("--headless")
44
+ if system("which xvfb-run > /dev/null 2>&1")
45
+ # Re-exec self under a private Xvfb server. GTK must take the x11 backend
46
+ # and not the real Wayland session. xvfb-run exits with our exit code.
47
+ ENV["GDK_BACKEND"] = "x11"
48
+ ENV.delete("WAYLAND_DISPLAY")
49
+ exec("xvfb-run", "-a", "-s", "-screen 0 1600x1000x24",
50
+ RbConfig.ruby, File.expand_path(selfpath), *(ARGV - ["--headless"]))
51
+ end
52
+ require "socket"
53
+ # Display :9 listens on broadway10.socket (broadwayd numbers sockets display+1).
54
+ # A killed broadwayd leaves its socket file behind; a new daemon then fails to
55
+ # bind and the app hangs connecting to the dead socket — so probe it and clean up.
56
+ sock = File.join(ENV["XDG_RUNTIME_DIR"] || "/run/user/#{Process.uid}", "broadway10.socket")
57
+ broadwayd_alive = false
58
+ if File.socket?(sock)
59
+ begin
60
+ UNIXSocket.new(sock).close
61
+ broadwayd_alive = true # reuse the running daemon
62
+ rescue SystemCallError
63
+ File.unlink(sock)
64
+ end
65
+ end
66
+ unless broadwayd_alive
67
+ bpid = Process.spawn("gtk4-broadwayd", ":9", :out => "/dev/null", :err => "/dev/null")
68
+ Process.detach(bpid)
69
+ at_exit do
70
+ begin
71
+ Process.kill("TERM", bpid)
72
+ rescue Errno::ESRCH, Errno::EPERM
73
+ end
74
+ end
75
+ sleep 0.5 # let broadwayd create its socket before GTK connects
76
+ end
77
+ ENV["GDK_BACKEND"] = "broadway"
78
+ ENV["BROADWAY_DISPLAY"] = ":9"
79
+ end
80
+
81
+ test_files = raw_args.select { |a| a.end_with?(".rb") && File.file?(a) }
82
+ class_filter = raw_args.select { |a| a.match?(/\A[A-Z]/) }
83
+
84
+ # Parse key=value options (e.g. duration=60)
85
+ raw_args.each do |a|
86
+ $vma_test_duration = $1.to_i if a =~ /\Aduration=(\d+)\z/
87
+ end
88
+
89
+ # Expand comma-separated shorthand: "foo,bar" -> tests/test_foo.rb, tests/test_bar.rb
90
+ # Accepts both "foo" and "test_foo" as shorthand for tests/test_foo.rb.
91
+ raw_args.each do |a|
92
+ next if a.end_with?(".rb") || a.match?(/\A[A-Z]/) || a.match?(/\A\w+=/)
93
+ a.split(",").each do |name|
94
+ name = name.strip.sub(/\Atest_/, "")
95
+ path = File.join(scriptdir, "tests", "test_#{name}.rb")
96
+ test_files << path if File.file?(path)
97
+ end
98
+ end
99
+
100
+ if test_files.empty?
101
+ test_files = Dir[File.join(scriptdir, "tests", "test_*.rb")].sort
102
+ # test_random_edit: stress test, run explicitly.
103
+ # test_notepad_bindings / test_vim_bindings: load alternative keybinding
104
+ # schemes, which would corrupt bindings for later test files in the
105
+ # shared process.
106
+ excluded = ["test_random_edit.rb", "test_notepad_bindings.rb", "test_vim_bindings.rb"]
107
+ test_files.reject! { |f| excluded.include?(File.basename(f)) }
108
+ end
109
+
110
+ $vma_test_class_filter = class_filter.empty? ? nil : class_filter
111
+
112
+ # Tests must not read or write the real user config (~/.config/vimamsa): the
113
+ # user's settings.rb/custom.rb would change editor behaviour, and test runs
114
+ # should not leave backups, sessions, etc. behind there. Point the config/data
115
+ # directory at an isolated location dedicated to tests (override with
116
+ # VMA_USER_DIR). See vma_user_dir/get_dot_path in editor.rb.
117
+ $vma_user_dir = File.expand_path(ENV["VMA_USER_DIR"] || "~/.config/vimamsa-test")
118
+
119
+ ARGV.replace(["--test"] + test_files)
120
+
20
121
  require "vimamsa"
21
- $vmag = VMAgui.new()
122
+ include Vimamsa
123
+ $vmag = Vimamsa::VMAgui.new()
22
124
  $vmag.run
23
125
 
126
+ # GTK has quit and the results are printed. Exit without normal teardown:
127
+ # StrIdx's C++ indexing threads race with static destructors at exit and can
128
+ # segfault after a fully successful run (timing-dependent, seen under
129
+ # --headless). exit! skips at_exit, so stop our broadwayd explicitly first.
130
+ STDOUT.flush
131
+ if defined?(bpid) && bpid
132
+ begin
133
+ Process.kill("TERM", bpid)
134
+ rescue Errno::ESRCH, Errno::EPERM
135
+ end
136
+ end
137
+ exit!($vma_tests_ok == false ? 1 : 0)
data/exe/vimamsa CHANGED
@@ -8,8 +8,20 @@ selfpath = __FILE__
8
8
  selfpath = File.readlink(selfpath) if File.lstat(selfpath).symlink?
9
9
  scriptdir = File.expand_path(File.dirname(selfpath) + "/..")
10
10
 
11
+ # --user-dir PATH (or --user-dir=PATH): use PATH as the config/data directory
12
+ # instead of ~/.config/vimamsa. Consumed here (and removed from ARGV) so it is
13
+ # available before anything reads the user dir, including the listen check below.
14
+ if (i = ARGV.index("--user-dir"))
15
+ $vma_user_dir = File.expand_path(ARGV[i + 1]) if ARGV[i + 1]
16
+ ARGV.slice!(i, 2)
17
+ elsif (arg = ARGV.find { |a| a.start_with?("--user-dir=") })
18
+ $vma_user_dir = File.expand_path(arg.split("=", 2)[1])
19
+ ARGV.delete(arg)
20
+ end
21
+ $vma_user_dir ||= File.expand_path("~/.config/vimamsa")
22
+
11
23
  # If process is already running, open the parameter file in the running process and exit.
12
- listen_dir = File.expand_path("~/.config/vimamsa/listen")
24
+ listen_dir = File.join($vma_user_dir, "listen")
13
25
  if File.exist?(listen_dir) and !ARGV[0].nil?
14
26
  tmpf = Tempfile.new("vmarun", listen_dir)
15
27
  fp = tmpf.path
@@ -29,11 +41,19 @@ if File.exist?(listen_dir) and !ARGV[0].nil?
29
41
  exit(0) if !timeout
30
42
  end
31
43
 
32
- $LOAD_PATH.unshift(File.expand_path("lib"))
33
- $LOAD_PATH.unshift(File.expand_path("ext"))
44
+ # Relative to this script, not the current directory: started from elsewhere
45
+ # (or from an AppImage) a "./lib" there must not be picked up.
46
+ $LOAD_PATH.unshift(File.join(scriptdir, "lib"))
47
+ $LOAD_PATH.unshift(File.join(scriptdir, "ext"))
34
48
 
35
49
  require "vimamsa"
50
+ include Vimamsa
51
+
52
+ # Persist crash/segfault debug info (native stderr dump + structured reports)
53
+ # to ~/.config/vimamsa/crash/ .
54
+ Vimamsa::CrashHandler.setup
55
+
36
56
  # Ilib:ext
37
57
  # r rbvma -e "puts VMA.new.run"
38
- $vmag = VMAgui.new()
58
+ $vmag = Vimamsa::VMAgui.new()
39
59
  $vmag.run