feat: implement remaining terminal handling functions via libvaxis
This commit is contained in:
parent
36f167221e
commit
49ad54d60c
10 changed files with 94 additions and 88 deletions
|
@ -105,7 +105,7 @@ pub fn State(ctx_type: type) type {
|
|||
tui.need_render();
|
||||
return true;
|
||||
} else if (try m.match(.{ "H", tp.extract(&self.hover) })) {
|
||||
tui.renderer.request_mouse_cursor_pointer(self.hover);
|
||||
tui.current().rdr.request_mouse_cursor_pointer(self.hover);
|
||||
tui.need_render();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ pub fn State(ctx_type: type) type {
|
|||
tui.need_render();
|
||||
return true;
|
||||
} else if (try m.match(.{ "H", tp.extract(&self.hover) })) {
|
||||
tui.renderer.request_mouse_cursor_pointer(self.hover);
|
||||
tui.current().rdr.request_mouse_cursor_pointer(self.hover);
|
||||
tui.need_render();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1860,7 +1860,7 @@ pub const Editor = struct {
|
|||
if (self.clipboard) |old|
|
||||
self.a.free(old);
|
||||
self.clipboard = text;
|
||||
tui.renderer.copy_to_system_clipboard(self.a, text);
|
||||
tui.current().rdr.copy_to_system_clipboard(text);
|
||||
}
|
||||
|
||||
fn copy_selection(root: Buffer.Root, sel: Selection, text_a: Allocator, plane: Plane) ![]const u8 {
|
||||
|
@ -1967,6 +1967,7 @@ pub const Editor = struct {
|
|||
if (!try ctx.args.match(.{tp.extract(&text)})) {
|
||||
if (self.clipboard) |text_| text = text_ else return;
|
||||
}
|
||||
self.logger.print("paste: {d} bytes", .{text.len});
|
||||
const b = self.buf_for_update() catch |e| return tp.exit_error(e);
|
||||
var root = b.root;
|
||||
if (self.cursels.items.len == 1) {
|
||||
|
@ -1992,10 +1993,11 @@ pub const Editor = struct {
|
|||
}
|
||||
self.update_buf(root) catch |e| return tp.exit_error(e);
|
||||
self.clamp();
|
||||
self.need_render();
|
||||
}
|
||||
|
||||
pub fn system_paste(_: *Self, _: command.Context) tp.result {
|
||||
tui.renderer.request_system_clipboard();
|
||||
tui.current().rdr.request_system_clipboard();
|
||||
}
|
||||
|
||||
pub fn delete_forward(self: *Self, _: command.Context) tp.result {
|
||||
|
@ -2867,12 +2869,12 @@ pub const Editor = struct {
|
|||
|
||||
pub fn enable_jump_mode(self: *Self, _: command.Context) tp.result {
|
||||
self.jump_mode = true;
|
||||
tui.renderer.request_mouse_cursor_pointer(true);
|
||||
tui.current().rdr.request_mouse_cursor_pointer(true);
|
||||
}
|
||||
|
||||
pub fn disable_jump_mode(self: *Self, _: command.Context) tp.result {
|
||||
self.jump_mode = false;
|
||||
tui.renderer.request_mouse_cursor_text(true);
|
||||
tui.current().rdr.request_mouse_cursor_text(true);
|
||||
}
|
||||
|
||||
fn update_syntax(self: *Self) !void {
|
||||
|
@ -3684,9 +3686,9 @@ pub const EditorWidget = struct {
|
|||
self.editor.add_match(m) catch {};
|
||||
} else if (try m.match(.{ "H", tp.extract(&self.hover) })) {
|
||||
if (self.editor.jump_mode)
|
||||
tui.renderer.request_mouse_cursor_pointer(self.hover)
|
||||
tui.current().rdr.request_mouse_cursor_pointer(self.hover)
|
||||
else
|
||||
tui.renderer.request_mouse_cursor_text(self.hover);
|
||||
tui.current().rdr.request_mouse_cursor_text(self.hover);
|
||||
} else if (try m.match(.{ "show_whitespace", tp.extract(&self.editor.show_whitespace) })) {
|
||||
_ = "";
|
||||
} else {
|
||||
|
|
|
@ -67,7 +67,7 @@ pub fn walk(self: *Self, walk_ctx: *anyopaque, f: Widget.WalkFn, w: *Widget) boo
|
|||
pub fn receive(_: *Self, _: tp.pid_ref, m: tp.message) error{Exit}!bool {
|
||||
var hover: bool = false;
|
||||
if (try m.match(.{ "H", tp.extract(&hover) })) {
|
||||
tui.renderer.request_mouse_cursor_default(hover);
|
||||
tui.current().rdr.request_mouse_cursor_default(hover);
|
||||
tui.need_render();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ fn render_terminal_title(self: *Self) void {
|
|||
if (std.mem.eql(u8, self.title, new_title)) return;
|
||||
@memcpy(self.title_buf[0..new_title.len], new_title);
|
||||
self.title = self.title_buf[0..new_title.len];
|
||||
tui.renderer.set_terminal_title(self.title);
|
||||
tui.current().rdr.set_terminal_title(self.title);
|
||||
}
|
||||
|
||||
pub fn receive(self: *Self, _: *Button.State(Self), _: tp.pid_ref, m: tp.message) error{Exit}!bool {
|
||||
|
|
|
@ -180,7 +180,7 @@ pub fn receive(self: *Self, _: tp.pid_ref, m: tp.message) error{Exit}!bool {
|
|||
return true;
|
||||
}
|
||||
if (try m.match(.{ "H", tp.extract(&self.hover) })) {
|
||||
tui.renderer.request_mouse_cursor_pointer(self.hover);
|
||||
tui.current().rdr.request_mouse_cursor_pointer(self.hover);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -287,6 +287,12 @@ fn receive_safe(self: *Self, from: tp.pid_ref, m: tp.message) tp.result {
|
|||
return;
|
||||
}
|
||||
|
||||
if (try m.match(.{"focus_in"}))
|
||||
return;
|
||||
|
||||
if (try m.match(.{"focus_out"}))
|
||||
return;
|
||||
|
||||
if (try self.send_widgets(from, m))
|
||||
return;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue