refactor: add support for backspace during completion
This commit is contained in:
parent
b2996cddbd
commit
911fc3160a
3 changed files with 22 additions and 3 deletions
|
|
@ -353,6 +353,15 @@ pub fn Create(options: type) type {
|
|||
return matches.items.len;
|
||||
}
|
||||
|
||||
fn delete_code_point(self: *Self) !void {
|
||||
if (self.query.items.len > 0) {
|
||||
self.query.shrinkRetainingCapacity(self.query.items.len - tui.egc_last(self.query.items).len);
|
||||
if (@hasDecl(options, "update_query"))
|
||||
options.update_query(self, self.query.items);
|
||||
}
|
||||
try self.start_query(0);
|
||||
}
|
||||
|
||||
fn insert_code_point(self: *Self, c: u32) !void {
|
||||
var buf: [6]u8 = undefined;
|
||||
const bytes = try input.ucs32_to_utf8(&[_]u32{c}, &buf);
|
||||
|
|
@ -523,6 +532,11 @@ pub fn Create(options: type) type {
|
|||
}
|
||||
pub const palette_menu_cancel_meta: Meta = .{};
|
||||
|
||||
pub fn overlay_delete_backwards(self: *Self, _: Ctx) Result {
|
||||
self.delete_code_point() catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||
}
|
||||
pub const overlay_delete_backwards_meta: Meta = .{ .description = "Delete backwards" };
|
||||
|
||||
pub fn overlay_insert_code_point(self: *Self, ctx: Ctx) Result {
|
||||
var egc: u32 = 0;
|
||||
if (!try ctx.args.match(.{tp.extract(&egc)}))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue