refactor: add tui.set_last_palette

This commit is contained in:
CJ van den Berg 2025-12-06 20:17:45 +01:00
parent 2f77dbb845
commit a7a7e313ce
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -85,9 +85,19 @@ clipboard_current_group_number: usize = 0,
color_scheme: enum { dark, light } = .dark,
color_scheme_locked: bool = false,
hint_mode: HintMode = .prefix,
last_palette: ?LastPalette = null,
const HintMode = enum { none, prefix, all };
const LastPalette = struct {
type_: PaletteType,
ctx: command.Context,
};
pub const PaletteType = enum {
open_recent,
};
pub const ClipboardEntry = struct {
text: []const u8 = &.{},
group: usize = 0,
@ -2234,3 +2244,15 @@ fn clipboard_send_to_system_internal(self: *Self, text: []const u8) void {
self.rdr_.copy_to_system_clipboard(text);
}
}
pub fn set_last_palette(type_: PaletteType, ctx: command.Context) void {
const self = current();
if (self.last_palette) |old| {
self.allocator.free(old.ctx.args.buf);
self.last_palette = null;
}
self.last_palette = .{
.type_ = type_,
.ctx = .{ .args = ctx.args.clone(self.allocator) catch return },
};
}