mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
handle backspace
This commit is contained in:
@ -302,12 +302,18 @@ fn keyCallback(
|
|||||||
_ = scancode;
|
_ = scancode;
|
||||||
_ = mods;
|
_ = mods;
|
||||||
|
|
||||||
//log.info("KEY {} {}", .{ key, action });
|
//log.info("KEY {} {} {} {}", .{ key, scancode, mods, action });
|
||||||
if (key == .enter and (action == .press or action == .repeat)) {
|
if (action == .press or action == .repeat) {
|
||||||
|
const c: u8 = switch (key) {
|
||||||
|
.backspace => 0x08,
|
||||||
|
.enter => '\n',
|
||||||
|
else => return,
|
||||||
|
};
|
||||||
|
|
||||||
const win = window.getUserPointer(Window) orelse return;
|
const win = window.getUserPointer(Window) orelse return;
|
||||||
const req = win.write_req_pool.get() catch unreachable;
|
const req = win.write_req_pool.get() catch unreachable;
|
||||||
const buf = win.buf_pool.get() catch unreachable;
|
const buf = win.buf_pool.get() catch unreachable;
|
||||||
buf[0] = @intCast(u8, '\n');
|
buf[0] = c;
|
||||||
win.pty_stream.write(
|
win.pty_stream.write(
|
||||||
.{ .req = req },
|
.{ .req = req },
|
||||||
&[1][]u8{buf[0..1]},
|
&[1][]u8{buf[0..1]},
|
||||||
@ -346,7 +352,7 @@ fn ttyRead(t: *libuv.Tty, n: isize, buf: []const u8) void {
|
|||||||
const win = t.getData(Window).?;
|
const win = t.getData(Window).?;
|
||||||
defer win.alloc.free(buf);
|
defer win.alloc.free(buf);
|
||||||
|
|
||||||
// log.info("DATA: {s}", .{buf[0..@intCast(usize, n)]});
|
// log.info("DATA: {any}", .{buf[0..@intCast(usize, n)]});
|
||||||
|
|
||||||
win.terminal.append(win.alloc, buf[0..@intCast(usize, n)]) catch |err|
|
win.terminal.append(win.alloc, buf[0..@intCast(usize, n)]) catch |err|
|
||||||
log.err("error writing terminal data: {}", .{err});
|
log.err("error writing terminal data: {}", .{err});
|
||||||
|
Reference in New Issue
Block a user