opencode-miniterm 1.0.9 → 1.0.10
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/index.ts +28 -21
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -182,48 +182,55 @@ let completionCycling = false;
|
|
|
182
182
|
let lastSpaceTime = 0;
|
|
183
183
|
let currentInputBuffer: string | null = null;
|
|
184
184
|
|
|
185
|
+
let count = 0;
|
|
185
186
|
let oldWrappedRows = 0;
|
|
187
|
+
let oldCursorRow = 0;
|
|
186
188
|
function renderLine(): void {
|
|
187
189
|
const consoleWidth = process.stdout.columns || 80;
|
|
188
190
|
|
|
189
191
|
readline.cursorTo(process.stdout, 0);
|
|
192
|
+
|
|
193
|
+
// Ensure the cursor is at the end of the old input
|
|
194
|
+
if (cursorPosition < inputBuffer.length) {
|
|
195
|
+
readline.moveCursor(process.stdout, 0, oldWrappedRows - oldCursorRow);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Clear the old input
|
|
190
199
|
if (oldWrappedRows > 0) {
|
|
191
200
|
readline.moveCursor(process.stdout, 0, -oldWrappedRows);
|
|
192
201
|
}
|
|
193
202
|
readline.clearScreenDown(process.stdout);
|
|
203
|
+
readline.cursorTo(process.stdout, 2);
|
|
194
204
|
|
|
205
|
+
// Write the prompt
|
|
195
206
|
writePrompt();
|
|
196
207
|
|
|
208
|
+
// Write the new input buffer
|
|
209
|
+
let renderExtent = Math.max(cursorPosition + 1, inputBuffer.length);
|
|
197
210
|
let currentCol = 2;
|
|
198
|
-
let
|
|
199
|
-
for (let i = 0; i <
|
|
211
|
+
let newWrappedRows = 0;
|
|
212
|
+
for (let i = 0; i < renderExtent; i++) {
|
|
200
213
|
if (currentCol >= consoleWidth) {
|
|
201
214
|
process.stdout.write("\n");
|
|
202
215
|
currentCol = 0;
|
|
203
|
-
|
|
216
|
+
newWrappedRows++;
|
|
204
217
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
oldWrappedRows = row;
|
|
209
|
-
|
|
210
|
-
let targetRow = 0;
|
|
211
|
-
let targetCol = 0;
|
|
212
|
-
let pos = 2;
|
|
213
|
-
for (let i = 0; i < cursorPosition; i++) {
|
|
214
|
-
if (pos >= consoleWidth) {
|
|
215
|
-
targetRow++;
|
|
216
|
-
pos = 0;
|
|
218
|
+
if (i < inputBuffer.length) {
|
|
219
|
+
process.stdout.write(inputBuffer[i]!);
|
|
217
220
|
}
|
|
218
|
-
|
|
221
|
+
currentCol++;
|
|
219
222
|
}
|
|
220
|
-
|
|
223
|
+
|
|
224
|
+
let absolutePos = 2 + cursorPosition;
|
|
225
|
+
let newCursorRow = Math.floor(absolutePos / consoleWidth);
|
|
226
|
+
let newCursorCol = absolutePos % consoleWidth;
|
|
221
227
|
|
|
222
228
|
readline.cursorTo(process.stdout, 0);
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
229
|
+
readline.moveCursor(process.stdout, 0, -1 * (newWrappedRows - newCursorRow));
|
|
230
|
+
readline.cursorTo(process.stdout, newCursorCol);
|
|
231
|
+
|
|
232
|
+
oldWrappedRows = newWrappedRows;
|
|
233
|
+
oldCursorRow = newCursorRow;
|
|
227
234
|
}
|
|
228
235
|
|
|
229
236
|
async function handleKeyPress(str: string, key: Key) {
|