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/exe/run_tests.rb CHANGED
@@ -1,4 +1,16 @@
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 perf_startup ref=HEAD~10 runs=7 # startup time vs an older commit
10
+ # run_tests.rb --headless # invisible window (xvfb-run, or Broadway if
11
+ # # xvfb not installed); does not disturb
12
+ # # normal use; e2e kbd tests skip
13
+
2
14
  require "ripl/multi_line"
3
15
  require "tempfile"
4
16
  require "pathname"
@@ -9,15 +21,124 @@ selfpath = __FILE__
9
21
  selfpath = File.readlink(selfpath) if File.lstat(selfpath).symlink?
10
22
  scriptdir = File.expand_path(File.dirname(selfpath) + "/..")
11
23
 
12
- $LOAD_PATH.unshift(File.expand_path("lib"))
13
- $LOAD_PATH.unshift(File.expand_path("ext"))
24
+ # Relative to this script, not the current directory: started from elsewhere
25
+ # (or from an AppImage) a "./lib" there must not be picked up.
26
+ $LOAD_PATH.unshift(File.join(scriptdir, "lib"))
27
+ $LOAD_PATH.unshift(File.join(scriptdir, "ext"))
14
28
  begin
15
29
  gem_spec = Gem::Specification.find_by_name("vimamsa")
16
30
  $LOAD_PATH.unshift(File.join(gem_spec.gem_dir, "ext", "vmaext")) if gem_spec
17
31
  rescue Gem::MissingSpecError
18
32
  end
19
33
 
