@pi-unipi/input-shortcuts 2.6.1 → 2.6.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/package.json +4 -2
- package/src/index.ts +3 -3
- package/src/registers.ts +0 -8
- package/src/settings-overlay.ts +4 -13
- package/src/undo-redo.ts +0 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-unipi/input-shortcuts",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.2",
|
|
4
4
|
"description": "Keyboard shortcuts for stash/restore, undo/redo, clipboard, and thinking toggle — chord-based overlay system",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -44,7 +44,9 @@
|
|
|
44
44
|
"typescript": "^6.0.0"
|
|
45
45
|
},
|
|
46
46
|
"pi": {
|
|
47
|
-
"extensions": [
|
|
47
|
+
"extensions": [
|
|
48
|
+
"./src/index.ts"
|
|
49
|
+
],
|
|
48
50
|
"skills": [],
|
|
49
51
|
"prompts": [],
|
|
50
52
|
"themes": []
|
package/src/index.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
15
|
-
import { Key } from "@earendil-works/pi-tui";
|
|
15
|
+
import { Key, matchesKey } from "@earendil-works/pi-tui";
|
|
16
16
|
import { MODULES, emitEvent, UNIPI_EVENTS, INPUT_SHORTCUTS_COMMANDS } from "@pi-unipi/core";
|
|
17
17
|
import { RegisterStore } from "./registers.ts";
|
|
18
18
|
import { UndoRedoBuffer } from "./undo-redo.ts";
|
|
@@ -20,6 +20,7 @@ import { ChordOverlay, type ChordCallbacks } from "./chord-overlay.ts";
|
|
|
20
20
|
import { SettingsOverlay } from "./settings-overlay.ts";
|
|
21
21
|
import { loadConfig } from "./settings-overlay.ts";
|
|
22
22
|
import { copyToClipboard } from "./clipboard.ts";
|
|
23
|
+
import { THINKING_CYCLE } from "./types.ts";
|
|
23
24
|
|
|
24
25
|
// ─── Status feedback ────────────────────────────────────────────────────────
|
|
25
26
|
|
|
@@ -111,7 +112,7 @@ export default function inputShortcutsExtension(pi: ExtensionAPI): void {
|
|
|
111
112
|
if (!ui || suppressInputListener) return;
|
|
112
113
|
|
|
113
114
|
// Only snapshot for edit keys (printable, backspace, delete, enter)
|
|
114
|
-
const isEditKey = data.length === 1 || data === "\x7f" || data
|
|
115
|
+
const isEditKey = data.length === 1 || data === "\x7f" || matchesKey(data, Key.delete) || data === "\r" || data === "\n";
|
|
115
116
|
if (!isEditKey) return;
|
|
116
117
|
|
|
117
118
|
// Capture text BEFORE the keypress is processed by the editor
|
|
@@ -254,7 +255,6 @@ export default function inputShortcutsExtension(pi: ExtensionAPI): void {
|
|
|
254
255
|
|
|
255
256
|
function doToggleThinking(): void {
|
|
256
257
|
const current = pi.getThinkingLevel();
|
|
257
|
-
const THINKING_CYCLE = ["off", "low", "medium", "high", "xhigh"] as const;
|
|
258
258
|
const idx = THINKING_CYCLE.indexOf(current as any);
|
|
259
259
|
const nextIdx = idx >= 0 ? (idx + 1) % THINKING_CYCLE.length : 0;
|
|
260
260
|
const next = THINKING_CYCLE[nextIdx];
|
package/src/registers.ts
CHANGED
|
@@ -44,14 +44,6 @@ export class RegisterStore {
|
|
|
44
44
|
return this.data!.registers[index] ?? "";
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
/** Set a numbered register (0-9) and persist. */
|
|
48
|
-
setRegister(index: number, text: string): void {
|
|
49
|
-
if (index < 0 || index > 9) return;
|
|
50
|
-
this.ensureLoaded();
|
|
51
|
-
this.data!.registers[index] = text;
|
|
52
|
-
this.save();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
47
|
/** Lazy load from disk on first access. */
|
|
56
48
|
private ensureLoaded(): void {
|
|
57
49
|
if (this.loaded) return;
|
package/src/settings-overlay.ts
CHANGED
|
@@ -74,17 +74,9 @@ const THEME: SettingsListTheme = {
|
|
|
74
74
|
export class SettingsOverlay implements Component {
|
|
75
75
|
private list: SettingsList;
|
|
76
76
|
private config: InputShortcutsConfig;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
constructor(
|
|
81
|
-
done: () => void,
|
|
82
|
-
baseDir?: string,
|
|
83
|
-
onSaved?: (config: InputShortcutsConfig) => void,
|
|
84
|
-
) {
|
|
85
|
-
this.baseDir = baseDir;
|
|
86
|
-
this.onSaved = onSaved;
|
|
87
|
-
this.config = loadConfig(baseDir);
|
|
77
|
+
|
|
78
|
+
constructor(done: () => void) {
|
|
79
|
+
this.config = loadConfig();
|
|
88
80
|
|
|
89
81
|
const items = this.buildItems();
|
|
90
82
|
this.list = new SettingsList(
|
|
@@ -93,8 +85,7 @@ export class SettingsOverlay implements Component {
|
|
|
93
85
|
THEME,
|
|
94
86
|
(id, newValue) => this.handleChange(id, newValue),
|
|
95
87
|
() => {
|
|
96
|
-
saveConfig(this.config
|
|
97
|
-
this.onSaved?.(this.config);
|
|
88
|
+
saveConfig(this.config);
|
|
98
89
|
done();
|
|
99
90
|
},
|
|
100
91
|
);
|
package/src/undo-redo.ts
CHANGED
|
@@ -20,7 +20,6 @@ export class UndoRedoBuffer {
|
|
|
20
20
|
private undoStack: TextSnapshot[] = [];
|
|
21
21
|
private redoStack: TextSnapshot[] = [];
|
|
22
22
|
private lastSnapshotAt = 0;
|
|
23
|
-
private lastUndoAt = 0;
|
|
24
23
|
|
|
25
24
|
/**
|
|
26
25
|
* Take a snapshot of current text BEFORE it changes.
|
|
@@ -66,21 +65,10 @@ export class UndoRedoBuffer {
|
|
|
66
65
|
return { text: snapshot.text, ok: true };
|
|
67
66
|
}
|
|
68
67
|
|
|
69
|
-
/** Check if undo stack has entries. */
|
|
70
|
-
hasUndo(): boolean {
|
|
71
|
-
return this.undoStack.length > 0;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/** Check if redo stack has entries. */
|
|
75
|
-
hasRedo(): boolean {
|
|
76
|
-
return this.redoStack.length > 0;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
68
|
/** Clear both stacks. Call on session shutdown. */
|
|
80
69
|
clear(): void {
|
|
81
70
|
this.undoStack = [];
|
|
82
71
|
this.redoStack = [];
|
|
83
72
|
this.lastSnapshotAt = 0;
|
|
84
|
-
this.lastUndoAt = 0;
|
|
85
73
|
}
|
|
86
74
|
}
|