Fix terminal rendering and add improvements
- Enable bracketed paste mode for handling large pastes - Fix editor duplicate line rendering bug at terminal width - Add padding support to Markdown component (paddingX/Y) - Add Spacer component for vertical spacing - Update chat-simple with spacers between messages
This commit is contained in:
@@ -84,16 +84,12 @@ editor.onSubmit = (value: string) => {
|
||||
// Insert before the editor (which is last)
|
||||
const children = tui.children;
|
||||
children.splice(children.length - 1, 0, userMessage);
|
||||
|
||||
// Add spacer after user message
|
||||
children.splice(children.length - 1, 0, new Spacer());
|
||||
|
||||
// Add loader
|
||||
const loader = new Loader(tui, "Thinking...");
|
||||
children.splice(children.length - 1, 0, loader);
|
||||
|
||||
// Add spacer after loader
|
||||
const loaderSpacer = new Spacer();
|
||||
children.splice(children.length - 1, 0, loader);
|
||||
children.splice(children.length - 1, 0, loaderSpacer);
|
||||
|
||||
tui.requestRender();
|
||||
@@ -101,15 +97,8 @@ editor.onSubmit = (value: string) => {
|
||||
// Simulate a 1 second delay
|
||||
setTimeout(() => {
|
||||
// Remove loader and its spacer
|
||||
const loaderIndex = children.indexOf(loader);
|
||||
if (loaderIndex !== -1) {
|
||||
children.splice(loaderIndex, 1);
|
||||
loader.stop();
|
||||
}
|
||||
const loaderSpacerIndex = children.indexOf(loaderSpacer);
|
||||
if (loaderSpacerIndex !== -1) {
|
||||
children.splice(loaderSpacerIndex, 1);
|
||||
}
|
||||
tui.removeChild(loader);
|
||||
tui.removeChild(loaderSpacer);
|
||||
|
||||
// Simulate a response
|
||||
const responses = [
|
||||
@@ -127,8 +116,6 @@ editor.onSubmit = (value: string) => {
|
||||
// Add assistant message with no background (transparent)
|
||||
const botMessage = new Markdown(randomResponse);
|
||||
children.splice(children.length - 1, 0, botMessage);
|
||||
|
||||
// Add spacer after assistant message
|
||||
children.splice(children.length - 1, 0, new Spacer());
|
||||
|
||||
// Re-enable submit
|
||||
|
||||
@@ -32,10 +32,13 @@ export class VirtualTerminal implements Terminal {
|
||||
start(onInput: (data: string) => void, onResize: () => void): void {
|
||||
this.inputHandler = onInput;
|
||||
this.resizeHandler = onResize;
|
||||
// No need for raw mode in virtual terminal
|
||||
// Enable bracketed paste mode for consistency with ProcessTerminal
|
||||
this.xterm.write("\x1b[?2004h");
|
||||
}
|
||||
|
||||
stop(): void {
|
||||
// Disable bracketed paste mode
|
||||
this.xterm.write("\x1b[?2004l");
|
||||
this.inputHandler = undefined;
|
||||
this.resizeHandler = undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user