mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
clear_history binding, default Cmd+K
This commit is contained in:
@ -896,6 +896,13 @@ pub fn keyCallback(
|
||||
self.setFontSize(size);
|
||||
},
|
||||
|
||||
.clear_screen => {
|
||||
_ = self.io_thread.mailbox.push(.{
|
||||
.clear_screen = .{ .history = true },
|
||||
}, .{ .forever = {} });
|
||||
try self.io_thread.wakeup.notify();
|
||||
},
|
||||
|
||||
.toggle_dev_mode => if (DevMode.enabled) {
|
||||
DevMode.instance.visible = !DevMode.instance.visible;
|
||||
try self.queueRender();
|
||||
|
@ -192,6 +192,12 @@ pub const Config = struct {
|
||||
.{ .paste_from_clipboard = {} },
|
||||
);
|
||||
|
||||
try result.keybind.set.put(
|
||||
alloc,
|
||||
.{ .key = .k, .mods = .{ .super = true } },
|
||||
.{ .clear_screen = {} },
|
||||
);
|
||||
|
||||
try result.keybind.set.put(alloc, .{ .key = .up }, .{ .cursor_key = .{
|
||||
.normal = "\x1b[A",
|
||||
.application = "\x1bOA",
|
||||
|
@ -146,6 +146,9 @@ pub const Action = union(enum) {
|
||||
/// Reset the font size to the original configured size
|
||||
reset_font_size: void,
|
||||
|
||||
/// Clear the screen. This also clears all scrollback.
|
||||
clear_screen: void,
|
||||
|
||||
/// Dev mode
|
||||
toggle_dev_mode: void,
|
||||
|
||||
|
@ -194,6 +194,19 @@ pub fn resize(
|
||||
}
|
||||
}
|
||||
|
||||
/// Clear the screen.
|
||||
pub fn clearScreen(self: *Exec, history: bool) !void {
|
||||
// Queue form-feed ASCII code to clear the visible page.
|
||||
try self.queueWrite(&[_]u8{0x0C});
|
||||
|
||||
// Clear our scrollback
|
||||
if (history) {
|
||||
self.renderer_state.mutex.lock();
|
||||
defer self.renderer_state.mutex.unlock();
|
||||
self.terminal.screen.clearHistory();
|
||||
}
|
||||
}
|
||||
|
||||
pub inline fn queueWrite(self: *Exec, data: []const u8) !void {
|
||||
const ev = self.data.?;
|
||||
|
||||
|
@ -130,6 +130,7 @@ fn drainMailbox(self: *Thread) !void {
|
||||
log.debug("mailbox message={}", .{message});
|
||||
switch (message) {
|
||||
.resize => |v| try self.impl.resize(v.grid_size, v.screen_size, v.padding),
|
||||
.clear_screen => |v| try self.impl.clearScreen(v.history),
|
||||
.write_small => |v| try self.impl.queueWrite(v.data[0..v.len]),
|
||||
.write_stable => |v| try self.impl.queueWrite(v),
|
||||
.write_alloc => |v| {
|
||||
|
@ -29,6 +29,12 @@ pub const Message = union(enum) {
|
||||
padding: renderer.Padding,
|
||||
},
|
||||
|
||||
/// Clear the screen.
|
||||
clear_screen: struct {
|
||||
/// Include clearing the history
|
||||
history: bool,
|
||||
},
|
||||
|
||||
/// Write where the data fits in the union.
|
||||
write_small: WriteReq.Small,
|
||||
|
||||
|
Reference in New Issue
Block a user