mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-21 19:26:09 +03:00
termio: clear_screen binding does not trigger scrollback preservation
Fixes #970
This commit is contained in:
@ -451,22 +451,24 @@ pub fn clearScreen(self: *Exec, history: bool) !void {
|
|||||||
if (self.terminal.active_screen == .alternate) return;
|
if (self.terminal.active_screen == .alternate) return;
|
||||||
|
|
||||||
// Clear our scrollback
|
// Clear our scrollback
|
||||||
if (history) try self.terminal.screen.clear(.history);
|
if (history) self.terminal.eraseDisplay(self.alloc, .scrollback, false);
|
||||||
|
|
||||||
// If we're not at a prompt, we clear the screen manually using
|
// If we're not at a prompt, we just delete above the cursor.
|
||||||
// the terminal screen state. If we are at a prompt, we send
|
|
||||||
// form-feed so that the shell can repaint the entire screen.
|
|
||||||
if (!self.terminal.cursorIsAtPrompt()) {
|
if (!self.terminal.cursorIsAtPrompt()) {
|
||||||
// Clear above the cursor
|
|
||||||
try self.terminal.screen.clear(.above_cursor);
|
try self.terminal.screen.clear(.above_cursor);
|
||||||
|
|
||||||
// Exit
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// At a prompt, we want to first fully clear the screen, and then after
|
||||||
|
// send a FF (0x0C) to the shell so that it can repaint the screen.
|
||||||
|
// Mark the current row as a not a prompt so we can properly
|
||||||
|
// clear the full screen in the next eraseDisplay call.
|
||||||
|
self.terminal.markSemanticPrompt(.command);
|
||||||
|
assert(!self.terminal.cursorIsAtPrompt());
|
||||||
|
self.terminal.eraseDisplay(self.alloc, .complete, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we reached here it means we're at a prompt, so we send a form-feed.
|
// If we reached here it means we're at a prompt, so we send a form-feed.
|
||||||
assert(self.terminal.cursorIsAtPrompt());
|
|
||||||
try self.queueWrite(&[_]u8{0x0C}, false);
|
try self.queueWrite(&[_]u8{0x0C}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user