@fresh-editor/fresh-editor 0.1.4

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 (38) hide show
  1. package/.gitignore +2 -0
  2. package/LICENSE +117 -0
  3. package/README.md +54 -0
  4. package/binary-install.js +212 -0
  5. package/binary.js +126 -0
  6. package/install.js +4 -0
  7. package/npm-shrinkwrap.json +900 -0
  8. package/package.json +100 -0
  9. package/plugins/README.md +121 -0
  10. package/plugins/clangd_support.md +20 -0
  11. package/plugins/clangd_support.ts +323 -0
  12. package/plugins/color_highlighter.ts +302 -0
  13. package/plugins/diagnostics_panel.ts +308 -0
  14. package/plugins/examples/README.md +245 -0
  15. package/plugins/examples/async_demo.ts +165 -0
  16. package/plugins/examples/bookmarks.ts +329 -0
  17. package/plugins/examples/buffer_query_demo.ts +110 -0
  18. package/plugins/examples/git_grep.ts +262 -0
  19. package/plugins/examples/hello_world.ts +93 -0
  20. package/plugins/examples/virtual_buffer_demo.ts +116 -0
  21. package/plugins/find_references.ts +357 -0
  22. package/plugins/git_find_file.ts +298 -0
  23. package/plugins/git_grep.ts +188 -0
  24. package/plugins/git_log.ts +1283 -0
  25. package/plugins/lib/fresh.d.ts +849 -0
  26. package/plugins/lib/index.ts +24 -0
  27. package/plugins/lib/navigation-controller.ts +214 -0
  28. package/plugins/lib/panel-manager.ts +218 -0
  29. package/plugins/lib/types.ts +72 -0
  30. package/plugins/lib/virtual-buffer-factory.ts +158 -0
  31. package/plugins/manual_help.ts +243 -0
  32. package/plugins/markdown_compose.ts +1207 -0
  33. package/plugins/merge_conflict.ts +1811 -0
  34. package/plugins/path_complete.ts +163 -0
  35. package/plugins/search_replace.ts +481 -0
  36. package/plugins/todo_highlighter.ts +204 -0
  37. package/plugins/welcome.ts +74 -0
  38. package/run-fresh.js +4 -0
