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
@@ -0,0 +1,615 @@
1
+
2
+ module Vimamsa
3
+
4
+ # Absolute path to this file, captured once, so gui_reload_theme_and_colors
5
+ # can `load` it again to pick up hand-edited palette defaults at runtime.
6
+ # `unless defined?` keeps a reload from re-pinning / warning on it.
7
+ GUI_THEME_FILE = File.expand_path(__FILE__) unless defined?(GUI_THEME_FILE)
8
+
9
+ # Optional "cyberpunk glow" chrome theme: neon teal/amber accents with glow
10
+ # shadows on near-black navy, ported from the rterm terminal project.
11
+ # Off by default; toggled via cnf.theme.cyberpunk_glow (Settings > Appearance).
12
+ # Only window chrome is themed — source view text colors stay with the
13
+ # GtkSourceView style scheme.
14
+
15
+ # ── Palettes ──────────────────────────────────────────────────────────────
16
+ # All GUI chrome / highlight colors live here as two named palettes. Every
17
+ # entry is overridable at runtime via config with no restart:
18
+ # cnf.theme.colors.<name> = "#rrggbb" # baseline palette (theme off)
19
+ # cnf.theme.cyber.<name> = "#rrggbb" # cyberpunk-glow palette (theme on)
20
+ # after which `gui_refresh_colors` (called on settings-save, or bind it to a
21
+ # key) re-reads the values and reloads the CSS providers live.
22
+ #
23
+ # The hashes below are only the *defaults* — a cnf override wins per-key
24
+ # (see theme_color / cyber_color). Mode *cursor* colors and the search-match
25
+ # color already have their own config (cnf.mode.*.cursor, cnf.match.highlight
26
+ # .color) and are intentionally not duplicated here.
27
+
28
+ # Cyberpunk-glow palette. Defaults mirror the user's live rterm colors
29
+ # (~/.config/rterm/settings.json), not the rterm repo defaults.
30
+ CYBER_COLOR_DEFAULTS = {
31
+ base: "#3dcbb8", # neon teal — primary accent
32
+ base_bright: "#81dbd6", # same teal hue, brighter — hover states
33
+ hover_bright: "#ffffff", # same teal hue, brighter — hover states
34
+ highlight: "#81dbd6", # light cyan — secondary accent / glow
35
+ bg_start: "#026b65",
36
+ bg_mid: "#0d1224",
37
+ bg_end: "#090c18",
38
+ window_fg: "#d6f7ff",
39
+ header_bg: "#014a47",
40
+ button_bg: "#0d172e",
41
+ button_hover_bg: "#5c9b98", #1f3330 #64aaa6
42
+ sidebar_bg: "#080e1c",
43
+ stack_bg: "#03080f",
44
+ status_bg: "#080e1c",
45
+ status_fg: "#9fd7e4",
46
+ tree_selection_fg: "#d5f7f5",
47
+ file_panel_current_fg: "#e8fffc", # current file row in the file panel
48
+ # file panel easy-jump (g s) labels: neon red + translucent "glow" tint
49
+ file_panel_ej_label_fg: "#ff7a90",
50
+ file_panel_ej_label_glow: "#ff2a55",
51
+ # file panel close (x) button: hover / pressed backgrounds
52
+ file_panel_close_hover_bg: "#1f3a44",
53
+ file_panel_close_pressed_bg: "#5c9b98",
54
+ # neon mode-badge tints (lit-tube colors per mode)
55
+ badge_glow_command: "#9fe8a4",
56
+ badge_glow_insert: "#ffc5ff",
57
+ badge_glow_visual: "#ffc890",
58
+ badge_glow_browse: "#ff9fb7",
59
+ badge_glow_replace: "#ff9d94",
60
+ badge_glow_other: "#c5c5ff",
61
+ }
62
+
63
+ # Baseline (default, non-cyberpunk) palette.
64
+ THEME_COLOR_DEFAULTS = {
65
+ # chrome
66
+ header_fg: "#d8e6ee",
67
+ menu_item_fg: "#b8ccd8",
68
+ gutter_fg: "#8aa",
69
+ title_fg: "#cdffee",
70
+ action_trail_fg: "#aaaaaa",
71
+ keytrail_fg: "#e6db74",
72
+ # module status indicators in the status area (see set_status_indicator)
73
+ status_busy_bg: "#d49e63",
74
+ status_active_bg: "#e05c5c",
75
+ status_error_bg: "#b03030",
76
+ # mode badge (base + per-mode background)
77
+ badge_fg: "#1b1d1e",
78
+ badge_bg: "#75715e",
79
+ badge_command: "#9e4cff",
80
+ badge_insert: "#78bf78",
81
+ badge_visual: "#d49e63",
82
+ badge_browse: "#a96bb0",
83
+ badge_replace: "#d66d63",
84
+ badge_other: "#9670d6",
85
+ # minibuffer / command line
86
+ minibuf_fg: "#cdd6f4",
87
+ minibuf_bg: "#1e1e2e",
88
+ # current file row in the file panel (also bold)
89
+ file_panel_current_fg: "#ffffff",
90
+ # file panel easy-jump (g s) labels + translucent background tint
91
+ file_panel_ej_label_fg: "#ff6b6b",
92
+ file_panel_ej_label_glow: "#d03030",
93
+ # file panel close (x) button: hover / pressed backgrounds
94
+ file_panel_close_hover_bg: "#4a4f55",
95
+ file_panel_close_pressed_bg: "#6e747b",
96
+ # key log panel newest-row outline
97
+ keylog_newest_border: "#94ffbb",
98
+ # media controls strip
99
+ medctr_bg: "#353535",
100
+ # source-view selected-text foreground
101
+ selection_fg: "#ffffff",
102
+ # text-highlight helpers (Gui.hilight_range / highlight_match defaults + callers)
103
+ highlight_default: "#aa0000ff", # generic range highlight
104
+ search_jump: "#4488ffff", # jump-to-match highlight (file_manager)
105
+ buffer_switch: "#666666ff", # buffer-switch highlight (buffer_manager)
106
+ }
107
+
108
+ # Look up a baseline palette color by name: a cnf.theme.colors.<name> override
109
+ # if set, else the default. Callable everywhere (the Vimamsa module is mixed
110
+ # into Object), including as a default-argument expression.
111
+ def theme_color(name)
112
+ cnf_get([:theme, :colors, name]) || THEME_COLOR_DEFAULTS.fetch(name)
113
+ end
114
+
115
+ # Look up a cyberpunk palette color: a cnf.theme.cyber.<name> override if set,
116
+ # else the default.
117
+ def cyber_color(name)
118
+ cnf_get([:theme, :cyber, name]) || CYBER_COLOR_DEFAULTS.fetch(name)
119
+ end
120
+
121
+ # Baseline chrome CSS (always installed; the cyberpunk provider layers over it
122
+ # at PRIORITY_USER when enabled). Colors come from theme_color; layout is
123
+ # literal. Relocated here from gui.rb so all color code lives in this file.
124
+ def base_chrome_css
125
+ <<~CSS
126
+ /* Edge-lit panel: near-black chrome, neon-cyan bottom edge */
127
+ headerbar { padding: 0 0px; min-height: 16px; border-width: 0 0 0px; border-style: solid; color: #{theme_color(:header_fg)}; }
128
+
129
+ menubar { background: transparent; }
130
+ menubar > item { color: #{theme_color(:menu_item_fg)}; }
131
+
132
+ /* Relative size so the gutter tracks the editor font setting
133
+ (a fixed pt size left the gutter unchanged when the font changed). */
134
+ textview border.left gutter { padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px; color: #{theme_color(:gutter_fg)}; font-size: 85%; }
135
+
136
+ headerbar .title { font-weight: bold; font-size: 11pt; color: #{theme_color(:title_fg)}; }
137
+
138
+ headerbar > windowhandle > box .start { border-spacing: 6px; }
139
+
140
+ headerbar windowcontrols button { min-height: 15px; min-width: 15px; }
141
+
142
+ popover background > contents { padding: 8px; border-radius: 20px; }
143
+
144
+ /* Buttons of ⟦run:…⟧ links on help pages, e.g. the demos on the
145
+ introduction page (intro_page.rb). Size and spacing here; colors, border
146
+ and corners come from the button rule of the theme (cyber_css). */
147
+ button.help-run-button { padding: 0px 0px; margin: 0px 0px; min-height: 0px; font-size: 80%;
148
+ border-radius: 1px;
149
+ box-shadow: none;
150
+ }
151
+
152
+ label.action-trail { font-family: monospace; font-size: 10pt; margin-right: 8px; color: #{theme_color(:action_trail_fg)}; }
153
+
154
+ label.mode-badge {
155
+ font-family: monospace; font-size: 9pt; font-weight: 800;
156
+ padding: 1px 7px; margin: 2px 4px 2px 0;
157
+ border-radius: 2px; min-width: 65px;
158
+ color: #{theme_color(:badge_fg)}; background-color: #{theme_color(:badge_bg)};
159
+ transition: background-color 120ms ease-out;
160
+ }
161
+ label.mode-badge.mode-command { background-color: #{theme_color(:badge_command)}; }
162
+ label.mode-badge.mode-insert { background-color: #{theme_color(:badge_insert)}; }
163
+ label.mode-badge.mode-visual { background-color: #{theme_color(:badge_visual)}; }
164
+ label.mode-badge.mode-browse { background-color: #{theme_color(:badge_browse)}; }
165
+ label.mode-badge.mode-replace { background-color: #{theme_color(:badge_replace)}; }
166
+ label.mode-badge.mode-other { background-color: #{theme_color(:badge_other)}; }
167
+
168
+ label.keytrail { font-family: monospace; font-size: 10pt; font-weight: bold; color: #{theme_color(:keytrail_fg)}; }
169
+
170
+ label.status-indicator {
171
+ font-family: monospace; font-size: 9pt; font-weight: 700;
172
+ padding: 1px 7px; margin: 2px 4px 2px 0; border-radius: 2px;
173
+ color: #{theme_color(:badge_fg)}; background-color: #{theme_color(:status_busy_bg)};
174
+ }
175
+ /* waiting on something slow (model load, download) */
176
+ label.status-indicator.status-busy { background-color: #{theme_color(:status_busy_bg)}; }
177
+ /* actively capturing — the state the user most needs to not miss */
178
+ label.status-indicator.status-active { background-color: #{theme_color(:status_active_bg)}; }
179
+ label.status-indicator.status-error { background-color: #{theme_color(:status_error_bg)}; }
180
+ CSS
181
+ end
182
+
183
+ # CSS for the minibuffer / command-line widgets (shared provider in gui.rb).
184
+ def minibuf_css
185
+ "label.minibuf, textview.minibuf, entry.minibuf { color: #{theme_color(:minibuf_fg)}; font-family: Monospace; font-size: 10pt; padding: 3px 8px; background-color: #{theme_color(:minibuf_bg)}; }"
186
+ end
187
+
188
+ # CSS for the key log panel's highlighted newest row.
189
+ def keylog_row_css
190
+ "row.keylog-newest { color:#fff; background-color: alpha(#000000, 0.12); border: 3px solid #{theme_color(:keylog_newest_border)}; }"
191
+ end
192
+
193
+ def cyber_rgba(hex, alpha)
194
+ "rgba(#{hex[1, 2].to_i(16)}, #{hex[3, 2].to_i(16)}, #{hex[5, 2].to_i(16)}, #{alpha})"
195
+ end
196
+
197
+ def cyberpunk_css
198
+ c = Hash.new { |_h, k| cyber_color(k) }
199
+ base = c[:base]
200
+ highlight = c[:highlight]
201
+ # Neon-sign mode badge: transparent center, thin border + text glowing in
202
+ # the mode's color (lightened tints of the baseline badge palette so they
203
+ # read as lit neon tubes on the dark chrome).
204
+ badge_glow = { "mode-command" => c[:badge_glow_command], "mode-insert" => c[:badge_glow_insert],
205
+ "mode-visual" => c[:badge_glow_visual], "mode-browse" => c[:badge_glow_browse],
206
+ "mode-replace" => c[:badge_glow_replace], "mode-other" => c[:badge_glow_other] }
207
+ .map { |cls, col|
208
+ <<~RULE
209
+ label.mode-badge.#{cls} {
210
+ color: #{col};
211
+ border-color: #{col};
212
+ background-color: transparent;
213
+ text-shadow: 0 0 5px #{cyber_rgba(col, 0.8)};
214
+ box-shadow: 0 0 6px #{cyber_rgba(col, 1.0)},
215
+ inset 0 0 5px #{cyber_rgba(col, 1.00)};
216
+ }
217
+ RULE
218
+ }.join("\n ")
219
+
220
+ <<~CSS
221
+ window {
222
+ background: linear-gradient(180deg, #{c[:bg_start]} 0%, #{c[:bg_mid]} 55%, #{c[:bg_end]} 100%);
223
+ color: #{c[:window_fg]};
224
+ }
225
+
226
+ headerbar, headerbar.titlebar, window > headerbar {
227
+ background-color: #{c[:header_bg]};
228
+ background-image: none;
229
+ color: #fff;
230
+ border-bottom: 1px solid #{cyber_rgba(base, 0.65)};
231
+ box-shadow: inset 0 -1px 0 #{cyber_rgba(highlight, 0.18)};
232
+ }
233
+
234
+ headerbar .title {
235
+ color: #fff;
236
+ text-shadow: 0 0 12px #{cyber_rgba(highlight, 0.4)};
237
+ font-family: "Oxanium", sans-serif;
238
+ }
239
+
240
+ box.menubar-row {
241
+ background: #{c[:header_bg]};
242
+ border-bottom: 1px solid #{cyber_rgba(base, 0.65)};
243
+ box-shadow: inset 0 -1px 0 #{cyber_rgba(highlight, 0.18)};
244
+ }
245
+
246
+ menubar { background: transparent; font-family: "Oxanium", sans-serif; }
247
+ menubar > item { color: #{base}; }
248
+ menubar > item:hover {
249
+ background: #{cyber_rgba(c[:base_bright], 0.18)};
250
+ color: #{c[:base_bright]};
251
+ }
252
+
253
+ paned > separator {
254
+ background: #{cyber_rgba(highlight, 0.34)};
255
+ min-width: 1px;
256
+ min-height: 1px;
257
+ }
258
+
259
+ .side-panel {
260
+ background: #{cyber_rgba(c[:sidebar_bg], 0.95)};
261
+ border-right: 1px solid #{cyber_rgba(base, 0.3)};
262
+ box-shadow: inset -1px 0 0 #{cyber_rgba(highlight, 0.12)};
263
+ }
264
+
265
+ .side-panel treeview {
266
+ background: transparent;
267
+ color: #{base};
268
+ font-family: "Oxanium", sans-serif;
269
+ }
270
+
271
+ .side-panel treeview:selected,
272
+ .side-panel treeview:selected:focus {
273
+ background: #{cyber_rgba(highlight, 0.24)};
274
+ color: #{c[:tree_selection_fg]};
275
+ box-shadow: 0 0 7px #{cyber_rgba(highlight, 0.3)};
276
+ }
277
+
278
+ .side-panel label { color: #{base}; font-family: "Oxanium", sans-serif; }
279
+
280
+ .side-panel list, .side-panel list > row {
281
+ background: transparent;
282
+ color: #{base};
283
+ }
284
+
285
+ .side-panel row.keylog-newest {
286
+ color: #fff;
287
+ background-color: transparent;
288
+ border: 1px solid #{cyber_rgba(c[:base_bright], 0.9)};
289
+ border-radius: 5px;
290
+ box-shadow: 0 0 8px #{cyber_rgba(c[:base_bright], 0.4)},
291
+ inset 0 0 6px #{cyber_rgba(c[:base_bright], 0.15)};
292
+ }
293
+
294
+ scrolledwindow.editor-frame {
295
+ border: 1px solid #{cyber_rgba(base, 0.34)};
296
+ box-shadow: 0 0 7px #{cyber_rgba(highlight, 0.15)},
297
+ 0 0 28px #{cyber_rgba(base, 0.12)};
298
+ }
299
+
300
+ label.minibuf, textview.minibuf, entry.minibuf {
301
+ background-color: #{c[:status_bg]};
302
+ color: #{c[:status_fg]};
303
+ border-top: 1px solid #{cyber_rgba(base, 0.34)};
304
+ box-shadow: inset 0 1px 0 #{cyber_rgba(highlight, 0.08)};
305
+ }
306
+
307
+ label.keytrail {
308
+ text-shadow: 0 0 8px #{cyber_rgba(highlight, 0.6)};
309
+ }
310
+
311
+ label.mode-badge {
312
+ background-color: transparent;
313
+ border: 1px solid #{base};
314
+ border-radius: 2px;
315
+ padding: 2px 12px;
316
+ font-family: "Oxanium", monospace;
317
+ font-size: 10pt;
318
+ font-weight: 700;
319
+ color: #{base};
320
+ }
321
+
322
+ #{badge_glow}
323
+
324
+ button {
325
+ background: #{cyber_rgba(c[:button_bg], 0.92)};
326
+ color: #{base};
327
+ border: 1px solid #{cyber_rgba(base, 0.72)};
328
+ border-radius: 10px;
329
+ box-shadow: 0 0 12px #{cyber_rgba(base, 0.18)};
330
+ }
331
+
332
+ /* Keyboard focus (Tab) mirrors mouse hover. */
333
+ button:hover, button:focus, button:focus-visible, button:focus-within {
334
+ background: #{cyber_rgba(c[:button_hover_bg], 0.96)};
335
+ color: #{c[:hover_bright]};
336
+ border-color: #{cyber_rgba(c[:base_bright], 0.9)};
337
+ box-shadow: 0 0 16px #{cyber_rgba(c[:base_bright], 0.3)};
338
+ outline: none;
339
+ }
340
+
341
+ popover > contents {
342
+ background: #{c[:bg_mid]};
343
+ color: #{c[:window_fg]};
344
+ border: 1px solid #{cyber_rgba(base, 0.34)};
345
+ }
346
+
347
+ window.vma-dialog {
348
+ background: #{c[:bg_mid]};
349
+ border: 1px solid #{cyber_rgba(base, 0.5)};
350
+ }
351
+
352
+ .vma-dialog entry {
353
+ background: #{cyber_rgba(c[:button_bg], 0.92)};
354
+ color: #{c[:window_fg]};
355
+ border: 1px solid #{cyber_rgba(base, 0.4)};
356
+ border-radius: 6px;
357
+ }
358
+
359
+ .vma-dialog entry:focus-within {
360
+ border-color: #{cyber_rgba(c[:base_bright], 0.9)};
361
+ box-shadow: 0 0 12px #{cyber_rgba(c[:base_bright], 0.25)};
362
+ }
363
+
364
+ .vma-dialog treeview {
365
+ background: #{c[:stack_bg]};
366
+ color: #{base};
367
+ }
368
+
369
+ .vma-dialog treeview:selected,
370
+ .vma-dialog treeview:selected:focus {
371
+ background: #{cyber_rgba(highlight, 0.24)};
372
+ color: #{c[:tree_selection_fg]};
373
+ box-shadow: 0 0 7px #{cyber_rgba(highlight, 0.3)};
374
+ }
375
+
376
+ .vma-dialog scrolledwindow { background: transparent; }
377
+
378
+ .vma-dialog spinbutton {
379
+ background: #{cyber_rgba(c[:button_bg], 0.92)};
380
+ color: #{c[:window_fg]};
381
+ border: 1px solid #{cyber_rgba(base, 0.4)};
382
+ border-radius: 6px;
383
+ }
384
+
385
+ .vma-dialog spinbutton > text {
386
+ background: transparent;
387
+ color: #{c[:window_fg]};
388
+ }
389
+
390
+ .vma-dialog switch {
391
+ background: #{cyber_rgba(c[:button_bg], 0.92)};
392
+ border: 1px solid #{cyber_rgba(base, 0.4)};
393
+ }
394
+
395
+ .vma-dialog switch:checked {
396
+ background: #{cyber_rgba(base, 0.45)};
397
+ border-color: #{cyber_rgba(highlight, 0.9)};
398
+ box-shadow: 0 0 10px #{cyber_rgba(highlight, 0.25)};
399
+ }
400
+
401
+ .vma-dialog switch > slider {
402
+ background: #{c[:status_fg]};
403
+ border: none;
404
+ }
405
+
406
+ .vma-dialog notebook > header {
407
+ background: #{c[:header_bg]};
408
+ border-bottom: 1px solid #{cyber_rgba(base, 0.34)};
409
+ }
410
+
411
+ .vma-dialog notebook > header tab { color: #{base}; }
412
+
413
+ .vma-dialog notebook > header tab:checked {
414
+ color: #{highlight};
415
+ box-shadow: inset 0 -2px 0 #{cyber_rgba(highlight, 0.6)};
416
+ }
417
+
418
+ .vma-dialog notebook stack { background: transparent; }
419
+
420
+ .vma-dialog frame > border { border-color: #{cyber_rgba(base, 0.34)}; }
421
+
422
+ /* File chooser: strip the default gray backgrounds off the internal
423
+ containers so the window gradient shows through, then tint the list. */
424
+ .vma-dialog filechooser,
425
+ .vma-dialog filechooser box,
426
+ .vma-dialog filechooser paned,
427
+ .vma-dialog filechooser stack,
428
+ .vma-dialog filechooser scrolledwindow,
429
+ .vma-dialog filechooser actionbar,
430
+ .vma-dialog .dialog-vbox,
431
+ .vma-dialog .dialog-vbox box {
432
+ background: transparent;
433
+ background-color: transparent;
434
+ }
435
+
436
+ .vma-dialog filechooser .view,
437
+ .vma-dialog filechooser list,
438
+ .vma-dialog filechooser columnview,
439
+ .vma-dialog filechooser columnview > listview,
440
+ .vma-dialog filechooser treeview.view {
441
+ background-color: #{c[:stack_bg]};
442
+ color: #{base};
443
+ }
444
+
445
+ .vma-dialog placessidebar,
446
+ .vma-dialog placessidebar list,
447
+ .vma-dialog placessidebar row,
448
+ .vma-dialog placessidebar scrolledwindow {
449
+ background: transparent;
450
+ background-color: transparent;
451
+ color: #{base};
452
+ }
453
+
454
+ .vma-dialog placessidebar row:selected {
455
+ background: #{cyber_rgba(highlight, 0.24)};
456
+ color: #{c[:tree_selection_fg]};
457
+ }
458
+
459
+ .vma-dialog pathbar,
460
+ .vma-dialog pathbar button {
461
+ background: transparent;
462
+ }
463
+
464
+ /* Recolor the folder/place symbolic icons to the neon accent so they fit
465
+ the theme. (Only symbolic icons honor `color`; full-color folder icons
466
+ from the system icon theme in the main list cannot be recolored here.) */
467
+ .vma-dialog placessidebar image.symbolic,
468
+ .vma-dialog filechooser image.symbolic,
469
+ .vma-dialog pathbar image.symbolic {
470
+ color: #{base};
471
+ -gtk-icon-shadow: 0 0 6px #{cyber_rgba(base, 0.45)};
472
+ }
473
+
474
+ .vma-dialog placessidebar row:selected image.symbolic {
475
+ color: #{c[:tree_selection_fg]};
476
+ -gtk-icon-shadow: 0 0 8px #{cyber_rgba(highlight, 0.5)};
477
+ }
478
+ CSS
479
+ end
480
+
481
+ # Install or remove the cyberpunk theme according to cnf.theme.cyberpunk_glow.
482
+ # Called at startup (gui.rb) and when settings are saved (gui_settings.rb).
483
+ # PRIORITY_USER so the theme outranks the baseline display provider and the
484
+ # per-widget minibuf provider (both PRIORITY_APPLICATION); removing the
485
+ # provider restores the default look exactly.
486
+ def gui_refresh_theme
487
+ return unless $vmag
488
+ # Keep the buffer color scheme in step with the chrome: the navy
489
+ # molokai_cyber variant goes with the theme, plain molokai_edit without it.
490
+ # A scheme the user picked themselves is left alone.
491
+ if cnf.theme.cyberpunk_glow? && cnf.style_scheme! == "molokai_edit"
492
+ cnf.style_scheme = "molokai_cyber"
493
+ gui_refresh_style_scheme
494
+ elsif !cnf.theme.cyberpunk_glow? && cnf.style_scheme! == "molokai_cyber"
495
+ cnf.style_scheme = "molokai_edit"
496
+ gui_refresh_style_scheme
497
+ end
498
+ disp = Gdk::Display.default
499
+ if $vmag.cyber_css_provider
500
+ Gtk::StyleContext.remove_provider_for_display(disp, $vmag.cyber_css_provider)
501
+ $vmag.cyber_css_provider = nil
502
+ end
503
+ if cnf.theme.cyberpunk_glow?
504
+ prov = Gtk::CssProvider.new
505
+ prov.load(data: cyberpunk_css)
506
+ Gtk::StyleContext.add_provider_for_display(disp, prov, Gtk::StyleProvider::PRIORITY_USER)
507
+ $vmag.cyber_css_provider = prov
508
+ end
509
+ gui_refresh_folder_icons
510
+ end
511
+
512
+ # Cyberpunk folder icons for the file dialogs (and anywhere else a "folder"
513
+ # icon shows). CSS cannot recolor the full-color folder icons the file chooser
514
+ # pulls from the system icon theme, so instead we generate a tiny icon theme
515
+ # that *inherits* the user's current theme and overrides only the folder
516
+ # icons, then point GTK at it while the cyberpunk theme is on. Turning the
517
+ # theme off restores the user's original icon theme.
518
+ VMA_ICON_THEME_NAME = "VimamsaCyber" unless defined?(VMA_ICON_THEME_NAME)
519
+
520
+ def vma_icon_theme_dir
521
+ File.expand_path("~/.local/share/icons/#{VMA_ICON_THEME_NAME}")
522
+ end
523
+
524
+ def gui_refresh_folder_icons
525
+ return unless $vmag
526
+ settings = Gtk::Settings.default
527
+ if cnf.theme.cyberpunk_glow?
528
+ # Remember the real icon theme once, ignoring our own override name so a
529
+ # restart with the theme already on doesn't inherit itself.
530
+ current = settings.gtk_icon_theme_name.to_s
531
+ if $vmag.orig_icon_theme.nil? && current != VMA_ICON_THEME_NAME
532
+ $vmag.orig_icon_theme = current
533
+ end
534
+ parent = $vmag.orig_icon_theme.to_s
535
+ parent = "Adwaita" if parent.empty? || parent == VMA_ICON_THEME_NAME
536
+ write_vma_icon_theme(parent)
537
+ settings.gtk_icon_theme_name = VMA_ICON_THEME_NAME
538
+ elsif $vmag.orig_icon_theme
539
+ settings.gtk_icon_theme_name = $vmag.orig_icon_theme
540
+ end
541
+ end
542
+
543
+ # (Re)write the override icon theme to disk: an index.theme that inherits the
544
+ # user's real theme plus neon folder SVGs. Regenerated on every refresh so a
545
+ # changed palette (cnf.theme.cyber.*) updates the icon colors too.
546
+ def write_vma_icon_theme(parent)
547
+ dir = vma_icon_theme_dir
548
+ places = File.join(dir, "scalable", "places")
549
+ FileUtils.mkdir_p(places)
550
+ File.write(File.join(dir, "index.theme"), <<~INI)
551
+ [Icon Theme]
552
+ Name=#{VMA_ICON_THEME_NAME}
553
+ Comment=Vimamsa cyberpunk folder icon overrides
554
+ Inherits=#{parent},hicolor
555
+ Directories=scalable/places
556
+
557
+ [scalable/places]
558
+ MinSize=8
559
+ Size=16
560
+ MaxSize=512
561
+ Type=Scalable
562
+ Context=Places
563
+ INI
564
+ fill = cyber_color(:stack_bg)
565
+ stroke = cyber_color(:base)
566
+ accent = cyber_color(:highlight)
567
+ File.write(File.join(places, "folder.svg"), vma_folder_svg(fill, stroke, accent, open: false))
568
+ File.write(File.join(places, "folder-open.svg"), vma_folder_svg(fill, stroke, accent, open: true))
569
+ rescue => ex
570
+ warn "write_vma_icon_theme failed: #{ex}"
571
+ end
572
+
573
+ # A neon-outline folder on a dark fill, matching the cyberpunk palette.
574
+ def vma_folder_svg(fill, stroke, accent, open: false)
575
+ if open
576
+ body = %{<path d="M1.5 4.2c0-.44.35-.8.8-.8h3.1c.2 0 .4.08.55.24l1 1.02c.15.15.35.24.55.24H13c.44 0 .8.36.8.8v1H4.6c-.5 0-.94.32-1.08.8L1.5 12.6z" fill="#{fill}" stroke="#{stroke}" stroke-width="0.9" stroke-linejoin="round"/>} +
577
+ %{<path d="M3.6 12.8 5.2 7.6c.1-.34.42-.58.78-.58H15l-1.7 5.2c-.11.34-.42.58-.78.58z" fill="#{fill}" stroke="#{stroke}" stroke-width="0.9" stroke-linejoin="round"/>}
578
+ else
579
+ body = %{<path d="M1.5 4.2c0-.44.35-.8.8-.8h3.1c.2 0 .4.08.55.24l1 1.02c.15.15.35.24.55.24h6.15c.44 0 .8.36.8.8v6.3c0 .44-.36.8-.8.8H2.3c-.45 0-.8-.36-.8-.8z" fill="#{fill}" stroke="#{stroke}" stroke-width="0.9" stroke-linejoin="round"/>} +
580
+ %{<path d="M1.9 7.1h12.2" stroke="#{accent}" stroke-width="0.7" opacity="0.75"/>}
581
+ end
582
+ %{<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">#{body}</svg>}
583
+ end
584
+
585
+ # Re-read every color from cnf and reload the CSS providers in place, so
586
+ # changing a cnf.theme.colors.* / cnf.theme.cyber.* value takes effect at
587
+ # runtime without restarting. Bound to "view.colors.reload" (see key_actions.rb)
588
+ # and called by the settings dialog on save.
589
+ def gui_refresh_colors
590
+ return unless $vmag
591
+ $vmag.chrome_css_provider&.load(data: base_chrome_css)
592
+ $vmag.minibuf_css_provider&.load(data: minibuf_css)
593
+ $vmag.keylog_panel&.refresh_css
594
+ $vmag.file_panel_refresh
595
+ gui_refresh_theme # rebuilds/reloads the cyberpunk provider from current cnf
596
+ help_button_refresh_css if $help_button_css_provider # intro_page.rb
597
+ end
598
+
599
+ # Re-`load` this source file, then refresh. Unlike gui_refresh_colors (which
600
+ # only re-reads cnf), this also picks up edits to the THEME_COLOR_DEFAULTS /
601
+ # CYBER_COLOR_DEFAULTS palette constants in the source — so tweaking the
602
+ # default colors and hitting "view.colors.reload" applies them without a restart.
603
+ # Warnings from redefining the palette constants are silenced during the load.
604
+ def gui_reload_theme_and_colors
605
+ begin
606
+ verbose, $VERBOSE = $VERBOSE, nil
607
+ load GUI_THEME_FILE
608
+ ensure
609
+ $VERBOSE = verbose
610
+ end
611
+ gui_refresh_colors
612
+ message("Theme colors reloaded from #{File.basename(GUI_THEME_FILE)}") if defined?(message)
613
+ end
614
+
615
+ end
data/lib/vimamsa/hook.rb CHANGED
@@ -1,4 +1,6 @@
1
1
 
2
+ module Vimamsa
3
+
2
4
  class HookItem
3
5
  attr_writer :method_name, :weight
4
6
 
@@ -19,6 +21,8 @@ class HookItem
19
21
  end
20
22
  end
21
23
 
24
+ #TODO: add a few comments/examples on how to use this
25
+
22
26
  #$hook.register(:puts,"puts")
23
27
  #$hook.call(:puts,"AAAA")
24
28
 
@@ -44,3 +48,4 @@ class Hook < Hash
44
48
  end
45
49
  end
46
50
  end
51
+ end # module Vimamsa
@@ -1,3 +1,5 @@
1
+
2
+ module Vimamsa
1
3
  def hpt_check_cur_word(w)
2
4
  debug "check_cur_word(w)"
3
5
  m = w.match(/⟦((audio|img):)?(.*)⟧/)
@@ -134,3 +136,4 @@ def hpt_scan_images(bf = nil)
134
136
  # vma.gui.delex.run #TODO:gtk4
135
137
  end
136
138
 
139
+ end # module Vimamsa