34
+ raw_args = ARGV.dup.reject { |a| a == "--test" }
35
+
36
+ # --headless: run on an invisible display instead of the desktop. No window
37
+ # appears and focus is not touched, so tests can run in the background during
38
+ # normal use. E2E virtual-keyboard tests detect this and skip (uinput events
39
+ # go to the real seat, not to a headless display).
40
+ #
41
+ # Preferred backend: xvfb-run (private X server per run, auto display
42
+ # allocation and teardown). Fallback: GTK's Broadway backend (no extra
43
+ # packages, but a fixed shared display :9).
44
+ if raw_args.delete("--headless")
45
+ if system("which xvfb-run > /dev/null 2>&1")
46
+ # Re-exec self under a private Xvfb server. GTK must take the x11 backend
47
+ # and not the real Wayland session. xvfb-run exits with our exit code.
48
+ ENV["GDK_BACKEND"] = "x11"
49
+ ENV.delete("WAYLAND_DISPLAY")
50
+ # No window manager there: tests that need one skip (VMA_HEADLESS)
51
+ ENV["VMA_HEADLESS"] = "xvfb"
52
+ exec("xvfb-run", "-a", "-s", "-screen 0 1600x1000x24",
53
+ RbConfig.ruby, File.expand_path(selfpath), *(ARGV - ["--headless"]))
54
+ end
55
+ require "socket"
56
+ # Display :9 listens on broadway10.socket (broadwayd numbers sockets display+1).
57
+ # A killed broadwayd leaves its socket file behind; a new daemon then fails to
58
+ # bind and the app hangs connecting to the dead socket — so probe it and clean up.
59
+ sock = File.join(ENV["XDG_RUNTIME_DIR"] || "/run/user/#{Process.uid}", "broadway10.socket")
60
+ broadwayd_alive = false
61
+ if File.socket?(sock)
62
+ begin
63
+ UNIXSocket.new(sock).close
64
+ broadwayd_alive = true # reuse the running daemon
65
+ rescue SystemCallError
66
+ File.unlink(sock)
67
+ end
68
+ end
69
+ unless broadwayd_alive
70
+ bpid = Process.spawn("gtk4-broadwayd", ":9", :out => "/dev/null", :err => "/dev/null")
71
+ Process.detach(bpid)
72
+ at_exit do
73
+ begin
74
+ Process.kill("TERM", bpid)
75
+ rescue Errno::ESRCH, Errno::EPERM
76
+ end
77
+ end
78
+ sleep 0.5 # let broadwayd create its socket before GTK connects
79
+ end
80
+ ENV["GDK_BACKEND"] = "broadway"
81
+ ENV["BROADWAY_DISPLAY"] = ":9"
82
+ ENV["VMA_HEADLESS"] = "broadway"
83
+ end
84
+
85
+ test_files = raw_args.select { |a| a.end_with?(".rb") && File.file?(a) }
86
+ class_filter = raw_args.select { |a| a.match?(/\A[A-Z]/) }
87
+
88
+ # Parse key=value options (e.g. duration=60)
89
+ raw_args.each do |a|
90
+ $vma_test_duration = $1.to_i if a =~ /\Aduration=(\d+)\z/
91
+ $vma_test_ref = $1 if a =~ /\Aref=(\S+)\z/ # test_perf_startup
92
+ $vma_test_runs = $1.to_i if a =~ /\Aruns=(\d+)\z/
93
+ end
94
+
95
+ # Expand comma-separated shorthand: "foo,bar" -> tests/test_foo.rb, tests/test_bar.rb
96
+ # Accepts both "foo" and "test_foo" as shorthand for tests/test_foo.rb.
97
+ raw_args.each do |a|
98
+ next if a.end_with?(".rb") || a.match?(/\A[A-Z]/) || a.match?(/\A\w+=/)
99
+ a.split(",").each do |name|
100
+ name = name.strip.sub(/\Atest_/, "")
101
+ path = File.join(scriptdir, "tests", "test_#{name}.rb")
102
+ test_files << path if File.file?(path)
103
+ end
104
+ end
105
+
106
+ if test_files.empty?
107
+ test_files = Dir[File.join(scriptdir, "tests", "test_*.rb")].sort
108
+ # test_random_edit: stress test, run explicitly.
109
+ # test_notepad_bindings / test_vim_bindings: load alternative keybinding
110
+ # schemes, which would corrupt bindings for later test files in the
111
+ # shared process.
112
+ # test_perf_startup: starts the editor a dozen times (about a minute).
113
+ excluded = ["test_random_edit.rb", "test_notepad_bindings.rb", "test_vim_bindings.rb", "test_perf_startup.rb"]
114
+ test_files.reject! { |f| excluded.include?(File.basename(f)) }
115
+ end
116
+
117
+ $vma_test_class_filter = class_filter.empty? ? nil : class_filter
118
+
119
+ # Tests must not read or write the real user config (~/.config/vimamsa): the
120
+ # user's settings.rb/custom.rb would change editor behaviour, and test runs
121
+ # should not leave backups, sessions, etc. behind there. Point the config/data
122
+ # directory at an isolated location dedicated to tests (override with
123
+ # VMA_USER_DIR). See vma_user_dir/get_dot_path in editor.rb.
124
+ $vma_user_dir = File.expand_path(ENV["VMA_USER_DIR"] || "~/.config/vimamsa-test")
125
+
126
+ ARGV.replace(["--test"] + test_files)
127
+
20
128
  require "vimamsa"
21
- $vmag = VMAgui.new()
129
+ include Vimamsa
130
+ $vmag = Vimamsa::VMAgui.new()
22
131
  $vmag.run
23
132
 
