dsh-neotui 0.0.21 → 0.0.22
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 +1 -1
- package/src/views.js +19 -2
package/package.json
CHANGED
package/src/views.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { Screen } from "./screen.js";
|
|
3
3
|
import { renderMd, C } from "./md.js";
|
|
4
4
|
import { truncate, strWidth, bars, fmtDuration } from "./text.js";
|
|
5
|
-
import { readFileSync } from "node:fs";
|
|
5
|
+
import { readFileSync, appendFileSync } from "node:fs";
|
|
6
|
+
import { join } from "node:path";
|
|
6
7
|
import { Widget, List, ScrollView, Input, Popup, Menu, StatusBar } from "./widgets.js";
|
|
7
8
|
import { userPrefix, saveTuiConfig, loadTuiConfig, userName } from "./config.js";
|
|
8
9
|
export { userPrefix, saveTuiConfig, loadTuiConfig, userName } from "./config.js";
|
|
@@ -839,6 +840,15 @@ export class ChatView extends Widget {
|
|
|
839
840
|
}).catch((e) => this.app.toast(`发送失败: ${e.message}`));
|
|
840
841
|
}
|
|
841
842
|
|
|
843
|
+
/** File-based click diagnostics (DSH_TUI_DEBUG_CLICK=1): stderr lines are
|
|
844
|
+
* painted over by the next frame, so the trace goes to a log file. */
|
|
845
|
+
#clickLog(msg) {
|
|
846
|
+
try {
|
|
847
|
+
const dir = process.env.DSH_HOME ?? join(process.env.HOME ?? ".", ".dsh");
|
|
848
|
+
appendFileSync(join(dir, "tui-click-debug.log"), `${new Date().toISOString()} ${msg}\n`);
|
|
849
|
+
} catch {}
|
|
850
|
+
}
|
|
851
|
+
|
|
842
852
|
#clickLine(y, ev) {
|
|
843
853
|
// NO flush here: the click maps against the exact frame the user saw.
|
|
844
854
|
// Flushing would re-derive the streaming tail (the chunk-stream and the
|
|
@@ -890,6 +900,9 @@ export class ChatView extends Widget {
|
|
|
890
900
|
const node = this.nodes[info.nodeIdx];
|
|
891
901
|
if (!node) return false;
|
|
892
902
|
const { lineKey, topKey, topFirst, topOffset, match, firstNonEmpty, preHeaderIdx, preHeaderRow } = ctx ?? this.#anchorCtx(info);
|
|
903
|
+
if (process.env.DSH_TUI_DEBUG_CLICK) {
|
|
904
|
+
this.#clickLog(`toggle mark=${JSON.stringify(info)} kind=${node.kind} blockIdx=${info.blockIdx} preHeaderRow=${preHeaderRow} topKey=${topKey} topOffset=${topOffset}`);
|
|
905
|
+
}
|
|
893
906
|
const reanchor = () => {
|
|
894
907
|
// primary anchor: the clicked block's header stays at its pre-click
|
|
895
908
|
// viewport row (zero shift) — only when the header was ON-SCREEN.
|
|
@@ -941,6 +954,10 @@ export class ChatView extends Widget {
|
|
|
941
954
|
}
|
|
942
955
|
this.#rebuild();
|
|
943
956
|
reanchor(); nudge();
|
|
957
|
+
if (process.env.DSH_TUI_DEBUG_CLICK) {
|
|
958
|
+
const t = this.lines[this.view.scrollY]?.map((g) => g.t).join("") ?? "";
|
|
959
|
+
this.#clickLog(`after scrollY=${this.view.scrollY} topKey="${topKey}" topText="${t.slice(0, 40)}"`);
|
|
960
|
+
}
|
|
944
961
|
return true;
|
|
945
962
|
}
|
|
946
963
|
}
|
|
@@ -1333,7 +1350,7 @@ export class ChatView extends Widget {
|
|
|
1333
1350
|
this.pressCtx = this.pressInfo ? this.#anchorCtx(this.pressInfo) : null;
|
|
1334
1351
|
if (process.env.DSH_TUI_DEBUG_CLICK) {
|
|
1335
1352
|
const t = this.lines[this.pressY]?.map((g) => g.t).join("") ?? "";
|
|
1336
|
-
this
|
|
1353
|
+
this.#clickLog(`press screenY=${ev.y} screenX=${ev.x} lineIdx=${this.pressY} mark=${JSON.stringify(this.pressInfo)} text="${t.slice(0, 40)}" scrollY=${this.view.scrollY} viewY=${this.view.y} viewH=${this.view.h}`);
|
|
1337
1354
|
}
|
|
1338
1355
|
return true;
|
|
1339
1356
|
}
|