refactor: split mini modes into input mode and a ui mode

This commit is contained in:
CJ van den Berg 2024-10-25 18:40:01 +02:00
parent d804203760
commit f41fb97d02
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
6 changed files with 56 additions and 58 deletions

View file

@ -16,6 +16,7 @@ const eql = @import("std").mem.eql;
const ArrayList = @import("std").ArrayList;
const Self = @This();
const name = "󱎸 find";
allocator: Allocator,
input: ArrayList(u8),
@ -25,7 +26,7 @@ start_cursor: ed.Cursor,
editor: *ed.Editor,
history_pos: ?usize = null,
pub fn create(allocator: Allocator, _: command.Context) !*Self {
pub fn create(allocator: Allocator, _: command.Context) !struct { tui.Mode, tui.MiniMode } {
if (tui.current().mainview.dynamic_cast(mainview)) |mv_| if (mv_.get_editor()) |editor| {
const self: *Self = try allocator.create(Self);
self.* = .{
@ -41,7 +42,14 @@ pub fn create(allocator: Allocator, _: command.Context) !*Self {
defer self.allocator.free(text);
try self.input.appendSlice(text);
}
return self;
return .{
.{
.handler = EventHandler.to_owned(self),
.name = name,
.description = name,
},
.{},
};
};
return error.NotFound;
}
@ -52,14 +60,6 @@ pub fn deinit(self: *Self) void {
self.allocator.destroy(self);
}
pub fn handler(self: *Self) EventHandler {
return EventHandler.to_owned(self);
}
pub fn name(_: *Self) []const u8 {
return "󱎸 find";
}
pub fn receive(self: *Self, _: tp.pid_ref, m: tp.message) error{Exit}!bool {
var evtype: u32 = undefined;
var keypress: u32 = undefined;