From 16f981a48ac773f6807734ec75cc92f809fcf676 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 17 Aug 2022 17:23:58 -0700 Subject: [PATCH] Typing a character clears selection, scrolls to bottom --- src/Window.zig | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Window.zig b/src/Window.zig index 22f085c92..ff2557769 100644 --- a/src/Window.zig +++ b/src/Window.zig @@ -458,6 +458,19 @@ fn charCallback(window: glfw.Window, codepoint: u21) void { return; } + // Anytime is character is created, we have to clear the selection + if (win.terminal.selection != null) { + win.terminal.selection = null; + win.render_timer.schedule() catch |err| + log.err("error scheduling render in charCallback err={}", .{err}); + } + + // We want to scroll to the bottom + // TODO: detect if we're at the bottom to avoid the render call here. + win.terminal.scrollViewport(.{ .bottom = {} }); + win.render_timer.schedule() catch |err| + log.err("error scheduling render in charCallback err={}", .{err}); + // Write the character to the pty win.queueWrite(&[1]u8{@intCast(u8, codepoint)}) catch |err| log.err("error queueing write in charCallback err={}", .{err});