Compare commits

...

4 commits

3 changed files with 27 additions and 3 deletions

View file

@ -109,8 +109,8 @@ fn clamp_row(self: *Self, cursor: *const Cursor, abs: bool, bottom_offset: usize
}
if (cursor.row < self.row) {
self.row = 0;
} else if (cursor.row > self.row + self.rows - bottom_min_border_distance) {
self.row = cursor.row + bottom_min_border_distance - self.rows;
} else if (cursor.row > self.row + self.rows -| bottom_min_border_distance) {
self.row = cursor.row + bottom_min_border_distance -| self.rows;
}
}

View file

@ -25,6 +25,7 @@
["ctrl+8", "focus_split", 7],
["ctrl+`", "focus_terminal"],
["ctrl+j", "toggle_panel"],
["ctrl+shift+j", "toggle_maximize_panel"],
["ctrl+q", "quit"],
["ctrl+w", "close_split"],
["ctrl+o", "open_file"],
@ -602,6 +603,7 @@
["alt+shift+p", "open_command_palette"],
["alt+x", "open_command_palette"],
["alt+!", "run_task"],
["ctrl+shift+j", "toggle_maximize_panel"],
["alt+f9", "panel_next_widget_style"],
["ctrl+shift+q", "quit_without_saving"],
["ctrl+alt+shift+r", "restart"]

View file

@ -59,6 +59,7 @@ buffer_manager: Buffer.Manager,
find_in_files_state: enum { init, adding, done } = .done,
file_list_type: FileListType = .find_in_files,
panel_height: ?usize = null,
panel_maximized: bool = false,
symbols: std.ArrayListUnmanaged(u8) = .empty,
symbols_complete: bool = true,
closing_project: bool = false,
@ -260,6 +261,10 @@ pub fn handle_resize(self: *Self, pos: Box) void {
if (self.panel_height) |h| if (h >= self.box().h) {
self.panel_height = null;
};
if (self.panel_maximized) {
if (self.panels) |panels|
panels.layout_ = .{ .static = self.box().h -| 1 };
}
self.widgets.handle_resize(pos);
self.floating_views.resize(pos);
}
@ -281,6 +286,7 @@ fn bottom_bar_primary_drag(self: *Self, y: usize) tp.result {
};
const h = self.plane.dim_y();
self.panel_height = @max(1, h - @min(h, y + 1));
self.panel_maximized = false;
panels.layout_ = .{ .static = self.panel_height.? };
if (self.panel_height == 1) {
self.panel_height = null;
@ -939,10 +945,26 @@ const cmds = struct {
else if (self.is_panel_view_showing(terminal_view))
try self.toggle_panel_view(terminal_view, .toggle)
else
try self.toggle_panel_view(logview, .toggle);
try focus_terminal(self, .{});
}
pub const toggle_panel_meta: Meta = .{ .description = "Toggle panel" };
pub fn toggle_maximize_panel(self: *Self, _: Ctx) Result {
const panels = self.panels orelse return;
const max_h = self.box().h -| 1;
if (self.panel_maximized) {
// Restore previous height
self.panel_maximized = false;
panels.layout_ = .{ .static = self.get_panel_height() };
} else {
// Maximize: fill screen minus status bar
self.panel_maximized = true;
panels.layout_ = .{ .static = max_h };
}
tui.resize();
}
pub const toggle_maximize_panel_meta: Meta = .{ .description = "Toggle maximize panel" };
pub fn toggle_logview(self: *Self, _: Ctx) Result {
try self.toggle_panel_view(logview, .toggle);
}