@opentui/core 0.1.60 → 0.1.62
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/3d.js +1 -1
- package/Renderable.d.ts +14 -3
- package/buffer.d.ts +4 -0
- package/console.d.ts +53 -1
- package/editor-view.d.ts +6 -1
- package/{index-916mvx7m.js → index-mrwvcpzb.js} +762 -170
- package/{index-916mvx7m.js.map → index-mrwvcpzb.js.map} +12 -11
- package/index.js +204 -149
- package/index.js.map +13 -14
- package/lib/keymapping.d.ts +11 -0
- package/lib/selection.d.ts +4 -4
- package/package.json +8 -8
- package/renderables/EditBufferRenderable.d.ts +10 -1
- package/renderables/Input.d.ts +1 -1
- package/renderables/ScrollBar.d.ts +1 -1
- package/renderables/ScrollBox.d.ts +1 -1
- package/renderables/Select.d.ts +1 -1
- package/renderables/TabSelect.d.ts +1 -1
- package/renderables/Textarea.d.ts +8 -2
- package/renderer.d.ts +1 -0
- package/testing/test-recorder.d.ts +16 -1
- package/testing.js +32 -8
- package/testing.js.map +4 -4
- package/text-buffer-view.d.ts +2 -0
- package/zig.d.ts +12 -1
|
@@ -2319,6 +2319,7 @@ var parseKeypress = (s = "", options = {}) => {
|
|
|
2319
2319
|
const segs = [...s];
|
|
2320
2320
|
if (segs[0] === "\x1B" && segs[1] === "\x1B") {
|
|
2321
2321
|
key.option = true;
|
|
2322
|
+
key.meta = true;
|
|
2322
2323
|
}
|
|
2323
2324
|
const code = [parts[1], parts[2], parts[4], parts[6]].filter(Boolean).join("");
|
|
2324
2325
|
const modifier = parseInt(parts[3] || parts[5] || "1", 10) - 1;
|
|
@@ -6479,37 +6480,30 @@ class SelectionAnchor {
|
|
|
6479
6480
|
|
|
6480
6481
|
class Selection {
|
|
6481
6482
|
_anchor;
|
|
6482
|
-
|
|
6483
|
-
_normalizedAnchor;
|
|
6484
|
-
_normalizedFocus;
|
|
6483
|
+
_focus;
|
|
6485
6484
|
_selectedRenderables = [];
|
|
6486
6485
|
_touchedRenderables = [];
|
|
6487
6486
|
_isActive = true;
|
|
6488
6487
|
_isSelecting = true;
|
|
6488
|
+
_isStart = false;
|
|
6489
6489
|
constructor(anchorRenderable, anchor, focus) {
|
|
6490
6490
|
this._anchor = new SelectionAnchor(anchorRenderable, anchor.x, anchor.y);
|
|
6491
|
-
this.
|
|
6492
|
-
|
|
6491
|
+
this._focus = { ...focus };
|
|
6492
|
+
}
|
|
6493
|
+
get isStart() {
|
|
6494
|
+
return this._isStart;
|
|
6495
|
+
}
|
|
6496
|
+
set isStart(value) {
|
|
6497
|
+
this._isStart = value;
|
|
6493
6498
|
}
|
|
6494
6499
|
get anchor() {
|
|
6495
|
-
return {
|
|
6500
|
+
return { x: this._anchor.x, y: this._anchor.y };
|
|
6496
6501
|
}
|
|
6497
6502
|
get focus() {
|
|
6498
|
-
return { ...this.
|
|
6503
|
+
return { ...this._focus };
|
|
6499
6504
|
}
|
|
6500
6505
|
set focus(value) {
|
|
6501
|
-
this.
|
|
6502
|
-
this._updateNormalizedSelection();
|
|
6503
|
-
}
|
|
6504
|
-
_updateNormalizedSelection() {
|
|
6505
|
-
const anchorBeforeFocus = this._anchor.y < this._originalFocus.y || this._anchor.y === this._originalFocus.y && this._anchor.x <= this._originalFocus.x;
|
|
6506
|
-
if (anchorBeforeFocus) {
|
|
6507
|
-
this._normalizedAnchor = { x: this._anchor.x, y: this._anchor.y };
|
|
6508
|
-
this._normalizedFocus = { ...this._originalFocus };
|
|
6509
|
-
} else {
|
|
6510
|
-
this._normalizedAnchor = { ...this._originalFocus };
|
|
6511
|
-
this._normalizedFocus = { x: this._anchor.x + 1, y: this._anchor.y };
|
|
6512
|
-
}
|
|
6506
|
+
this._focus = { ...value };
|
|
6513
6507
|
}
|
|
6514
6508
|
get isActive() {
|
|
6515
6509
|
return this._isActive;
|
|
@@ -6524,11 +6518,17 @@ class Selection {
|
|
|
6524
6518
|
this._isSelecting = value;
|
|
6525
6519
|
}
|
|
6526
6520
|
get bounds() {
|
|
6521
|
+
const minX = Math.min(this._anchor.x, this._focus.x);
|
|
6522
|
+
const maxX = Math.max(this._anchor.x, this._focus.x);
|
|
6523
|
+
const minY = Math.min(this._anchor.y, this._focus.y);
|
|
6524
|
+
const maxY = Math.max(this._anchor.y, this._focus.y);
|
|
6525
|
+
const width = maxX - minX + 1;
|
|
6526
|
+
const height = maxY - minY + 1;
|
|
6527
6527
|
return {
|
|
6528
|
-
x:
|
|
6529
|
-
y:
|
|
6530
|
-
width
|
|
6531
|
-
height
|
|
6528
|
+
x: minX,
|
|
6529
|
+
y: minY,
|
|
6530
|
+
width,
|
|
6531
|
+
height
|
|
6532
6532
|
};
|
|
6533
6533
|
}
|
|
6534
6534
|
updateSelectedRenderables(selectedRenderables) {
|
|
@@ -9390,6 +9390,22 @@ class OptimizedBuffer {
|
|
|
9390
9390
|
this.guard();
|
|
9391
9391
|
this.lib.bufferClearScissorRects(this.bufferPtr);
|
|
9392
9392
|
}
|
|
9393
|
+
pushOpacity(opacity) {
|
|
9394
|
+
this.guard();
|
|
9395
|
+
this.lib.bufferPushOpacity(this.bufferPtr, Math.max(0, Math.min(1, opacity)));
|
|
9396
|
+
}
|
|
9397
|
+
popOpacity() {
|
|
9398
|
+
this.guard();
|
|
9399
|
+
this.lib.bufferPopOpacity(this.bufferPtr);
|
|
9400
|
+
}
|
|
9401
|
+
getCurrentOpacity() {
|
|
9402
|
+
this.guard();
|
|
9403
|
+
return this.lib.bufferGetCurrentOpacity(this.bufferPtr);
|
|
9404
|
+
}
|
|
9405
|
+
clearOpacity() {
|
|
9406
|
+
this.guard();
|
|
9407
|
+
this.lib.bufferClearOpacity(this.bufferPtr);
|
|
9408
|
+
}
|
|
9393
9409
|
encodeUnicode(text) {
|
|
9394
9410
|
this.guard();
|
|
9395
9411
|
return this.lib.encodeUnicode(text, this._widthMethod);
|
|
@@ -10132,6 +10148,9 @@ registerEnvVar({
|
|
|
10132
10148
|
type: "boolean",
|
|
10133
10149
|
default: false
|
|
10134
10150
|
});
|
|
10151
|
+
var globalTraceSymbols = null;
|
|
10152
|
+
var globalFFILogWriter = null;
|
|
10153
|
+
var exitHandlerRegistered = false;
|
|
10135
10154
|
function getOpenTUILib(libPath) {
|
|
10136
10155
|
const resolvedLibPath = libPath || targetLibPath;
|
|
10137
10156
|
const rawSymbols = dlopen(resolvedLibPath, {
|
|
@@ -10319,6 +10338,22 @@ function getOpenTUILib(libPath) {
|
|
|
10319
10338
|
args: ["ptr"],
|
|
10320
10339
|
returns: "void"
|
|
10321
10340
|
},
|
|
10341
|
+
bufferPushOpacity: {
|
|
10342
|
+
args: ["ptr", "f32"],
|
|
10343
|
+
returns: "void"
|
|
10344
|
+
},
|
|
10345
|
+
bufferPopOpacity: {
|
|
10346
|
+
args: ["ptr"],
|
|
10347
|
+
returns: "void"
|
|
10348
|
+
},
|
|
10349
|
+
bufferGetCurrentOpacity: {
|
|
10350
|
+
args: ["ptr"],
|
|
10351
|
+
returns: "f32"
|
|
10352
|
+
},
|
|
10353
|
+
bufferClearOpacity: {
|
|
10354
|
+
args: ["ptr"],
|
|
10355
|
+
returns: "void"
|
|
10356
|
+
},
|
|
10322
10357
|
addToHitGrid: {
|
|
10323
10358
|
args: ["ptr", "i32", "i32", "u32", "u32", "u32"],
|
|
10324
10359
|
returns: "void"
|
|
@@ -10531,6 +10566,14 @@ function getOpenTUILib(libPath) {
|
|
|
10531
10566
|
args: ["ptr", "i32", "i32", "i32", "i32", "ptr", "ptr"],
|
|
10532
10567
|
returns: "bool"
|
|
10533
10568
|
},
|
|
10569
|
+
textBufferViewUpdateSelection: {
|
|
10570
|
+
args: ["ptr", "u32", "ptr", "ptr"],
|
|
10571
|
+
returns: "void"
|
|
10572
|
+
},
|
|
10573
|
+
textBufferViewUpdateLocalSelection: {
|
|
10574
|
+
args: ["ptr", "i32", "i32", "i32", "i32", "ptr", "ptr"],
|
|
10575
|
+
returns: "bool"
|
|
10576
|
+
},
|
|
10534
10577
|
textBufferViewResetLocalSelection: {
|
|
10535
10578
|
args: ["ptr"],
|
|
10536
10579
|
returns: "void"
|
|
@@ -10603,6 +10646,10 @@ function getOpenTUILib(libPath) {
|
|
|
10603
10646
|
args: ["ptr", "u32", "u32"],
|
|
10604
10647
|
returns: "void"
|
|
10605
10648
|
},
|
|
10649
|
+
editorViewSetViewport: {
|
|
10650
|
+
args: ["ptr", "u32", "u32", "u32", "u32", "bool"],
|
|
10651
|
+
returns: "void"
|
|
10652
|
+
},
|
|
10606
10653
|
editorViewGetViewport: {
|
|
10607
10654
|
args: ["ptr", "ptr", "ptr", "ptr", "ptr"],
|
|
10608
10655
|
returns: "void"
|
|
@@ -10808,7 +10855,15 @@ function getOpenTUILib(libPath) {
|
|
|
10808
10855
|
returns: "u64"
|
|
10809
10856
|
},
|
|
10810
10857
|
editorViewSetLocalSelection: {
|
|
10811
|
-
args: ["ptr", "i32", "i32", "i32", "i32", "ptr", "ptr"],
|
|
10858
|
+
args: ["ptr", "i32", "i32", "i32", "i32", "ptr", "ptr", "bool"],
|
|
10859
|
+
returns: "bool"
|
|
10860
|
+
},
|
|
10861
|
+
editorViewUpdateSelection: {
|
|
10862
|
+
args: ["ptr", "u32", "ptr", "ptr"],
|
|
10863
|
+
returns: "void"
|
|
10864
|
+
},
|
|
10865
|
+
editorViewUpdateLocalSelection: {
|
|
10866
|
+
args: ["ptr", "i32", "i32", "i32", "i32", "ptr", "ptr", "bool"],
|
|
10812
10867
|
returns: "bool"
|
|
10813
10868
|
},
|
|
10814
10869
|
editorViewResetLocalSelection: {
|
|
@@ -10859,6 +10914,14 @@ function getOpenTUILib(libPath) {
|
|
|
10859
10914
|
args: ["ptr", "ptr"],
|
|
10860
10915
|
returns: "void"
|
|
10861
10916
|
},
|
|
10917
|
+
editorViewGetVisualSOL: {
|
|
10918
|
+
args: ["ptr", "ptr"],
|
|
10919
|
+
returns: "void"
|
|
10920
|
+
},
|
|
10921
|
+
editorViewGetVisualEOL: {
|
|
10922
|
+
args: ["ptr", "ptr"],
|
|
10923
|
+
returns: "void"
|
|
10924
|
+
},
|
|
10862
10925
|
editorViewSetPlaceholderStyledText: {
|
|
10863
10926
|
args: ["ptr", "ptr", "usize"],
|
|
10864
10927
|
returns: "void"
|
|
@@ -10924,19 +10987,22 @@ function getOpenTUILib(libPath) {
|
|
|
10924
10987
|
return rawSymbols;
|
|
10925
10988
|
}
|
|
10926
10989
|
function convertToDebugSymbols(symbols) {
|
|
10990
|
+
if (!globalTraceSymbols) {
|
|
10991
|
+
globalTraceSymbols = {};
|
|
10992
|
+
}
|
|
10993
|
+
if (env.OTUI_DEBUG_FFI && !globalFFILogWriter) {
|
|
10994
|
+
const now = new Date;
|
|
10995
|
+
const timestamp = now.toISOString().replace(/[:.]/g, "-").replace(/T/, "_").split("Z")[0];
|
|
10996
|
+
const logFilePath = `ffi_otui_debug_${timestamp}.log`;
|
|
10997
|
+
globalFFILogWriter = Bun.file(logFilePath).writer();
|
|
10998
|
+
}
|
|
10927
10999
|
const debugSymbols = {};
|
|
10928
|
-
const traceSymbols = {};
|
|
10929
11000
|
let hasTracing = false;
|
|
10930
|
-
let ffiLogWriter = null;
|
|
10931
11001
|
Object.entries(symbols).forEach(([key, value]) => {
|
|
10932
11002
|
debugSymbols[key] = value;
|
|
10933
11003
|
});
|
|
10934
|
-
if (env.OTUI_DEBUG_FFI) {
|
|
10935
|
-
const
|
|
10936
|
-
const timestamp = now.toISOString().replace(/[:.]/g, "-").replace(/T/, "_").split("Z")[0];
|
|
10937
|
-
const logFilePath = `ffi_otui_debug_${timestamp}.log`;
|
|
10938
|
-
ffiLogWriter = Bun.file(logFilePath).writer();
|
|
10939
|
-
const writer = ffiLogWriter;
|
|
11004
|
+
if (env.OTUI_DEBUG_FFI && globalFFILogWriter) {
|
|
11005
|
+
const writer = globalFFILogWriter;
|
|
10940
11006
|
const writeSync = (msg) => {
|
|
10941
11007
|
const buffer = new TextEncoder().encode(msg + `
|
|
10942
11008
|
`);
|
|
@@ -10958,89 +11024,104 @@ function convertToDebugSymbols(symbols) {
|
|
|
10958
11024
|
hasTracing = true;
|
|
10959
11025
|
Object.entries(symbols).forEach(([key, value]) => {
|
|
10960
11026
|
if (typeof value === "function") {
|
|
10961
|
-
|
|
11027
|
+
if (!globalTraceSymbols[key]) {
|
|
11028
|
+
globalTraceSymbols[key] = [];
|
|
11029
|
+
}
|
|
10962
11030
|
const originalFunc = debugSymbols[key];
|
|
10963
11031
|
debugSymbols[key] = (...args) => {
|
|
10964
11032
|
const start = performance.now();
|
|
10965
11033
|
const result = originalFunc(...args);
|
|
10966
11034
|
const end = performance.now();
|
|
10967
|
-
|
|
11035
|
+
globalTraceSymbols[key].push(end - start);
|
|
10968
11036
|
return result;
|
|
10969
11037
|
};
|
|
10970
11038
|
}
|
|
10971
11039
|
});
|
|
10972
11040
|
}
|
|
10973
|
-
if (env.OTUI_DEBUG_FFI &&
|
|
11041
|
+
if ((env.OTUI_DEBUG_FFI || env.OTUI_TRACE_FFI) && !exitHandlerRegistered) {
|
|
11042
|
+
exitHandlerRegistered = true;
|
|
10974
11043
|
process.on("exit", () => {
|
|
10975
11044
|
try {
|
|
10976
|
-
|
|
11045
|
+
if (globalFFILogWriter) {
|
|
11046
|
+
globalFFILogWriter.end();
|
|
11047
|
+
}
|
|
10977
11048
|
} catch (e) {}
|
|
10978
|
-
|
|
10979
|
-
|
|
10980
|
-
|
|
10981
|
-
|
|
10982
|
-
|
|
10983
|
-
|
|
10984
|
-
|
|
10985
|
-
|
|
11049
|
+
if (globalTraceSymbols) {
|
|
11050
|
+
const allStats = [];
|
|
11051
|
+
for (const [key, timings] of Object.entries(globalTraceSymbols)) {
|
|
11052
|
+
if (!Array.isArray(timings) || timings.length === 0) {
|
|
11053
|
+
continue;
|
|
11054
|
+
}
|
|
11055
|
+
const sortedTimings = [...timings].sort((a, b) => a - b);
|
|
11056
|
+
const count = sortedTimings.length;
|
|
11057
|
+
const total = sortedTimings.reduce((acc, t2) => acc + t2, 0);
|
|
11058
|
+
const average = total / count;
|
|
11059
|
+
const min = sortedTimings[0];
|
|
11060
|
+
const max = sortedTimings[count - 1];
|
|
11061
|
+
const medianIndex = Math.floor(count / 2);
|
|
11062
|
+
const p90Index = Math.floor(count * 0.9);
|
|
11063
|
+
const p99Index = Math.floor(count * 0.99);
|
|
11064
|
+
const median = sortedTimings[medianIndex];
|
|
11065
|
+
const p90 = sortedTimings[Math.min(p90Index, count - 1)];
|
|
11066
|
+
const p99 = sortedTimings[Math.min(p99Index, count - 1)];
|
|
11067
|
+
allStats.push({
|
|
11068
|
+
name: key,
|
|
11069
|
+
count,
|
|
11070
|
+
total,
|
|
11071
|
+
average,
|
|
11072
|
+
min,
|
|
11073
|
+
max,
|
|
11074
|
+
median,
|
|
11075
|
+
p90,
|
|
11076
|
+
p99
|
|
11077
|
+
});
|
|
10986
11078
|
}
|
|
10987
|
-
|
|
10988
|
-
const
|
|
10989
|
-
|
|
10990
|
-
const average = total / count;
|
|
10991
|
-
const min = sortedTimings[0];
|
|
10992
|
-
const max = sortedTimings[count - 1];
|
|
10993
|
-
const medianIndex = Math.floor(count / 2);
|
|
10994
|
-
const p90Index = Math.floor(count * 0.9);
|
|
10995
|
-
const p99Index = Math.floor(count * 0.99);
|
|
10996
|
-
const median = sortedTimings[medianIndex];
|
|
10997
|
-
const p90 = sortedTimings[Math.min(p90Index, count - 1)];
|
|
10998
|
-
const p99 = sortedTimings[Math.min(p99Index, count - 1)];
|
|
10999
|
-
allStats.push({
|
|
11000
|
-
name: key,
|
|
11001
|
-
count,
|
|
11002
|
-
total,
|
|
11003
|
-
average,
|
|
11004
|
-
min,
|
|
11005
|
-
max,
|
|
11006
|
-
median,
|
|
11007
|
-
p90,
|
|
11008
|
-
p99
|
|
11009
|
-
});
|
|
11010
|
-
}
|
|
11011
|
-
allStats.sort((a, b) => b.total - a.total);
|
|
11012
|
-
console.log(`
|
|
11079
|
+
allStats.sort((a, b) => b.total - a.total);
|
|
11080
|
+
const lines = [];
|
|
11081
|
+
lines.push(`
|
|
11013
11082
|
--- OpenTUI FFI Call Performance ---`);
|
|
11014
|
-
|
|
11015
|
-
|
|
11016
|
-
|
|
11017
|
-
|
|
11018
|
-
|
|
11019
|
-
|
|
11020
|
-
|
|
11021
|
-
|
|
11022
|
-
|
|
11023
|
-
|
|
11024
|
-
|
|
11025
|
-
|
|
11026
|
-
|
|
11027
|
-
|
|
11028
|
-
|
|
11029
|
-
|
|
11030
|
-
|
|
11031
|
-
|
|
11032
|
-
|
|
11033
|
-
|
|
11034
|
-
|
|
11035
|
-
|
|
11036
|
-
|
|
11037
|
-
|
|
11038
|
-
|
|
11039
|
-
|
|
11040
|
-
|
|
11041
|
-
|
|
11083
|
+
lines.push("Sorted by total time spent (descending)");
|
|
11084
|
+
lines.push("-------------------------------------------------------------------------------------------------------------------------");
|
|
11085
|
+
if (allStats.length === 0) {
|
|
11086
|
+
lines.push("No trace data collected or all symbols had zero calls.");
|
|
11087
|
+
} else {
|
|
11088
|
+
const nameHeader = "Symbol";
|
|
11089
|
+
const callsHeader = "Calls";
|
|
11090
|
+
const totalHeader = "Total (ms)";
|
|
11091
|
+
const avgHeader = "Avg (ms)";
|
|
11092
|
+
const minHeader = "Min (ms)";
|
|
11093
|
+
const maxHeader = "Max (ms)";
|
|
11094
|
+
const medHeader = "Med (ms)";
|
|
11095
|
+
const p90Header = "P90 (ms)";
|
|
11096
|
+
const p99Header = "P99 (ms)";
|
|
11097
|
+
const nameWidth = Math.max(nameHeader.length, ...allStats.map((s) => s.name.length));
|
|
11098
|
+
const countWidth = Math.max(callsHeader.length, ...allStats.map((s) => String(s.count).length));
|
|
11099
|
+
const totalWidth = Math.max(totalHeader.length, ...allStats.map((s) => s.total.toFixed(2).length));
|
|
11100
|
+
const avgWidth = Math.max(avgHeader.length, ...allStats.map((s) => s.average.toFixed(2).length));
|
|
11101
|
+
const minWidth = Math.max(minHeader.length, ...allStats.map((s) => s.min.toFixed(2).length));
|
|
11102
|
+
const maxWidth = Math.max(maxHeader.length, ...allStats.map((s) => s.max.toFixed(2).length));
|
|
11103
|
+
const medianWidth = Math.max(medHeader.length, ...allStats.map((s) => s.median.toFixed(2).length));
|
|
11104
|
+
const p90Width = Math.max(p90Header.length, ...allStats.map((s) => s.p90.toFixed(2).length));
|
|
11105
|
+
const p99Width = Math.max(p99Header.length, ...allStats.map((s) => s.p99.toFixed(2).length));
|
|
11106
|
+
lines.push(`${nameHeader.padEnd(nameWidth)} | ${callsHeader.padStart(countWidth)} | ${totalHeader.padStart(totalWidth)} | ${avgHeader.padStart(avgWidth)} | ${minHeader.padStart(minWidth)} | ${maxHeader.padStart(maxWidth)} | ${medHeader.padStart(medianWidth)} | ${p90Header.padStart(p90Width)} | ${p99Header.padStart(p99Width)}`);
|
|
11107
|
+
lines.push(`${"-".repeat(nameWidth)}-+-${"-".repeat(countWidth)}-+-${"-".repeat(totalWidth)}-+-${"-".repeat(avgWidth)}-+-${"-".repeat(minWidth)}-+-${"-".repeat(maxWidth)}-+-${"-".repeat(medianWidth)}-+-${"-".repeat(p90Width)}-+-${"-".repeat(p99Width)}`);
|
|
11108
|
+
allStats.forEach((stat) => {
|
|
11109
|
+
lines.push(`${stat.name.padEnd(nameWidth)} | ${String(stat.count).padStart(countWidth)} | ${stat.total.toFixed(2).padStart(totalWidth)} | ${stat.average.toFixed(2).padStart(avgWidth)} | ${stat.min.toFixed(2).padStart(minWidth)} | ${stat.max.toFixed(2).padStart(maxWidth)} | ${stat.median.toFixed(2).padStart(medianWidth)} | ${stat.p90.toFixed(2).padStart(p90Width)} | ${stat.p99.toFixed(2).padStart(p99Width)}`);
|
|
11110
|
+
});
|
|
11111
|
+
}
|
|
11112
|
+
lines.push("-------------------------------------------------------------------------------------------------------------------------");
|
|
11113
|
+
const output = lines.join(`
|
|
11114
|
+
`);
|
|
11115
|
+
console.log(output);
|
|
11116
|
+
try {
|
|
11117
|
+
const now = new Date;
|
|
11118
|
+
const timestamp = now.toISOString().replace(/[:.]/g, "-").replace(/T/, "_").split("Z")[0];
|
|
11119
|
+
const traceFilePath = `ffi_otui_trace_${timestamp}.log`;
|
|
11120
|
+
Bun.write(traceFilePath, output);
|
|
11121
|
+
} catch (e) {
|
|
11122
|
+
console.error("Failed to write FFI trace file:", e);
|
|
11123
|
+
}
|
|
11042
11124
|
}
|
|
11043
|
-
console.log("-------------------------------------------------------------------------------------------------------------------------");
|
|
11044
11125
|
});
|
|
11045
11126
|
}
|
|
11046
11127
|
return debugSymbols;
|
|
@@ -11531,6 +11612,16 @@ class FFIRenderLib {
|
|
|
11531
11612
|
const fg2 = fgColor ? fgColor.buffer : null;
|
|
11532
11613
|
return this.opentui.symbols.textBufferViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2);
|
|
11533
11614
|
}
|
|
11615
|
+
textBufferViewUpdateSelection(view, end, bgColor, fgColor) {
|
|
11616
|
+
const bg2 = bgColor ? bgColor.buffer : null;
|
|
11617
|
+
const fg2 = fgColor ? fgColor.buffer : null;
|
|
11618
|
+
this.opentui.symbols.textBufferViewUpdateSelection(view, end, bg2, fg2);
|
|
11619
|
+
}
|
|
11620
|
+
textBufferViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor) {
|
|
11621
|
+
const bg2 = bgColor ? bgColor.buffer : null;
|
|
11622
|
+
const fg2 = fgColor ? fgColor.buffer : null;
|
|
11623
|
+
return this.opentui.symbols.textBufferViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2);
|
|
11624
|
+
}
|
|
11534
11625
|
textBufferViewResetLocalSelection(view) {
|
|
11535
11626
|
this.opentui.symbols.textBufferViewResetLocalSelection(view);
|
|
11536
11627
|
}
|
|
@@ -11678,6 +11769,9 @@ class FFIRenderLib {
|
|
|
11678
11769
|
editorViewSetViewportSize(view, width, height) {
|
|
11679
11770
|
this.opentui.symbols.editorViewSetViewportSize(view, width, height);
|
|
11680
11771
|
}
|
|
11772
|
+
editorViewSetViewport(view, x, y, width, height, moveCursor) {
|
|
11773
|
+
this.opentui.symbols.editorViewSetViewport(view, x, y, width, height, moveCursor);
|
|
11774
|
+
}
|
|
11681
11775
|
editorViewGetViewport(view) {
|
|
11682
11776
|
const x = new Uint32Array(1);
|
|
11683
11777
|
const y = new Uint32Array(1);
|
|
@@ -11920,10 +12014,20 @@ class FFIRenderLib {
|
|
|
11920
12014
|
const end = Number(packedInfo & 0xffff_ffffn);
|
|
11921
12015
|
return { start, end };
|
|
11922
12016
|
}
|
|
11923
|
-
editorViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor) {
|
|
12017
|
+
editorViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor, updateCursor) {
|
|
11924
12018
|
const bg2 = bgColor ? bgColor.buffer : null;
|
|
11925
12019
|
const fg2 = fgColor ? fgColor.buffer : null;
|
|
11926
|
-
return this.opentui.symbols.editorViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2);
|
|
12020
|
+
return this.opentui.symbols.editorViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2, updateCursor);
|
|
12021
|
+
}
|
|
12022
|
+
editorViewUpdateSelection(view, end, bgColor, fgColor) {
|
|
12023
|
+
const bg2 = bgColor ? bgColor.buffer : null;
|
|
12024
|
+
const fg2 = fgColor ? fgColor.buffer : null;
|
|
12025
|
+
this.opentui.symbols.editorViewUpdateSelection(view, end, bg2, fg2);
|
|
12026
|
+
}
|
|
12027
|
+
editorViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor, updateCursor) {
|
|
12028
|
+
const bg2 = bgColor ? bgColor.buffer : null;
|
|
12029
|
+
const fg2 = fgColor ? fgColor.buffer : null;
|
|
12030
|
+
return this.opentui.symbols.editorViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2, updateCursor);
|
|
11927
12031
|
}
|
|
11928
12032
|
editorViewResetLocalSelection(view) {
|
|
11929
12033
|
this.opentui.symbols.editorViewResetLocalSelection(view);
|
|
@@ -11982,6 +12086,16 @@ class FFIRenderLib {
|
|
|
11982
12086
|
this.opentui.symbols.editorViewGetEOL(view, ptr3(cursorBuffer));
|
|
11983
12087
|
return VisualCursorStruct.unpack(cursorBuffer);
|
|
11984
12088
|
}
|
|
12089
|
+
editorViewGetVisualSOL(view) {
|
|
12090
|
+
const cursorBuffer = new ArrayBuffer(VisualCursorStruct.size);
|
|
12091
|
+
this.opentui.symbols.editorViewGetVisualSOL(view, ptr3(cursorBuffer));
|
|
12092
|
+
return VisualCursorStruct.unpack(cursorBuffer);
|
|
12093
|
+
}
|
|
12094
|
+
editorViewGetVisualEOL(view) {
|
|
12095
|
+
const cursorBuffer = new ArrayBuffer(VisualCursorStruct.size);
|
|
12096
|
+
this.opentui.symbols.editorViewGetVisualEOL(view, ptr3(cursorBuffer));
|
|
12097
|
+
return VisualCursorStruct.unpack(cursorBuffer);
|
|
12098
|
+
}
|
|
11985
12099
|
bufferPushScissorRect(buffer, x, y, width, height) {
|
|
11986
12100
|
this.opentui.symbols.bufferPushScissorRect(buffer, x, y, width, height);
|
|
11987
12101
|
}
|
|
@@ -11991,6 +12105,18 @@ class FFIRenderLib {
|
|
|
11991
12105
|
bufferClearScissorRects(buffer) {
|
|
11992
12106
|
this.opentui.symbols.bufferClearScissorRects(buffer);
|
|
11993
12107
|
}
|
|
12108
|
+
bufferPushOpacity(buffer, opacity) {
|
|
12109
|
+
this.opentui.symbols.bufferPushOpacity(buffer, opacity);
|
|
12110
|
+
}
|
|
12111
|
+
bufferPopOpacity(buffer) {
|
|
12112
|
+
this.opentui.symbols.bufferPopOpacity(buffer);
|
|
12113
|
+
}
|
|
12114
|
+
bufferGetCurrentOpacity(buffer) {
|
|
12115
|
+
return this.opentui.symbols.bufferGetCurrentOpacity(buffer);
|
|
12116
|
+
}
|
|
12117
|
+
bufferClearOpacity(buffer) {
|
|
12118
|
+
this.opentui.symbols.bufferClearOpacity(buffer);
|
|
12119
|
+
}
|
|
11994
12120
|
getTerminalCapabilities(renderer) {
|
|
11995
12121
|
const capsBuffer = new ArrayBuffer(TerminalCapabilitiesStruct.size);
|
|
11996
12122
|
this.opentui.symbols.getTerminalCapabilities(renderer, ptr3(capsBuffer));
|
|
@@ -12483,6 +12609,7 @@ class Renderable extends BaseRenderable {
|
|
|
12483
12609
|
_positionType = "relative";
|
|
12484
12610
|
_overflow = "visible";
|
|
12485
12611
|
_position = {};
|
|
12612
|
+
_opacity = 1;
|
|
12486
12613
|
_flexShrink = 1;
|
|
12487
12614
|
renderableMapById = new Map;
|
|
12488
12615
|
_childrenInLayoutOrder = [];
|
|
@@ -12515,6 +12642,7 @@ class Renderable extends BaseRenderable {
|
|
|
12515
12642
|
this.buffered = options.buffered ?? false;
|
|
12516
12643
|
this._live = options.live ?? false;
|
|
12517
12644
|
this._liveCount = this._live && this._visible ? 1 : 0;
|
|
12645
|
+
this._opacity = options.opacity !== undefined ? Math.max(0, Math.min(1, options.opacity)) : 1;
|
|
12518
12646
|
this.yogaNode = src_default.Node.create(yogaConfig);
|
|
12519
12647
|
this.yogaNode.setDisplay(this._visible ? Display.Flex : Display.None);
|
|
12520
12648
|
this.setupYogaProperties(options);
|
|
@@ -12564,6 +12692,16 @@ class Renderable extends BaseRenderable {
|
|
|
12564
12692
|
}
|
|
12565
12693
|
this.requestRender();
|
|
12566
12694
|
}
|
|
12695
|
+
get opacity() {
|
|
12696
|
+
return this._opacity;
|
|
12697
|
+
}
|
|
12698
|
+
set opacity(value) {
|
|
12699
|
+
const clamped = Math.max(0, Math.min(1, value));
|
|
12700
|
+
if (this._opacity !== clamped) {
|
|
12701
|
+
this._opacity = clamped;
|
|
12702
|
+
this.requestRender();
|
|
12703
|
+
}
|
|
12704
|
+
}
|
|
12567
12705
|
hasSelection() {
|
|
12568
12706
|
return false;
|
|
12569
12707
|
}
|
|
@@ -12682,7 +12820,7 @@ class Renderable extends BaseRenderable {
|
|
|
12682
12820
|
this.parent.childrenPrimarySortDirty = true;
|
|
12683
12821
|
}
|
|
12684
12822
|
get x() {
|
|
12685
|
-
if (this.parent
|
|
12823
|
+
if (this.parent) {
|
|
12686
12824
|
return this.parent.x + this._x + this._translateX;
|
|
12687
12825
|
}
|
|
12688
12826
|
return this._x + this._translateX;
|
|
@@ -12723,7 +12861,7 @@ class Renderable extends BaseRenderable {
|
|
|
12723
12861
|
}
|
|
12724
12862
|
}
|
|
12725
12863
|
get y() {
|
|
12726
|
-
if (this.parent
|
|
12864
|
+
if (this.parent) {
|
|
12727
12865
|
return this.parent.y + this._y + this._translateY;
|
|
12728
12866
|
}
|
|
12729
12867
|
return this._y + this._translateY;
|
|
@@ -13308,6 +13446,10 @@ class Renderable extends BaseRenderable {
|
|
|
13308
13446
|
}
|
|
13309
13447
|
if (this._isDestroyed)
|
|
13310
13448
|
return;
|
|
13449
|
+
const shouldPushOpacity = this._opacity < 1;
|
|
13450
|
+
if (shouldPushOpacity) {
|
|
13451
|
+
renderList.push({ action: "pushOpacity", opacity: this._opacity });
|
|
13452
|
+
}
|
|
13311
13453
|
renderList.push({ action: "render", renderable: this });
|
|
13312
13454
|
this.ensureZIndexSorted();
|
|
13313
13455
|
const shouldPushScissor = this._overflow !== "visible" && this.width > 0 && this.height > 0;
|
|
@@ -13332,6 +13474,9 @@ class Renderable extends BaseRenderable {
|
|
|
13332
13474
|
if (shouldPushScissor) {
|
|
13333
13475
|
renderList.push({ action: "popScissorRect" });
|
|
13334
13476
|
}
|
|
13477
|
+
if (shouldPushOpacity) {
|
|
13478
|
+
renderList.push({ action: "popOpacity" });
|
|
13479
|
+
}
|
|
13335
13480
|
}
|
|
13336
13481
|
render(buffer, deltaTime) {
|
|
13337
13482
|
let renderBuffer = buffer;
|
|
@@ -13545,6 +13690,12 @@ class RootRenderable extends Renderable {
|
|
|
13545
13690
|
case "popScissorRect":
|
|
13546
13691
|
buffer.popScissorRect();
|
|
13547
13692
|
break;
|
|
13693
|
+
case "pushOpacity":
|
|
13694
|
+
buffer.pushOpacity(command.opacity);
|
|
13695
|
+
break;
|
|
13696
|
+
case "popOpacity":
|
|
13697
|
+
buffer.popOpacity();
|
|
13698
|
+
break;
|
|
13548
13699
|
}
|
|
13549
13700
|
}
|
|
13550
13701
|
}
|
|
@@ -13788,6 +13939,59 @@ class CapturedWritableStream extends Writable {
|
|
|
13788
13939
|
}
|
|
13789
13940
|
}
|
|
13790
13941
|
|
|
13942
|
+
// src/lib/keymapping.ts
|
|
13943
|
+
var defaultKeyAliases = {
|
|
13944
|
+
enter: "return",
|
|
13945
|
+
esc: "escape"
|
|
13946
|
+
};
|
|
13947
|
+
function mergeKeyAliases(defaults, custom) {
|
|
13948
|
+
return { ...defaults, ...custom };
|
|
13949
|
+
}
|
|
13950
|
+
function mergeKeyBindings(defaults, custom) {
|
|
13951
|
+
const map = new Map;
|
|
13952
|
+
for (const binding of defaults) {
|
|
13953
|
+
const key = getKeyBindingKey(binding);
|
|
13954
|
+
map.set(key, binding);
|
|
13955
|
+
}
|
|
13956
|
+
for (const binding of custom) {
|
|
13957
|
+
const key = getKeyBindingKey(binding);
|
|
13958
|
+
map.set(key, binding);
|
|
13959
|
+
}
|
|
13960
|
+
return Array.from(map.values());
|
|
13961
|
+
}
|
|
13962
|
+
function getKeyBindingKey(binding) {
|
|
13963
|
+
return `${binding.name}:${binding.ctrl ? 1 : 0}:${binding.shift ? 1 : 0}:${binding.meta ? 1 : 0}:${binding.super ? 1 : 0}`;
|
|
13964
|
+
}
|
|
13965
|
+
function buildKeyBindingsMap(bindings, aliasMap) {
|
|
13966
|
+
const map = new Map;
|
|
13967
|
+
const aliases = aliasMap || {};
|
|
13968
|
+
for (const binding of bindings) {
|
|
13969
|
+
const key = getKeyBindingKey(binding);
|
|
13970
|
+
map.set(key, binding.action);
|
|
13971
|
+
}
|
|
13972
|
+
for (const binding of bindings) {
|
|
13973
|
+
const normalizedName = aliases[binding.name] || binding.name;
|
|
13974
|
+
if (normalizedName !== binding.name) {
|
|
13975
|
+
const aliasedKey = getKeyBindingKey({ ...binding, name: normalizedName });
|
|
13976
|
+
map.set(aliasedKey, binding.action);
|
|
13977
|
+
}
|
|
13978
|
+
}
|
|
13979
|
+
return map;
|
|
13980
|
+
}
|
|
13981
|
+
function keyBindingToString(binding) {
|
|
13982
|
+
const parts = [];
|
|
13983
|
+
if (binding.ctrl)
|
|
13984
|
+
parts.push("ctrl");
|
|
13985
|
+
if (binding.shift)
|
|
13986
|
+
parts.push("shift");
|
|
13987
|
+
if (binding.meta)
|
|
13988
|
+
parts.push("meta");
|
|
13989
|
+
if (binding.super)
|
|
13990
|
+
parts.push("super");
|
|
13991
|
+
parts.push(binding.name);
|
|
13992
|
+
return parts.join("+");
|
|
13993
|
+
}
|
|
13994
|
+
|
|
13791
13995
|
// src/console.ts
|
|
13792
13996
|
function getCallerInfo() {
|
|
13793
13997
|
const err = new Error;
|
|
@@ -13927,6 +14131,19 @@ var ConsolePosition;
|
|
|
13927
14131
|
ConsolePosition2["LEFT"] = "left";
|
|
13928
14132
|
ConsolePosition2["RIGHT"] = "right";
|
|
13929
14133
|
})(ConsolePosition ||= {});
|
|
14134
|
+
var defaultConsoleKeybindings = [
|
|
14135
|
+
{ name: "up", action: "scroll-up" },
|
|
14136
|
+
{ name: "down", action: "scroll-down" },
|
|
14137
|
+
{ name: "up", shift: true, action: "scroll-to-top" },
|
|
14138
|
+
{ name: "down", shift: true, action: "scroll-to-bottom" },
|
|
14139
|
+
{ name: "p", ctrl: true, action: "position-previous" },
|
|
14140
|
+
{ name: "o", ctrl: true, action: "position-next" },
|
|
14141
|
+
{ name: "+", action: "size-increase" },
|
|
14142
|
+
{ name: "=", shift: true, action: "size-increase" },
|
|
14143
|
+
{ name: "-", action: "size-decrease" },
|
|
14144
|
+
{ name: "s", ctrl: true, action: "save-logs" },
|
|
14145
|
+
{ name: "c", ctrl: true, shift: true, action: "copy-selection" }
|
|
14146
|
+
];
|
|
13930
14147
|
var DEFAULT_CONSOLE_OPTIONS = {
|
|
13931
14148
|
position: "bottom" /* BOTTOM */,
|
|
13932
14149
|
sizePercent: 30,
|
|
@@ -13943,7 +14160,12 @@ var DEFAULT_CONSOLE_OPTIONS = {
|
|
|
13943
14160
|
titleBarTextColor: "#FFFFFF",
|
|
13944
14161
|
cursorColor: "#00A0FF",
|
|
13945
14162
|
maxStoredLogs: 2000,
|
|
13946
|
-
maxDisplayLines: 3000
|
|
14163
|
+
maxDisplayLines: 3000,
|
|
14164
|
+
onCopySelection: undefined,
|
|
14165
|
+
keyBindings: undefined,
|
|
14166
|
+
keyAliasMap: undefined,
|
|
14167
|
+
selectionColor: RGBA.fromValues(0.3, 0.5, 0.8, 0.5),
|
|
14168
|
+
copyButtonColor: "#00A0FF"
|
|
13947
14169
|
};
|
|
13948
14170
|
var INDENT_WIDTH = 2;
|
|
13949
14171
|
|
|
@@ -13966,10 +14188,34 @@ class TerminalConsole extends EventEmitter8 {
|
|
|
13966
14188
|
_allLogEntries = [];
|
|
13967
14189
|
_needsFrameBufferUpdate = false;
|
|
13968
14190
|
_entryListener;
|
|
14191
|
+
_selectionStart = null;
|
|
14192
|
+
_selectionEnd = null;
|
|
14193
|
+
_isSelecting = false;
|
|
14194
|
+
_copyButtonBounds = {
|
|
14195
|
+
x: 0,
|
|
14196
|
+
y: 0,
|
|
14197
|
+
width: 0,
|
|
14198
|
+
height: 0
|
|
14199
|
+
};
|
|
14200
|
+
_autoScrollInterval = null;
|
|
14201
|
+
_keyBindingsMap;
|
|
14202
|
+
_keyAliasMap;
|
|
14203
|
+
_keyBindings;
|
|
14204
|
+
_mergedKeyBindings;
|
|
14205
|
+
_actionHandlers;
|
|
13969
14206
|
markNeedsRerender() {
|
|
13970
14207
|
this._needsFrameBufferUpdate = true;
|
|
13971
14208
|
this.renderer.requestRender();
|
|
13972
14209
|
}
|
|
14210
|
+
getCopyButtonLabel() {
|
|
14211
|
+
const copyBindings = this._mergedKeyBindings.filter((b) => b.action === "copy-selection");
|
|
14212
|
+
const copyBinding = copyBindings[copyBindings.length - 1];
|
|
14213
|
+
if (copyBinding) {
|
|
14214
|
+
const shortcut = keyBindingToString(copyBinding);
|
|
14215
|
+
return `[Copy (${shortcut})]`;
|
|
14216
|
+
}
|
|
14217
|
+
return "[Copy]";
|
|
14218
|
+
}
|
|
13973
14219
|
_rgbaInfo;
|
|
13974
14220
|
_rgbaWarn;
|
|
13975
14221
|
_rgbaError;
|
|
@@ -13980,6 +14226,8 @@ class TerminalConsole extends EventEmitter8 {
|
|
|
13980
14226
|
_rgbaTitleBarText;
|
|
13981
14227
|
_title;
|
|
13982
14228
|
_rgbaCursor;
|
|
14229
|
+
_rgbaSelection;
|
|
14230
|
+
_rgbaCopyButton;
|
|
13983
14231
|
_positions = [
|
|
13984
14232
|
"top" /* TOP */,
|
|
13985
14233
|
"right" /* RIGHT */,
|
|
@@ -14003,6 +14251,13 @@ class TerminalConsole extends EventEmitter8 {
|
|
|
14003
14251
|
this._rgbaTitleBarText = parseColor(this.options.titleBarTextColor || this.options.colorDefault);
|
|
14004
14252
|
this._title = this.options.title;
|
|
14005
14253
|
this._rgbaCursor = parseColor(this.options.cursorColor);
|
|
14254
|
+
this._rgbaSelection = parseColor(this.options.selectionColor);
|
|
14255
|
+
this._rgbaCopyButton = parseColor(this.options.copyButtonColor);
|
|
14256
|
+
this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, options.keyAliasMap || {});
|
|
14257
|
+
this._keyBindings = options.keyBindings || [];
|
|
14258
|
+
this._mergedKeyBindings = mergeKeyBindings(defaultConsoleKeybindings, this._keyBindings);
|
|
14259
|
+
this._keyBindingsMap = buildKeyBindingsMap(this._mergedKeyBindings, this._keyAliasMap);
|
|
14260
|
+
this._actionHandlers = this.buildActionHandlers();
|
|
14006
14261
|
this._updateConsoleDimensions();
|
|
14007
14262
|
this._scrollToBottom(true);
|
|
14008
14263
|
this._entryListener = (logEntry) => {
|
|
@@ -14013,6 +14268,20 @@ class TerminalConsole extends EventEmitter8 {
|
|
|
14013
14268
|
this.show();
|
|
14014
14269
|
}
|
|
14015
14270
|
}
|
|
14271
|
+
buildActionHandlers() {
|
|
14272
|
+
return new Map([
|
|
14273
|
+
["scroll-up", () => this.scrollUp()],
|
|
14274
|
+
["scroll-down", () => this.scrollDown()],
|
|
14275
|
+
["scroll-to-top", () => this.scrollToTop()],
|
|
14276
|
+
["scroll-to-bottom", () => this.scrollToBottomAction()],
|
|
14277
|
+
["position-previous", () => this.positionPrevious()],
|
|
14278
|
+
["position-next", () => this.positionNext()],
|
|
14279
|
+
["size-increase", () => this.sizeIncrease()],
|
|
14280
|
+
["size-decrease", () => this.sizeDecrease()],
|
|
14281
|
+
["save-logs", () => this.saveLogsAction()],
|
|
14282
|
+
["copy-selection", () => this.triggerCopyAction()]
|
|
14283
|
+
]);
|
|
14284
|
+
}
|
|
14016
14285
|
activate() {
|
|
14017
14286
|
terminalConsoleCache.activate();
|
|
14018
14287
|
}
|
|
@@ -14039,8 +14308,8 @@ class TerminalConsole extends EventEmitter8 {
|
|
|
14039
14308
|
this.markNeedsRerender();
|
|
14040
14309
|
}
|
|
14041
14310
|
_updateConsoleDimensions(termWidth, termHeight) {
|
|
14042
|
-
const width = termWidth ?? this.renderer.
|
|
14043
|
-
const height = termHeight ?? this.renderer.
|
|
14311
|
+
const width = termWidth ?? this.renderer.width;
|
|
14312
|
+
const height = termHeight ?? this.renderer.height;
|
|
14044
14313
|
const sizePercent = this.options.sizePercent / 100;
|
|
14045
14314
|
switch (this.options.position) {
|
|
14046
14315
|
case "top" /* TOP */:
|
|
@@ -14071,68 +14340,103 @@ class TerminalConsole extends EventEmitter8 {
|
|
|
14071
14340
|
this.currentLineIndex = Math.max(0, Math.min(this.currentLineIndex, this.consoleHeight - 1));
|
|
14072
14341
|
}
|
|
14073
14342
|
handleKeyPress(event) {
|
|
14074
|
-
let needsRedraw = false;
|
|
14075
|
-
const displayLineCount = this._displayLines.length;
|
|
14076
|
-
const logAreaHeight = Math.max(1, this.consoleHeight - 1);
|
|
14077
|
-
const maxScrollTop = Math.max(0, displayLineCount - logAreaHeight);
|
|
14078
|
-
const currentPositionIndex = this._positions.indexOf(this.options.position);
|
|
14079
14343
|
if (event.name === "escape") {
|
|
14080
14344
|
this.blur();
|
|
14081
14345
|
return;
|
|
14082
14346
|
}
|
|
14083
|
-
|
|
14084
|
-
|
|
14085
|
-
|
|
14086
|
-
|
|
14087
|
-
|
|
14088
|
-
|
|
14089
|
-
|
|
14090
|
-
}
|
|
14091
|
-
|
|
14092
|
-
|
|
14093
|
-
|
|
14094
|
-
|
|
14095
|
-
|
|
14096
|
-
|
|
14097
|
-
|
|
14098
|
-
|
|
14099
|
-
|
|
14100
|
-
|
|
14101
|
-
|
|
14102
|
-
|
|
14103
|
-
|
|
14104
|
-
|
|
14105
|
-
|
|
14106
|
-
|
|
14107
|
-
|
|
14108
|
-
|
|
14109
|
-
|
|
14110
|
-
|
|
14111
|
-
|
|
14112
|
-
|
|
14113
|
-
|
|
14114
|
-
|
|
14115
|
-
|
|
14116
|
-
|
|
14117
|
-
|
|
14118
|
-
this.
|
|
14119
|
-
this.
|
|
14120
|
-
} else if (
|
|
14121
|
-
|
|
14122
|
-
this.
|
|
14123
|
-
this.
|
|
14124
|
-
}
|
|
14125
|
-
|
|
14126
|
-
|
|
14127
|
-
|
|
14128
|
-
|
|
14129
|
-
this.
|
|
14130
|
-
|
|
14131
|
-
this.
|
|
14132
|
-
|
|
14133
|
-
|
|
14347
|
+
const bindingKey = getKeyBindingKey({
|
|
14348
|
+
name: event.name,
|
|
14349
|
+
ctrl: event.ctrl,
|
|
14350
|
+
shift: event.shift,
|
|
14351
|
+
meta: event.meta,
|
|
14352
|
+
super: event.super,
|
|
14353
|
+
action: "scroll-up"
|
|
14354
|
+
});
|
|
14355
|
+
const action = this._keyBindingsMap.get(bindingKey);
|
|
14356
|
+
if (action) {
|
|
14357
|
+
const handler = this._actionHandlers.get(action);
|
|
14358
|
+
if (handler) {
|
|
14359
|
+
handler();
|
|
14360
|
+
return;
|
|
14361
|
+
}
|
|
14362
|
+
}
|
|
14363
|
+
}
|
|
14364
|
+
scrollUp() {
|
|
14365
|
+
const logAreaHeight = Math.max(1, this.consoleHeight - 1);
|
|
14366
|
+
if (this.currentLineIndex > 0) {
|
|
14367
|
+
this.currentLineIndex--;
|
|
14368
|
+
this.markNeedsRerender();
|
|
14369
|
+
} else if (this.scrollTopIndex > 0) {
|
|
14370
|
+
this.scrollTopIndex--;
|
|
14371
|
+
this.isScrolledToBottom = false;
|
|
14372
|
+
this.markNeedsRerender();
|
|
14373
|
+
}
|
|
14374
|
+
return true;
|
|
14375
|
+
}
|
|
14376
|
+
scrollDown() {
|
|
14377
|
+
const displayLineCount = this._displayLines.length;
|
|
14378
|
+
const logAreaHeight = Math.max(1, this.consoleHeight - 1);
|
|
14379
|
+
const maxScrollTop = Math.max(0, displayLineCount - logAreaHeight);
|
|
14380
|
+
const canCursorMoveDown = this.currentLineIndex < logAreaHeight - 1 && this.scrollTopIndex + this.currentLineIndex < displayLineCount - 1;
|
|
14381
|
+
if (canCursorMoveDown) {
|
|
14382
|
+
this.currentLineIndex++;
|
|
14383
|
+
this.markNeedsRerender();
|
|
14384
|
+
} else if (this.scrollTopIndex < maxScrollTop) {
|
|
14385
|
+
this.scrollTopIndex++;
|
|
14386
|
+
this.isScrolledToBottom = this.scrollTopIndex === maxScrollTop;
|
|
14387
|
+
this.markNeedsRerender();
|
|
14388
|
+
}
|
|
14389
|
+
return true;
|
|
14390
|
+
}
|
|
14391
|
+
scrollToTop() {
|
|
14392
|
+
if (this.scrollTopIndex > 0 || this.currentLineIndex > 0) {
|
|
14393
|
+
this.scrollTopIndex = 0;
|
|
14394
|
+
this.currentLineIndex = 0;
|
|
14395
|
+
this.isScrolledToBottom = this._displayLines.length <= Math.max(1, this.consoleHeight - 1);
|
|
14396
|
+
this.markNeedsRerender();
|
|
14397
|
+
}
|
|
14398
|
+
return true;
|
|
14399
|
+
}
|
|
14400
|
+
scrollToBottomAction() {
|
|
14401
|
+
const logAreaHeightForScroll = Math.max(1, this.consoleHeight - 1);
|
|
14402
|
+
const maxScrollPossible = Math.max(0, this._displayLines.length - logAreaHeightForScroll);
|
|
14403
|
+
if (this.scrollTopIndex < maxScrollPossible || !this.isScrolledToBottom) {
|
|
14404
|
+
this._scrollToBottom(true);
|
|
14134
14405
|
this.markNeedsRerender();
|
|
14135
14406
|
}
|
|
14407
|
+
return true;
|
|
14408
|
+
}
|
|
14409
|
+
positionPrevious() {
|
|
14410
|
+
const currentPositionIndex = this._positions.indexOf(this.options.position);
|
|
14411
|
+
const prevIndex = (currentPositionIndex - 1 + this._positions.length) % this._positions.length;
|
|
14412
|
+
this.options.position = this._positions[prevIndex];
|
|
14413
|
+
this.resize(this.renderer.width, this.renderer.height);
|
|
14414
|
+
return true;
|
|
14415
|
+
}
|
|
14416
|
+
positionNext() {
|
|
14417
|
+
const currentPositionIndex = this._positions.indexOf(this.options.position);
|
|
14418
|
+
const nextIndex = (currentPositionIndex + 1) % this._positions.length;
|
|
14419
|
+
this.options.position = this._positions[nextIndex];
|
|
14420
|
+
this.resize(this.renderer.width, this.renderer.height);
|
|
14421
|
+
return true;
|
|
14422
|
+
}
|
|
14423
|
+
sizeIncrease() {
|
|
14424
|
+
this.options.sizePercent = Math.min(100, this.options.sizePercent + 5);
|
|
14425
|
+
this.resize(this.renderer.width, this.renderer.height);
|
|
14426
|
+
return true;
|
|
14427
|
+
}
|
|
14428
|
+
sizeDecrease() {
|
|
14429
|
+
this.options.sizePercent = Math.max(10, this.options.sizePercent - 5);
|
|
14430
|
+
this.resize(this.renderer.width, this.renderer.height);
|
|
14431
|
+
return true;
|
|
14432
|
+
}
|
|
14433
|
+
saveLogsAction() {
|
|
14434
|
+
this.saveLogsToFile();
|
|
14435
|
+
return true;
|
|
14436
|
+
}
|
|
14437
|
+
triggerCopyAction() {
|
|
14438
|
+
this.triggerCopy();
|
|
14439
|
+
return true;
|
|
14136
14440
|
}
|
|
14137
14441
|
attachStdin() {
|
|
14138
14442
|
if (this.isFocused)
|
|
@@ -14249,6 +14553,7 @@ class TerminalConsole extends EventEmitter8 {
|
|
|
14249
14553
|
}
|
|
14250
14554
|
}
|
|
14251
14555
|
destroy() {
|
|
14556
|
+
this.stopAutoScroll();
|
|
14252
14557
|
this.hide();
|
|
14253
14558
|
this.deactivate();
|
|
14254
14559
|
terminalConsoleCache.off("entry", this._entryListener);
|
|
@@ -14268,13 +14573,26 @@ class TerminalConsole extends EventEmitter8 {
|
|
|
14268
14573
|
const dynamicTitle = `${this._title}${this.isFocused ? " (Focused)" : ""}`;
|
|
14269
14574
|
const titleX = Math.max(0, Math.floor((this.consoleWidth - dynamicTitle.length) / 2));
|
|
14270
14575
|
this.frameBuffer.drawText(dynamicTitle, titleX, 0, this._rgbaTitleBarText, this._rgbaTitleBar);
|
|
14576
|
+
const copyLabel = this.getCopyButtonLabel();
|
|
14577
|
+
const copyButtonX = this.consoleWidth - copyLabel.length - 1;
|
|
14578
|
+
if (copyButtonX >= 0) {
|
|
14579
|
+
const copyButtonEnabled = this.hasSelection();
|
|
14580
|
+
const disabledColor = RGBA.fromInts(100, 100, 100, 255);
|
|
14581
|
+
const copyColor = copyButtonEnabled ? this._rgbaCopyButton : disabledColor;
|
|
14582
|
+
this.frameBuffer.drawText(copyLabel, copyButtonX, 0, copyColor, this._rgbaTitleBar);
|
|
14583
|
+
this._copyButtonBounds = { x: copyButtonX, y: 0, width: copyLabel.length, height: 1 };
|
|
14584
|
+
} else {
|
|
14585
|
+
this._copyButtonBounds = { x: -1, y: -1, width: 0, height: 0 };
|
|
14586
|
+
}
|
|
14271
14587
|
const startIndex = this.scrollTopIndex;
|
|
14272
14588
|
const endIndex = Math.min(startIndex + logAreaHeight, displayLineCount);
|
|
14273
14589
|
const visibleDisplayLines = displayLines.slice(startIndex, endIndex);
|
|
14274
14590
|
let lineY = 1;
|
|
14275
|
-
for (
|
|
14591
|
+
for (let i = 0;i < visibleDisplayLines.length; i++) {
|
|
14276
14592
|
if (lineY >= this.consoleHeight)
|
|
14277
14593
|
break;
|
|
14594
|
+
const displayLine = visibleDisplayLines[i];
|
|
14595
|
+
const absoluteLineIndex = startIndex + i;
|
|
14278
14596
|
let levelColor = this._rgbaDefault;
|
|
14279
14597
|
switch (displayLine.level) {
|
|
14280
14598
|
case "INFO" /* INFO */:
|
|
@@ -14299,7 +14617,24 @@ class TerminalConsole extends EventEmitter8 {
|
|
|
14299
14617
|
} else {
|
|
14300
14618
|
this.frameBuffer.drawText(" ", 0, lineY, this._rgbaDefault, this.backgroundColor);
|
|
14301
14619
|
}
|
|
14302
|
-
|
|
14620
|
+
const fullText = `${linePrefix}${textToDraw.substring(0, textAvailableWidth)}`;
|
|
14621
|
+
const selectionRange = this.getLineSelectionRange(absoluteLineIndex);
|
|
14622
|
+
if (selectionRange) {
|
|
14623
|
+
const adjustedStart = Math.max(0, selectionRange.start);
|
|
14624
|
+
const adjustedEnd = Math.min(fullText.length, selectionRange.end);
|
|
14625
|
+
if (adjustedStart > 0) {
|
|
14626
|
+
this.frameBuffer.drawText(fullText.substring(0, adjustedStart), 1, lineY, levelColor);
|
|
14627
|
+
}
|
|
14628
|
+
if (adjustedStart < adjustedEnd) {
|
|
14629
|
+
this.frameBuffer.fillRect(1 + adjustedStart, lineY, adjustedEnd - adjustedStart, 1, this._rgbaSelection);
|
|
14630
|
+
this.frameBuffer.drawText(fullText.substring(adjustedStart, adjustedEnd), 1 + adjustedStart, lineY, levelColor, this._rgbaSelection);
|
|
14631
|
+
}
|
|
14632
|
+
if (adjustedEnd < fullText.length) {
|
|
14633
|
+
this.frameBuffer.drawText(fullText.substring(adjustedEnd), 1 + adjustedEnd, lineY, levelColor);
|
|
14634
|
+
}
|
|
14635
|
+
} else {
|
|
14636
|
+
this.frameBuffer.drawText(fullText, 1, lineY, levelColor);
|
|
14637
|
+
}
|
|
14303
14638
|
lineY++;
|
|
14304
14639
|
}
|
|
14305
14640
|
}
|
|
@@ -14322,6 +14657,24 @@ class TerminalConsole extends EventEmitter8 {
|
|
|
14322
14657
|
toggleDebugMode() {
|
|
14323
14658
|
this.setDebugMode(!this._debugModeEnabled);
|
|
14324
14659
|
}
|
|
14660
|
+
set keyBindings(bindings) {
|
|
14661
|
+
this._keyBindings = bindings;
|
|
14662
|
+
this._mergedKeyBindings = mergeKeyBindings(defaultConsoleKeybindings, bindings);
|
|
14663
|
+
this._keyBindingsMap = buildKeyBindingsMap(this._mergedKeyBindings, this._keyAliasMap);
|
|
14664
|
+
this.markNeedsRerender();
|
|
14665
|
+
}
|
|
14666
|
+
set keyAliasMap(aliases) {
|
|
14667
|
+
this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, aliases);
|
|
14668
|
+
this._mergedKeyBindings = mergeKeyBindings(defaultConsoleKeybindings, this._keyBindings);
|
|
14669
|
+
this._keyBindingsMap = buildKeyBindingsMap(this._mergedKeyBindings, this._keyAliasMap);
|
|
14670
|
+
this.markNeedsRerender();
|
|
14671
|
+
}
|
|
14672
|
+
set onCopySelection(callback) {
|
|
14673
|
+
this.options.onCopySelection = callback;
|
|
14674
|
+
}
|
|
14675
|
+
get onCopySelection() {
|
|
14676
|
+
return this.options.onCopySelection;
|
|
14677
|
+
}
|
|
14325
14678
|
_scrollToBottom(forceCursorToLastLine = false) {
|
|
14326
14679
|
const displayLineCount = this._displayLines.length;
|
|
14327
14680
|
const logAreaHeight = Math.max(1, this.consoleHeight - 1);
|
|
@@ -14379,6 +14732,214 @@ class TerminalConsole extends EventEmitter8 {
|
|
|
14379
14732
|
this._displayLines.splice(0, this._displayLines.length - this.options.maxDisplayLines);
|
|
14380
14733
|
}
|
|
14381
14734
|
}
|
|
14735
|
+
hasSelection() {
|
|
14736
|
+
if (this._selectionStart === null || this._selectionEnd === null)
|
|
14737
|
+
return false;
|
|
14738
|
+
return this._selectionStart.line !== this._selectionEnd.line || this._selectionStart.col !== this._selectionEnd.col;
|
|
14739
|
+
}
|
|
14740
|
+
normalizeSelection() {
|
|
14741
|
+
if (!this._selectionStart || !this._selectionEnd)
|
|
14742
|
+
return null;
|
|
14743
|
+
const start = this._selectionStart;
|
|
14744
|
+
const end = this._selectionEnd;
|
|
14745
|
+
const startBeforeEnd = start.line < end.line || start.line === end.line && start.col <= end.col;
|
|
14746
|
+
if (startBeforeEnd) {
|
|
14747
|
+
return {
|
|
14748
|
+
startLine: start.line,
|
|
14749
|
+
startCol: start.col,
|
|
14750
|
+
endLine: end.line,
|
|
14751
|
+
endCol: end.col
|
|
14752
|
+
};
|
|
14753
|
+
} else {
|
|
14754
|
+
return {
|
|
14755
|
+
startLine: end.line,
|
|
14756
|
+
startCol: end.col,
|
|
14757
|
+
endLine: start.line,
|
|
14758
|
+
endCol: start.col
|
|
14759
|
+
};
|
|
14760
|
+
}
|
|
14761
|
+
}
|
|
14762
|
+
getSelectedText() {
|
|
14763
|
+
const selection2 = this.normalizeSelection();
|
|
14764
|
+
if (!selection2)
|
|
14765
|
+
return "";
|
|
14766
|
+
const lines = [];
|
|
14767
|
+
for (let i = selection2.startLine;i <= selection2.endLine; i++) {
|
|
14768
|
+
if (i < 0 || i >= this._displayLines.length)
|
|
14769
|
+
continue;
|
|
14770
|
+
const line = this._displayLines[i];
|
|
14771
|
+
const linePrefix = line.indent ? " ".repeat(INDENT_WIDTH) : "";
|
|
14772
|
+
const textAvailableWidth = this.consoleWidth - 1 - (line.indent ? INDENT_WIDTH : 0);
|
|
14773
|
+
const fullText = linePrefix + line.text.substring(0, textAvailableWidth);
|
|
14774
|
+
let text = fullText;
|
|
14775
|
+
if (i === selection2.startLine && i === selection2.endLine) {
|
|
14776
|
+
text = fullText.substring(selection2.startCol, selection2.endCol);
|
|
14777
|
+
} else if (i === selection2.startLine) {
|
|
14778
|
+
text = fullText.substring(selection2.startCol);
|
|
14779
|
+
} else if (i === selection2.endLine) {
|
|
14780
|
+
text = fullText.substring(0, selection2.endCol);
|
|
14781
|
+
}
|
|
14782
|
+
lines.push(text);
|
|
14783
|
+
}
|
|
14784
|
+
return lines.join(`
|
|
14785
|
+
`);
|
|
14786
|
+
}
|
|
14787
|
+
clearSelection() {
|
|
14788
|
+
this._selectionStart = null;
|
|
14789
|
+
this._selectionEnd = null;
|
|
14790
|
+
this._isSelecting = false;
|
|
14791
|
+
this.stopAutoScroll();
|
|
14792
|
+
}
|
|
14793
|
+
stopAutoScroll() {
|
|
14794
|
+
if (this._autoScrollInterval !== null) {
|
|
14795
|
+
clearInterval(this._autoScrollInterval);
|
|
14796
|
+
this._autoScrollInterval = null;
|
|
14797
|
+
}
|
|
14798
|
+
}
|
|
14799
|
+
startAutoScroll(direction) {
|
|
14800
|
+
this.stopAutoScroll();
|
|
14801
|
+
this._autoScrollInterval = setInterval(() => {
|
|
14802
|
+
if (direction === "up") {
|
|
14803
|
+
if (this.scrollTopIndex > 0) {
|
|
14804
|
+
this.scrollTopIndex--;
|
|
14805
|
+
this.isScrolledToBottom = false;
|
|
14806
|
+
if (this._selectionEnd) {
|
|
14807
|
+
this._selectionEnd = {
|
|
14808
|
+
line: this.scrollTopIndex,
|
|
14809
|
+
col: this._selectionEnd.col
|
|
14810
|
+
};
|
|
14811
|
+
}
|
|
14812
|
+
this.markNeedsRerender();
|
|
14813
|
+
} else {
|
|
14814
|
+
this.stopAutoScroll();
|
|
14815
|
+
}
|
|
14816
|
+
} else {
|
|
14817
|
+
const displayLineCount = this._displayLines.length;
|
|
14818
|
+
const logAreaHeight = Math.max(1, this.consoleHeight - 1);
|
|
14819
|
+
const maxScrollTop = Math.max(0, displayLineCount - logAreaHeight);
|
|
14820
|
+
if (this.scrollTopIndex < maxScrollTop) {
|
|
14821
|
+
this.scrollTopIndex++;
|
|
14822
|
+
this.isScrolledToBottom = this.scrollTopIndex === maxScrollTop;
|
|
14823
|
+
if (this._selectionEnd) {
|
|
14824
|
+
const maxLine = this.scrollTopIndex + logAreaHeight - 1;
|
|
14825
|
+
this._selectionEnd = {
|
|
14826
|
+
line: Math.min(maxLine, displayLineCount - 1),
|
|
14827
|
+
col: this._selectionEnd.col
|
|
14828
|
+
};
|
|
14829
|
+
}
|
|
14830
|
+
this.markNeedsRerender();
|
|
14831
|
+
} else {
|
|
14832
|
+
this.stopAutoScroll();
|
|
14833
|
+
}
|
|
14834
|
+
}
|
|
14835
|
+
}, 50);
|
|
14836
|
+
}
|
|
14837
|
+
triggerCopy() {
|
|
14838
|
+
if (!this.hasSelection())
|
|
14839
|
+
return;
|
|
14840
|
+
const text = this.getSelectedText();
|
|
14841
|
+
if (text && this.options.onCopySelection) {
|
|
14842
|
+
try {
|
|
14843
|
+
this.options.onCopySelection(text);
|
|
14844
|
+
} catch {}
|
|
14845
|
+
this.clearSelection();
|
|
14846
|
+
this.markNeedsRerender();
|
|
14847
|
+
}
|
|
14848
|
+
}
|
|
14849
|
+
getLineSelectionRange(lineIndex) {
|
|
14850
|
+
const selection2 = this.normalizeSelection();
|
|
14851
|
+
if (!selection2)
|
|
14852
|
+
return null;
|
|
14853
|
+
if (lineIndex < selection2.startLine || lineIndex > selection2.endLine) {
|
|
14854
|
+
return null;
|
|
14855
|
+
}
|
|
14856
|
+
const line = this._displayLines[lineIndex];
|
|
14857
|
+
if (!line)
|
|
14858
|
+
return null;
|
|
14859
|
+
const linePrefix = line.indent ? " ".repeat(INDENT_WIDTH) : "";
|
|
14860
|
+
const textAvailableWidth = this.consoleWidth - 1 - (line.indent ? INDENT_WIDTH : 0);
|
|
14861
|
+
const fullTextLength = linePrefix.length + Math.min(line.text.length, textAvailableWidth);
|
|
14862
|
+
let start = 0;
|
|
14863
|
+
let end = fullTextLength;
|
|
14864
|
+
if (lineIndex === selection2.startLine) {
|
|
14865
|
+
start = Math.max(0, selection2.startCol);
|
|
14866
|
+
}
|
|
14867
|
+
if (lineIndex === selection2.endLine) {
|
|
14868
|
+
end = Math.min(fullTextLength, selection2.endCol);
|
|
14869
|
+
}
|
|
14870
|
+
if (start >= end)
|
|
14871
|
+
return null;
|
|
14872
|
+
return { start, end };
|
|
14873
|
+
}
|
|
14874
|
+
handleMouse(event) {
|
|
14875
|
+
if (!this.isVisible)
|
|
14876
|
+
return false;
|
|
14877
|
+
const localX = event.x - this.consoleX;
|
|
14878
|
+
const localY = event.y - this.consoleY;
|
|
14879
|
+
if (localX < 0 || localX >= this.consoleWidth || localY < 0 || localY >= this.consoleHeight) {
|
|
14880
|
+
return false;
|
|
14881
|
+
}
|
|
14882
|
+
if (event.type === "scroll" && event.scroll) {
|
|
14883
|
+
if (event.scroll.direction === "up") {
|
|
14884
|
+
this.scrollUp();
|
|
14885
|
+
} else if (event.scroll.direction === "down") {
|
|
14886
|
+
this.scrollDown();
|
|
14887
|
+
}
|
|
14888
|
+
return true;
|
|
14889
|
+
}
|
|
14890
|
+
if (localY === 0) {
|
|
14891
|
+
if (event.type === "down" && event.button === 0 && localX >= this._copyButtonBounds.x && localX < this._copyButtonBounds.x + this._copyButtonBounds.width) {
|
|
14892
|
+
this.triggerCopy();
|
|
14893
|
+
return true;
|
|
14894
|
+
}
|
|
14895
|
+
return true;
|
|
14896
|
+
}
|
|
14897
|
+
const lineIndex = this.scrollTopIndex + (localY - 1);
|
|
14898
|
+
const colIndex = Math.max(0, localX - 1);
|
|
14899
|
+
if (event.type === "down" && event.button === 0) {
|
|
14900
|
+
this.clearSelection();
|
|
14901
|
+
this._selectionStart = { line: lineIndex, col: colIndex };
|
|
14902
|
+
this._selectionEnd = { line: lineIndex, col: colIndex };
|
|
14903
|
+
this._isSelecting = true;
|
|
14904
|
+
this.markNeedsRerender();
|
|
14905
|
+
return true;
|
|
14906
|
+
}
|
|
14907
|
+
if (event.type === "drag" && this._isSelecting) {
|
|
14908
|
+
this._selectionEnd = { line: lineIndex, col: colIndex };
|
|
14909
|
+
const logAreaHeight = Math.max(1, this.consoleHeight - 1);
|
|
14910
|
+
const relativeY = localY - 1;
|
|
14911
|
+
if (relativeY <= 0) {
|
|
14912
|
+
this.startAutoScroll("up");
|
|
14913
|
+
} else if (relativeY >= logAreaHeight - 1) {
|
|
14914
|
+
this.startAutoScroll("down");
|
|
14915
|
+
} else {
|
|
14916
|
+
this.stopAutoScroll();
|
|
14917
|
+
}
|
|
14918
|
+
this.markNeedsRerender();
|
|
14919
|
+
return true;
|
|
14920
|
+
}
|
|
14921
|
+
if (event.type === "up") {
|
|
14922
|
+
if (this._isSelecting) {
|
|
14923
|
+
this._selectionEnd = { line: lineIndex, col: colIndex };
|
|
14924
|
+
this._isSelecting = false;
|
|
14925
|
+
this.stopAutoScroll();
|
|
14926
|
+
this.markNeedsRerender();
|
|
14927
|
+
}
|
|
14928
|
+
return true;
|
|
14929
|
+
}
|
|
14930
|
+
return true;
|
|
14931
|
+
}
|
|
14932
|
+
get visible() {
|
|
14933
|
+
return this.isVisible;
|
|
14934
|
+
}
|
|
14935
|
+
get bounds() {
|
|
14936
|
+
return {
|
|
14937
|
+
x: this.consoleX,
|
|
14938
|
+
y: this.consoleY,
|
|
14939
|
+
width: this.consoleWidth,
|
|
14940
|
+
height: this.consoleHeight
|
|
14941
|
+
};
|
|
14942
|
+
}
|
|
14382
14943
|
saveLogsToFile() {
|
|
14383
14944
|
try {
|
|
14384
14945
|
const timestamp = Date.now();
|
|
@@ -14423,8 +14984,15 @@ import { EventEmitter as EventEmitter9 } from "events";
|
|
|
14423
14984
|
|
|
14424
14985
|
// src/lib/objects-in-viewport.ts
|
|
14425
14986
|
function getObjectsInViewport(viewport, objects, direction = "column", padding = 10, minTriggerSize = 16) {
|
|
14426
|
-
if (
|
|
14987
|
+
if (viewport.width <= 0 || viewport.height <= 0) {
|
|
14988
|
+
return [];
|
|
14989
|
+
}
|
|
14990
|
+
if (objects.length === 0) {
|
|
14991
|
+
return [];
|
|
14992
|
+
}
|
|
14993
|
+
if (objects.length < minTriggerSize) {
|
|
14427
14994
|
return objects;
|
|
14995
|
+
}
|
|
14428
14996
|
const viewportTop = viewport.y - padding;
|
|
14429
14997
|
const viewportBottom = viewport.y + viewport.height + padding;
|
|
14430
14998
|
const viewportLeft = viewport.x - padding;
|
|
@@ -14759,6 +15327,7 @@ class CliRenderer extends EventEmitter9 {
|
|
|
14759
15327
|
_stdinBuffer;
|
|
14760
15328
|
animationRequest = new Map;
|
|
14761
15329
|
resizeTimeoutId = null;
|
|
15330
|
+
capabilityTimeoutId = null;
|
|
14762
15331
|
resizeDebounceDelay = 100;
|
|
14763
15332
|
enableMouseMovement = false;
|
|
14764
15333
|
_useMouse = true;
|
|
@@ -15201,7 +15770,8 @@ Captured output:
|
|
|
15201
15770
|
this._terminalIsSetup = true;
|
|
15202
15771
|
this.lib.setupTerminal(this.rendererPtr, this._useAlternateScreen);
|
|
15203
15772
|
this._capabilities = this.lib.getTerminalCapabilities(this.rendererPtr);
|
|
15204
|
-
setTimeout(() => {
|
|
15773
|
+
this.capabilityTimeoutId = setTimeout(() => {
|
|
15774
|
+
this.capabilityTimeoutId = null;
|
|
15205
15775
|
this.removeInputHandler(this.capabilityHandler);
|
|
15206
15776
|
}, 5000);
|
|
15207
15777
|
if (this._useMouse) {
|
|
@@ -15298,6 +15868,15 @@ Captured output:
|
|
|
15298
15868
|
}
|
|
15299
15869
|
this._latestPointer.x = mouseEvent.x;
|
|
15300
15870
|
this._latestPointer.y = mouseEvent.y;
|
|
15871
|
+
if (this._console.visible) {
|
|
15872
|
+
const consoleBounds = this._console.bounds;
|
|
15873
|
+
if (mouseEvent.x >= consoleBounds.x && mouseEvent.x < consoleBounds.x + consoleBounds.width && mouseEvent.y >= consoleBounds.y && mouseEvent.y < consoleBounds.y + consoleBounds.height) {
|
|
15874
|
+
const event2 = new MouseEvent(null, mouseEvent);
|
|
15875
|
+
const handled = this._console.handleMouse(event2);
|
|
15876
|
+
if (handled)
|
|
15877
|
+
return true;
|
|
15878
|
+
}
|
|
15879
|
+
}
|
|
15301
15880
|
if (mouseEvent.type === "scroll") {
|
|
15302
15881
|
const maybeRenderableId2 = this.lib.checkHit(this.rendererPtr, mouseEvent.x, mouseEvent.y);
|
|
15303
15882
|
const maybeRenderable2 = Renderable.renderablesByNumber.get(maybeRenderableId2);
|
|
@@ -15669,7 +16248,17 @@ Captured output:
|
|
|
15669
16248
|
process.removeListener("uncaughtException", this.handleError);
|
|
15670
16249
|
process.removeListener("unhandledRejection", this.handleError);
|
|
15671
16250
|
process.removeListener("warning", this.warningHandler);
|
|
16251
|
+
process.removeListener("beforeExit", this.exitHandler);
|
|
15672
16252
|
capture.removeListener("write", this.captureCallback);
|
|
16253
|
+
this.removeExitListeners();
|
|
16254
|
+
if (this.resizeTimeoutId !== null) {
|
|
16255
|
+
clearTimeout(this.resizeTimeoutId);
|
|
16256
|
+
this.resizeTimeoutId = null;
|
|
16257
|
+
}
|
|
16258
|
+
if (this.capabilityTimeoutId !== null) {
|
|
16259
|
+
clearTimeout(this.capabilityTimeoutId);
|
|
16260
|
+
this.capabilityTimeoutId = null;
|
|
16261
|
+
}
|
|
15673
16262
|
if (this.memorySnapshotTimer) {
|
|
15674
16263
|
clearInterval(this.memorySnapshotTimer);
|
|
15675
16264
|
}
|
|
@@ -15868,10 +16457,12 @@ Captured output:
|
|
|
15868
16457
|
this.clearSelection();
|
|
15869
16458
|
this.selectionContainers.push(renderable.parent || this.root);
|
|
15870
16459
|
this.currentSelection = new Selection(renderable, { x, y }, { x, y });
|
|
16460
|
+
this.currentSelection.isStart = true;
|
|
15871
16461
|
this.notifySelectablesOfSelectionChange();
|
|
15872
16462
|
}
|
|
15873
16463
|
updateSelection(currentRenderable, x, y) {
|
|
15874
16464
|
if (this.currentSelection) {
|
|
16465
|
+
this.currentSelection.isStart = false;
|
|
15875
16466
|
this.currentSelection.focus = { x, y };
|
|
15876
16467
|
if (this.selectionContainers.length > 0) {
|
|
15877
16468
|
const currentContainer = this.selectionContainers[this.selectionContainers.length - 1];
|
|
@@ -15913,6 +16504,7 @@ Captured output:
|
|
|
15913
16504
|
if (this.currentSelection) {
|
|
15914
16505
|
this.currentSelection.isSelecting = false;
|
|
15915
16506
|
this.emit("selection", this.currentSelection);
|
|
16507
|
+
this.notifySelectablesOfSelectionChange();
|
|
15916
16508
|
}
|
|
15917
16509
|
}
|
|
15918
16510
|
notifySelectablesOfSelectionChange() {
|
|
@@ -15931,7 +16523,7 @@ Captured output:
|
|
|
15931
16523
|
}
|
|
15932
16524
|
}
|
|
15933
16525
|
walkSelectableRenderables(container, selectionBounds, selectedRenderables, touchedRenderables) {
|
|
15934
|
-
const children = getObjectsInViewport(selectionBounds, container.getChildrenSortedByPrimaryAxis(), container.primaryAxis, 0);
|
|
16526
|
+
const children = getObjectsInViewport(selectionBounds, container.getChildrenSortedByPrimaryAxis(), container.primaryAxis, 0, 0);
|
|
15935
16527
|
for (const child of children) {
|
|
15936
16528
|
if (child.selectable) {
|
|
15937
16529
|
const hasSelection = child.onSelectionChanged(this.currentSelection);
|
|
@@ -15982,7 +16574,7 @@ Captured output:
|
|
|
15982
16574
|
}
|
|
15983
16575
|
}
|
|
15984
16576
|
|
|
15985
|
-
export { __toESM, __commonJS, __export, __require, Edge, Gutter, MeasureMode, exports_src, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, nonAlphanumericKeys, parseKeypress, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, DebugOverlayCorner, createTextAttributes, visualizeRenderableTree, isStyledText, StyledText, stringToStyledText, black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bold, italic, underline, strikethrough, dim, reverse, blink, fg, bg, t, hastToStyledText, LinearScrollAccel, MacOSScrollAccel, StdinBuffer, parseAlign, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, envRegistry, registerEnvVar, clearEnvCache, generateEnvMarkdown, generateEnvColored, env, treeSitterToTextChunks, treeSitterToStyledText, addDefaultParsers, TreeSitterClient, DataPathsManager, getDataPaths, extToFiletype, pathToFiletype, main, getTreeSitterClient, ExtmarksController, createExtmarksController, TerminalPalette, createTerminalPalette, TextBuffer, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, isValidPercentage, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, ANSI, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, buildKittyKeyboardFlags, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, RendererControlState, CliRenderer };
|
|
16577
|
+
export { __toESM, __commonJS, __export, __require, Edge, Gutter, MeasureMode, exports_src, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, nonAlphanumericKeys, parseKeypress, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, DebugOverlayCorner, createTextAttributes, visualizeRenderableTree, isStyledText, StyledText, stringToStyledText, black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bold, italic, underline, strikethrough, dim, reverse, blink, fg, bg, t, hastToStyledText, LinearScrollAccel, MacOSScrollAccel, StdinBuffer, parseAlign, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, envRegistry, registerEnvVar, clearEnvCache, generateEnvMarkdown, generateEnvColored, env, treeSitterToTextChunks, treeSitterToStyledText, addDefaultParsers, TreeSitterClient, DataPathsManager, getDataPaths, extToFiletype, pathToFiletype, main, getTreeSitterClient, ExtmarksController, createExtmarksController, TerminalPalette, createTerminalPalette, TextBuffer, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, isValidPercentage, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, ANSI, defaultKeyAliases, mergeKeyAliases, mergeKeyBindings, getKeyBindingKey, buildKeyBindingsMap, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, buildKittyKeyboardFlags, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, RendererControlState, CliRenderer };
|
|
15986
16578
|
|
|
15987
|
-
//# debugId=
|
|
15988
|
-
//# sourceMappingURL=index-
|
|
16579
|
+
//# debugId=7D82DD76DE3E9D9064756E2164756E21
|
|
16580
|
+
//# sourceMappingURL=index-mrwvcpzb.js.map
|