@duckmind/dm-darwin-x64 0.33.8 → 0.34.0
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.
|
@@ -51,6 +51,8 @@ export function isNativeEditorRule(line: string): boolean {
|
|
|
51
51
|
|
|
52
52
|
export function splitNativeEditorRender(lines: readonly string[]): SplitEditorRenderResult {
|
|
53
53
|
if (lines.length === 0) return { editorLines: [], popupLines: [] };
|
|
54
|
+
const boxed = splitNativeEditorBoxRender(lines);
|
|
55
|
+
if (boxed) return boxed;
|
|
54
56
|
const withoutTop = isNativeEditorRule(lines[0] ?? "") ? lines.slice(1) : [...lines];
|
|
55
57
|
const bottomRuleIndex = withoutTop.findIndex(isNativeEditorRule);
|
|
56
58
|
if (bottomRuleIndex === -1) {
|
|
@@ -62,6 +64,38 @@ export function splitNativeEditorRender(lines: readonly string[]): SplitEditorRe
|
|
|
62
64
|
};
|
|
63
65
|
}
|
|
64
66
|
|
|
67
|
+
function splitNativeEditorBoxRender(lines: readonly string[]): SplitEditorRenderResult | null {
|
|
68
|
+
if (!isNativeEditorBoxTop(lines[0] ?? "")) return null;
|
|
69
|
+
const bottomIndex = lines.findIndex((line, index) => index > 0 && isNativeEditorBoxBottom(line));
|
|
70
|
+
if (bottomIndex === -1) return null;
|
|
71
|
+
return {
|
|
72
|
+
editorLines: lines.slice(1, bottomIndex).map(stripNativeEditorBoxContentLine),
|
|
73
|
+
popupLines: lines.slice(bottomIndex + 1),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function isNativeEditorBoxTop(line: string): boolean {
|
|
78
|
+
const plain = stripAnsi(line).trim();
|
|
79
|
+
return plain.startsWith("╭") && plain.endsWith("╮") && plain.includes("─");
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function isNativeEditorBoxBottom(line: string): boolean {
|
|
83
|
+
const plain = stripAnsi(line).trim();
|
|
84
|
+
return plain.startsWith("╰") && plain.endsWith("╯") && plain.includes("─");
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function isNativeEditorBoxContent(line: string): boolean {
|
|
88
|
+
const plain = stripAnsi(line);
|
|
89
|
+
return plain.startsWith("│") && plain.endsWith("│");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function stripNativeEditorBoxContentLine(line: string): string {
|
|
93
|
+
if (!isNativeEditorBoxContent(line)) return line;
|
|
94
|
+
return line
|
|
95
|
+
.replace(/^(?:\x1b\[[0-?]*[ -/]*[@-~])*│(?:\x1b\[[0-?]*[ -/]*[@-~])*/, "")
|
|
96
|
+
.replace(/(?:\x1b\[[0-?]*[ -/]*[@-~])*│(?:\x1b\[[0-?]*[ -/]*[@-~])*$/, "");
|
|
97
|
+
}
|
|
98
|
+
|
|
65
99
|
export function renderBottomInputEditorLines(input: { lines: readonly string[]; width: number; theme: ThemeLike; state: BottomInputEditorState }): string[] {
|
|
66
100
|
const width = Number.isFinite(input.width) ? Math.max(0, Math.floor(input.width)) : 0;
|
|
67
101
|
if (!input.state.beautifiedInputEnabled || width < MIN_FRAME_WIDTH) return [...input.lines];
|