mod(renderer): initial version of double buffer intermediate renderer
This branch will implement the necessary changes for the widgets and their implementations to use the new renderer correctly.
This commit is contained in:
@@ -7,7 +7,7 @@ const App = zterm.App(
|
||||
tui, // view instance to the corresponding view for 'tui'
|
||||
},
|
||||
},
|
||||
zterm.Renderer.Direct,
|
||||
zterm.Renderer.Buffered,
|
||||
true,
|
||||
);
|
||||
const Cell = zterm.Cell;
|
||||
@@ -24,49 +24,26 @@ const Tui = struct {
|
||||
pub fn init(allocator: std.mem.Allocator) *Tui {
|
||||
var tui = allocator.create(Tui) catch @panic("Out of memory: tui.zig");
|
||||
tui.allocator = allocator;
|
||||
// FIXME: the layout creates an 'incorrect alignment'?
|
||||
tui.layout = Layout.createFrom(Layout.VContainer.init(allocator, .{
|
||||
.{
|
||||
Layout.createFrom(Layout.Framing.init(allocator, .{
|
||||
.title = .{
|
||||
.str = "Welcome to my terminal website",
|
||||
.style = .{
|
||||
.ul = .{ .index = 6 },
|
||||
.ul_style = .single,
|
||||
},
|
||||
},
|
||||
}, .{
|
||||
.layout = Layout.createFrom(Layout.HContainer.init(allocator, .{
|
||||
.{
|
||||
Widget.createFrom(Widget.Text.init(allocator, .left, &[1]Cell{
|
||||
.{ .content = "Yves Biener", .style = .{ .bold = true } },
|
||||
})),
|
||||
25,
|
||||
},
|
||||
.{
|
||||
Widget.createFrom(Widget.Text.init(allocator, .left, &[1]Cell{
|
||||
.{ .content = "File name", .style = .{ .bold = true } },
|
||||
})),
|
||||
50,
|
||||
},
|
||||
.{
|
||||
Widget.createFrom(Widget.Text.init(allocator, .left, &[1]Cell{
|
||||
.{ .content = "Contacts", .style = .{ .bold = true } },
|
||||
})),
|
||||
25,
|
||||
},
|
||||
})),
|
||||
tui.layout = Layout.createFrom(Layout.VStack.init(allocator, .{
|
||||
Layout.createFrom(Layout.HStack.init(allocator, .{
|
||||
Widget.createFrom(Widget.Text.init(allocator, .left, &[1]Cell{
|
||||
.{ .rune = 'Y', .style = .{ .fg = .{ .index = 6 }, .bold = true } },
|
||||
})),
|
||||
10,
|
||||
},
|
||||
.{
|
||||
Layout.createFrom(Layout.Margin.init(allocator, .{ .left = 15, .right = 15 }, .{
|
||||
.widget = Widget.createFrom(Widget.Text.init(allocator, .default, &[1]Cell{
|
||||
.{ .content = "Does this change anything", .style = .{ .ul = .default, .ul_style = .single } },
|
||||
})),
|
||||
Widget.createFrom(Widget.Text.init(allocator, .left, &[1]Cell{
|
||||
.{ .rune = 'F', .style = .{ .fg = .{ .index = 6 }, .bold = true } },
|
||||
})),
|
||||
90,
|
||||
},
|
||||
Widget.createFrom(Widget.Text.init(allocator, .left, &[1]Cell{
|
||||
.{ .rune = 'C', .style = .{ .fg = .{ .index = 6 }, .bold = true } },
|
||||
})),
|
||||
})),
|
||||
// .{
|
||||
// Layout.createFrom(Layout.Margin.init(allocator, .{ .left = 15, .right = 15 }, .{
|
||||
// .widget = Widget.createFrom(Widget.Text.init(allocator, .default, &[1]Cell{
|
||||
// .{ .rune = 'D', .style = .{ .ul = .default, .ul_style = .single } },
|
||||
// })),
|
||||
// })),
|
||||
// 90,
|
||||
// },
|
||||
}));
|
||||
return tui;
|
||||
}
|
||||
@@ -76,6 +53,14 @@ const Tui = struct {
|
||||
this.allocator.destroy(this);
|
||||
}
|
||||
|
||||
pub fn enable(this: *Tui) void {
|
||||
_ = this;
|
||||
}
|
||||
|
||||
pub fn disable(this: *Tui) void {
|
||||
_ = this;
|
||||
}
|
||||
|
||||
pub fn handle(this: *Tui, event: App.Event) !*Events {
|
||||
return try this.layout.handle(event);
|
||||
}
|
||||
@@ -99,7 +84,9 @@ pub fn main() !void {
|
||||
const allocator = arena.allocator();
|
||||
|
||||
var app: App = .{};
|
||||
var renderer: App.Renderer = .{};
|
||||
var renderer = App.Renderer.init(allocator);
|
||||
defer renderer.deinit();
|
||||
|
||||
var view: View = undefined;
|
||||
|
||||
var tui_view = View.createFrom(Tui.init(allocator));
|
||||
@@ -147,5 +134,6 @@ pub fn main() !void {
|
||||
app.postEvent(e);
|
||||
}
|
||||
try view.render(&renderer);
|
||||
try renderer.flush();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user