Adjust the look of TabBar
This commit is contained in:
parent
bb807a86f3
commit
5affb6dbb8
@ -69,9 +69,9 @@ pub fn main() !void {
|
||||
},
|
||||
.{ .pane = line.VerticalLine.create(&lineV, .{ .border = borders.BoldBorder, .style = s }), .dimensions = .{ .width = .{ .type = .Absolute, .value = 1 }, .height = .{ .type = .Fill, .value = 100 } } },
|
||||
.{
|
||||
.pane = stack.Stack.create(&child, .{ .direction = .Vertical, .style = sb }, &[_]stack.StackedPane{
|
||||
.pane = stack.Stack.create(&child, .{ .direction = .Vertical, .style = s }, &[_]stack.StackedPane{
|
||||
.{
|
||||
.pane = tabs.TabBar.create(&tabbar, .{ .highlight_color = color.RGB(0, 125, 0), .style = .{ .background = gray } }, &tabs_),
|
||||
.pane = tabs.TabBar.create(&tabbar, .{ .style = s, .highlight_color = green }, &tabs_),
|
||||
.dimensions = .{ .width = .{ .type = .Fill, .value = 100 }, .height = .{ .type = .Absolute, .value = 1 } },
|
||||
},
|
||||
.{
|
||||
|
17
src/tabs.zig
17
src/tabs.zig
@ -38,6 +38,7 @@ pub const TabBar = struct {
|
||||
.style = config.style,
|
||||
.vtable = .{
|
||||
.draw = draw,
|
||||
.focus = focus,
|
||||
.update = update,
|
||||
},
|
||||
};
|
||||
@ -54,13 +55,15 @@ pub const TabBar = struct {
|
||||
self.pane.cursor = .{ .x = 0, .y = 0 };
|
||||
self.pane.moveCursor(term_io);
|
||||
|
||||
const normal_background = self.pane.style.background;
|
||||
// const normal_background = self.pane.style.background;
|
||||
term_io.enableFormats(.{ .underline = self.config.underline });
|
||||
for (self.tabs, 0..) |tab, i| {
|
||||
if (i == self.index) {
|
||||
self.pane.style.background = self.config.highlight_color;
|
||||
// self.pane.style.background = self.config.highlight_color;
|
||||
term_io.enableFormats(.{ .highlight = true, .dim = !pane_ptr.focused });
|
||||
} else {
|
||||
self.pane.style.background = normal_background;
|
||||
// self.pane.style.background = normal_background;
|
||||
term_io.disableFormats(.{ .highlight = true, .dim = true });
|
||||
}
|
||||
|
||||
const width = if (i < extra) tab_width + 1 else tab_width;
|
||||
@ -73,8 +76,8 @@ pub const TabBar = struct {
|
||||
try writer.writeAll(tab.name);
|
||||
try writer.writeByteNTimes(' ', width - (tab.name.len + left));
|
||||
}
|
||||
self.pane.style.background = normal_background;
|
||||
term_io.disableFormats(.{ .underline = self.config.underline });
|
||||
// self.pane.style.background = normal_background;
|
||||
term_io.disableFormats(.{ .underline = self.config.underline, .highlight = true, .dim = true });
|
||||
}
|
||||
|
||||
fn update(pane_ptr: *pane.Pane, term_io: *TermIO, key: term.Key) !bool {
|
||||
@ -117,4 +120,8 @@ pub const TabBar = struct {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
fn focus(pane_ptr: *Pane, term_io: *TermIO) !void {
|
||||
try draw(pane_ptr, term_io);
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user