feat: add multi-cursor support to copy/cut/paste commands

This commit is contained in:
CJ van den Berg 2024-03-11 21:37:41 +01:00
parent 8a020717f3
commit 69a6e659bd
2 changed files with 74 additions and 23 deletions

View file

@ -51,9 +51,7 @@ pub fn receive(self: *Self, _: tp.pid_ref, m: tp.message) error{Exit}!bool {
} else if (try m.match(.{"F"})) {
try self.flush_input();
} else if (try m.match(.{ "system_clipboard", tp.extract(&text) })) {
try self.flush_input();
try self.insert_bytes(text);
try self.flush_input();
try self.paste_bytes(text);
}
return false;
}
@ -253,6 +251,11 @@ fn insert_bytes(self: *Self, bytes: []const u8) tp.result {
self.input.appendSlice(bytes) catch |e| return tp.exit_error(e);
}
fn paste_bytes(self: *Self, bytes: []const u8) tp.result {
try self.flush_input();
try command.executeName("paste", command.fmt(.{bytes}));
}
var insert_chars_id: ?command.ID = null;
fn flush_input(self: *Self) tp.result {