133
+ # GTK has quit and the results are printed. Exit without normal teardown:
134
+ # StrIdx's C++ indexing threads race with static destructors at exit and can
135
+ # segfault after a fully successful run (timing-dependent, seen under
136
+ # --headless). exit! skips at_exit, so stop our broadwayd explicitly first.
137
+ STDOUT.flush
138
+ if defined?(bpid) && bpid
139
+ begin
140
+ Process.kill("TERM", bpid)
141
+ rescue Errno::ESRCH, Errno::EPERM
142
+ end
143
+ end
144
+ exit!($vma_tests_ok == false ? 1 : 0)
data/exe/vimamsa CHANGED
@@ -8,9 +8,50 @@ 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
+ # Config and data dirs (user_dirs.rb): ~/.config/vimamsa and
12
+ # ~/.local/share/vimamsa by default (the XDG dirs)
13
+ require File.join(scriptdir, "lib/vimamsa/user_dirs")
14
+
15
+ # --user-dir PATH (or --user-dir=PATH): use PATH as the config and data
16
+ # directory instead of those two. Consumed here (and removed from ARGV) so it is
17
+ # available before anything reads the user dir, including the listen check below.
18
+ if (i = ARGV.index("--user-dir"))
19
+ $vma_user_dir = File.expand_path(ARGV[i + 1]) if ARGV[i + 1]
20
+ ARGV.slice!(i, 2)
21
+ elsif (arg = ARGV.find { |a| a.start_with?("--user-dir=") })
22
+ $vma_user_dir = File.expand_path(arg.split("=", 2)[1])
23
+ ARGV.delete(arg)
24
+ end
25
+ $vma_user_dir ||= Vimamsa::UserDirs.default_config_dir
26
+
27
+ # --intro: show the introduction page at start (intro_page.rb), whatever the
28
+ # settings say. Removed from ARGV so it isn't taken for a file name.
29
+ $vma_show_intro = !ARGV.delete("--intro").nil?
30
+
31
+ # --help / -h: the options and the actions (cli_help.rb), then exit
32
+ $vma_cli_help = [ARGV.delete("--help"), ARGV.delete("-h")].any?
33
+
34
+ # --tmp-user-dir: a new, empty user dir in the system temp dir, deleted on
35
+ # quit (tmp_user_dir.rb). After an editor restart the dir comes in the
36
+ # environment instead, so the new process keeps using (and deletes) it.
37
+ require File.join(scriptdir, "lib/vimamsa/tmp_user_dir")
38
+ tmp_requested = !ARGV.delete("--tmp-user-dir").nil?
39
+ if Vimamsa::TmpUserDir.ours?(ENV[Vimamsa::TmpUserDir::ENV_KEY]) && File.directory?(ENV[Vimamsa::TmpUserDir::ENV_KEY])
40
+ $vma_tmp_user_dir = ENV.delete(Vimamsa::TmpUserDir::ENV_KEY)
41
+ elsif tmp_requested && !$vma_cli_help
42
+ $vma_tmp_user_dir = Vimamsa::TmpUserDir.create
43
+ puts "Temporary user dir (deleted on quit): #{$vma_tmp_user_dir}"
44
+ end
45
+ ENV.delete(Vimamsa::TmpUserDir::ENV_KEY) # not for programs the editor starts
46
+ if $vma_tmp_user_dir
47
+ $vma_user_dir = $vma_tmp_user_dir
48
+ # Not run on exec (restart_editor), which keeps the dir
49
+ at_exit { Vimamsa::TmpUserDir.delete($vma_tmp_user_dir) }
50
+ end
51
+
11
52
  # If process is already running, open the parameter file in the running process and exit.
12
- listen_dir = File.expand_path("~/.config/vimamsa/listen")
13
- if File.exist?(listen_dir) and !ARGV[0].nil?
53
+ listen_dir = File.join(Vimamsa::UserDirs.data_dir_for($vma_user_dir), "listen")
54
+ if File.exist?(listen_dir) and !ARGV[0].nil? and !$vma_cli_help
14
55
  tmpf = Tempfile.new("vmarun", listen_dir)
15
56
  fp = tmpf.path
16
57
  paramfn = File.expand_path(ARGV[0])
@@ -29,11 +70,33 @@ if File.exist?(listen_dir) and !ARGV[0].nil?
29
70
  exit(0) if !timeout
30
71
  end
31
72
 
32
- $LOAD_PATH.unshift(File.expand_path("lib"))
33
- $LOAD_PATH.unshift(File.expand_path("ext"))
73
+ # Relative to this script, not the current directory: started from elsewhere
74
+ # (or from an AppImage) a "./lib" there must not be picked up.
75
+ $LOAD_PATH.unshift(File.join(scriptdir, "lib"))
76
+ $LOAD_PATH.unshift(File.join(scriptdir, "ext"))
77
+
78
+ if $vma_cli_help
79
+ require "vimamsa/cli_help"
80
+ Vimamsa.print_cli_usage # before loading the rest (GTK takes a while)
81
+ end
34
82
 
35
83
  require "vimamsa"
