Chat TUI
This commit is contained in:
@@ -186,6 +186,24 @@ function bareEditCup(row1, col1) {
|
||||
return '\x1b[' + r + ';' + c + 'H'
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Record<string, unknown>} ctx
|
||||
* @param {import('stream').Writable} stdout
|
||||
* @param {string} s
|
||||
*/
|
||||
function bareEditWrite(ctx, stdout, s) {
|
||||
if (!stdout || typeof stdout.write !== 'function') return
|
||||
try {
|
||||
stdout.write(s)
|
||||
} catch {
|
||||
try {
|
||||
ctx.console?.error?.('edit: stdout write failed')
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** TTY key parsing for /bin/edit: consume one logical key from a mutable byte queue. */
|
||||
|
||||
/**
|
||||
|
||||
@@ -186,6 +186,24 @@ function bareEditCup(row1, col1) {
|
||||
return '\x1b[' + r + ';' + c + 'H'
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Record<string, unknown>} ctx
|
||||
* @param {import('stream').Writable} stdout
|
||||
* @param {string} s
|
||||
*/
|
||||
function bareEditWrite(ctx, stdout, s) {
|
||||
if (!stdout || typeof stdout.write !== 'function') return
|
||||
try {
|
||||
stdout.write(s)
|
||||
} catch {
|
||||
try {
|
||||
ctx.console?.error?.('edit: stdout write failed')
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** TTY key parsing for /bin/edit: consume one logical key from a mutable byte queue. */
|
||||
|
||||
/**
|
||||
|
||||
+1022
-19
File diff suppressed because it is too large
Load Diff
+20
-18
@@ -186,6 +186,24 @@ function bareEditCup(row1, col1) {
|
||||
return '\x1b[' + r + ';' + c + 'H'
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Record<string, unknown>} ctx
|
||||
* @param {import('stream').Writable} stdout
|
||||
* @param {string} s
|
||||
*/
|
||||
function bareEditWrite(ctx, stdout, s) {
|
||||
if (!stdout || typeof stdout.write !== 'function') return
|
||||
try {
|
||||
stdout.write(s)
|
||||
} catch {
|
||||
try {
|
||||
ctx.console?.error?.('edit: stdout write failed')
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Syntax highlighting for /bin/edit (line-oriented, best-effort). */
|
||||
|
||||
const EDIT_KW_JS =
|
||||
@@ -981,7 +999,7 @@ function bareEditTryConsumeKey(q) {
|
||||
return { type: 'key', ch: bareEditUtf8DecodeKey(chunk) }
|
||||
}
|
||||
|
||||
/** Full-screen TUI for /bin/edit (raw TTY, fish suspend/resume). */
|
||||
/** Stdin chunk queue + async key reader for edit/chat TUIs (requires edit-key-parse.js first). */
|
||||
|
||||
/**
|
||||
* @param {unknown} chunk
|
||||
@@ -1094,23 +1112,7 @@ function bareEditCreateStdinReader(stdin) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Record<string, unknown>} ctx
|
||||
* @param {import('stream').Writable} stdout
|
||||
* @param {string} s
|
||||
*/
|
||||
function bareEditWrite(ctx, stdout, s) {
|
||||
if (!stdout || typeof stdout.write !== 'function') return
|
||||
try {
|
||||
stdout.write(s)
|
||||
} catch {
|
||||
try {
|
||||
ctx.console?.error?.('edit: stdout write failed')
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
}
|
||||
/** Full-screen TUI for /bin/edit (stdin/key helpers in edit-stream-read.js; bareEditWrite in edit-ansi.js). */
|
||||
|
||||
/**
|
||||
* @param {Record<string, unknown>} ctx
|
||||
|
||||
+20
-18
@@ -186,6 +186,24 @@ function bareEditCup(row1, col1) {
|
||||
return '\x1b[' + r + ';' + c + 'H'
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Record<string, unknown>} ctx
|
||||
* @param {import('stream').Writable} stdout
|
||||
* @param {string} s
|
||||
*/
|
||||
function bareEditWrite(ctx, stdout, s) {
|
||||
if (!stdout || typeof stdout.write !== 'function') return
|
||||
try {
|
||||
stdout.write(s)
|
||||
} catch {
|
||||
try {
|
||||
ctx.console?.error?.('edit: stdout write failed')
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Syntax highlighting for /bin/edit (line-oriented, best-effort). */
|
||||
|
||||
const EDIT_KW_JS =
|
||||
@@ -981,7 +999,7 @@ function bareEditTryConsumeKey(q) {
|
||||
return { type: 'key', ch: bareEditUtf8DecodeKey(chunk) }
|
||||
}
|
||||
|
||||
/** Full-screen TUI for /bin/edit (raw TTY, fish suspend/resume). */
|
||||
/** Stdin chunk queue + async key reader for edit/chat TUIs (requires edit-key-parse.js first). */
|
||||
|
||||
/**
|
||||
* @param {unknown} chunk
|
||||
@@ -1094,23 +1112,7 @@ function bareEditCreateStdinReader(stdin) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Record<string, unknown>} ctx
|
||||
* @param {import('stream').Writable} stdout
|
||||
* @param {string} s
|
||||
*/
|
||||
function bareEditWrite(ctx, stdout, s) {
|
||||
if (!stdout || typeof stdout.write !== 'function') return
|
||||
try {
|
||||
stdout.write(s)
|
||||
} catch {
|
||||
try {
|
||||
ctx.console?.error?.('edit: stdout write failed')
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
}
|
||||
/** Full-screen TUI for /bin/edit (stdin/key helpers in edit-stream-read.js; bareEditWrite in edit-ansi.js). */
|
||||
|
||||
/**
|
||||
* @param {Record<string, unknown>} ctx
|
||||
|
||||
Reference in New Issue
Block a user