Compare commits
No commits in common. "32f4bcec3af3923c4d47d376e3a74bc9ff2bd766" and "049cecdae6c469678651e3913cb04e396bdd6b23" have entirely different histories.
32f4bcec3a
...
049cecdae6
2 changed files with 15 additions and 24 deletions
|
|
@ -20,7 +20,6 @@ whitespace_mode: WhitespaceMode = .indent,
|
|||
inline_diagnostics: bool = true,
|
||||
inline_diagnostics_alignment: Alignment = .right,
|
||||
inline_vcs_blame: bool = false,
|
||||
inline_vcs_blame_alignment: Alignment = .right,
|
||||
animation_min_lag: usize = 0, //milliseconds
|
||||
animation_max_lag: usize = 50, //milliseconds
|
||||
hover_time_ms: usize = 500, //milliseconds
|
||||
|
|
|
|||
|
|
@ -1225,14 +1225,13 @@ pub const Editor = struct {
|
|||
return Buffer.Walker.keep_walking;
|
||||
}
|
||||
};
|
||||
const pc_row: usize = self.get_primary().cursor.row;
|
||||
const hl_row: ?usize = if (tui.config().highlight_current_line) blk: {
|
||||
if (self.get_primary().selection) |_|
|
||||
if (theme.editor_selection.bg) |sel_bg|
|
||||
if (theme.editor_line_highlight.bg) |hl_bg|
|
||||
if (sel_bg.color == hl_bg.color and sel_bg.alpha == hl_bg.alpha)
|
||||
break :blk null;
|
||||
break :blk pc_row;
|
||||
break :blk self.get_primary().cursor.row;
|
||||
} else null;
|
||||
var ctx_: ctx = .{
|
||||
.self = self,
|
||||
|
|
@ -1250,18 +1249,16 @@ pub const Editor = struct {
|
|||
|
||||
self.plane.set_base_style(theme.editor);
|
||||
self.plane.erase();
|
||||
if (hl_row) |row|
|
||||
self.render_line_highlight(row, theme) catch {};
|
||||
if (hl_row) |_|
|
||||
self.render_line_highlight(&self.get_primary().cursor, theme) catch {};
|
||||
self.plane.home();
|
||||
_ = root.walk_from_line_begin_const(self.view.row, ctx.walker, &ctx_, self.metrics) catch {};
|
||||
}
|
||||
self.render_syntax(theme, cache, root) catch {};
|
||||
self.render_whitespace_map(theme, ctx_.cell_map) catch {};
|
||||
const pc_row_diag = if (tui.config().inline_diagnostics)
|
||||
self.render_diagnostics(theme, pc_row, hl_row, ctx_.cell_map)
|
||||
else
|
||||
false;
|
||||
if (tui.config().inline_vcs_blame and !pc_row_diag)
|
||||
if (tui.config().inline_diagnostics)
|
||||
self.render_diagnostics(theme, hl_row, ctx_.cell_map) catch {};
|
||||
if (tui.config().inline_vcs_blame)
|
||||
self.render_blame(theme, hl_row, ctx_.cell_map) catch {};
|
||||
self.render_column_highlights() catch {};
|
||||
self.render_cursors(theme, ctx_.cell_map, focused) catch {};
|
||||
|
|
@ -1356,12 +1353,12 @@ pub const Editor = struct {
|
|||
}
|
||||
}
|
||||
|
||||
fn render_line_highlight(self: *Self, pc_row: usize, theme: *const Widget.Theme) !void {
|
||||
fn render_line_highlight(self: *Self, cursor: *const Cursor, theme: *const Widget.Theme) !void {
|
||||
const row_min = self.view.row;
|
||||
const row_max = row_min + self.view.rows;
|
||||
if (pc_row < row_min or row_max < pc_row)
|
||||
if (cursor.row < row_min or row_max < cursor.row)
|
||||
return;
|
||||
const row = pc_row - self.view.row;
|
||||
const row = cursor.row - self.view.row;
|
||||
for (0..self.view.cols) |i| {
|
||||
self.plane.cursor_move_yx(@intCast(row), @intCast(i));
|
||||
var cell = self.plane.cell_init();
|
||||
|
|
@ -1404,14 +1401,8 @@ pub const Editor = struct {
|
|||
};
|
||||
}
|
||||
|
||||
fn render_diagnostics(self: *Self, theme: *const Widget.Theme, pc_row: usize, hl_row: ?usize, cell_map: CellMap) bool {
|
||||
var diagnostic_on_pc_row: bool = false;
|
||||
for (self.diagnostics.items) |*diag| {
|
||||
if (diag.sel.begin.row == pc_row)
|
||||
diagnostic_on_pc_row = true;
|
||||
self.render_diagnostic(diag, theme, hl_row, cell_map);
|
||||
}
|
||||
return diagnostic_on_pc_row;
|
||||
fn render_diagnostics(self: *Self, theme: *const Widget.Theme, hl_row: ?usize, cell_map: CellMap) !void {
|
||||
for (self.diagnostics.items) |*diag| self.render_diagnostic(diag, theme, hl_row, cell_map);
|
||||
}
|
||||
|
||||
fn render_diagnostic(self: *Self, diag: *const Diagnostic, theme: *const Widget.Theme, hl_row: ?usize, cell_map: CellMap) void {
|
||||
|
|
@ -1488,13 +1479,14 @@ pub const Editor = struct {
|
|||
.bg = if (hl_row) |_| theme.editor_line_highlight.bg else theme.editor_hint.bg,
|
||||
});
|
||||
|
||||
switch (tui.config().inline_vcs_blame_alignment) {
|
||||
.left => {
|
||||
// Opposite as diagnostics
|
||||
switch (tui.config().inline_diagnostics_alignment) {
|
||||
.right => {
|
||||
const width = self.plane.window.width;
|
||||
self.plane.cursor_move_yx(@intCast(pos.row), @intCast(width -| (screen_width - space_begin) + 2));
|
||||
_ = self.plane.print("{s}", .{msg}) catch 0;
|
||||
},
|
||||
.right => _ = self.plane.print_aligned_right(@intCast(pos.row), "{s}", .{msg[0..@min(screen_width - space_begin, msg.len)]}) catch {},
|
||||
.left => _ = self.plane.print_aligned_right(@intCast(pos.row), "{s}", .{msg[0..@min(screen_width - space_begin, msg.len)]}) catch {},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue