@involvex/fresh-editor 0.1.76 → 0.1.78

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 (90) hide show
  1. package/bin/CHANGELOG.md +1017 -0
  2. package/bin/LICENSE +117 -0
  3. package/bin/README.md +248 -0
  4. package/bin/fresh.exe +0 -0
  5. package/bin/plugins/README.md +71 -0
  6. package/bin/plugins/audit_mode.i18n.json +821 -0
  7. package/bin/plugins/audit_mode.ts +1810 -0
  8. package/bin/plugins/buffer_modified.i18n.json +67 -0
  9. package/bin/plugins/buffer_modified.ts +281 -0
  10. package/bin/plugins/calculator.i18n.json +93 -0
  11. package/bin/plugins/calculator.ts +770 -0
  12. package/bin/plugins/clangd-lsp.ts +168 -0
  13. package/bin/plugins/clangd_support.i18n.json +223 -0
  14. package/bin/plugins/clangd_support.md +20 -0
  15. package/bin/plugins/clangd_support.ts +325 -0
  16. package/bin/plugins/color_highlighter.i18n.json +145 -0
  17. package/bin/plugins/color_highlighter.ts +304 -0
  18. package/bin/plugins/config-schema.json +768 -0
  19. package/bin/plugins/csharp-lsp.ts +147 -0
  20. package/bin/plugins/csharp_support.i18n.json +80 -0
  21. package/bin/plugins/csharp_support.ts +170 -0
  22. package/bin/plugins/css-lsp.ts +143 -0
  23. package/bin/plugins/diagnostics_panel.i18n.json +236 -0
  24. package/bin/plugins/diagnostics_panel.ts +642 -0
  25. package/bin/plugins/examples/README.md +85 -0
  26. package/bin/plugins/examples/async_demo.ts +165 -0
  27. package/bin/plugins/examples/bookmarks.ts +329 -0
  28. package/bin/plugins/examples/buffer_query_demo.ts +110 -0
  29. package/bin/plugins/examples/git_grep.ts +262 -0
  30. package/bin/plugins/examples/hello_world.ts +93 -0
  31. package/bin/plugins/examples/virtual_buffer_demo.ts +116 -0
  32. package/bin/plugins/find_references.i18n.json +275 -0
  33. package/bin/plugins/find_references.ts +359 -0
  34. package/bin/plugins/git_blame.i18n.json +496 -0
  35. package/bin/plugins/git_blame.ts +707 -0
  36. package/bin/plugins/git_find_file.i18n.json +314 -0
  37. package/bin/plugins/git_find_file.ts +300 -0
  38. package/bin/plugins/git_grep.i18n.json +171 -0
  39. package/bin/plugins/git_grep.ts +191 -0
  40. package/bin/plugins/git_gutter.i18n.json +93 -0
  41. package/bin/plugins/git_gutter.ts +477 -0
  42. package/bin/plugins/git_log.i18n.json +481 -0
  43. package/bin/plugins/git_log.ts +1285 -0
  44. package/bin/plugins/go-lsp.ts +143 -0
  45. package/bin/plugins/html-lsp.ts +145 -0
  46. package/bin/plugins/json-lsp.ts +145 -0
  47. package/bin/plugins/lib/fresh.d.ts +1321 -0
  48. package/bin/plugins/lib/index.ts +24 -0
  49. package/bin/plugins/lib/navigation-controller.ts +214 -0
  50. package/bin/plugins/lib/panel-manager.ts +220 -0
  51. package/bin/plugins/lib/types.ts +72 -0
  52. package/bin/plugins/lib/virtual-buffer-factory.ts +130 -0
  53. package/bin/plugins/live_grep.i18n.json +171 -0
  54. package/bin/plugins/live_grep.ts +422 -0
  55. package/bin/plugins/markdown_compose.i18n.json +223 -0
  56. package/bin/plugins/markdown_compose.ts +630 -0
  57. package/bin/plugins/merge_conflict.i18n.json +821 -0
  58. package/bin/plugins/merge_conflict.ts +1810 -0
  59. package/bin/plugins/path_complete.i18n.json +80 -0
  60. package/bin/plugins/path_complete.ts +165 -0
  61. package/bin/plugins/python-lsp.ts +162 -0
  62. package/bin/plugins/rust-lsp.ts +166 -0
  63. package/bin/plugins/search_replace.i18n.json +405 -0
  64. package/bin/plugins/search_replace.ts +484 -0
  65. package/bin/plugins/test_i18n.i18n.json +67 -0
  66. package/bin/plugins/test_i18n.ts +18 -0
  67. package/bin/plugins/theme_editor.i18n.json +3746 -0
  68. package/bin/plugins/theme_editor.ts +2063 -0
  69. package/bin/plugins/todo_highlighter.i18n.json +184 -0
  70. package/bin/plugins/todo_highlighter.ts +206 -0
  71. package/bin/plugins/typescript-lsp.ts +167 -0
  72. package/bin/plugins/vi_mode.i18n.json +1549 -0
  73. package/bin/plugins/vi_mode.ts +2747 -0
  74. package/bin/plugins/welcome.i18n.json +236 -0
  75. package/bin/plugins/welcome.ts +76 -0
  76. package/bin/themes/dark.json +102 -0
  77. package/bin/themes/dracula.json +62 -0
  78. package/bin/themes/high-contrast.json +102 -0
  79. package/bin/themes/light.json +102 -0
  80. package/bin/themes/nord.json +62 -0
  81. package/bin/themes/nostalgia.json +102 -0
  82. package/bin/themes/solarized-dark.json +62 -0
  83. package/binary-install.js +1 -1
  84. package/dist/bin/fresh.js +9 -0
  85. package/dist/binary-install.js +149 -0
  86. package/dist/binary.js +30 -0
  87. package/dist/fresh-6yhknp07.exe +0 -0
  88. package/dist/install.js +158 -0
  89. package/dist/run-fresh.js +43 -0
  90. package/package.json +7 -2
