feat: add toggle_completion_info_mode command and keybindings
This commit is contained in:
parent
c1ae1fe25f
commit
1c2e1ae494
4 changed files with 36 additions and 3 deletions
|
|
@ -396,7 +396,9 @@
|
|||
"overlay/dropdown-noninvasive": {
|
||||
"inherit": "normal",
|
||||
"press": [
|
||||
["ctrl+space", "toggle_completion_info_mode"],
|
||||
["alt+f9", "dropdown_next_widget_style"],
|
||||
["shift+alt+f9", "info_box_next_widget_style"],
|
||||
["ctrl+p", "palette_menu_up"],
|
||||
["ctrl+n", "palette_menu_down"],
|
||||
["escape", "palette_menu_cancel"],
|
||||
|
|
@ -409,7 +411,9 @@
|
|||
"overlay/dropdown": {
|
||||
"inherit": "normal",
|
||||
"press": [
|
||||
["ctrl+space", "toggle_completion_info_mode"],
|
||||
["alt+f9", "dropdown_next_widget_style"],
|
||||
["shift+alt+f9", "info_box_next_widget_style"],
|
||||
["ctrl+p", "palette_menu_up"],
|
||||
["ctrl+n", "palette_menu_down"],
|
||||
["escape", "palette_menu_cancel"],
|
||||
|
|
|
|||
|
|
@ -14,9 +14,13 @@ plane: Plane,
|
|||
view_rows: usize = 0,
|
||||
lines: std.ArrayList([]const u8),
|
||||
|
||||
const widget_type: Widget.Type = .panel;
|
||||
const default_widget_type: Widget.Type = .panel;
|
||||
|
||||
pub fn create(allocator: Allocator, parent: Plane) !Widget {
|
||||
return create_widget_type(allocator, parent, default_widget_type);
|
||||
}
|
||||
|
||||
pub fn create_widget_type(allocator: Allocator, parent: Plane, widget_type: Widget.Type) !Widget {
|
||||
const self = try allocator.create(Self);
|
||||
errdefer allocator.destroy(self);
|
||||
const container = try WidgetList.createHStyled(allocator, parent, "panel_frame", .dynamic, widget_type);
|
||||
|
|
@ -60,6 +64,12 @@ pub fn set_content(self: *Self, content: []const u8) !void {
|
|||
return self.append_content(content);
|
||||
}
|
||||
|
||||
pub fn content_size(self: *Self) struct { rows: usize, cols: usize } {
|
||||
var cols: usize = 0;
|
||||
for (self.lines.items) |line| cols = @max(cols, line.len);
|
||||
return .{ .rows = self.lines.items.len, .cols = cols };
|
||||
}
|
||||
|
||||
pub fn render(self: *Self, theme: *const Widget.Theme) bool {
|
||||
self.plane.set_base_style(theme.panel);
|
||||
self.plane.erase();
|
||||
|
|
|
|||
|
|
@ -339,6 +339,10 @@ fn close_all_panel_views(self: *Self) void {
|
|||
tui.resize();
|
||||
}
|
||||
|
||||
pub fn hide_info_view_panel(self: *Self) void {
|
||||
self.toggle_panel_view(info_view, .disable) catch {};
|
||||
}
|
||||
|
||||
fn check_all_not_dirty(self: *const Self) command.Result {
|
||||
if (self.buffer_manager.is_dirty())
|
||||
return tp.exit("unsaved changes");
|
||||
|
|
|
|||
|
|
@ -1178,6 +1178,21 @@ const cmds = struct {
|
|||
}
|
||||
pub const toggle_completion_insert_mode_meta: Meta = .{ .description = "Toggle completion insert mode" };
|
||||
|
||||
pub fn toggle_completion_info_mode(self: *Self, _: Ctx) Result {
|
||||
self.config_.completion_info_mode = switch (self.config_.completion_info_mode) {
|
||||
.none => .box,
|
||||
.box => .panel,
|
||||
.panel => blk: {
|
||||
if (mainview()) |mv| mv.hide_info_view_panel();
|
||||
break :blk .none;
|
||||
},
|
||||
};
|
||||
defer self.logger.print("completion info mode {t}", .{self.config_.completion_info_mode});
|
||||
try save_config();
|
||||
resize();
|
||||
}
|
||||
pub const toggle_completion_info_mode_meta: Meta = .{ .description = "Toggle completion item info display" };
|
||||
|
||||
pub fn toggle_keybind_hints(self: *Self, _: Ctx) Result {
|
||||
self.hint_mode = switch (self.hint_mode) {
|
||||
.all => .prefix,
|
||||
|
|
@ -1663,12 +1678,12 @@ const cmds = struct {
|
|||
}
|
||||
pub const dropdown_next_widget_style_meta: Meta = .{};
|
||||
|
||||
pub fn info_box_widget_style(_: *Self, _: Ctx) Result {
|
||||
pub fn info_box_next_widget_style(_: *Self, _: Ctx) Result {
|
||||
set_next_style(.info_box);
|
||||
need_render(@src());
|
||||
try save_config();
|
||||
}
|
||||
pub const info_box_widget_style_meta: Meta = .{};
|
||||
pub const info_box_next_widget_style_meta: Meta = .{};
|
||||
|
||||
pub fn enable_fast_scroll(self: *Self, _: Ctx) Result {
|
||||
self.fast_scroll_ = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue