Refactor CLI and InkApp components for improved functionality and user experience. Update model settings in InkApp, enhance terminal input handling, and streamline dependency management in package.json. Remove unused dependencies and update dotenv version for better environment variable management.
This commit is contained in:
@@ -30,22 +30,24 @@ class TerminalService extends EventEmitter {
|
||||
env: {
|
||||
...process.env,
|
||||
TERM: 'xterm-256color',
|
||||
PS1: '> '
|
||||
PS1: 'bash> '
|
||||
},
|
||||
});
|
||||
|
||||
this.ptyProcess.onData((data) => {
|
||||
const str = String(data);
|
||||
for (let i = 0; i < str.length; i += 1) {
|
||||
const ch = str[i];
|
||||
if (ch === '\\n') {
|
||||
// Normalize CRLF to LF to avoid double-handling \r and \n
|
||||
const normalized = str.replace(/\r\n/g, '\n');
|
||||
for (let i = 0; i < normalized.length; i += 1) {
|
||||
const ch = normalized[i];
|
||||
if (ch === '\n') {
|
||||
// Line feed completes the current line
|
||||
this.lines.push(this.partial);
|
||||
this.partial = '';
|
||||
} else if (ch === '\\r') {
|
||||
// Carriage return: move to start of line; start overwriting
|
||||
} else if (ch === '\r') {
|
||||
// Standalone carriage return: simulate return to start of line (overwrite)
|
||||
this.partial = '';
|
||||
} else if (ch === '\\b' || ch === '\\x7f') {
|
||||
} else if (ch === '\b' || ch === '\x7f') {
|
||||
// Backspace or DEL: remove last char if present
|
||||
if (this.partial.length > 0) {
|
||||
this.partial = this.partial.slice(0, -1);
|
||||
|
||||
Reference in New Issue
Block a user