@@ -0,0 +1,304 @@
1
+ // TypeScript Color Highlighter Plugin
2
+ // Highlights color codes in source code with a colored swatch
3
+ // Supports: #RGB, #RRGGBB, rgb(), rgba(), hsl(), hsla(), Color::Rgb()
4
+ const editor = getEditor();
5
+
6
+
7
+ interface ColorHighlighterConfig {
8
+ enabled: boolean;
9
+ }
10
+
11
+ // Plugin configuration
12
+ const config: ColorHighlighterConfig = {
13
+ enabled: false, // Start disabled, use Enable or Toggle to activate
14
+ };
15
+
16
+ // Track which buffers need their virtual texts refreshed (content changed)
17
+ const dirtyBuffers = new Set<number>();
18
+
19
+ // Color block character for display
20
+ const COLOR_BLOCK = "█";
21
+
22
+ // Parse a hex color string to RGB
23
+ function parseHexColor(hex: string): [number, number, number] | null {
24
+ // Remove # prefix
25
+ hex = hex.replace(/^#/, "");
26
+
27
+ let r: number, g: number, b: number;
28
+
29
+ if (hex.length === 3) {
30
+ // #RGB format
31
+ r = parseInt(hex[0] + hex[0], 16);
32
+ g = parseInt(hex[1] + hex[1], 16);
33
+ b = parseInt(hex[2] + hex[2], 16);
34
+ } else if (hex.length === 6 || hex.length === 8) {
35
+ // #RRGGBB or #RRGGBBAA format
36
+ r = parseInt(hex.substring(0, 2), 16);
37
+ g = parseInt(hex.substring(2, 4), 16);
38
+ b = parseInt(hex.substring(4, 6), 16);
39
+ } else {
40
+ return null;
41
+ }
42
+
43
+ if (isNaN(r) || isNaN(g) || isNaN(b)) {
44
+ return null;
45
+ }
46
+
47
+ return [r, g, b];
48
+ }
49
+
50
+ // Parse rgb() or rgba() color to RGB
51
+ function parseRgbColor(match: string): [number, number, number] | null {
52
+ const rgbMatch = match.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);
53
+ if (!rgbMatch) {
54
+ return null;
55
+ }
56
+
57
+ const r = parseInt(rgbMatch[1], 10);
58
+ const g = parseInt(rgbMatch[2], 10);
59
+ const b = parseInt(rgbMatch[3], 10);
60
+
61
+ if (r > 255 || g > 255 || b > 255) {
62
+ return null;
63
+ }
64
+
65
+ return [r, g, b];
66
+ }
67
+
68
+ // Convert HSL to RGB
69
+ function hslToRgb(h: number, s: number, l: number): [number, number, number] {
70
+ // Normalize h to 0-360, s and l to 0-1
71
+ h = h % 360;
72
+ if (h < 0) h += 360;
73
+ s = Math.max(0, Math.min(1, s / 100));
74
+ l = Math.max(0, Math.min(1, l / 100));
75
+
76
+ const c = (1 - Math.abs(2 * l - 1)) * s;
77
+ const x = c * (1 - Math.abs(((h / 60) % 2) - 1));
78
+ const m = l - c / 2;
79
+
80
+ let r = 0, g = 0, b = 0;
81
+
82
+ if (h >= 0 && h < 60) {
83
+ r = c; g = x; b = 0;
84
+ } else if (h >= 60 && h < 120) {
85
+ r = x; g = c; b = 0;
86
+ } else if (h >= 120 && h < 180) {
87
+ r = 0; g = c; b = x;
88
+ } else if (h >= 180 && h < 240) {
89
+ r = 0; g = x; b = c;
90
+ } else if (h >= 240 && h < 300) {
91
+ r = x; g = 0; b = c;
92
+ } else {
93
+ r = c; g = 0; b = x;
94
+ }
95
+
96
+ return [
97
+ Math.round((r + m) * 255),
98
+ Math.round((g + m) * 255),
99
+ Math.round((b + m) * 255),
100
+ ];
101
+ }
102
+
103
+ // Parse hsl() or hsla() color to RGB
104
+ function parseHslColor(match: string): [number, number, number] | null {
105
+ const hslMatch = match.match(/hsla?\s*\(\s*(-?\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)%\s*,\s*(\d+(?:\.\d+)?)%/);
106
+ if (!hslMatch) {
107
+ return null;
108
+ }
109
+
110
+ const h = parseFloat(hslMatch[1]);
111
+ const s = parseFloat(hslMatch[2]);
112
+ const l = parseFloat(hslMatch[3]);
113
+
114
+ return hslToRgb(h, s, l);
115
+ }
116
+
117
+ // Parse Rust Color::Rgb(r, g, b) to RGB
118
+ function parseRustRgbColor(match: string): [number, number, number] | null {
119
+ const rustMatch = match.match(/Color::Rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);
120
+ if (!rustMatch) {
121
+ return null;
122
+ }
123
+
124
+ const r = parseInt(rustMatch[1], 10);
125
+ const g = parseInt(rustMatch[2], 10);
126
+ const b = parseInt(rustMatch[3], 10);
127
+
128
+ if (r > 255 || g > 255 || b > 255) {
129
+ return null;
130
+ }
131
+
132
+ return [r, g, b];
133
+ }
134
+
135
+ // Color patterns to match
136
+ const colorPatterns = [
137
+ {
138
+ // Hex colors: #RGB, #RRGGBB, #RRGGBBAA
139
+ regex: /#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})\b/g,
140
+ parse: parseHexColor,
141
+ },
142
+ {
143
+ // CSS rgb() and rgba()
144
+ regex: /rgba?\s*\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*[\d.]+\s*)?\)/g,
145
+ parse: parseRgbColor,
146
+ },
147
+ {
148
+ // CSS hsl() and hsla()
149
+ regex: /hsla?\s*\(\s*-?\d+(?:\.\d+)?\s*,\s*\d+(?:\.\d+)?%\s*,\s*\d+(?:\.\d+)?%\s*(?:,\s*[\d.]+\s*)?\)/g,
150
+ parse: parseHslColor,
151
+ },
152
+ {
153
+ // Rust Color::Rgb(r, g, b)
154
+ regex: /Color::Rgb\s*\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\)/g,
155
+ parse: parseRustRgbColor,
156
+ },
157
+ ];
158
+
159
+ // Process a single line for color highlighting
160
+ function highlightLine(
161
+ bufferId: number,
162
+ lineNumber: number,
163
+ byteStart: number,
164
+ content: string
165
+ ): void {
166
+ // Search for color patterns
167
+ for (const pattern of colorPatterns) {
168
+ // Reset regex lastIndex
169
+ pattern.regex.lastIndex = 0;
170
+
171
+ let match;
172
+ while ((match = pattern.regex.exec(content)) !== null) {
173
+ const matchText = match[0];
174
+ const pos = match.index;
175
+ const color = pattern.parse(matchText);
176
+
177
+ if (color) {
178
+ const absolutePos = byteStart + pos;
179
+ const virtualTextId = `color-${bufferId}-${lineNumber}-${pos}`;
180
+
181
+ // Add virtual text with color swatch before the color code
182
+ editor.addVirtualText(
183
+ bufferId,
184
+ virtualTextId,
185
+ absolutePos,
186
+ COLOR_BLOCK + " ",
187
+ color[0],
188
+ color[1],
189
+ color[2],
190
+ true // before the character
191
+ );
192
+ }
193
+ }
194
+ }
195
+ }
196
+
197
+ // Clear color highlights for a buffer
198
+ function clearHighlights(bufferId: number): void {
199
+ editor.removeVirtualTextsByPrefix(bufferId, "color-");
200
+ }
201
+
202
+ // Handle render-start events (only clear virtual texts if buffer content changed)
203
+ globalThis.onColorRenderStart = function(data: { buffer_id: number }): void {
204
+ if (!config.enabled) return;
205
+
206
+ // Only clear and recreate virtual texts if the buffer content changed
207
+ if (dirtyBuffers.has(data.buffer_id)) {
208
+ clearHighlights(data.buffer_id);
209
+ dirtyBuffers.delete(data.buffer_id);
210
+ }
211
+ };
212
+
213
+ // Handle lines_changed events (batched for efficiency)
214
+ globalThis.onColorLinesChanged = function(data: {
215
+ buffer_id: number;
216
+ lines: Array<{
217
+ line_number: number;
218
+ byte_start: number;
219
+ byte_end: number;
220
+ content: string;
221
+ }>;
222
+ }): void {
223
+ if (!config.enabled) return;
224
+
225
+ // Process all changed lines
226
+ for (const line of data.lines) {
227
+ highlightLine(data.buffer_id, line.line_number, line.byte_start, line.content);
228
+ }
229
+ };
230
+
231
+ // Handle buffer content changes - mark buffer as needing virtual text refresh
232
+ globalThis.onColorAfterInsert = function(data: { buffer_id: number }): void {
233
+ dirtyBuffers.add(data.buffer_id);
234
+ };
235
+
236
+ globalThis.onColorAfterDelete = function(data: { buffer_id: number }): void {
237
+ dirtyBuffers.add(data.buffer_id);
238
+ };
239
+
240
+ // Handle buffer close events
241
+ globalThis.onColorBufferClosed = function(data: { buffer_id: number }): void {
242
+ dirtyBuffers.delete(data.buffer_id);
243
+ };
244
+
245
+ // Register hooks
246
+ editor.on("render_start", "onColorRenderStart");
247
+ editor.on("lines_changed", "onColorLinesChanged");
248
+ editor.on("after_insert", "onColorAfterInsert");
249
+ editor.on("after_delete", "onColorAfterDelete");
250
+ editor.on("buffer_closed", "onColorBufferClosed");
251
+
252
+ // Plugin commands
253
+ globalThis.colorHighlighterEnable = function(): void {
254
+ config.enabled = true;
255
+ // Refresh lines so next render processes all visible lines
256
+ const bufferId = editor.getActiveBufferId();
257
+ editor.refreshLines(bufferId);
258
+ editor.setStatus(editor.t("status.enabled"));
259
+ };
260
+
261
+ globalThis.colorHighlighterDisable = function(): void {
262
+ config.enabled = false;
263
+ const bufferId = editor.getActiveBufferId();
264
+ clearHighlights(bufferId);
265
+ editor.setStatus(editor.t("status.disabled"));
266
+ };
267
+
268
+ globalThis.colorHighlighterToggle = function(): void {
269
+ config.enabled = !config.enabled;
270
+ const bufferId = editor.getActiveBufferId();
271
+ if (config.enabled) {
272
+ // Refresh lines so next render processes all visible lines
273
+ editor.refreshLines(bufferId);
274
+ } else {
275
+ clearHighlights(bufferId);
276
+ }
277
+ editor.setStatus(config.enabled ? editor.t("status.enabled") : editor.t("status.disabled"));
278
+ };
279
+
280
+ // Register commands
281
+ editor.registerCommand(
282
+ "%cmd.enable",
283
+ "%cmd.enable_desc",
284
+ "colorHighlighterEnable",
285
+ "normal"
286
+ );
287
+
288
+ editor.registerCommand(
289
+ "%cmd.disable",
290
+ "%cmd.disable_desc",
291
+ "colorHighlighterDisable",
292
+ "normal"
293
+ );
294
+
295
+ editor.registerCommand(
296
+ "%cmd.toggle",
297
+ "%cmd.toggle_desc",
298
+ "colorHighlighterToggle",
299
+ "normal"
300
+ );
301
+
302
+ // Initialization
303
+ editor.setStatus(editor.t("status.loaded"));
304
+ editor.debug("Color Highlighter initialized - supports hex, rgb, hsl, and Rust Color::Rgb");