Merge branch 'master' into zig-0.14
This commit is contained in:
commit
4a6f610514
1 changed files with 6 additions and 15 deletions
|
@ -38,8 +38,8 @@ widgets: *WidgetList,
|
||||||
widgets_widget: Widget,
|
widgets_widget: Widget,
|
||||||
floating_views: WidgetStack,
|
floating_views: WidgetStack,
|
||||||
commands: Commands = undefined,
|
commands: Commands = undefined,
|
||||||
top_bar: ?*Widget = null,
|
top_bar: ?Widget = null,
|
||||||
bottom_bar: ?*Widget = null,
|
bottom_bar: ?Widget = null,
|
||||||
active_editor: ?usize = null,
|
active_editor: ?usize = null,
|
||||||
editors: std.ArrayListUnmanaged(*ed.Editor) = .{},
|
editors: std.ArrayListUnmanaged(*ed.Editor) = .{},
|
||||||
views: *WidgetList,
|
views: *WidgetList,
|
||||||
|
@ -79,7 +79,7 @@ pub fn create(allocator: std.mem.Allocator) !Widget {
|
||||||
self.widgets = widgets;
|
self.widgets = widgets;
|
||||||
self.widgets_widget = widgets.widget();
|
self.widgets_widget = widgets.widget();
|
||||||
if (tui.config().top_bar.len > 0)
|
if (tui.config().top_bar.len > 0)
|
||||||
self.top_bar = try widgets.addP(try @import("status/bar.zig").create(allocator, self.plane, tui.config().top_bar, .none, null));
|
self.top_bar = (try widgets.addP(try @import("status/bar.zig").create(allocator, self.plane, tui.config().top_bar, .none, null))).*;
|
||||||
|
|
||||||
const views = try WidgetList.createH(allocator, self.plane, @typeName(Self), .dynamic);
|
const views = try WidgetList.createH(allocator, self.plane, @typeName(Self), .dynamic);
|
||||||
self.views = views;
|
self.views = views;
|
||||||
|
@ -89,7 +89,7 @@ pub fn create(allocator: std.mem.Allocator) !Widget {
|
||||||
try widgets.add(self.views_widget);
|
try widgets.add(self.views_widget);
|
||||||
|
|
||||||
if (tui.config().bottom_bar.len > 0) {
|
if (tui.config().bottom_bar.len > 0) {
|
||||||
self.bottom_bar = try widgets.addP(try @import("status/bar.zig").create(allocator, self.plane, tui.config().bottom_bar, .grip, EventHandler.bind(self, handle_bottom_bar_event)));
|
self.bottom_bar = (try widgets.addP(try @import("status/bar.zig").create(allocator, self.plane, tui.config().bottom_bar, .grip, EventHandler.bind(self, handle_bottom_bar_event)))).*;
|
||||||
}
|
}
|
||||||
if (tp.env.get().is("show-input"))
|
if (tp.env.get().is("show-input"))
|
||||||
self.toggle_inputview_async();
|
self.toggle_inputview_async();
|
||||||
|
@ -224,15 +224,6 @@ fn close_all_panel_views(self: *Self) void {
|
||||||
tui.resize();
|
tui.resize();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn toggle_view(self: *Self, view: anytype) !void {
|
|
||||||
if (self.widgets.get(@typeName(view))) |w| {
|
|
||||||
self.widgets.remove(w.*);
|
|
||||||
} else {
|
|
||||||
try self.widgets.add(try view.create(self.allocator, self.plane));
|
|
||||||
}
|
|
||||||
tui.resize();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn check_all_not_dirty(self: *const Self) command.Result {
|
fn check_all_not_dirty(self: *const Self) command.Result {
|
||||||
if (self.buffer_manager.is_dirty())
|
if (self.buffer_manager.is_dirty())
|
||||||
return tp.exit("unsaved changes");
|
return tp.exit("unsaved changes");
|
||||||
|
@ -1063,8 +1054,8 @@ fn create_editor(self: *Self) !void {
|
||||||
var editor_widget = try ed.create(self.allocator, self.plane, &self.buffer_manager);
|
var editor_widget = try ed.create(self.allocator, self.plane, &self.buffer_manager);
|
||||||
errdefer editor_widget.deinit(self.allocator);
|
errdefer editor_widget.deinit(self.allocator);
|
||||||
const editor = editor_widget.get("editor") orelse @panic("mainview editor not found");
|
const editor = editor_widget.get("editor") orelse @panic("mainview editor not found");
|
||||||
if (self.top_bar) |bar| editor.subscribe(EventHandler.to_unowned(bar)) catch @panic("subscribe unsupported");
|
if (self.top_bar) |*bar| editor.subscribe(EventHandler.to_unowned(bar)) catch @panic("subscribe unsupported");
|
||||||
if (self.bottom_bar) |bar| editor.subscribe(EventHandler.to_unowned(bar)) catch @panic("subscribe unsupported");
|
if (self.bottom_bar) |*bar| editor.subscribe(EventHandler.to_unowned(bar)) catch @panic("subscribe unsupported");
|
||||||
editor.subscribe(EventHandler.bind(self, handle_editor_event)) catch @panic("subscribe unsupported");
|
editor.subscribe(EventHandler.bind(self, handle_editor_event)) catch @panic("subscribe unsupported");
|
||||||
try self.replace_active_view(editor_widget);
|
try self.replace_active_view(editor_widget);
|
||||||
if (editor.dynamic_cast(ed.EditorWidget)) |p|
|
if (editor.dynamic_cast(ed.EditorWidget)) |p|
|
||||||
|
|
Loading…
Add table
Reference in a new issue