bunmicro 0.8.0 → 0.8.2
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 +11 -0
- package/README.md +27 -5
- package/package.json +1 -1
- package/src/highlight/highlighter.js +8 -2
- package/src/index.js +15 -2
- package/src/platform/clipboard.js +3 -6
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.8.2] - 2026-06-02
|
|
4
|
+
- Fixed Windows TTS function
|
|
5
|
+
- Added ttslang for Windows
|
|
6
|
+
|
|
7
|
+
## [0.8.1] - 2026-06-02
|
|
8
|
+
- Added help for prompts and actions in readme
|
|
9
|
+
- Added more install guides in readme
|
|
10
|
+
- Fixed crash when opening `config.fish`
|
|
11
|
+
- 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
|
|
14
|
-
- or inside the editor Ctrl-E open
|
|
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
|
|
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
|
|
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
|
|
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
|
@@ -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;
|
package/src/index.js
CHANGED
|
@@ -3863,6 +3863,16 @@ class App {
|
|
|
3863
3863
|
this.message = `TTS_PITCH = ${tpv}`;
|
|
3864
3864
|
break;
|
|
3865
3865
|
}
|
|
3866
|
+
case "ttslang": {
|
|
3867
|
+
if (cmdArgs.length === 0) {
|
|
3868
|
+
this.message = `TTS_LANG = ${Bun.env.TTS_LANG ?? "zh-TW"}`;
|
|
3869
|
+
break;
|
|
3870
|
+
}
|
|
3871
|
+
|
|
3872
|
+
Bun.env.TTS_LANG = String(cmdArgs[0]);
|
|
3873
|
+
this.message = `TTS_LANG = ${Bun.env.TTS_LANG}`;
|
|
3874
|
+
break;
|
|
3875
|
+
}
|
|
3866
3876
|
case "help": {
|
|
3867
3877
|
const helpsplit = this.context?.config?.globalSettings?.helpsplit ?? "hsplit";
|
|
3868
3878
|
let helpHsplit = helpsplit !== "vsplit";
|
|
@@ -4410,7 +4420,7 @@ function ansiMagenta(text) { return ansiWrap("95", text); }
|
|
|
4410
4420
|
|
|
4411
4421
|
const COMMAND_NAMES = [
|
|
4412
4422
|
"set", "setlocal", "show", "get", "open", "open!", "save", "quit", "q", "exit", "goto", "comment", "find", "replace", "replaceall",
|
|
4413
|
-
"cd", "pwd", "tab", "run", "vsplit", "hsplit", "term", "tts", "ttsspeed", "ttspitch", "reopen", "theme", "toggle", "tog",
|
|
4423
|
+
"cd", "pwd", "tab", "run", "vsplit", "hsplit", "term", "tts", "ttsspeed", "ttspitch", "ttslang", "reopen", "theme", "toggle", "tog",
|
|
4414
4424
|
"togglelocal", "reset", "jump", "tabmove", "tabswitch", "textfilter", "bind", "unbind", "reload", "lintlog", "act", "action", "raw",
|
|
4415
4425
|
"help", "plugin", "showkey", "memusage", "retab", "eval",
|
|
4416
4426
|
];
|
|
@@ -4849,6 +4859,9 @@ function detectTtsCmd() {
|
|
|
4849
4859
|
const speed = parseFloat(Bun.env.TTS_SPEED) || 1.5;
|
|
4850
4860
|
Bun.env.TTS_PITCH = String(pitch);
|
|
4851
4861
|
Bun.env.TTS_SPEED = String(speed);
|
|
4862
|
+
|
|
4863
|
+
const lang = Bun.env.TTS_LANG || 'zh-TW'
|
|
4864
|
+
Bun.env.TTS_LANG = lang ;
|
|
4852
4865
|
|
|
4853
4866
|
if (platform === "android") {
|
|
4854
4867
|
if (runSync(["sh", "-c", "command -v termux-tts-speak"], { stdout: "ignore", stderr: "ignore" }).ok)
|
|
@@ -4878,7 +4891,7 @@ function detectTtsCmd() {
|
|
|
4878
4891
|
`$s = New-Object System.Speech.Synthesis.SpeechSynthesizer; $s.Rate = ${rate}; ` +
|
|
4879
4892
|
`$t = [Console]::In.ReadToEnd(); ` +
|
|
4880
4893
|
`$x = [System.Security.SecurityElement]::Escape($t); ` +
|
|
4881
|
-
`$s.SpeakSsml('<speak version="
|
|
4894
|
+
`$s.SpeakSsml('<speak xml:lang="${lang}" version="1.0" xmlns="http://www.w3.org/2001/10/synthesis"><prosody pitch="${pitchAttr}">' + $x + '</prosody></speak>')`;
|
|
4882
4895
|
return { cmd: [shell, "-NoProfile", "-Command", psCmd], via: "stdin" };
|
|
4883
4896
|
}
|
|
4884
4897
|
}
|
|
@@ -145,16 +145,13 @@ function xselClipboard(xsel) {
|
|
|
145
145
|
function powershellClipboard(shell) {
|
|
146
146
|
return {
|
|
147
147
|
name: "powershell",
|
|
148
|
-
|
|
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
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function trimOneTrailingNewline(text) {
|
|
159
|
-
return text.replace(/\r?\n$/, "");
|
|
156
|
+
return result.stdout;
|
|
160
157
|
}
|