@@ -0,0 +1,243 @@
1
+ /// <reference path="../types/fresh.d.ts" />
2
+
3
+ import { VirtualBufferFactory } from "./lib/index.ts";
4
+
5
+
6
+
7
+ const MANUAL_MODE = "help-manual";
8
+ const SHORTCUTS_MODE = "help-keyboard";
9
+
10
+ // ANSI color codes for styling
11
+ const COLORS = {
12
+ RESET: "\x1b[0m",
13
+ BOLD: "\x1b[1m",
14
+ DIM: "\x1b[2m",
15
+ UNDERLINE: "\x1b[4m",
16
+
17
+ // Foreground colors
18
+ CYAN: "\x1b[36m",
19
+ GREEN: "\x1b[32m",
20
+ YELLOW: "\x1b[33m",
21
+ BLUE: "\x1b[34m",
22
+ MAGENTA: "\x1b[35m",
23
+ WHITE: "\x1b[37m",
24
+ BRIGHT_CYAN: "\x1b[96m",
25
+ BRIGHT_GREEN: "\x1b[92m",
26
+ BRIGHT_YELLOW: "\x1b[93m",
27
+ BRIGHT_BLUE: "\x1b[94m",
28
+ BRIGHT_MAGENTA: "\x1b[95m",
29
+ };
30
+
31
+ const createEntriesFromLines = (lines: string[]): TextPropertyEntry[] =>
32
+ lines.map((line) => ({
33
+ text: `${line}\n`,
34
+ properties: {},
35
+ }));
36
+
37
+
38
+
39
+ const buildManualEntries = (): TextPropertyEntry[] => {
40
+ const C = COLORS;
41
+ const manualText = [
42
+ // Content from example.html converted to ANSI
43
+ "",
44
+ `${C.BOLD}${C.BRIGHT_GREEN}███████╗██████╗ ███████╗███████╗██╗ ██╗`,
45
+ `${C.BOLD}${C.BRIGHT_GREEN}██╔════╝██╔══██╗██╔════╝██╔════╝██║ ██║`,
46
+ `${C.BOLD}${C.BRIGHT_GREEN}█████╗ ██████╔╝█████╗ ███████╗███████║`,
47
+ `${C.BOLD}${C.BRIGHT_GREEN}██╔══╝ ██╔══██╗██╔══╝ ╚════██║██╔══██║`,
48
+ `${C.BOLD}${C.BRIGHT_GREEN}██║ ██║ ██║███████╗███████║██║ ██║`,
49
+ `${C.BOLD}${C.BRIGHT_GREEN}╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝${C.RESET}`,
50
+ "",
51
+ `${C.BOLD}${C.BRIGHT_YELLOW}The Terminal Text Editor${C.RESET}`,
52
+ "",
53
+ `${C.BOLD}${C.BRIGHT_GREEN}Easy To Use${C.RESET} | ${C.BOLD}${C.BRIGHT_MAGENTA}TypeScript Extensible${C.RESET} | ${C.BOLD}${C.BRIGHT_BLUE}Light And Fast${C.RESET} | ${C.BOLD}${C.BRIGHT_YELLOW}Huge File Support${C.RESET}`,
54
+ "",
55
+ `${C.BOLD}${C.BRIGHT_CYAN}╔════════════════════════════════════════════════════════════╗${C.RESET}`,
56
+ `${C.BOLD}${C.BRIGHT_CYAN}║${C.RESET} ${C.BOLD}${C.BRIGHT_YELLOW}FEATURE OVERVIEW${C.RESET} ${C.BOLD}${C.BRIGHT_CYAN}║${C.RESET}`,
57
+ `${C.BOLD}${C.BRIGHT_CYAN}╚════════════════════════════════════════════════════════════╝${C.RESET}`,
58
+ "",
59
+ `${C.BOLD}${C.BRIGHT_GREEN}📁 File Management${C.RESET}`,
60
+ `${C.DIM}────────────────────────────────────────────────────────────${C.RESET}`,
61
+ ` ${C.CYAN}•${C.RESET} Open, save, save-as, new file, close buffer, revert`,
62
+ ` ${C.CYAN}•${C.RESET} File explorer sidebar with create/delete/rename`,
63
+ ` ${C.CYAN}•${C.RESET} Tab-based buffer switching with scroll overflow`,
64
+ ` ${C.CYAN}•${C.RESET} Auto-revert when files change on disk`,
65
+ ` ${C.CYAN}•${C.RESET} Git file finder (fuzzy search tracked files)`,
66
+ "",
67
+ `${C.BOLD}${C.BRIGHT_MAGENTA}✏️ Editing${C.RESET}`,
68
+ `${C.DIM}────────────────────────────────────────────────────────────${C.RESET}`,
69
+ ` ${C.MAGENTA}•${C.RESET} Unlimited undo/redo with full history`,
70
+ ` ${C.MAGENTA}•${C.RESET} Multi-cursor editing (add above/below, next match)`,
71
+ ` ${C.MAGENTA}•${C.RESET} Block/column selection mode`,
72
+ ` ${C.MAGENTA}•${C.RESET} Word, line, and expanding selection`,
73
+ ` ${C.MAGENTA}•${C.RESET} Smart indent/dedent and auto-indentation`,
74
+ ` ${C.MAGENTA}•${C.RESET} Toggle line comments (language-aware)`,
75
+ ` ${C.MAGENTA}•${C.RESET} Clipboard with system integration`,
76
+ "",
77
+ `${C.BOLD}${C.BRIGHT_BLUE}🔍 Search & Replace${C.RESET}`,
78
+ `${C.DIM}────────────────────────────────────────────────────────────${C.RESET}`,
79
+ ` ${C.BLUE}•${C.RESET} Incremental search with match highlighting`,
80
+ ` ${C.BLUE}•${C.RESET} Search within selection`,
81
+ ` ${C.BLUE}•${C.RESET} Replace and replace-all`,
82
+ ` ${C.BLUE}•${C.RESET} Interactive query-replace (y/n/!/q per match)`,
83
+ ` ${C.BLUE}•${C.RESET} Git grep across entire repository`,
84
+ "",
85
+ `${C.BOLD}${C.BRIGHT_YELLOW}🧭 Navigation${C.RESET}`,
86
+ `${C.DIM}────────────────────────────────────────────────────────────${C.RESET}`,
87
+ ` ${C.YELLOW}•${C.RESET} Go to line, go to matching bracket`,
88
+ ` ${C.YELLOW}•${C.RESET} Word and document movement`,
89
+ ` ${C.YELLOW}•${C.RESET} Position history (back/forward)`,
90
+ ` ${C.YELLOW}•${C.RESET} Numbered bookmarks (0-9) with jump`,
91
+ ` ${C.YELLOW}•${C.RESET} Jump to next/previous error`,
92
+ "",
93
+ `${C.BOLD}${C.BRIGHT_CYAN}🖥️ Views & Layout${C.RESET}`,
94
+ `${C.DIM}────────────────────────────────────────────────────────────${C.RESET}`,
95
+ ` ${C.CYAN}•${C.RESET} Horizontal and vertical split panes`,
96
+ ` ${C.CYAN}•${C.RESET} Resizable splits with keyboard/mouse`,
97
+ ` ${C.CYAN}•${C.RESET} Toggle line numbers, line wrap, hidden files`,
98
+ ` ${C.CYAN}•${C.RESET} ANSI art background images with blend control`,
99
+ ` ${C.CYAN}•${C.RESET} Markdown compose/preview mode`,
100
+ "",
101
+ `${C.BOLD}${C.BRIGHT_GREEN}🤖 Language Server (LSP)${C.RESET}`,
102
+ `${C.DIM}────────────────────────────────────────────────────────────${C.RESET}`,
103
+ ` ${C.GREEN}•${C.RESET} Go to definition, find references`,
104
+ ` ${C.GREEN}•${C.RESET} Hover documentation and signature help`,
105
+ ` ${C.GREEN}•${C.RESET} Code actions and quick fixes`,
106
+ ` ${C.GREEN}•${C.RESET} Rename symbol across project`,
107
+ ` ${C.GREEN}•${C.RESET} Real-time diagnostics (errors/warnings)`,
108
+ ` ${C.GREEN}•${C.RESET} Autocompletion with snippets`,
109
+ "",
110
+ `${C.BOLD}${C.BRIGHT_MAGENTA}🎯 Productivity${C.RESET}`,
111
+ `${C.DIM}────────────────────────────────────────────────────────────${C.RESET}`,
112
+ ` ${C.MAGENTA}•${C.RESET} Command palette (${C.YELLOW}Ctrl+P${C.RESET}) for all actions`,
113
+ ` ${C.MAGENTA}•${C.RESET} Full menu bar with mouse/keyboard navigation`,
114
+ ` ${C.MAGENTA}•${C.RESET} Keyboard macros (record/playback, slots 0-9)`,
115
+ ` ${C.MAGENTA}•${C.RESET} Git log viewer with diff display`,
116
+ ` ${C.MAGENTA}•${C.RESET} Diagnostics panel for all errors`,
117
+ "",
118
+ `${C.BOLD}${C.BRIGHT_BLUE}🔌 Plugins & Extensibility${C.RESET}`,
119
+ `${C.DIM}────────────────────────────────────────────────────────────${C.RESET}`,
120
+ ` ${C.BLUE}•${C.RESET} TypeScript plugins in sandboxed Deno runtime`,
121
+ ` ${C.BLUE}•${C.RESET} Color highlighter (hex/rgb colors in code)`,
122
+ ` ${C.BLUE}•${C.RESET} TODO/FIXME highlighter`,
123
+ ` ${C.BLUE}•${C.RESET} Git merge conflict resolver`,
124
+ ` ${C.BLUE}•${C.RESET} Path autocomplete`,
125
+ ` ${C.BLUE}•${C.RESET} Customizable keymaps (JSON config)`,
126
+ "",
127
+ `${C.BOLD}${C.BRIGHT_CYAN}╔════════════════════════════════════════════════════════════╗${C.RESET}`,
128
+ `${C.BOLD}${C.BRIGHT_CYAN}║${C.RESET} ${C.BOLD}${C.BRIGHT_YELLOW}GETTING STARTED${C.RESET} ${C.BOLD}${C.BRIGHT_CYAN}║${C.RESET}`,
129
+ `${C.BOLD}${C.BRIGHT_CYAN}╚════════════════════════════════════════════════════════════╝${C.RESET}`,
130
+ "",
131
+ `${C.BOLD}${C.BRIGHT_GREEN}⭐ Quick Start${C.RESET}`,
132
+ `${C.DIM}────────────────────────────────────────────────────────────${C.RESET}`,
133
+ ` ${C.CYAN}•${C.RESET} ${C.BOLD}Open Files:${C.RESET} Press ${C.YELLOW}Ctrl+O${C.RESET} to browse and open any file`,
134
+ ` ${C.CYAN}•${C.RESET} ${C.BOLD}Command Palette:${C.RESET} Hit ${C.YELLOW}Ctrl+P${C.RESET} - your Swiss Army knife!`,
135
+ ` ${C.CYAN}•${C.RESET} ${C.BOLD}Use the Mouse!${C.RESET} Scroll bars, menus, tabs all work`,
136
+ ` ${C.CYAN}•${C.RESET} ${C.BOLD}Menu Bar:${C.RESET} ${C.YELLOW}Alt+F${C.RESET} for File, ${C.YELLOW}Alt+E${C.RESET} for Edit, etc.`,
137
+ "",
138
+ `${C.BOLD}${C.BRIGHT_YELLOW}⭐ Pro Tips${C.RESET}`,
139
+ `${C.DIM}────────────────────────────────────────────────────────────${C.RESET}`,
140
+ ` ${C.YELLOW}•${C.RESET} ${C.BOLD}Multi-cursor:${C.RESET} ${C.YELLOW}Ctrl+D${C.RESET} adds cursor at next match`,
141
+ ` ${C.YELLOW}•${C.RESET} ${C.BOLD}Search:${C.RESET} ${C.YELLOW}Ctrl+F${C.RESET} finds, ${C.YELLOW}F3${C.RESET}/${C.YELLOW}Shift+F3${C.RESET} navigates matches`,
142
+ ` ${C.YELLOW}•${C.RESET} ${C.BOLD}File Explorer:${C.RESET} ${C.YELLOW}Ctrl+B${C.RESET} toggles sidebar`,
143
+ ` ${C.YELLOW}•${C.RESET} ${C.BOLD}Splits:${C.RESET} Use View menu or command palette`,
144
+ "",
145
+ `${C.BOLD}${C.WHITE}📚 Documentation${C.RESET}`,
146
+ `${C.DIM}────────────────────────────────────────────────────────────${C.RESET}`,
147
+ ` • ${C.GREEN}README.md${C.RESET} - Quick start guide`,
148
+ ` • ${C.GREEN}docs/USER_GUIDE.md${C.RESET} - Comprehensive documentation`,
149
+ ` • ${C.GREEN}docs/PLUGIN_DEVELOPMENT.md${C.RESET} - Build your own plugins`,
150
+ "",
151
+ `${C.DIM}Press ${C.YELLOW}q${C.RESET}${C.DIM} or ${C.YELLOW}Esc${C.RESET}${C.DIM} to close | ${C.YELLOW}Shift+F1${C.RESET}${C.DIM} for keyboard shortcuts${C.RESET}`,
152
+ ];
153
+ return createEntriesFromLines(manualText);
154
+ };
155
+
156
+
157
+
158
+
159
+ const openVirtualBuffer = async (
160
+ name: string,
161
+ entries: TextPropertyEntry[],
162
+ mode: string,
163
+ ): Promise<void> => {
164
+ try {
165
+ await VirtualBufferFactory.create({
166
+ name,
167
+ mode,
168
+ entries,
169
+ showLineNumbers: false,
170
+ editingDisabled: true,
171
+ readOnly: true,
172
+ });
173
+ } catch (error) {
174
+ const message = error instanceof Error ? error.message : String(error);
175
+ editor.setStatus(`Failed to open ${name}: ${message}`);
176
+ }
177
+ };
178
+
179
+ const openManual = async (): Promise<void> => {
180
+ const entries = buildManualEntries();
181
+ await openVirtualBuffer("*Fresh Manual*", entries, MANUAL_MODE);
182
+ };
183
+
184
+ const openShortcuts = async (bindings: { key: string; action: string }[]): Promise<void> => {
185
+ const entries = buildShortcutEntries(bindings);
186
+ await openVirtualBuffer("*Keyboard Shortcuts*", entries, SHORTCUTS_MODE);
187
+ };
188
+
189
+ editor.defineMode(
190
+ MANUAL_MODE,
191
+ null,
192
+ [
193
+ ["q", "manual_help_close"],
194
+ ["Escape", "manual_help_close"],
195
+ ],
196
+ true,
197
+ );
198
+
199
+ editor.defineMode(
200
+ SHORTCUTS_MODE,
201
+ null,
202
+ [
203
+ ["q", "manual_help_close"],
204
+ ["Escape", "manual_help_close"],
205
+ ],
206
+ true,
207
+ );
208
+
209
+ globalThis.manual_help_close = () => {
210
+ const bufferId = editor.getActiveBufferId();
211
+ editor.closeBuffer(bufferId);
212
+ };
213
+
214
+ globalThis.onManualPage = async (): Promise<boolean> => {
215
+ await openManual();
216
+ return true;
217
+ };
218
+
219
+ globalThis.onKeyboardShortcuts = async (args: {
220
+ bindings: { key: string; action: string }[];
221
+ }): Promise<boolean> => {
222
+ await openShortcuts(args.bindings);
223
+ return true;
224
+ };
225
+
226
+ editor.on("manual_page", "onManualPage");
227
+ editor.on("keyboard_shortcuts", "onKeyboardShortcuts");
228
+
229
+ editor.registerCommand(
230
+ "Show Fresh Manual",
231
+ "Open the Fresh manual (virtual buffer)",
232
+ "show_help",
233
+ "normal",
234
+ );
235
+
236
+ editor.registerCommand(
237
+ "Keyboard Shortcuts",
238
+ "Show the keyboard shortcuts list (virtual buffer)",
239
+ "keyboard_shortcuts",
240
+ "normal",
241
+ );
242
+
243
+ editor.debug("Manual/help plugin initialized");