@narumitw/pi-statusline 0.49.6 → 0.49.7
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/package.json +2 -2
- package/src/directory.ts +1 -1
- package/src/render.ts +1 -1
- package/src/terminal.ts +0 -60
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@narumitw/pi-statusline",
|
|
3
|
-
"version": "0.49.
|
|
3
|
+
"version": "0.49.7",
|
|
4
4
|
"description": "Pi extension that replaces the footer with an information-rich statusline.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,6 +47,6 @@
|
|
|
47
47
|
"directory": "packages/pi-statusline"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@narumitw/pi-tui-kit": "^0.
|
|
50
|
+
"@narumitw/pi-tui-kit": "^0.54.0"
|
|
51
51
|
}
|
|
52
52
|
}
|
package/src/directory.ts
CHANGED
package/src/render.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
Theme,
|
|
6
6
|
ThemeColor,
|
|
7
7
|
} from "@earendil-works/pi-coding-agent";
|
|
8
|
+
import { sanitizeTerminalText } from "@narumitw/pi-tui-kit";
|
|
8
9
|
import { formatDirectoryPath } from "./directory.js";
|
|
9
10
|
import {
|
|
10
11
|
type ExtensionStatusRuntime,
|
|
@@ -13,7 +14,6 @@ import {
|
|
|
13
14
|
} from "./extension-status.js";
|
|
14
15
|
import { formatGitBranchValue, type GitStatusSummary } from "./git-status.js";
|
|
15
16
|
import { renderPowerlineStatusline } from "./powerline.js";
|
|
16
|
-
import { sanitizeTerminalText } from "./terminal.js";
|
|
17
17
|
import {
|
|
18
18
|
LINE_BREAK_SEGMENT_NAME,
|
|
19
19
|
type PowerlineBlockName,
|
package/src/terminal.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
export function sanitizeTerminalText(value: string): string {
|
|
2
|
-
let result = "";
|
|
3
|
-
for (let index = 0; index < value.length; ) {
|
|
4
|
-
const codePoint = value.codePointAt(index) ?? 0;
|
|
5
|
-
const character = String.fromCodePoint(codePoint);
|
|
6
|
-
if (codePoint === 0x1b || codePoint === 0x9b || codePoint === 0x9d) {
|
|
7
|
-
index = skipTerminalEscape(value, index, codePoint);
|
|
8
|
-
continue;
|
|
9
|
-
}
|
|
10
|
-
if (
|
|
11
|
-
codePoint <= 0x1f ||
|
|
12
|
-
(codePoint >= 0x7f && codePoint <= 0x9f) ||
|
|
13
|
-
codePoint === 0x2028 ||
|
|
14
|
-
codePoint === 0x2029
|
|
15
|
-
) {
|
|
16
|
-
if (
|
|
17
|
-
codePoint === 0x09 ||
|
|
18
|
-
codePoint === 0x0a ||
|
|
19
|
-
codePoint === 0x0d ||
|
|
20
|
-
codePoint === 0x85 ||
|
|
21
|
-
codePoint === 0x2028 ||
|
|
22
|
-
codePoint === 0x2029
|
|
23
|
-
) {
|
|
24
|
-
result += " ";
|
|
25
|
-
}
|
|
26
|
-
index += character.length;
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
result += character;
|
|
30
|
-
index += character.length;
|
|
31
|
-
}
|
|
32
|
-
return result;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function skipTerminalEscape(value: string, start: number, codePoint: number): number {
|
|
36
|
-
let index = start + 1;
|
|
37
|
-
const next = value.charCodeAt(index);
|
|
38
|
-
const isOsc = codePoint === 0x9d || (codePoint === 0x1b && next === 0x5d);
|
|
39
|
-
if (isOsc) {
|
|
40
|
-
if (codePoint === 0x1b) index += 1;
|
|
41
|
-
while (index < value.length) {
|
|
42
|
-
const current = value.charCodeAt(index);
|
|
43
|
-
if (current === 0x07 || current === 0x9c) return index + 1;
|
|
44
|
-
if (current === 0x1b && value.charCodeAt(index + 1) === 0x5c) return index + 2;
|
|
45
|
-
index += 1;
|
|
46
|
-
}
|
|
47
|
-
return index;
|
|
48
|
-
}
|
|
49
|
-
const isCsi = codePoint === 0x9b || (codePoint === 0x1b && next === 0x5b);
|
|
50
|
-
if (isCsi) {
|
|
51
|
-
if (codePoint === 0x1b) index += 1;
|
|
52
|
-
while (index < value.length) {
|
|
53
|
-
const current = value.charCodeAt(index);
|
|
54
|
-
index += 1;
|
|
55
|
-
if (current >= 0x40 && current <= 0x7e) break;
|
|
56
|
-
}
|
|
57
|
-
return index;
|
|
58
|
-
}
|
|
59
|
-
return Math.min(value.length, start + (codePoint === 0x1b ? 2 : 1));
|
|
60
|
-
}
|