refactor: improve capsulation and safety of tui module public api
This commit is contained in:
parent
4145460012
commit
1d947ab499
28 changed files with 239 additions and 198 deletions
|
@ -90,7 +90,7 @@ pub fn render(self: *Self, btn: *Button.State(Self), theme: *const Widget.Theme)
|
|||
btn.plane.fill(" ");
|
||||
btn.plane.home();
|
||||
}
|
||||
if (tui.current().mini_mode) |_|
|
||||
if (tui.mini_mode()) |_|
|
||||
render_mini_mode(&btn.plane, theme)
|
||||
else if (self.detailed)
|
||||
self.render_detailed(&btn.plane, theme)
|
||||
|
@ -102,14 +102,13 @@ pub fn render(self: *Self, btn: *Button.State(Self), theme: *const Widget.Theme)
|
|||
|
||||
fn render_mini_mode(plane: *Plane, theme: *const Widget.Theme) void {
|
||||
plane.off_styles(style.italic);
|
||||
const tui_ = tui.current();
|
||||
const mini_mode = tui_.mini_mode orelse return;
|
||||
const mini_mode = tui.mini_mode() orelse return;
|
||||
_ = plane.print(" {s}", .{mini_mode.text}) catch {};
|
||||
if (mini_mode.cursor) |cursor| {
|
||||
const pos: c_int = @intCast(cursor);
|
||||
if (tui_.config.enable_terminal_cursor) {
|
||||
if (tui.config().enable_terminal_cursor) {
|
||||
const y, const x = plane.rel_yx_to_abs(0, pos + 1);
|
||||
tui_.rdr.cursor_enable(y, x, tui_.get_cursor_shape()) catch {};
|
||||
tui.rdr().cursor_enable(y, x, tui.get_cursor_shape()) catch {};
|
||||
} else {
|
||||
plane.cursor_move_yx(0, pos + 1) catch return;
|
||||
var cell = plane.cell_init();
|
||||
|
@ -189,7 +188,7 @@ fn render_terminal_title(self: *Self) void {
|
|||
if (std.mem.eql(u8, self.previous_title, new_title)) return;
|
||||
@memcpy(self.previous_title_buf[0..new_title.len], new_title);
|
||||
self.previous_title = self.previous_title_buf[0..new_title.len];
|
||||
tui.current().rdr.set_terminal_title(new_title);
|
||||
tui.rdr().set_terminal_title(new_title);
|
||||
}
|
||||
|
||||
pub fn receive(self: *Self, _: *Button.State(Self), _: tp.pid_ref, m: tp.message) error{Exit}!bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue