bunmicro 0.8.0 → 0.8.1

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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ ## [0.8.1] - 2026-06-02
4
+ - Added help for prompts and actions in readme
5
+ - Added more install guides in readme
6
+ - Fixed crash when opening `config.fish`
7
+ - Fixed Ctrl-k Ctrl-v newline behavior
package/README.md CHANGED
@@ -10,8 +10,8 @@
10
10
 
11
11
  # Unique features
12
12
  ## Load URLs directly
13
- - bunmicro <url>
14
- - or inside the editor Ctrl-E open <url>
13
+ - bunmicro `url`
14
+ - or inside the editor Ctrl-E open `url`
15
15
  ## Long line protection
16
16
  - In the original micro, if you open a minified file like vue.min.js it will be very slow due to re-highlighting
17
17
  - In this Bun version, if line > 300 characters, re-highlighting is paused until ESC is pressed
@@ -25,7 +25,10 @@
25
25
  - Also available: Ctrl-E act SelectRight
26
26
  ## js plugin
27
27
  - Instead of writing Lua, use your familiar JavaScript to extend functionalities
28
- - runtime/jsplugins/<name>/<name>.js
28
+ - runtime/jsplugins/`name`/`name`.js
29
+ - a full documentation in example.js
30
+ - an example plugin named chapter for turning to the next/prev page by number.
31
+ - It registers 2 commands: next/prevchapter
29
32
  ## Output highlighted text to terminal
30
33
  - Works like bat ccat glow
31
34
  - bunmicro -bat file
@@ -37,6 +40,8 @@
37
40
  - A complete help is at the end
38
41
  ## Auto-completions arrow keys
39
42
  - Press Tab and use arrow keys to select items
43
+ ## action/js commands
44
+ - A complete help is at the end
40
45
  ## Version shows backends
41
46
  - bunmicro --version shows http/clipboard/tts backends
42
47
 
@@ -60,7 +65,7 @@
60
65
 
61
66
  ```sh
62
67
  # Install Bun
63
- npm i -g bun
68
+ npm install -g bun
64
69
 
65
70
  # Run bunmicro(stable)
66
71
  npx bunmicro
@@ -69,7 +74,7 @@ npx bunmicro
69
74
  # if npx is not available, use npm x -- bunmicro
70
75
 
71
76
  # Run bunmicro(shorter command, less stable)
72
- # npm i -g bunmicro
77
+ # npm install -g bunmicro
73
78
  # bunmicro
74
79
  ```
75
80
 
@@ -82,6 +87,10 @@ npx bunmicro
82
87
  bun x bunmicro
83
88
  # bun x bunmicro [options] [file1] [file2] ...
84
89
  # alternative: bun bunmicro/src/index.js [options] [file1] [file2] ...
90
+
91
+ # If bunx is broken, follow the 2 steps below
92
+ # bun i -g --backend=copyfile bunmicro
93
+ # bun ~/.bun/bin/bunmicro
85
94
  ```
86
95
 
87
96
  # Basic features
@@ -151,3 +160,16 @@ bun x bunmicro
151
160
  - Encoding: Reopen with a specific encoding.
152
161
  * Show supported encodings by bunmicro --version
153
162
  - Alt-G: Show nano-like key bindings menu
163
+
164
+ # Command/Shell Prompts
165
+ ## Command
166
+ - Internal commands for automating / tuning bunmicro
167
+ - Press Tab for available commands, arrow keys for selection
168
+ - In this Bun version, I added more commands like
169
+ * js to eval JavaScript
170
+ * act/action to do automation actions.
171
+ * Press tab after act to get a list of them
172
+ * or use help actions to show the list
173
+ ## Shell
174
+ - Executes a given shell command like sh -c
175
+ - Outputs the result to the original terminal before entering bunmicro
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunmicro",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Bun JavaScript rewrite of the micro editor originally in Golang",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -188,8 +188,11 @@ function findAllMatches(regex, line, start, end, progress = null) {
188
188
  const matchStart = match.index ?? 0;
189
189
  if (matchStart >= end) break;
190
190
  const matchEnd = matchStart + match[0].length;
191
+ if (match[0].length === 0) {
192
+ global.lastIndex++;
193
+ continue;
194
+ }
191
195
  if (matchEnd > start) out.push({ start: Math.max(matchStart, start), end: Math.min(matchEnd, end) });
192
- if (match[0].length === 0) global.lastIndex++;
193
196
  }
194
197
  return out;
195
198
  }
@@ -198,9 +201,12 @@ function findAllMatches(regex, line, start, end, progress = null) {
198
201
  const matchEnd = matchStart + match[0].length;
199
202
  if (matchStart >= end) break;
200
203
  progress?.(matchStart);
204
+ if (match[0].length === 0) {
205
+ global.lastIndex++;
206
+ continue;
207
+ }
201
208
  if (matchEnd <= start || matchStart >= end) continue;
202
209
  out.push({ start: Math.max(matchStart, start), end: Math.min(matchEnd, end) });
203
- if (match[0].length === 0) global.lastIndex++;
204
210
  }
205
211
  progress?.(end);
206
212
  return out;
@@ -145,16 +145,13 @@ function xselClipboard(xsel) {
145
145
  function powershellClipboard(shell) {
146
146
  return {
147
147
  name: "powershell",
148
- read: () => outputOrThrow(runSync([shell, "-NoProfile", "-Command", "Get-Clipboard -Raw"], { timeout: CLIPBOARD_TIMEOUT_MS })),
148
+ // Get-Clipboard -Raw appends \r\n to stdout; strip exactly one trailing line ending.
149
+ read: () => outputOrThrow(runSync([shell, "-NoProfile", "-Command", "Get-Clipboard -Raw"], { timeout: CLIPBOARD_TIMEOUT_MS })).replace(/\r?\n$/, ""),
149
150
  write: (text) => runSync([shell, "-NoProfile", "-Command", "Set-Clipboard"], { stdin: text, stdout: "ignore", timeout: CLIPBOARD_TIMEOUT_MS }).ok,
150
151
  };
151
152
  }
152
153
 
153
154
  function outputOrThrow(result) {
154
155
  if (!result.ok) throw new Error(result.stderr || result.stdout || "clipboard command failed");
155
- return trimOneTrailingNewline(result.stdout);
156
- }
157
-
158
- function trimOneTrailingNewline(text) {
159
- return text.replace(/\r?\n$/, "");
156
+ return result.stdout;
160
157
  }