refactor: split mini modes into input mode and a ui mode
This commit is contained in:
parent
d804203760
commit
f41fb97d02
6 changed files with 56 additions and 58 deletions
|
|
@ -29,7 +29,7 @@ const Operation = enum {
|
|||
select,
|
||||
};
|
||||
|
||||
pub fn create(allocator: Allocator, ctx: command.Context) !*Self {
|
||||
pub fn create(allocator: Allocator, ctx: command.Context) !struct { tui.Mode, tui.MiniMode } {
|
||||
var right: bool = true;
|
||||
const select = if (tui.current().mainview.dynamic_cast(mainview)) |mv| if (mv.get_editor()) |editor| if (editor.get_primary().selection) |_| true else false else false else false;
|
||||
_ = ctx.args.match(.{tp.extract(&right)}) catch return error.NotFound;
|
||||
|
|
@ -39,18 +39,21 @@ pub fn create(allocator: Allocator, ctx: command.Context) !*Self {
|
|||
.direction = if (right) .right else .left,
|
||||
.operation = if (select) .select else .move,
|
||||
};
|
||||
return self;
|
||||
return .{
|
||||
.{
|
||||
.handler = EventHandler.to_owned(self),
|
||||
.name = self.name(),
|
||||
.description = self.name(),
|
||||
},
|
||||
.{},
|
||||
};
|
||||
}
|
||||
|
||||
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: *Self) []const u8 {
|
||||
fn name(self: *Self) []const u8 {
|
||||
return switch (self.operation) {
|
||||
.move => switch (self.direction) {
|
||||
.left => "↶ move",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue