mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-24 20:56:08 +03:00
termio: clear selection
This commit is contained in:
@ -810,7 +810,13 @@ fn charCallback(window: glfw.Window, codepoint: u21) void {
|
||||
return;
|
||||
}
|
||||
|
||||
// Anytime is character is created, we have to clear the selection
|
||||
// Anytime a char is created, we have to clear the selection if there is one.
|
||||
_ = win.io_thread.mailbox.push(.{
|
||||
.clear_selection = {},
|
||||
}, .{ .forever = {} });
|
||||
|
||||
// TODO: the stuff below goes away with IO thread
|
||||
|
||||
if (win.terminal.selection != null) {
|
||||
win.terminal.selection = null;
|
||||
win.queueRender() catch |err|
|
||||
|
@ -188,6 +188,17 @@ pub fn resize(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clearSelection(self: *Exec) !void {
|
||||
// We don't need a lock to read because nothing else can possibly write
|
||||
// as we're looking at this.
|
||||
if (self.terminal.selection != null) {
|
||||
// We need to lock so we can write because other things might be reading.
|
||||
self.renderer_state.mutex.lock();
|
||||
defer self.renderer_state.mutex.unlock();
|
||||
self.terminal.selection = null;
|
||||
}
|
||||
}
|
||||
|
||||
const ThreadData = struct {
|
||||
/// Allocator used for the event data
|
||||
alloc: Allocator,
|
||||
|
@ -150,15 +150,28 @@ fn drainMailbox(self: *Thread) !void {
|
||||
// This holds the mailbox lock for the duration of the drain. The
|
||||
// expectation is that all our message handlers will be non-blocking
|
||||
// ENOUGH to not mess up throughput on producers.
|
||||
var drain = self.mailbox.drain();
|
||||
defer drain.deinit();
|
||||
var redraw: bool = false;
|
||||
{
|
||||
var drain = self.mailbox.drain();
|
||||
defer drain.deinit();
|
||||
|
||||
while (drain.next()) |message| {
|
||||
log.debug("mailbox message={}", .{message});
|
||||
switch (message) {
|
||||
.resize => |v| try self.impl.resize(v.grid_size, v.screen_size),
|
||||
while (drain.next()) |message| {
|
||||
// If we have a message we always redraw
|
||||
redraw = true;
|
||||
|
||||
log.debug("mailbox message={}", .{message});
|
||||
switch (message) {
|
||||
.resize => |v| try self.impl.resize(v.grid_size, v.screen_size),
|
||||
.clear_selection => try self.impl.clearSelection(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Trigger a redraw after we've drained so we don't waste cyces
|
||||
// messaging a redraw.
|
||||
if (redraw) {
|
||||
try self.impl.renderer_wakeup.send();
|
||||
}
|
||||
}
|
||||
|
||||
fn wakeupCallback(h: *libuv.Async) void {
|
||||
|
@ -9,8 +9,8 @@ pub const IO = union(enum) {
|
||||
screen_size: renderer.ScreenSize,
|
||||
},
|
||||
|
||||
// /// Clear the selection
|
||||
// clear_selection: void,
|
||||
/// Clear the selection
|
||||
clear_selection: void,
|
||||
//
|
||||
// /// Scroll the viewport
|
||||
// scroll_viewport: terminal.Terminal.ScrollViewport,
|
||||
|
Reference in New Issue
Block a user