Merge branch 'master' into zig-0.14
This commit is contained in:
commit
1943d65924
9 changed files with 26 additions and 18 deletions
|
@ -42,18 +42,11 @@ pub const char_pairs = [_]struct { []const u8, []const u8 }{
|
|||
.{ "\"", "\"" },
|
||||
.{ "'", "'" },
|
||||
.{ "(", ")" },
|
||||
.{ "(", ")" },
|
||||
.{ "[", "]" },
|
||||
.{ "[", "]" },
|
||||
.{ "{", "}" },
|
||||
.{ "{", "}" },
|
||||
.{ "‘", "’" },
|
||||
.{ "‘", "’" },
|
||||
.{ "“", "”" },
|
||||
.{ "“", "”" },
|
||||
.{ "‚", "‘" },
|
||||
.{ "‚", "‘" },
|
||||
.{ "«", "»" },
|
||||
.{ "«", "»" },
|
||||
};
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ tab_width: usize = 8,
|
|||
|
||||
top_bar: []const u8 = "tabs",
|
||||
bottom_bar: []const u8 = "mode file log selection diagnostics keybind linenumber clock spacer",
|
||||
show_scrollbars: bool = true,
|
||||
show_fileicons: bool = true,
|
||||
|
||||
lsp_request_timeout: usize = 10,
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ const WidgetList = @import("WidgetList.zig");
|
|||
const Button = @import("Button.zig");
|
||||
const scrollbar_v = @import("scrollbar_v.zig");
|
||||
const Plane = @import("renderer").Plane;
|
||||
const tui = @import("tui.zig");
|
||||
|
||||
pub const Container = WidgetList;
|
||||
pub const scroll_lines = 3;
|
||||
|
@ -61,7 +62,10 @@ pub fn create(ctx_type: type, allocator: std.mem.Allocator, parent: Plane, opts:
|
|||
.menu = try WidgetList.createV(allocator, container.plane, @typeName(@This()), .dynamic),
|
||||
.container = container,
|
||||
.container_widget = container.widget(),
|
||||
.scrollbar = if (opts.on_scroll) |on_scroll| (try scrollbar_v.create(allocator, parent, null, on_scroll)).dynamic_cast(scrollbar_v).? else null,
|
||||
.scrollbar = if (tui.config().show_scrollbars)
|
||||
if (opts.on_scroll) |on_scroll| (try scrollbar_v.create(allocator, parent, null, on_scroll)).dynamic_cast(scrollbar_v).? else null
|
||||
else
|
||||
null,
|
||||
.opts = opts,
|
||||
};
|
||||
self.menu.ctx = self;
|
||||
|
|
|
@ -5513,7 +5513,8 @@ pub const EditorWidget = struct {
|
|||
const editorWidget = Widget.to(self);
|
||||
try container.add(try editor_gutter.create(allocator, container.widget(), editorWidget, &self.editor));
|
||||
try container.add(editorWidget);
|
||||
try container.add(try scrollbar_v.create(allocator, container.plane, editorWidget, EventHandler.to_unowned(container)));
|
||||
if (tui.config().show_scrollbars)
|
||||
try container.add(try scrollbar_v.create(allocator, container.plane, editorWidget, EventHandler.to_unowned(container)));
|
||||
return container.widget();
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ pub fn create(allocator: Allocator, parent: Plane) !Widget {
|
|||
.on_click5 = mouse_click_button5,
|
||||
}),
|
||||
};
|
||||
self.menu.scrollbar.?.style_factory = scrollbar_style;
|
||||
if (self.menu.scrollbar) |scrollbar| scrollbar.style_factory = scrollbar_style;
|
||||
try self.commands.init(self);
|
||||
return Widget.to(self);
|
||||
}
|
||||
|
@ -184,7 +184,8 @@ fn handle_scroll(self: *Self, _: tp.pid_ref, m: tp.message) error{Exit}!void {
|
|||
}
|
||||
|
||||
fn update_scrollbar(self: *Self) void {
|
||||
self.menu.scrollbar.?.set(@intCast(self.entries.items.len), @intCast(self.view_rows), @intCast(self.view_pos));
|
||||
if (self.menu.scrollbar) |scrollbar|
|
||||
scrollbar.set(@intCast(self.entries.items.len), @intCast(self.view_rows), @intCast(self.view_pos));
|
||||
}
|
||||
|
||||
fn mouse_click_button4(menu: **Menu.State(*Self), _: *Button.State(*Menu.State(*Self))) void {
|
||||
|
|
|
@ -84,7 +84,10 @@ pub fn on_render_menu(_: *Type, button: *Type.ButtonState, theme: *const Widget.
|
|||
if (!(cbor.matchString(&iter, &file_path_) catch false)) @panic("invalid buffer file path");
|
||||
if (!(cbor.matchString(&iter, &icon) catch false)) @panic("invalid buffer file type icon");
|
||||
if (!(cbor.matchInt(u24, &iter, &color) catch false)) @panic("invalid buffer file type color");
|
||||
tui.render_file_icon(&button.plane, icon, color);
|
||||
if (tui.config().show_fileicons) {
|
||||
tui.render_file_icon(&button.plane, icon, color);
|
||||
_ = button.plane.print(" ", .{}) catch {};
|
||||
}
|
||||
button.plane.set_style(style_label);
|
||||
_ = button.plane.print(" {s} ", .{file_path_}) catch {};
|
||||
|
||||
|
|
|
@ -90,9 +90,12 @@ pub fn on_render_menu(_: *Type, button: *Type.ButtonState, theme: *const Widget.
|
|||
if (!(cbor.matchString(&iter, &description_) catch false)) @panic("invalid file_type description");
|
||||
if (!(cbor.matchString(&iter, &icon) catch false)) @panic("invalid file_type icon");
|
||||
if (!(cbor.matchInt(u24, &iter, &color) catch false)) @panic("invalid file_type color");
|
||||
tui.render_file_icon(&button.plane, icon, color);
|
||||
if (tui.config().show_fileicons) {
|
||||
tui.render_file_icon(&button.plane, icon, color);
|
||||
_ = button.plane.print(" ", .{}) catch {};
|
||||
}
|
||||
button.plane.set_style(style_label);
|
||||
_ = button.plane.print(" {s} ", .{description_}) catch {};
|
||||
_ = button.plane.print("{s} ", .{description_}) catch {};
|
||||
|
||||
var name_: []const u8 = undefined;
|
||||
if (!(cbor.matchString(&iter, &name_) catch false))
|
||||
|
|
|
@ -70,7 +70,7 @@ pub fn Create(options: type) type {
|
|||
.view_rows = get_view_rows(tui.screen()),
|
||||
.entries = std.ArrayList(Entry).init(allocator),
|
||||
};
|
||||
self.menu.scrollbar.?.style_factory = scrollbar_style;
|
||||
if (self.menu.scrollbar) |scrollbar| scrollbar.style_factory = scrollbar_style;
|
||||
self.longest_hint = try options.load_entries(self);
|
||||
if (@hasDecl(options, "restore_state"))
|
||||
options.restore_state(self) catch {};
|
||||
|
@ -173,7 +173,8 @@ pub fn Create(options: type) type {
|
|||
}
|
||||
|
||||
fn update_scrollbar(self: *Self) void {
|
||||
self.menu.scrollbar.?.set(@intCast(@max(self.total_items, 1) - 1), @intCast(self.view_rows), @intCast(self.view_pos));
|
||||
if (self.menu.scrollbar) |scrollbar|
|
||||
scrollbar.set(@intCast(@max(self.total_items, 1) - 1), @intCast(self.view_rows), @intCast(self.view_pos));
|
||||
}
|
||||
|
||||
fn mouse_click_button4(menu: **Menu.State(*Self), _: *Button.State(*Menu.State(*Self))) void {
|
||||
|
|
|
@ -132,7 +132,7 @@ fn render_mini_mode(plane: *Plane, theme: *const Widget.Theme) void {
|
|||
fn render_normal(self: *Self, plane: *Plane, theme: *const Widget.Theme) void {
|
||||
plane.on_styles(styles.italic);
|
||||
_ = plane.putstr(" ") catch {};
|
||||
if (self.file_icon.len > 0) {
|
||||
if (self.file_icon.len > 0 and tui.config().show_fileicons) {
|
||||
self.render_file_icon(plane, theme);
|
||||
_ = plane.print(" ", .{}) catch {};
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ fn render_normal(self: *Self, plane: *Plane, theme: *const Widget.Theme) void {
|
|||
fn render_detailed(self: *Self, plane: *Plane, theme: *const Widget.Theme) void {
|
||||
plane.on_styles(styles.italic);
|
||||
_ = plane.putstr(" ") catch {};
|
||||
if (self.file_icon.len > 0) {
|
||||
if (self.file_icon.len > 0 and tui.config().show_fileicons) {
|
||||
self.render_file_icon(plane, theme);
|
||||
_ = plane.print(" ", .{}) catch {};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue