Add a web browser tab.
This commit is contained in:
+18
-9
@@ -1,5 +1,5 @@
|
||||
//! A view: the content of one tab, holding one or more terminal panes
|
||||
//! arranged in a split tree.
|
||||
//! A view: the content of one tab, holding one or more panes — terminals, web
|
||||
//! views, or a mix — arranged in a split tree.
|
||||
//!
|
||||
//! Dragging a pane rearranges the view live rather than on release. Each time
|
||||
//! the drop target changes, the move is applied for real, so what you see
|
||||
@@ -18,6 +18,7 @@ const Terminal = @import("Terminal.zig");
|
||||
const View = @This();
|
||||
|
||||
pub const Side = Layout.Side;
|
||||
pub const Kind = Pane.Kind;
|
||||
|
||||
/// Where a dragged pane would land.
|
||||
pub const Target = struct {
|
||||
@@ -113,8 +114,8 @@ pub fn widget(self: *View) *gtk.Widget {
|
||||
return self.box.as(gtk.Widget);
|
||||
}
|
||||
|
||||
/// Text for the tab label: the focused terminal's title, prefixed with the
|
||||
/// pane count once there is more than one.
|
||||
/// Text for the tab label: the focused pane's title, prefixed with the pane
|
||||
/// count once there is more than one.
|
||||
pub fn label(self: *View, buf: []u8) []const u8 {
|
||||
const pane = self.focusedPane() orelse return "";
|
||||
const title = pane.titleSlice();
|
||||
@@ -132,19 +133,27 @@ pub fn focusedPane(self: *View) ?*Pane {
|
||||
return self.focused orelse (if (self.panes.items.len > 0) self.panes.items[0] else null);
|
||||
}
|
||||
|
||||
/// The focused pane's terminal, or null when the focused pane holds a web
|
||||
/// view instead.
|
||||
pub fn focusedTerminal(self: *View) ?*Terminal {
|
||||
const pane = self.focusedPane() orelse return null;
|
||||
return pane.term;
|
||||
return pane.terminal();
|
||||
}
|
||||
|
||||
/// Icon for the tab row: whatever the focused pane is showing.
|
||||
pub fn iconName(self: *View) [:0]const u8 {
|
||||
const pane = self.focusedPane() orelse return Kind.terminal.iconName();
|
||||
return pane.kind.iconName();
|
||||
}
|
||||
|
||||
pub fn focus(self: *View) void {
|
||||
if (self.focusedPane()) |pane| pane.grabFocus();
|
||||
}
|
||||
|
||||
/// Add a terminal, splitting the focused pane so the new one appears beside
|
||||
/// the terminal you were working in.
|
||||
pub fn addPane(self: *View) !void {
|
||||
const pane = try Pane.create(self.alloc, self);
|
||||
/// Add a pane, splitting the focused one so the new pane appears beside
|
||||
/// whatever you were working in.
|
||||
pub fn addPane(self: *View, kind: Kind) !void {
|
||||
const pane = try Pane.create(self.alloc, self, kind);
|
||||
errdefer pane.destroy();
|
||||
|
||||
const node = try self.layout.newLeaf(pane);
|
||||
|
||||
Reference in New Issue
Block a user