84
+ include Vimamsa
85
+
86
+ if $vma_cli_help
87
+ Vimamsa.print_cli_actions
88
+ exit(0)
89
+ end
90
+
91
+ # Persist crash/segfault debug info (native stderr dump + structured reports)
92
+ # to the crash dir in the data dir (~/.local/share/vimamsa/crash/).
93
+ Vimamsa::CrashHandler.setup
94
+
95
+ # kill / ctrl-c: quit as from the menu (session saved, a --tmp-user-dir
96
+ # deleted). The trap only sets a flag; VMAgui#monitor quits on the main loop.
97
+ %w[TERM INT].each { |sig| Signal.trap(sig) { $vma_quit_requested = true } }
98
+
36
99
  # Ilib:ext
37
100
  # r rbvma -e "puts VMA.new.run"
38
- $vmag = VMAgui.new()
101
+ $vmag = Vimamsa::VMAgui.new()
39
102
  $vmag.run
@@ -0,0 +1,93 @@
1
+ Copyright 2019 The Oxanium Project Authors (https://github.com/sevmeyer/oxanium)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ https://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file
data/help/intro.txt ADDED
@@ -0,0 +1,30 @@
1
+ ❙Welcome to Vimamsa❙
2
+ A Vim-inspired text editor. This page is always in Help ▸ Introduction.
3
+
4
+ ◼ Modes
5
+ Command mode: keys move the cursor and edit. The badge at the bottom right shows the mode.
6
+ Insert mode: keys type text. Enter it with {key:C:mode.insert}, leave it with {key:I:mode.prev}.
7
+ Visual mode: select text, {key:C:mode.visual}.
8
+ (ctrl! = press and release ctrl alone, with no other key)
9
+
10
+ ◼ Watch a demo
11
+ Each demo plays in its own buffer. The key log on the right shows every key and
12
+ what it did; the controls above it pause, change the speed or switch the demo.
13
+ {demos}
14
+
15
+ ◼ The essentials
16
+ Open a file {key:file.open}
17
+ Find a file {key:file.finder}
18
+ Save {key:buf.save}
19
+ Search {key:search.buf}
20
+ Undo {key:undo.last}
21
+ Command line {key:mode.cmdline}
22
+
23
+ ◼ Coming from Vim?
24
+ ⟦run:help.vim_intro|Vim differences⟧ the main differences, in one screen
25
+
26
+ ◼ Learn more
27
+ ⟦run:help.keys|Key bindings⟧ all key bindings
28
+ ⟦run:app.demo|Install demo files⟧ text and images to try
29
+
30
+ ⟦run:help.intro.startup.toggle|Show at startup: on / off⟧
@@ -0,0 +1,31 @@
1
+ ❙Vimamsa for Vim users❙
2
+ The differences you meet first. Back: ⟦help:intro⟧
3
+
4
+ ◼ The command line (:) is very limited
5
+ It understands only :w, :q, :wq, :e <file>, :<line number>, :!<shell command>
6
+ (the output goes to a buffer) and :reg. Anything else is run as Ruby, so there is
7
+ no :s///, :g, :set, ranges or :help. Search with {key:search.buf}; search and
8
+ replace is in the Search menu; settings are in Settings.
9
+
10
+ ◼ ctrl alone switches modes
11
+ Press and release ctrl with no other key: in Command mode it enters Insert mode,
12
+ in Insert and Visual mode it leaves them. esc works too, but it doesn't move the
13
+ cursor one character left as Vim's does.
14
+
15
+ ◼ Keys that do something else
16
+ {vim_key_table}
17
+ , starts many of Vimamsa's own commands (see ⟦help:keybindings⟧).
18
+
19
+ ◼ Not there yet
20
+ Line-wise and block visual mode (V, ctrl-v); ge, { }, %; = and gq;
21
+ ctrl-e / ctrl-y; gv and gi.
22
+
23
+ ◼ The same as in Vim
24
+ Operators with motions and text objects (d c y gU gu g~ > <, dw, ci(, yap ...),
25
+ counts, registers ("a-"z, "+), . (repeat), macros (q, @) and marks.
26
+
27
+ ◼ Prefer Vim's keys?
28
+ Settings ▸ Keybinding scheme ▸ vim (needs a restart).
29
+
30
+ ◼ All the differences
31
+ ⟦help:vim_conflicts⟧ every key that differs (generated from the keymaps)
data/icon.png ADDED
Binary file
data/img/demo.gif ADDED
Binary file
data/img/demo.mp4 ADDED
Binary file
@@ -14,6 +14,7 @@
14
14
  <style id="heading3" name="heading4" map-to="def:heading3"/>
15
15
  <style id="heading4" name="heading4" map-to="def:heading4"/>
16
16
  <style id="bold" name="bold" map-to="def:bold"/>
17
+ <style id="italic" name="italic" map-to="def:emphasis"/>
17
18
  <style id="string" name="String" map-to="def:string"/>
18
19
  <style id="floating-point" name="Floating point number" map-to="def:floating-point"/>
19
20
  </styles>
@@ -67,7 +68,11 @@
67
68
  </context>
68
69
 
69
70
  <context id="bold" style-ref="bold">
70
- <match>(⦁.*⦁)</match>
71
+ <match>(⦁[^⦁\n]*⦁)</match>
72
+ </context>
73
+
74
+ <context id="italic" style-ref="italic">
75
+ <match>(╱[^╱\n]*╱)</match>
71
76
  </context>
72
77
 
73
78
  <context id="hyperlink" style-ref="hyperlink">
@@ -105,6 +110,7 @@
105
110
  <context ref="heading3"/>
106
111
  <context ref="heading4"/>
107
112
  <context ref="bold"/>
113
+ <context ref="italic"/>
108
114
  <context ref="float"/>
109
115
  </include>
110
116
  </context>
data/lib/vimamsa/ack.rb CHANGED
@@ -1,3 +1,6 @@
1
+
2
+ #TODO: separate this into its own module. Could ack be included in appimage? If yes, enable by default (if appimage).
3
+ module Vimamsa
1
4
  # Interface for ack! https://beyondgrep.com/
2
5
 
3
6
  class FileContentSearch
@@ -81,6 +84,7 @@ class FileContentSearch
81
84
  end
82
85
  end
83
86
 
87
+ #TODO: avoid global functions. put into own module or class.
84
88
  def gui_ack()
85
89
  search_paths = vma.get_content_search_paths.join("<br/>")
86
90
 
@@ -145,8 +149,14 @@ class Ack
145
149
  instr = Shellwords.escape(_instr)
146
150
  bufstr = ""
147
151
  for path in vma.get_content_search_paths
148
- bufstr += run_cmd("ack -Q --type-add=gd=.gd -ki --nohtml --nojs --nojson #{instr} #{path}")
152
+ # Skip editor autosave files (.<name>_vma_autosave, see Buffer#autosave_path)
153
+ # stdin from /dev/null: ack 3 reads a piped stdin instead of the given
154
+ # path, which hangs forever if the editor was started with stdin a pipe.
155
+ bufstr += run_cmd("ack -Q --type-add=gd=.gd -ki --nohtml --nojs --nojson --ignore-file=match:/_vma_autosave$/ #{instr} #{Shellwords.escape(path)} < /dev/null")
149
156
  end
157
+ # Matches from non-UTF-8 files (e.g. latin-1) would make the regexp below
158
+ # raise "invalid byte sequence", which kills the app from a GTK callback.
159
+ bufstr = bufstr.scrub
150
160
 
151
161
  b = ""
152
162
  list = []
@@ -155,6 +165,7 @@ class Ack
155
165
  fn = $1
156
166
  lineno = $2
157
167
  matchpart = $3
168
+ next if fn.end_with?("_vma_autosave")
158
169
  pp [fn, lineno, matchpart]
159
170
  b << "[#{fn},#{lineno},#{matchpart}]\n"
160
171
  list << { fpath: fn, lineno: lineno, matchpart: matchpart }
@@ -192,3 +203,4 @@ class Ack
192
203
  jump_to_file(nfo[:fpath], nfo[:lineno].to_i)
193
204
  end
194
205
  end
206
+ end # module Vimamsa