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,606 @@
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
+ label.action-trail { font-family: monospace; font-size: 10pt; margin-right: 8px; color: #{theme_color(:action_trail_fg)}; }
145
+
146
+ label.mode-badge {
147
+ font-family: monospace; font-size: 9pt; font-weight: 800;
148
+ padding: 1px 7px; margin: 2px 4px 2px 0;
149
+ border-radius: 2px; min-width: 65px;
150
+ color: #{theme_color(:badge_fg)}; background-color: #{theme_color(:badge_bg)};
151
+ transition: background-color 120ms ease-out;
152
+ }
153
+ label.mode-badge.mode-command { background-color: #{theme_color(:badge_command)}; }
154
+ label.mode-badge.mode-insert { background-color: #{theme_color(:badge_insert)}; }
155
+ label.mode-badge.mode-visual { background-color: #{theme_color(:badge_visual)}; }
156
+ label.mode-badge.mode-browse { background-color: #{theme_color(:badge_browse)}; }
157
+ label.mode-badge.mode-replace { background-color: #{theme_color(:badge_replace)}; }
158
+ label.mode-badge.mode-other { background-color: #{theme_color(:badge_other)}; }
159
+
160
+ label.keytrail { font-family: monospace; font-size: 10pt; font-weight: bold; color: #{theme_color(:keytrail_fg)}; }
161
+
162
+ label.status-indicator {
163
+ font-family: monospace; font-size: 9pt; font-weight: 700;
164
+ padding: 1px 7px; margin: 2px 4px 2px 0; border-radius: 2px;
165
+ color: #{theme_color(:badge_fg)}; background-color: #{theme_color(:status_busy_bg)};
166
+ }
167
+ /* waiting on something slow (model load, download) */
168
+ label.status-indicator.status-busy { background-color: #{theme_color(:status_busy_bg)}; }
169
+ /* actively capturing — the state the user most needs to not miss */
170
+ label.status-indicator.status-active { background-color: #{theme_color(:status_active_bg)}; }
171
+ label.status-indicator.status-error { background-color: #{theme_color(:status_error_bg)}; }
172
+ CSS
173
+ end
174
+
175
+ # CSS for the minibuffer / command-line widgets (shared provider in gui.rb).
176
+ def minibuf_css
177
+ "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)}; }"
178
+ end
179
+
180
+ # CSS for the key log panel's highlighted newest row.
181
+ def keylog_row_css
182
+ "row.keylog-newest { color:#fff; background-color: alpha(#000000, 0.12); border: 3px solid #{theme_color(:keylog_newest_border)}; }"
183
+ end
184
+
185
+ def cyber_rgba(hex, alpha)
186
+ "rgba(#{hex[1, 2].to_i(16)}, #{hex[3, 2].to_i(16)}, #{hex[5, 2].to_i(16)}, #{alpha})"
187
+ end
188
+
189
+ def cyberpunk_css
190
+ c = Hash.new { |_h, k| cyber_color(k) }
191
+ base = c[:base]
192
+ highlight = c[:highlight]
193
+ # Neon-sign mode badge: transparent center, thin border + text glowing in
194
+ # the mode's color (lightened tints of the baseline badge palette so they
195
+ # read as lit neon tubes on the dark chrome).
196
+ badge_glow = { "mode-command" => c[:badge_glow_command], "mode-insert" => c[:badge_glow_insert],
197
+ "mode-visual" => c[:badge_glow_visual], "mode-browse" => c[:badge_glow_browse],
198
+ "mode-replace" => c[:badge_glow_replace], "mode-other" => c[:badge_glow_other] }
199
+ .map { |cls, col|
200
+ <<~RULE
201
+ label.mode-badge.#{cls} {
202
+ color: #{col};
203
+ border-color: #{col};
204
+ background-color: transparent;
205
+ text-shadow: 0 0 5px #{cyber_rgba(col, 0.8)};
206
+ box-shadow: 0 0 6px #{cyber_rgba(col, 1.0)},
207
+ inset 0 0 5px #{cyber_rgba(col, 1.00)};
208
+ }
209
+ RULE
210
+ }.join("\n ")
211
+
212
+ <<~CSS
213
+ window {
214
+ background: linear-gradient(180deg, #{c[:bg_start]} 0%, #{c[:bg_mid]} 55%, #{c[:bg_end]} 100%);
215
+ color: #{c[:window_fg]};
216
+ }
217
+
218
+ headerbar, headerbar.titlebar, window > headerbar {
219
+ background-color: #{c[:header_bg]};
220
+ background-image: none;
221
+ color: #fff;
222
+ border-bottom: 1px solid #{cyber_rgba(base, 0.65)};
223
+ box-shadow: inset 0 -1px 0 #{cyber_rgba(highlight, 0.18)};
224
+ }
225
+
226
+ headerbar .title {
227
+ color: #fff;
228
+ text-shadow: 0 0 12px #{cyber_rgba(highlight, 0.4)};
229
+ font-family: "Oxanium", sans-serif;
230
+ }
231
+
232
+ box.menubar-row {
233
+ background: #{c[:header_bg]};
234
+ border-bottom: 1px solid #{cyber_rgba(base, 0.65)};
235
+ box-shadow: inset 0 -1px 0 #{cyber_rgba(highlight, 0.18)};
236
+ }
237
+
238
+ menubar { background: transparent; font-family: "Oxanium", sans-serif; }
239
+ menubar > item { color: #{base}; }
240
+ menubar > item:hover {
241
+ background: #{cyber_rgba(c[:base_bright], 0.18)};
242
+ color: #{c[:base_bright]};
243
+ }
244
+
245
+ paned > separator {
246
+ background: #{cyber_rgba(highlight, 0.34)};
247
+ min-width: 1px;
248
+ min-height: 1px;
249
+ }
250
+
251
+ .side-panel {
252
+ background: #{cyber_rgba(c[:sidebar_bg], 0.95)};
253
+ border-right: 1px solid #{cyber_rgba(base, 0.3)};
254
+ box-shadow: inset -1px 0 0 #{cyber_rgba(highlight, 0.12)};
255
+ }
256
+
257
+ .side-panel treeview {
258
+ background: transparent;
259
+ color: #{base};
260
+ font-family: "Oxanium", sans-serif;
261
+ }
262
+
263
+ .side-panel treeview:selected,
264
+ .side-panel treeview:selected:focus {
265
+ background: #{cyber_rgba(highlight, 0.24)};
266
+ color: #{c[:tree_selection_fg]};
267
+ box-shadow: 0 0 7px #{cyber_rgba(highlight, 0.3)};
268
+ }
269
+
270
+ .side-panel label { color: #{base}; font-family: "Oxanium", sans-serif; }
271
+
272
+ .side-panel list, .side-panel list > row {
273
+ background: transparent;
274
+ color: #{base};
275
+ }
276
+
277
+ .side-panel row.keylog-newest {
278
+ color: #fff;
279
+ background-color: transparent;
280
+ border: 1px solid #{cyber_rgba(c[:base_bright], 0.9)};
281
+ border-radius: 5px;
282
+ box-shadow: 0 0 8px #{cyber_rgba(c[:base_bright], 0.4)},
283
+ inset 0 0 6px #{cyber_rgba(c[:base_bright], 0.15)};
284
+ }
285
+
286
+ scrolledwindow.editor-frame {
287
+ border: 1px solid #{cyber_rgba(base, 0.34)};
288
+ box-shadow: 0 0 7px #{cyber_rgba(highlight, 0.15)},
289
+ 0 0 28px #{cyber_rgba(base, 0.12)};
290
+ }
291
+
292
+ label.minibuf, textview.minibuf, entry.minibuf {
293
+ background-color: #{c[:status_bg]};
294
+ color: #{c[:status_fg]};
295
+ border-top: 1px solid #{cyber_rgba(base, 0.34)};
296
+ box-shadow: inset 0 1px 0 #{cyber_rgba(highlight, 0.08)};
297
+ }
298
+
299
+ label.keytrail {
300
+ text-shadow: 0 0 8px #{cyber_rgba(highlight, 0.6)};
301
+ }
302
+
303
+ label.mode-badge {
304
+ background-color: transparent;
305
+ border: 1px solid #{base};
306
+ border-radius: 2px;
307
+ padding: 2px 12px;
308
+ font-family: "Oxanium", monospace;
309
+ font-size: 10pt;
310
+ font-weight: 700;
311
+ color: #{base};
312
+ }
313
+
314
+ #{badge_glow}
315
+
316
+ button {
317
+ background: #{cyber_rgba(c[:button_bg], 0.92)};
318
+ color: #{base};
319
+ border: 1px solid #{cyber_rgba(base, 0.72)};
320
+ border-radius: 10px;
321
+ box-shadow: 0 0 12px #{cyber_rgba(base, 0.18)};
322
+ }
323
+
324
+ /* Keyboard focus (Tab) mirrors mouse hover. */
325
+ button:hover, button:focus, button:focus-visible, button:focus-within {
326
+ background: #{cyber_rgba(c[:button_hover_bg], 0.96)};
327
+ color: #{c[:hover_bright]};
328
+ border-color: #{cyber_rgba(c[:base_bright], 0.9)};
329
+ box-shadow: 0 0 16px #{cyber_rgba(c[:base_bright], 0.3)};
330
+ outline: none;
331
+ }
332
+
333
+ popover > contents {
334
+ background: #{c[:bg_mid]};
335
+ color: #{c[:window_fg]};
336
+ border: 1px solid #{cyber_rgba(base, 0.34)};
337
+ }
338
+
339
+ window.vma-dialog {
340
+ background: #{c[:bg_mid]};
341
+ border: 1px solid #{cyber_rgba(base, 0.5)};
342
+ }
343
+
344
+ .vma-dialog entry {
345
+ background: #{cyber_rgba(c[:button_bg], 0.92)};
346
+ color: #{c[:window_fg]};
347
+ border: 1px solid #{cyber_rgba(base, 0.4)};
348
+ border-radius: 6px;
349
+ }
350
+
351
+ .vma-dialog entry:focus-within {
352
+ border-color: #{cyber_rgba(c[:base_bright], 0.9)};
353
+ box-shadow: 0 0 12px #{cyber_rgba(c[:base_bright], 0.25)};
354
+ }
355
+
356
+ .vma-dialog treeview {
357
+ background: #{c[:stack_bg]};
358
+ color: #{base};
359
+ }
360
+
361
+ .vma-dialog treeview:selected,
362
+ .vma-dialog treeview:selected:focus {
363
+ background: #{cyber_rgba(highlight, 0.24)};
364
+ color: #{c[:tree_selection_fg]};
365
+ box-shadow: 0 0 7px #{cyber_rgba(highlight, 0.3)};
366
+ }
367
+
368
+ .vma-dialog scrolledwindow { background: transparent; }
369
+
370
+ .vma-dialog spinbutton {
371
+ background: #{cyber_rgba(c[:button_bg], 0.92)};
372
+ color: #{c[:window_fg]};
373
+ border: 1px solid #{cyber_rgba(base, 0.4)};
374
+ border-radius: 6px;
375
+ }
376
+
377
+ .vma-dialog spinbutton > text {
378
+ background: transparent;
379
+ color: #{c[:window_fg]};
380
+ }
381
+
382
+ .vma-dialog switch {
383
+ background: #{cyber_rgba(c[:button_bg], 0.92)};
384
+ border: 1px solid #{cyber_rgba(base, 0.4)};
385
+ }
386
+
387
+ .vma-dialog switch:checked {
388
+ background: #{cyber_rgba(base, 0.45)};
389
+ border-color: #{cyber_rgba(highlight, 0.9)};
390
+ box-shadow: 0 0 10px #{cyber_rgba(highlight, 0.25)};
391
+ }
392
+
393
+ .vma-dialog switch > slider {
394
+ background: #{c[:status_fg]};
395
+ border: none;
396
+ }
397
+
398
+ .vma-dialog notebook > header {
399
+ background: #{c[:header_bg]};
400
+ border-bottom: 1px solid #{cyber_rgba(base, 0.34)};
401
+ }
402
+
403
+ .vma-dialog notebook > header tab { color: #{base}; }
404
+
405
+ .vma-dialog notebook > header tab:checked {
406
+ color: #{highlight};
407
+ box-shadow: inset 0 -2px 0 #{cyber_rgba(highlight, 0.6)};
408
+ }
409
+
410
+ .vma-dialog notebook stack { background: transparent; }
411
+
412
+ .vma-dialog frame > border { border-color: #{cyber_rgba(base, 0.34)}; }
413
+
414
+ /* File chooser: strip the default gray backgrounds off the internal
415
+ containers so the window gradient shows through, then tint the list. */
416
+ .vma-dialog filechooser,
417
+ .vma-dialog filechooser box,
418
+ .vma-dialog filechooser paned,
419
+ .vma-dialog filechooser stack,
420
+ .vma-dialog filechooser scrolledwindow,
421
+ .vma-dialog filechooser actionbar,
422
+ .vma-dialog .dialog-vbox,
423
+ .vma-dialog .dialog-vbox box {
424
+ background: transparent;
425
+ background-color: transparent;
426
+ }
427
+
428
+ .vma-dialog filechooser .view,
429
+ .vma-dialog filechooser list,
430
+ .vma-dialog filechooser columnview,
431
+ .vma-dialog filechooser columnview > listview,
432
+ .vma-dialog filechooser treeview.view {
433
+ background-color: #{c[:stack_bg]};
434
+ color: #{base};
435
+ }
436
+
437
+ .vma-dialog placessidebar,
438
+ .vma-dialog placessidebar list,
439
+ .vma-dialog placessidebar row,
440
+ .vma-dialog placessidebar scrolledwindow {
441
+ background: transparent;
442
+ background-color: transparent;
443
+ color: #{base};
444
+ }
445
+
446
+ .vma-dialog placessidebar row:selected {
447
+ background: #{cyber_rgba(highlight, 0.24)};
448
+ color: #{c[:tree_selection_fg]};
449
+ }
450
+
451
+ .vma-dialog pathbar,
452
+ .vma-dialog pathbar button {
453
+ background: transparent;
454
+ }
455
+
456
+ /* Recolor the folder/place symbolic icons to the neon accent so they fit
457
+ the theme. (Only symbolic icons honor `color`; full-color folder icons
458
+ from the system icon theme in the main list cannot be recolored here.) */
459
+ .vma-dialog placessidebar image.symbolic,
460
+ .vma-dialog filechooser image.symbolic,
461
+ .vma-dialog pathbar image.symbolic {
462
+ color: #{base};
463
+ -gtk-icon-shadow: 0 0 6px #{cyber_rgba(base, 0.45)};
464
+ }
465
+
466
+ .vma-dialog placessidebar row:selected image.symbolic {
467
+ color: #{c[:tree_selection_fg]};
468
+ -gtk-icon-shadow: 0 0 8px #{cyber_rgba(highlight, 0.5)};
469
+ }
470
+ CSS
471
+ end
472
+
473
+ # Install or remove the cyberpunk theme according to cnf.theme.cyberpunk_glow.
474
+ # Called at startup (gui.rb) and when settings are saved (gui_settings.rb).
475
+ # PRIORITY_USER so the theme outranks the baseline display provider and the
476
+ # per-widget minibuf provider (both PRIORITY_APPLICATION); removing the
477
+ # provider restores the default look exactly.
478
+ def gui_refresh_theme
479
+ return unless $vmag
480
+ # Keep the buffer color scheme in step with the chrome: the navy
481
+ # molokai_cyber variant goes with the theme, plain molokai_edit without it.
482
+ # A scheme the user picked themselves is left alone.
483
+ if cnf.theme.cyberpunk_glow? && cnf.style_scheme! == "molokai_edit"
484
+ cnf.style_scheme = "molokai_cyber"
485
+ gui_refresh_style_scheme
486
+ elsif !cnf.theme.cyberpunk_glow? && cnf.style_scheme! == "molokai_cyber"
487
+ cnf.style_scheme = "molokai_edit"
488
+ gui_refresh_style_scheme
489
+ end
490
+ disp = Gdk::Display.default
491
+ if $vmag.cyber_css_provider
492
+ Gtk::StyleContext.remove_provider_for_display(disp, $vmag.cyber_css_provider)
493
+ $vmag.cyber_css_provider = nil
494
+ end
495
+ if cnf.theme.cyberpunk_glow?
496
+ prov = Gtk::CssProvider.new
497
+ prov.load(data: cyberpunk_css)
498
+ Gtk::StyleContext.add_provider_for_display(disp, prov, Gtk::StyleProvider::PRIORITY_USER)
499
+ $vmag.cyber_css_provider = prov
500
+ end
501
+ gui_refresh_folder_icons
502
+ end
503
+
504
+ # Cyberpunk folder icons for the file dialogs (and anywhere else a "folder"
505
+ # icon shows). CSS cannot recolor the full-color folder icons the file chooser
506
+ # pulls from the system icon theme, so instead we generate a tiny icon theme
507
+ # that *inherits* the user's current theme and overrides only the folder
508
+ # icons, then point GTK at it while the cyberpunk theme is on. Turning the
509
+ # theme off restores the user's original icon theme.
510
+ VMA_ICON_THEME_NAME = "VimamsaCyber" unless defined?(VMA_ICON_THEME_NAME)
511
+
512
+ def vma_icon_theme_dir
513
+ File.expand_path("~/.local/share/icons/#{VMA_ICON_THEME_NAME}")
514
+ end
515
+
516
+ def gui_refresh_folder_icons
517
+ return unless $vmag
518
+ settings = Gtk::Settings.default
519
+ if cnf.theme.cyberpunk_glow?
520
+ # Remember the real icon theme once, ignoring our own override name so a
521
+ # restart with the theme already on doesn't inherit itself.
522
+ current = settings.gtk_icon_theme_name.to_s
523
+ if $vmag.orig_icon_theme.nil? && current != VMA_ICON_THEME_NAME
524
+ $vmag.orig_icon_theme = current
525
+ end
526
+ parent = $vmag.orig_icon_theme.to_s
527
+ parent = "Adwaita" if parent.empty? || parent == VMA_ICON_THEME_NAME
528
+ write_vma_icon_theme(parent)
529
+ settings.gtk_icon_theme_name = VMA_ICON_THEME_NAME
530
+ elsif $vmag.orig_icon_theme
531
+ settings.gtk_icon_theme_name = $vmag.orig_icon_theme
532
+ end
533
+ end
534
+
535
+ # (Re)write the override icon theme to disk: an index.theme that inherits the
536
+ # user's real theme plus neon folder SVGs. Regenerated on every refresh so a
537
+ # changed palette (cnf.theme.cyber.*) updates the icon colors too.
538
+ def write_vma_icon_theme(parent)
539
+ dir = vma_icon_theme_dir
540
+ places = File.join(dir, "scalable", "places")
541
+ FileUtils.mkdir_p(places)
542
+ File.write(File.join(dir, "index.theme"), <<~INI)
543
+ [Icon Theme]
544
+ Name=#{VMA_ICON_THEME_NAME}
545
+ Comment=Vimamsa cyberpunk folder icon overrides
546
+ Inherits=#{parent},hicolor
547
+ Directories=scalable/places
548
+
549
+ [scalable/places]
550
+ MinSize=8
551
+ Size=16
552
+ MaxSize=512
553
+ Type=Scalable
554
+ Context=Places
555
+ INI
556
+ fill = cyber_color(:stack_bg)
557
+ stroke = cyber_color(:base)
558
+ accent = cyber_color(:highlight)
559
+ File.write(File.join(places, "folder.svg"), vma_folder_svg(fill, stroke, accent, open: false))
560
+ File.write(File.join(places, "folder-open.svg"), vma_folder_svg(fill, stroke, accent, open: true))
561
+ rescue => ex
562
+ warn "write_vma_icon_theme failed: #{ex}"
563
+ end
564
+
565
+ # A neon-outline folder on a dark fill, matching the cyberpunk palette.
566
+ def vma_folder_svg(fill, stroke, accent, open: false)
567
+ if open
568
+ 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"/>} +
569
+ %{<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"/>}
570
+ else
571
+ 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"/>} +
572
+ %{<path d="M1.9 7.1h12.2" stroke="#{accent}" stroke-width="0.7" opacity="0.75"/>}
573
+ end
574
+ %{<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">#{body}</svg>}
575
+ end
576
+
577
+ # Re-read every color from cnf and reload the CSS providers in place, so
578
+ # changing a cnf.theme.colors.* / cnf.theme.cyber.* value takes effect at
579
+ # runtime without restarting. Bound to :refresh_colors (see key_actions.rb)
580
+ # and called by the settings dialog on save.
581
+ def gui_refresh_colors
582
+ return unless $vmag
583
+ $vmag.chrome_css_provider&.load(data: base_chrome_css)
584
+ $vmag.minibuf_css_provider&.load(data: minibuf_css)
585
+ $vmag.keylog_panel&.refresh_css
586
+ $vmag.file_panel_refresh
587
+ gui_refresh_theme # rebuilds/reloads the cyberpunk provider from current cnf
588
+ end
589
+
590
+ # Re-`load` this source file, then refresh. Unlike gui_refresh_colors (which
591
+ # only re-reads cnf), this also picks up edits to the THEME_COLOR_DEFAULTS /
592
+ # CYBER_COLOR_DEFAULTS palette constants in the source — so tweaking the
593
+ # default colors and hitting :refresh_colors applies them without a restart.
594
+ # Warnings from redefining the palette constants are silenced during the load.
595
+ def gui_reload_theme_and_colors
596
+ begin
597
+ verbose, $VERBOSE = $VERBOSE, nil
598
+ load GUI_THEME_FILE
599
+ ensure
600
+ $VERBOSE = verbose
601
+ end
602
+ gui_refresh_colors
603
+ message("Theme colors reloaded from #{File.basename(GUI_THEME_FILE)}") if defined?(message)
604
+ end
605
+
606
+ 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
 
@@ -44,3 +46,4 @@ class Hook < Hash
44
46
  end
45
47
  end
46
48
  end
49
+ 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