diff --git a/src/renderer/vaxis/Plane.zig b/src/renderer/vaxis/Plane.zig index 52b227c..23ba7db 100644 --- a/src/renderer/vaxis/Plane.zig +++ b/src/renderer/vaxis/Plane.zig @@ -242,8 +242,8 @@ pub fn putc(self: *Plane, cell: *const Cell) !usize { return self.putc_yx(self.row, self.col, cell); } -pub fn putc_yx(self: *Plane, y: i32, x: i32, cell: *const Cell) !usize { - try self.cursor_move_yx(y, x); +pub fn putc_yx(self: *Plane, y: i32, x: i32, cell: *const Cell) usize { + 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; if (w == 0) return w; 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; } -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 <= y or self.window.width <= x) return; if (y >= 0) self.row = y; diff --git a/src/tui/Fire.zig b/src/tui/Fire.zig index 2965cce..7d73e4d 100644 --- a/src/tui/Fire.zig +++ b/src/tui/Fire.zig @@ -124,7 +124,7 @@ pub fn render(self: *Fire) void { self.plane.set_bg_palindex(fire_palette[px_lo]) catch {}; _ = 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 {}; } } diff --git a/src/tui/InputBox.zig b/src/tui/InputBox.zig index defb7c1..cffeaa4 100644 --- a/src/tui/InputBox.zig +++ b/src/tui/InputBox.zig @@ -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); tui.rdr().cursor_enable(y, x, tui.get_cursor_shape()) catch {}; } 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(); _ = self.plane.at_cursor_cell(&cell) catch return false; cell.set_style(theme.editor_cursor); diff --git a/src/tui/ModalBackground.zig b/src/tui/ModalBackground.zig index fb3c39b..9005a31 100644 --- a/src/tui/ModalBackground.zig +++ b/src/tui/ModalBackground.zig @@ -129,7 +129,7 @@ pub fn State(ctx_type: type) type { } 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(); _ = plane.at_cursor_cell(&cell) catch return; cell.dim(dim_target); diff --git a/src/tui/WidgetStyle.zig b/src/tui/WidgetStyle.zig index f550ee3..00a447b 100644 --- a/src/tui/WidgetStyle.zig +++ b/src/tui/WidgetStyle.zig @@ -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 { - plane.cursor_move_yx(@intCast(y), @intCast(x)) catch return; + plane.cursor_move_yx(@intCast(y), @intCast(x)); plane.putchar(egc); } diff --git a/src/tui/editor.zig b/src/tui/editor.zig index b389557..755b24d 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -1174,7 +1174,7 @@ pub const Editor = struct { if (cell_map_val == .tab) cell_map_val = .extension; advance -= 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) { 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 }); if (cell_map_val == .tab) cell_map_val = .extension; 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; chunk = chunk[bytes..]; @@ -1214,7 +1214,7 @@ pub const Editor = struct { ctx.x = 0; ctx.leading = true; 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; } @@ -1274,7 +1274,7 @@ pub const Editor = struct { if (!tui.is_mainview_focused() or !self.enable_terminal_cursor) { if (self.screen_cursor(cursor)) |pos| { 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; 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)); tui.rdr().show_multi_cursor_yx(y, x) catch return; } 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); } } @@ -1335,7 +1335,7 @@ pub const Editor = struct { for (0..self.view.rows) |row| for (0..self.view.cols) |col| { const view_col = col + offset; 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(); _ = self.plane.at_cursor_cell(&cell) catch return; cell.dim_bg(alpha); @@ -1352,7 +1352,7 @@ pub const Editor = struct { return; const row = cursor.row - self.view.row; 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(); _ = self.plane.at_cursor_cell(&cell) catch return; 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 }; }; - 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); if (diag.sel.begin.row == diag.sel.end.row) { var col = pos.col; 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); } } @@ -1541,7 +1541,7 @@ pub const Editor = struct { } } 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(); _ = ctx.self.plane.at_cursor_cell(&cell) catch return; cell.set_style(style); @@ -1605,7 +1605,7 @@ pub const Editor = struct { } if (cell_type == .character) 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(); _ = self.plane.at_cursor_cell(&cell) catch return; switch (self.render_whitespace) { @@ -1691,7 +1691,7 @@ pub const Editor = struct { for (trailing..eol) |x| { const cell_type = cell_map.get_yx(y, x).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(); _ = self.plane.at_cursor_cell(&cell) catch return; cell.cell.char.grapheme = get_whitespace_char(cell_type, next_cell_type) orelse continue; diff --git a/src/tui/editor_gutter.zig b/src/tui/editor_gutter.zig index 44f120a..1f33e83 100644 --- a/src/tui/editor_gutter.zig +++ b/src/tui/editor_gutter.zig @@ -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.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); if (self.highlight and linenum == self.line + 1) 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); 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) _ = self.plane.print_aligned_right(@intCast(pos), "==> ", .{}) catch {} 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 { 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(); _ = self.plane.at_cursor_cell(&cell) catch return; 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 => "", }; 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(); _ = self.plane.at_cursor_cell(&cell) catch return; cell.set_style_fg(style_); @@ -469,7 +469,7 @@ fn print_digits(self: *Self, n_: anytype, style_: DigitStyle) !void { if (n == 0) break; } 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); } diff --git a/src/tui/filelist_view.zig b/src/tui/filelist_view.zig index acc64fd..38d4cdb 100644 --- a/src/tui/filelist_view.zig +++ b/src/tui/filelist_view.zig @@ -174,7 +174,7 @@ fn handle_render_menu(self: *Self, button: *ButtonType, theme: *const Widget.The var removed_prefix: usize = 0; 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.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.print(" ▏", .{}) catch {}; switch (entry.severity) { diff --git a/src/tui/home.zig b/src/tui/home.zig index 3555a65..6093c2b 100644 --- a/src/tui/home.zig +++ b/src/tui/home.zig @@ -318,30 +318,30 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool { self.home_style.subtext; 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; - 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; 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) { - 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; 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.set_style(theme.editor); self.position_menu(self.v_center(9, self.menu_len, 9), self.center(8, self.menu_w)); } else { 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.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.set_style(theme.editor); @@ -356,7 +356,7 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool { self.plane.cursor_move_yx( @intCast(self.plane.dim_y() - 2), @intCast(@max(self.plane.dim_x(), version.len + 3) - version.len - 3), - ) catch {}; + ); self.plane.set_style_bg_transparent(style_subtext); _ = self.plane.print("{s}", .{version}) catch return false; if (builtin.mode == .Debug) { @@ -365,7 +365,7 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool { self.plane.cursor_move_yx( @intCast(self.plane.dim_y() - 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.print("{s}", .{debug_warning_text}) catch return false; } diff --git a/src/tui/info_view.zig b/src/tui/info_view.zig index 7dee8b2..e9635b3 100644 --- a/src/tui/info_view.zig +++ b/src/tui/info_view.zig @@ -68,7 +68,7 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool { _ = self.plane.putstr(line) catch {}; if (self.plane.cursor_y() >= self.view_rows - 1) 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 {}; } return false; diff --git a/src/tui/keyhints.zig b/src/tui/keyhints.zig index 4c17a5a..cb358b1 100644 --- a/src/tui/keyhints.zig +++ b/src/tui/keyhints.zig @@ -75,14 +75,14 @@ fn render(mode: *keybind.Mode, bindings: []const keybind.Binding, theme: *const if (bindings.len > max_items) { 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}", .{ widget_style.border.sib, top, bindings.len, widget_style.border.sie, }) 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}", .{ widget_style.border.sib, 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) { - 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) { _ = top_layer_.print("{s} {s}/{s} prefix: {s} {s}", .{ 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 ""; break :blk writer.buffered(); }; - plane.cursor_move_yx(@intCast(y), 0) catch break; + plane.cursor_move_yx(@intCast(y), 0); switch (render_mode) { .no_key_event_prefix => _ = plane.print("{s}", .{keybind_txt[key_events.len..]}) 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]"; }; - 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 {}; } } diff --git a/src/tui/scrollbar_v.zig b/src/tui/scrollbar_v.zig index 64dfe01..c8d33d9 100644 --- a/src/tui/scrollbar_v.zig +++ b/src/tui/scrollbar_v.zig @@ -201,18 +201,18 @@ fn smooth_bar_at(plane: *Plane, pos_: u32, size_: u32) !void { const blk = @mod(pos, eighths_c); const b = eighths_b[blk]; plane.erase(); - plane.cursor_move_yx(pos_y, 0) catch return; + plane.cursor_move_yx(pos_y, 0); _ = try plane.putstr(@ptrCast(b)); size -= eighths_c -| blk; while (size >= 8) { pos_y += 1; 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])); } if (size > 0) { pos_y += 1; - plane.cursor_move_yx(pos_y, 0) catch return; + plane.cursor_move_yx(pos_y, 0); const t = eighths_t[size]; _ = try plane.putstr(@ptrCast(t)); } diff --git a/src/tui/status/bar.zig b/src/tui/status/bar.zig index c9f8a63..ce5638b 100644 --- a/src/tui/status/bar.zig +++ b/src/tui/status/bar.zig @@ -34,7 +34,7 @@ fn render_grip(ctx: ?*anyopaque, theme: *const Widget.Theme) void { const w: *WidgetList = @ptrCast(@alignCast(ctx.?)); if (w.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 {}; } } diff --git a/src/tui/status/filestate.zig b/src/tui/status/filestate.zig index 7fd8bb3..876d2c4 100644 --- a/src/tui/status/filestate.zig +++ b/src/tui/status/filestate.zig @@ -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); tui.rdr().cursor_enable(y, x, tui.get_cursor_shape()) catch {}; } else { - plane.cursor_move_yx(0, pos + 1) catch return; + plane.cursor_move_yx(0, pos + 1); var cell = plane.cell_init(); _ = plane.at_cursor_cell(&cell) catch return; cell.set_style(theme.editor_cursor); diff --git a/src/tui/status/keystate.zig b/src/tui/status/keystate.zig index afa9ff3..ea02168 100644 --- a/src/tui/status/keystate.zig +++ b/src/tui/status/keystate.zig @@ -201,7 +201,7 @@ fn smooth_block_at(plane: *Plane, pos: u64) void { const l = eighths_l[eighths_c - blk]; const r = eighths_r[eighths_c - blk]; 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(l)) catch return; } diff --git a/src/tui/tui.zig b/src/tui/tui.zig index fd7aa1b..5bf75e1 100644 --- a/src/tui/tui.zig +++ b/src/tui/tui.zig @@ -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 { - self.cursor_move_yx(@intCast(y), @intCast(x)) catch return; + self.cursor_move_yx(@intCast(y), @intCast(x)); var cell = self.cell_init(); _ = self.at_cursor_cell(&cell) catch return; cell.set_style(theme_.editor_match);