refactor: remove unused error return in Plane.put_yx and Plane.cursor_move_yx
This commit is contained in:
parent
52dfc1e706
commit
2d5288aa6f
16 changed files with 46 additions and 46 deletions
|
|
@ -242,8 +242,8 @@ pub fn putc(self: *Plane, cell: *const Cell) !usize {
|
||||||
return self.putc_yx(self.row, self.col, cell);
|
return self.putc_yx(self.row, self.col, cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn putc_yx(self: *Plane, y: i32, x: i32, cell: *const Cell) !usize {
|
pub fn putc_yx(self: *Plane, y: i32, x: i32, cell: *const Cell) usize {
|
||||||
try self.cursor_move_yx(y, x);
|
self.cursor_move_yx(y, x);
|
||||||
const w = if (cell.cell.char.width == 0) self.window.gwidth(cell.cell.char.grapheme) else cell.cell.char.width;
|
const w = if (cell.cell.char.width == 0) self.window.gwidth(cell.cell.char.grapheme) else cell.cell.char.width;
|
||||||
if (w == 0) return w;
|
if (w == 0) return w;
|
||||||
self.window.writeCell(@intCast(self.col), @intCast(self.row), cell.cell);
|
self.window.writeCell(@intCast(self.col), @intCast(self.row), cell.cell);
|
||||||
|
|
@ -280,7 +280,7 @@ pub fn cursor_x(self: Plane) i32 {
|
||||||
return self.col;
|
return self.col;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cursor_move_yx(self: *Plane, y: i32, x: i32) error{}!void {
|
pub fn cursor_move_yx(self: *Plane, y: i32, x: i32) void {
|
||||||
if (self.window.height == 0 or self.window.width == 0) return;
|
if (self.window.height == 0 or self.window.width == 0) return;
|
||||||
if (self.window.height <= y or self.window.width <= x) return;
|
if (self.window.height <= y or self.window.width <= x) return;
|
||||||
if (y >= 0) self.row = y;
|
if (y >= 0) self.row = y;
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ pub fn render(self: *Fire) void {
|
||||||
self.plane.set_bg_palindex(fire_palette[px_lo]) catch {};
|
self.plane.set_bg_palindex(fire_palette[px_lo]) catch {};
|
||||||
_ = self.plane.putchar(px);
|
_ = self.plane.putchar(px);
|
||||||
}
|
}
|
||||||
self.plane.cursor_move_yx(-1, 0) catch {};
|
self.plane.cursor_move_yx(-1, 0);
|
||||||
self.plane.cursor_move_rel(1, 0) catch {};
|
self.plane.cursor_move_rel(1, 0) catch {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ pub fn Options(context: type) type {
|
||||||
const y, const x = self.plane.rel_yx_to_abs(0, pos + self.opts.padding + self.icon_width);
|
const y, const x = self.plane.rel_yx_to_abs(0, pos + self.opts.padding + self.icon_width);
|
||||||
tui.rdr().cursor_enable(y, x, tui.get_cursor_shape()) catch {};
|
tui.rdr().cursor_enable(y, x, tui.get_cursor_shape()) catch {};
|
||||||
} else {
|
} else {
|
||||||
self.plane.cursor_move_yx(0, pos + self.opts.padding + self.icon_width) catch return false;
|
self.plane.cursor_move_yx(0, pos + self.opts.padding + self.icon_width);
|
||||||
var cell = self.plane.cell_init();
|
var cell = self.plane.cell_init();
|
||||||
_ = self.plane.at_cursor_cell(&cell) catch return false;
|
_ = self.plane.at_cursor_cell(&cell) catch return false;
|
||||||
cell.set_style(theme.editor_cursor);
|
cell.set_style(theme.editor_cursor);
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ pub fn State(ctx_type: type) type {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dim_cell(plane: *Plane, y: usize, x: usize, dim_target: u8) !void {
|
fn dim_cell(plane: *Plane, y: usize, x: usize, dim_target: u8) !void {
|
||||||
plane.cursor_move_yx(@intCast(y), @intCast(x)) catch return;
|
plane.cursor_move_yx(@intCast(y), @intCast(x));
|
||||||
var cell = plane.cell_init();
|
var cell = plane.cell_init();
|
||||||
_ = plane.at_cursor_cell(&cell) catch return;
|
_ = plane.at_cursor_cell(&cell) catch return;
|
||||||
cell.dim(dim_target);
|
cell.dim(dim_target);
|
||||||
|
|
|
||||||
|
|
@ -201,6 +201,6 @@ pub fn render_decoration(widget_style: *const @This(), box: Box, widget_type: Wi
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fn put_at_pos(plane: *Plane, y: usize, x: usize, egc: []const u8) void {
|
inline fn put_at_pos(plane: *Plane, y: usize, x: usize, egc: []const u8) void {
|
||||||
plane.cursor_move_yx(@intCast(y), @intCast(x)) catch return;
|
plane.cursor_move_yx(@intCast(y), @intCast(x));
|
||||||
plane.putchar(egc);
|
plane.putchar(egc);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1174,7 +1174,7 @@ pub const Editor = struct {
|
||||||
if (cell_map_val == .tab) cell_map_val = .extension;
|
if (cell_map_val == .tab) cell_map_val = .extension;
|
||||||
advance -= 1;
|
advance -= 1;
|
||||||
ctx.x += 1;
|
ctx.x += 1;
|
||||||
n.cursor_move_yx(@intCast(ctx.y), @intCast(ctx.x)) catch {};
|
n.cursor_move_yx(@intCast(ctx.y), @intCast(ctx.x));
|
||||||
}
|
}
|
||||||
while (advance > 0) : (advance -= 1) {
|
while (advance > 0) : (advance -= 1) {
|
||||||
if (ctx.x >= view.cols) break;
|
if (ctx.x >= view.cols) break;
|
||||||
|
|
@ -1188,7 +1188,7 @@ pub const Editor = struct {
|
||||||
ctx.cell_map.set_yx(ctx.y, ctx.x, .{ .cell_type = cell_map_val });
|
ctx.cell_map.set_yx(ctx.y, ctx.x, .{ .cell_type = cell_map_val });
|
||||||
if (cell_map_val == .tab) cell_map_val = .extension;
|
if (cell_map_val == .tab) cell_map_val = .extension;
|
||||||
ctx.x += 1;
|
ctx.x += 1;
|
||||||
n.cursor_move_yx(@intCast(ctx.y), @intCast(ctx.x)) catch {};
|
n.cursor_move_yx(@intCast(ctx.y), @intCast(ctx.x));
|
||||||
}
|
}
|
||||||
ctx.buf_col += colcount;
|
ctx.buf_col += colcount;
|
||||||
chunk = chunk[bytes..];
|
chunk = chunk[bytes..];
|
||||||
|
|
@ -1214,7 +1214,7 @@ pub const Editor = struct {
|
||||||
ctx.x = 0;
|
ctx.x = 0;
|
||||||
ctx.leading = true;
|
ctx.leading = true;
|
||||||
if (ctx.y >= view.rows) return Buffer.Walker.stop;
|
if (ctx.y >= view.rows) return Buffer.Walker.stop;
|
||||||
n.cursor_move_yx(@intCast(ctx.y), @intCast(ctx.x)) catch return Buffer.Walker.stop;
|
n.cursor_move_yx(@intCast(ctx.y), @intCast(ctx.x));
|
||||||
}
|
}
|
||||||
return Buffer.Walker.keep_walking;
|
return Buffer.Walker.keep_walking;
|
||||||
}
|
}
|
||||||
|
|
@ -1274,7 +1274,7 @@ pub const Editor = struct {
|
||||||
if (!tui.is_mainview_focused() or !self.enable_terminal_cursor) {
|
if (!tui.is_mainview_focused() or !self.enable_terminal_cursor) {
|
||||||
if (self.screen_cursor(cursor)) |pos| {
|
if (self.screen_cursor(cursor)) |pos| {
|
||||||
set_cell_map_cursor(cell_map, pos.row, pos.col);
|
set_cell_map_cursor(cell_map, pos.row, pos.col);
|
||||||
self.plane.cursor_move_yx(@intCast(pos.row), @intCast(pos.col)) catch return;
|
self.plane.cursor_move_yx(@intCast(pos.row), @intCast(pos.col));
|
||||||
const style = if (tui.is_mainview_focused()) theme.editor_cursor else theme.editor_cursor_secondary;
|
const style = if (tui.is_mainview_focused()) theme.editor_cursor else theme.editor_cursor_secondary;
|
||||||
self.render_cursor_cell(style);
|
self.render_cursor_cell(style);
|
||||||
}
|
}
|
||||||
|
|
@ -1306,7 +1306,7 @@ pub const Editor = struct {
|
||||||
const y, const x = self.plane.rel_yx_to_abs(@intCast(pos.row), @intCast(pos.col));
|
const y, const x = self.plane.rel_yx_to_abs(@intCast(pos.row), @intCast(pos.col));
|
||||||
tui.rdr().show_multi_cursor_yx(y, x) catch return;
|
tui.rdr().show_multi_cursor_yx(y, x) catch return;
|
||||||
} else {
|
} else {
|
||||||
self.plane.cursor_move_yx(@intCast(pos.row), @intCast(pos.col)) catch return;
|
self.plane.cursor_move_yx(@intCast(pos.row), @intCast(pos.col));
|
||||||
self.render_cursor_cell(theme.editor_cursor_secondary);
|
self.render_cursor_cell(theme.editor_cursor_secondary);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1335,7 +1335,7 @@ pub const Editor = struct {
|
||||||
for (0..self.view.rows) |row| for (0..self.view.cols) |col| {
|
for (0..self.view.rows) |row| for (0..self.view.cols) |col| {
|
||||||
const view_col = col + offset;
|
const view_col = col + offset;
|
||||||
if (hl_col <= view_col) {
|
if (hl_col <= view_col) {
|
||||||
self.plane.cursor_move_yx(@intCast(row), @intCast(col)) catch return;
|
self.plane.cursor_move_yx(@intCast(row), @intCast(col));
|
||||||
var cell = self.plane.cell_init();
|
var cell = self.plane.cell_init();
|
||||||
_ = self.plane.at_cursor_cell(&cell) catch return;
|
_ = self.plane.at_cursor_cell(&cell) catch return;
|
||||||
cell.dim_bg(alpha);
|
cell.dim_bg(alpha);
|
||||||
|
|
@ -1352,7 +1352,7 @@ pub const Editor = struct {
|
||||||
return;
|
return;
|
||||||
const row = cursor.row - self.view.row;
|
const row = cursor.row - self.view.row;
|
||||||
for (0..self.view.cols) |i| {
|
for (0..self.view.cols) |i| {
|
||||||
self.plane.cursor_move_yx(@intCast(row), @intCast(i)) catch return;
|
self.plane.cursor_move_yx(@intCast(row), @intCast(i));
|
||||||
var cell = self.plane.cell_init();
|
var cell = self.plane.cell_init();
|
||||||
_ = self.plane.at_cursor_cell(&cell) catch return;
|
_ = self.plane.at_cursor_cell(&cell) catch return;
|
||||||
self.render_line_highlight_cell(theme, &cell);
|
self.render_line_highlight_cell(theme, &cell);
|
||||||
|
|
@ -1410,12 +1410,12 @@ pub const Editor = struct {
|
||||||
style = .{ .fg = style.fg, .bg = theme.editor_line_highlight.bg };
|
style = .{ .fg = style.fg, .bg = theme.editor_line_highlight.bg };
|
||||||
};
|
};
|
||||||
|
|
||||||
self.plane.cursor_move_yx(@intCast(pos.row), @intCast(pos.col)) catch return;
|
self.plane.cursor_move_yx(@intCast(pos.row), @intCast(pos.col));
|
||||||
self.render_diagnostic_cell(style);
|
self.render_diagnostic_cell(style);
|
||||||
if (diag.sel.begin.row == diag.sel.end.row) {
|
if (diag.sel.begin.row == diag.sel.end.row) {
|
||||||
var col = pos.col;
|
var col = pos.col;
|
||||||
while (col < diag.sel.end.col) : (col += 1) {
|
while (col < diag.sel.end.col) : (col += 1) {
|
||||||
self.plane.cursor_move_yx(@intCast(pos.row), @intCast(col)) catch return;
|
self.plane.cursor_move_yx(@intCast(pos.row), @intCast(col));
|
||||||
self.render_diagnostic_cell(style);
|
self.render_diagnostic_cell(style);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1541,7 +1541,7 @@ pub const Editor = struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn render_cell(ctx: *@This(), y: usize, x: usize, style: Widget.Theme.Style) !void {
|
fn render_cell(ctx: *@This(), y: usize, x: usize, style: Widget.Theme.Style) !void {
|
||||||
ctx.self.plane.cursor_move_yx(@intCast(y), @intCast(x)) catch return;
|
ctx.self.plane.cursor_move_yx(@intCast(y), @intCast(x));
|
||||||
var cell = ctx.self.plane.cell_init();
|
var cell = ctx.self.plane.cell_init();
|
||||||
_ = ctx.self.plane.at_cursor_cell(&cell) catch return;
|
_ = ctx.self.plane.at_cursor_cell(&cell) catch return;
|
||||||
cell.set_style(style);
|
cell.set_style(style);
|
||||||
|
|
@ -1605,7 +1605,7 @@ pub const Editor = struct {
|
||||||
}
|
}
|
||||||
if (cell_type == .character)
|
if (cell_type == .character)
|
||||||
continue;
|
continue;
|
||||||
self.plane.cursor_move_yx(@intCast(y), @intCast(x)) catch return;
|
self.plane.cursor_move_yx(@intCast(y), @intCast(x));
|
||||||
var cell = self.plane.cell_init();
|
var cell = self.plane.cell_init();
|
||||||
_ = self.plane.at_cursor_cell(&cell) catch return;
|
_ = self.plane.at_cursor_cell(&cell) catch return;
|
||||||
switch (self.render_whitespace) {
|
switch (self.render_whitespace) {
|
||||||
|
|
@ -1691,7 +1691,7 @@ pub const Editor = struct {
|
||||||
for (trailing..eol) |x| {
|
for (trailing..eol) |x| {
|
||||||
const cell_type = cell_map.get_yx(y, x).cell_type;
|
const cell_type = cell_map.get_yx(y, x).cell_type;
|
||||||
const next_cell_type = cell_map.get_yx(y, x + 1).cell_type;
|
const next_cell_type = cell_map.get_yx(y, x + 1).cell_type;
|
||||||
self.plane.cursor_move_yx(@intCast(y), @intCast(x)) catch return;
|
self.plane.cursor_move_yx(@intCast(y), @intCast(x));
|
||||||
var cell = self.plane.cell_init();
|
var cell = self.plane.cell_init();
|
||||||
_ = self.plane.at_cursor_cell(&cell) catch return;
|
_ = self.plane.at_cursor_cell(&cell) catch return;
|
||||||
cell.cell.char.grapheme = get_whitespace_char(cell_type, next_cell_type) orelse continue;
|
cell.cell.char.grapheme = get_whitespace_char(cell_type, next_cell_type) orelse continue;
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,7 @@ pub fn render_linear(self: *Self, theme: *const Widget.Theme) void {
|
||||||
self.plane.set_style(.{ .fg = theme.editor_gutter.fg });
|
self.plane.set_style(.{ .fg = theme.editor_gutter.fg });
|
||||||
self.plane.off_styles(styles.bold);
|
self.plane.off_styles(styles.bold);
|
||||||
}
|
}
|
||||||
try self.plane.cursor_move_yx(@intCast(pos), 0);
|
self.plane.cursor_move_yx(@intCast(pos), 0);
|
||||||
try self.print_digits(linenum, self.line_number_style);
|
try self.print_digits(linenum, self.line_number_style);
|
||||||
if (self.highlight and linenum == self.line + 1)
|
if (self.highlight and linenum == self.line + 1)
|
||||||
self.render_line_highlight(pos, theme);
|
self.render_line_highlight(pos, theme);
|
||||||
|
|
@ -223,7 +223,7 @@ pub fn render_relative(self: *Self, theme: *const Widget.Theme) void {
|
||||||
self.plane.set_style(if (linenum == 0) theme.editor_gutter_active else theme.editor_gutter);
|
self.plane.set_style(if (linenum == 0) theme.editor_gutter_active else theme.editor_gutter);
|
||||||
const val = @abs(if (linenum == 0) line else linenum);
|
const val = @abs(if (linenum == 0) line else linenum);
|
||||||
|
|
||||||
try self.plane.cursor_move_yx(@intCast(pos), 0);
|
self.plane.cursor_move_yx(@intCast(pos), 0);
|
||||||
if (val > 999999)
|
if (val > 999999)
|
||||||
_ = self.plane.print_aligned_right(@intCast(pos), "==> ", .{}) catch {}
|
_ = self.plane.print_aligned_right(@intCast(pos), "==> ", .{}) catch {}
|
||||||
else
|
else
|
||||||
|
|
@ -240,7 +240,7 @@ pub fn render_relative(self: *Self, theme: *const Widget.Theme) void {
|
||||||
|
|
||||||
inline fn render_line_highlight(self: *Self, pos: usize, theme: *const Widget.Theme) void {
|
inline fn render_line_highlight(self: *Self, pos: usize, theme: *const Widget.Theme) void {
|
||||||
for (0..self.get_width()) |i| {
|
for (0..self.get_width()) |i| {
|
||||||
self.plane.cursor_move_yx(@intCast(pos), @intCast(i)) catch return;
|
self.plane.cursor_move_yx(@intCast(pos), @intCast(i));
|
||||||
var cell = self.plane.cell_init();
|
var cell = self.plane.cell_init();
|
||||||
_ = self.plane.at_cursor_cell(&cell) catch return;
|
_ = self.plane.at_cursor_cell(&cell) catch return;
|
||||||
cell.set_style_bg(theme.editor_line_highlight);
|
cell.set_style_bg(theme.editor_line_highlight);
|
||||||
|
|
@ -303,7 +303,7 @@ fn render_diagnostic(self: *Self, diag: *const ed.Diagnostic, theme: *const Widg
|
||||||
.Hint => "",
|
.Hint => "",
|
||||||
};
|
};
|
||||||
const y = row - self.view_top;
|
const y = row - self.view_top;
|
||||||
self.plane.cursor_move_yx(@intCast(y), 0) catch return;
|
self.plane.cursor_move_yx(@intCast(y), 0);
|
||||||
var cell = self.plane.cell_init();
|
var cell = self.plane.cell_init();
|
||||||
_ = self.plane.at_cursor_cell(&cell) catch return;
|
_ = self.plane.at_cursor_cell(&cell) catch return;
|
||||||
cell.set_style_fg(style_);
|
cell.set_style_fg(style_);
|
||||||
|
|
@ -469,7 +469,7 @@ fn print_digits(self: *Self, n_: anytype, style_: DigitStyle) !void {
|
||||||
if (n == 0) break;
|
if (n == 0) break;
|
||||||
}
|
}
|
||||||
std.mem.reverse([]const u8, digits.items);
|
std.mem.reverse([]const u8, digits.items);
|
||||||
try self.plane.cursor_move_yx(@intCast(self.plane.cursor_y()), @intCast(self.width -| digits.items.len -| 1));
|
self.plane.cursor_move_yx(@intCast(self.plane.cursor_y()), @intCast(self.width -| digits.items.len -| 1));
|
||||||
for (digits.items) |digit| _ = try self.plane.putstr(digit);
|
for (digits.items) |digit| _ = try self.plane.putstr(digit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,7 @@ fn handle_render_menu(self: *Self, button: *ButtonType, theme: *const Widget.The
|
||||||
var removed_prefix: usize = 0;
|
var removed_prefix: usize = 0;
|
||||||
const max_len = self.view_cols / path_column_ratio;
|
const max_len = self.view_cols / path_column_ratio;
|
||||||
_ = button.plane.print("{s}:{d}", .{ root.shorten_path(&buf, entry.path, &removed_prefix, max_len - 7), entry.begin_line + 1 }) catch {};
|
_ = button.plane.print("{s}:{d}", .{ root.shorten_path(&buf, entry.path, &removed_prefix, max_len - 7), entry.begin_line + 1 }) catch {};
|
||||||
button.plane.cursor_move_yx(0, @intCast(max_len)) catch return false;
|
button.plane.cursor_move_yx(0, @intCast(max_len));
|
||||||
button.plane.set_style(style_separator);
|
button.plane.set_style(style_separator);
|
||||||
_ = button.plane.print(" ▏", .{}) catch {};
|
_ = button.plane.print(" ▏", .{}) catch {};
|
||||||
switch (entry.severity) {
|
switch (entry.severity) {
|
||||||
|
|
|
||||||
|
|
@ -318,30 +318,30 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool {
|
||||||
self.home_style.subtext;
|
self.home_style.subtext;
|
||||||
|
|
||||||
if (self.plane.dim_x() > 120 and self.plane.dim_y() > 22) {
|
if (self.plane.dim_x() > 120 and self.plane.dim_y() > 22) {
|
||||||
self.plane.cursor_move_yx(2, self.centerI(4, title.len * 8)) catch return false;
|
self.plane.cursor_move_yx(2, self.centerI(4, title.len * 8));
|
||||||
fonts.print_string_large(&self.plane, title, style_title) catch return false;
|
fonts.print_string_large(&self.plane, title, style_title) catch return false;
|
||||||
|
|
||||||
self.plane.cursor_move_yx(10, self.centerI(8, subtext.len * 4)) catch return false;
|
self.plane.cursor_move_yx(10, self.centerI(8, subtext.len * 4));
|
||||||
fonts.print_string_medium(&self.plane, subtext, style_subtext) catch return false;
|
fonts.print_string_medium(&self.plane, subtext, style_subtext) catch return false;
|
||||||
|
|
||||||
self.position_menu(self.v_center(15, self.menu_len, 15), self.center(10, self.menu_w));
|
self.position_menu(self.v_center(15, self.menu_len, 15), self.center(10, self.menu_w));
|
||||||
} else if (self.plane.dim_x() > 55 and self.plane.dim_y() > 16) {
|
} else if (self.plane.dim_x() > 55 and self.plane.dim_y() > 16) {
|
||||||
self.plane.cursor_move_yx(2, self.centerI(4, title.len * 4)) catch return false;
|
self.plane.cursor_move_yx(2, self.centerI(4, title.len * 4));
|
||||||
fonts.print_string_medium(&self.plane, title, style_title) catch return false;
|
fonts.print_string_medium(&self.plane, title, style_title) catch return false;
|
||||||
|
|
||||||
self.plane.set_style_bg_transparent(style_subtext);
|
self.plane.set_style_bg_transparent(style_subtext);
|
||||||
self.plane.cursor_move_yx(7, self.centerI(6, subtext.len)) catch return false;
|
self.plane.cursor_move_yx(7, self.centerI(6, subtext.len));
|
||||||
_ = self.plane.print("{s}", .{subtext}) catch {};
|
_ = self.plane.print("{s}", .{subtext}) catch {};
|
||||||
self.plane.set_style(theme.editor);
|
self.plane.set_style(theme.editor);
|
||||||
|
|
||||||
self.position_menu(self.v_center(9, self.menu_len, 9), self.center(8, self.menu_w));
|
self.position_menu(self.v_center(9, self.menu_len, 9), self.center(8, self.menu_w));
|
||||||
} else {
|
} else {
|
||||||
self.plane.set_style_bg_transparent(style_title);
|
self.plane.set_style_bg_transparent(style_title);
|
||||||
self.plane.cursor_move_yx(1, self.centerI(4, title.len)) catch return false;
|
self.plane.cursor_move_yx(1, self.centerI(4, title.len));
|
||||||
_ = self.plane.print("{s}", .{title}) catch return false;
|
_ = self.plane.print("{s}", .{title}) catch return false;
|
||||||
|
|
||||||
self.plane.set_style_bg_transparent(style_subtext);
|
self.plane.set_style_bg_transparent(style_subtext);
|
||||||
self.plane.cursor_move_yx(3, self.centerI(6, subtext.len)) catch return false;
|
self.plane.cursor_move_yx(3, self.centerI(6, subtext.len));
|
||||||
_ = self.plane.print("{s}", .{subtext}) catch {};
|
_ = self.plane.print("{s}", .{subtext}) catch {};
|
||||||
self.plane.set_style(theme.editor);
|
self.plane.set_style(theme.editor);
|
||||||
|
|
||||||
|
|
@ -356,7 +356,7 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool {
|
||||||
self.plane.cursor_move_yx(
|
self.plane.cursor_move_yx(
|
||||||
@intCast(self.plane.dim_y() - 2),
|
@intCast(self.plane.dim_y() - 2),
|
||||||
@intCast(@max(self.plane.dim_x(), version.len + 3) - version.len - 3),
|
@intCast(@max(self.plane.dim_x(), version.len + 3) - version.len - 3),
|
||||||
) catch {};
|
);
|
||||||
self.plane.set_style_bg_transparent(style_subtext);
|
self.plane.set_style_bg_transparent(style_subtext);
|
||||||
_ = self.plane.print("{s}", .{version}) catch return false;
|
_ = self.plane.print("{s}", .{version}) catch return false;
|
||||||
if (builtin.mode == .Debug) {
|
if (builtin.mode == .Debug) {
|
||||||
|
|
@ -365,7 +365,7 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool {
|
||||||
self.plane.cursor_move_yx(
|
self.plane.cursor_move_yx(
|
||||||
@intCast(self.plane.dim_y() - 3),
|
@intCast(self.plane.dim_y() - 3),
|
||||||
@intCast(@max(self.plane.dim_x(), debug_warning_text.len + 3) - debug_warning_text.len - 3),
|
@intCast(@max(self.plane.dim_x(), debug_warning_text.len + 3) - debug_warning_text.len - 3),
|
||||||
) catch {};
|
);
|
||||||
self.plane.set_style_bg_transparent(theme.editor_error);
|
self.plane.set_style_bg_transparent(theme.editor_error);
|
||||||
_ = self.plane.print("{s}", .{debug_warning_text}) catch return false;
|
_ = self.plane.print("{s}", .{debug_warning_text}) catch return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool {
|
||||||
_ = self.plane.putstr(line) catch {};
|
_ = self.plane.putstr(line) catch {};
|
||||||
if (self.plane.cursor_y() >= self.view_rows - 1)
|
if (self.plane.cursor_y() >= self.view_rows - 1)
|
||||||
return false;
|
return false;
|
||||||
self.plane.cursor_move_yx(-1, 0) catch {};
|
self.plane.cursor_move_yx(-1, 0);
|
||||||
self.plane.cursor_move_rel(1, 0) catch {};
|
self.plane.cursor_move_rel(1, 0) catch {};
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -75,14 +75,14 @@ fn render(mode: *keybind.Mode, bindings: []const keybind.Binding, theme: *const
|
||||||
|
|
||||||
if (bindings.len > max_items) {
|
if (bindings.len > max_items) {
|
||||||
if (widget_style.padding.bottom > 0) {
|
if (widget_style.padding.bottom > 0) {
|
||||||
top_layer_.cursor_move_yx(@intCast(top_layer_.window.height -| 1), @intCast(max_len -| 13)) catch return;
|
top_layer_.cursor_move_yx(@intCast(top_layer_.window.height -| 1), @intCast(max_len -| 13));
|
||||||
_ = top_layer_.print("{s} {d}/{d} {s}", .{
|
_ = top_layer_.print("{s} {d}/{d} {s}", .{
|
||||||
widget_style.border.sib,
|
widget_style.border.sib,
|
||||||
top,
|
top,
|
||||||
bindings.len,
|
bindings.len,
|
||||||
widget_style.border.sie,
|
widget_style.border.sie,
|
||||||
}) catch {};
|
}) catch {};
|
||||||
top_layer_.cursor_move_yx(@intCast(top_layer_.window.height -| 1), @intCast(4)) catch return;
|
top_layer_.cursor_move_yx(@intCast(top_layer_.window.height -| 1), @intCast(4));
|
||||||
_ = top_layer_.print("{s} C-A-? for more {s}", .{
|
_ = top_layer_.print("{s} C-A-? for more {s}", .{
|
||||||
widget_style.border.sib,
|
widget_style.border.sib,
|
||||||
widget_style.border.sie,
|
widget_style.border.sie,
|
||||||
|
|
@ -90,7 +90,7 @@ fn render(mode: *keybind.Mode, bindings: []const keybind.Binding, theme: *const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (widget_style.padding.top > 0) {
|
if (widget_style.padding.top > 0) {
|
||||||
top_layer_.cursor_move_yx(@intCast(0), @intCast(3)) catch return;
|
top_layer_.cursor_move_yx(@intCast(0), @intCast(3));
|
||||||
if (key_events.len > 0) {
|
if (key_events.len > 0) {
|
||||||
_ = top_layer_.print("{s} {s}/{s} prefix: {s} {s}", .{
|
_ = top_layer_.print("{s} {s}/{s} prefix: {s} {s}", .{
|
||||||
widget_style.border.nib,
|
widget_style.border.nib,
|
||||||
|
|
@ -143,7 +143,7 @@ fn render(mode: *keybind.Mode, bindings: []const keybind.Binding, theme: *const
|
||||||
writer.print("{f}", .{keybind.key_event_sequence_fmt(binding.key_events)}) catch break :blk "";
|
writer.print("{f}", .{keybind.key_event_sequence_fmt(binding.key_events)}) catch break :blk "";
|
||||||
break :blk writer.buffered();
|
break :blk writer.buffered();
|
||||||
};
|
};
|
||||||
plane.cursor_move_yx(@intCast(y), 0) catch break;
|
plane.cursor_move_yx(@intCast(y), 0);
|
||||||
switch (render_mode) {
|
switch (render_mode) {
|
||||||
.no_key_event_prefix => _ = plane.print("{s}", .{keybind_txt[key_events.len..]}) catch {},
|
.no_key_event_prefix => _ = plane.print("{s}", .{keybind_txt[key_events.len..]}) catch {},
|
||||||
.full => _ = plane.print(" {s}", .{keybind_txt}) catch {},
|
.full => _ = plane.print(" {s}", .{keybind_txt}) catch {},
|
||||||
|
|
@ -163,7 +163,7 @@ fn render(mode: *keybind.Mode, bindings: []const keybind.Binding, theme: *const
|
||||||
break :blk command.get_description(id) orelse break :blk "[n/a]";
|
break :blk command.get_description(id) orelse break :blk "[n/a]";
|
||||||
};
|
};
|
||||||
|
|
||||||
plane.cursor_move_yx(@intCast(y), @intCast(padding)) catch break;
|
plane.cursor_move_yx(@intCast(y), @intCast(padding));
|
||||||
_ = plane.print("{s}", .{if (description.len > 0) description else binding.commands[0].command}) catch {};
|
_ = plane.print("{s}", .{if (description.len > 0) description else binding.commands[0].command}) catch {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -201,18 +201,18 @@ fn smooth_bar_at(plane: *Plane, pos_: u32, size_: u32) !void {
|
||||||
const blk = @mod(pos, eighths_c);
|
const blk = @mod(pos, eighths_c);
|
||||||
const b = eighths_b[blk];
|
const b = eighths_b[blk];
|
||||||
plane.erase();
|
plane.erase();
|
||||||
plane.cursor_move_yx(pos_y, 0) catch return;
|
plane.cursor_move_yx(pos_y, 0);
|
||||||
_ = try plane.putstr(@ptrCast(b));
|
_ = try plane.putstr(@ptrCast(b));
|
||||||
size -= eighths_c -| blk;
|
size -= eighths_c -| blk;
|
||||||
while (size >= 8) {
|
while (size >= 8) {
|
||||||
pos_y += 1;
|
pos_y += 1;
|
||||||
size -= 8;
|
size -= 8;
|
||||||
plane.cursor_move_yx(pos_y, 0) catch return;
|
plane.cursor_move_yx(pos_y, 0);
|
||||||
_ = try plane.putstr(@ptrCast(eighths_b[0]));
|
_ = try plane.putstr(@ptrCast(eighths_b[0]));
|
||||||
}
|
}
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
pos_y += 1;
|
pos_y += 1;
|
||||||
plane.cursor_move_yx(pos_y, 0) catch return;
|
plane.cursor_move_yx(pos_y, 0);
|
||||||
const t = eighths_t[size];
|
const t = eighths_t[size];
|
||||||
_ = try plane.putstr(@ptrCast(t));
|
_ = try plane.putstr(@ptrCast(t));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ fn render_grip(ctx: ?*anyopaque, theme: *const Widget.Theme) void {
|
||||||
const w: *WidgetList = @ptrCast(@alignCast(ctx.?));
|
const w: *WidgetList = @ptrCast(@alignCast(ctx.?));
|
||||||
if (w.hover()) {
|
if (w.hover()) {
|
||||||
w.plane.set_style(theme.statusbar_hover);
|
w.plane.set_style(theme.statusbar_hover);
|
||||||
w.plane.cursor_move_yx(0, 0) catch {};
|
w.plane.cursor_move_yx(0, 0);
|
||||||
_ = w.plane.putstr(" ") catch {};
|
_ = w.plane.putstr(" ") catch {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ fn render_mini_mode(plane: *Plane, theme: *const Widget.Theme) void {
|
||||||
const y, const x = plane.rel_yx_to_abs(0, pos + 1);
|
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 {
|
} else {
|
||||||
plane.cursor_move_yx(0, pos + 1) catch return;
|
plane.cursor_move_yx(0, pos + 1);
|
||||||
var cell = plane.cell_init();
|
var cell = plane.cell_init();
|
||||||
_ = plane.at_cursor_cell(&cell) catch return;
|
_ = plane.at_cursor_cell(&cell) catch return;
|
||||||
cell.set_style(theme.editor_cursor);
|
cell.set_style(theme.editor_cursor);
|
||||||
|
|
|
||||||
|
|
@ -201,7 +201,7 @@ fn smooth_block_at(plane: *Plane, pos: u64) void {
|
||||||
const l = eighths_l[eighths_c - blk];
|
const l = eighths_l[eighths_c - blk];
|
||||||
const r = eighths_r[eighths_c - blk];
|
const r = eighths_r[eighths_c - blk];
|
||||||
plane.erase();
|
plane.erase();
|
||||||
plane.cursor_move_yx(0, @as(c_int, @intCast(@divFloor(pos, eighths_c)))) catch return;
|
plane.cursor_move_yx(0, @as(c_int, @intCast(@divFloor(pos, eighths_c))));
|
||||||
_ = plane.putstr(@ptrCast(r)) catch return;
|
_ = plane.putstr(@ptrCast(r)) catch return;
|
||||||
_ = plane.putstr(@ptrCast(l)) catch return;
|
_ = plane.putstr(@ptrCast(l)) catch return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2021,7 +2021,7 @@ pub fn render_file_icon(self: *renderer.Plane, icon: []const u8, color: u24) usi
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render_match_cell(self: *renderer.Plane, y: usize, x: usize, theme_: *const Widget.Theme) !void {
|
pub fn render_match_cell(self: *renderer.Plane, y: usize, x: usize, theme_: *const Widget.Theme) !void {
|
||||||
self.cursor_move_yx(@intCast(y), @intCast(x)) catch return;
|
self.cursor_move_yx(@intCast(y), @intCast(x));
|
||||||
var cell = self.cell_init();
|
var cell = self.cell_init();
|
||||||
_ = self.at_cursor_cell(&cell) catch return;
|
_ = self.at_cursor_cell(&cell) catch return;
|
||||||
cell.set_style(theme_.editor_match);
|
cell.set_style(theme_.editor_match);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue