Compare commits

...

3 commits

3 changed files with 23 additions and 14 deletions

View file

@ -10,8 +10,8 @@ enable_terminal_cursor: bool = true,
enable_terminal_color_scheme: bool = builtin.os.tag != .windows, enable_terminal_color_scheme: bool = builtin.os.tag != .windows,
highlight_current_line: bool = true, highlight_current_line: bool = true,
highlight_current_line_gutter: bool = true, highlight_current_line_gutter: bool = true,
highlight_columns: []const u8 = "", highlight_columns: []const u8 = "80 100 120",
highlight_columns_alpha: u8 = 224, highlight_columns_alpha: u8 = 240,
whitespace_mode: []const u8 = "none", whitespace_mode: []const u8 = "none",
inline_diagnostics: bool = true, inline_diagnostics: bool = true,
animation_min_lag: usize = 0, //milliseconds animation_min_lag: usize = 0, //milliseconds

View file

@ -1137,7 +1137,11 @@ pub const Editor = struct {
defer frame.deinit(); defer frame.deinit();
const hl_cols: []const u16 = tui.highlight_columns(); const hl_cols: []const u16 = tui.highlight_columns();
const alpha: u8 = tui.config().highlight_columns_alpha; const alpha: u8 = tui.config().highlight_columns_alpha;
for (hl_cols) |hl_col| { const offset = self.view.col;
for (hl_cols) |hl_col_| {
if (hl_col_ < offset) continue;
const hl_col = hl_col_ - offset;
if (hl_col > self.view.cols) continue;
for (0..self.view.rows) |row| for (0..self.view.cols) |col| for (0..self.view.rows) |row| for (0..self.view.cols) |col|
if (hl_col > 0 and hl_col <= col) { if (hl_col > 0 and hl_col <= col) {
self.plane.cursor_move_yx(@intCast(row), @intCast(col)) catch return; self.plane.cursor_move_yx(@intCast(row), @intCast(col)) catch return;

View file

@ -23,7 +23,7 @@ const Allocator = std.mem.Allocator;
allocator: Allocator, allocator: Allocator,
rdr_: renderer, rdr_: renderer,
config_: @import("config"), config_: @import("config"),
highlight_columns_: [3]u16, highlight_columns_: []u16,
frame_time: usize, // in microseconds frame_time: usize, // in microseconds
frame_clock: tp.metronome, frame_clock: tp.metronome,
frame_clock_running: bool = false, frame_clock_running: bool = false,
@ -120,11 +120,19 @@ fn init(allocator: Allocator) InitError!*Self {
const frame_time = std.time.us_per_s / conf.frame_rate; const frame_time = std.time.us_per_s / conf.frame_rate;
const frame_clock = try tp.metronome.init(frame_time); const frame_clock = try tp.metronome.init(frame_time);
const hl_cols: usize = blk: {
var it = std.mem.splitScalar(u8, conf.highlight_columns, ' ');
var idx: usize = 0;
while (it.next()) |_|
idx += 1;
break :blk idx;
};
var self = try allocator.create(Self); var self = try allocator.create(Self);
self.* = .{ self.* = .{
.allocator = allocator, .allocator = allocator,
.config_ = conf, .config_ = conf,
.highlight_columns_ = @splat(0), .highlight_columns_ = try allocator.alloc(u16, hl_cols),
.rdr_ = try renderer.init(allocator, self, tp.env.get().is("no-alternate"), dispatch_initialized), .rdr_ = try renderer.init(allocator, self, tp.env.get().is("no-alternate"), dispatch_initialized),
.frame_time = frame_time, .frame_time = frame_time,
.frame_clock = frame_clock, .frame_clock = frame_clock,
@ -144,14 +152,11 @@ fn init(allocator: Allocator) InitError!*Self {
instance_ = self; instance_ = self;
defer instance_ = null; defer instance_ = null;
if (conf.highlight_columns.len > 0) { var it = std.mem.splitScalar(u8, conf.highlight_columns, ' ');
var it = std.mem.splitScalar(u8, conf.highlight_columns, ' '); var idx: usize = 0;
var idx: usize = 0; while (it.next()) |arg| {
while (it.next()) |arg| { self.highlight_columns_[idx] = std.fmt.parseInt(u16, arg, 10) catch 0;
if (idx >= self.highlight_columns_.len) break; idx += 1;
self.highlight_columns_[idx] = std.fmt.parseInt(u16, arg, 10) catch 0;
idx += 1;
}
} }
self.default_cursor = std.meta.stringToEnum(keybind.CursorShape, conf.default_cursor) orelse .default; self.default_cursor = std.meta.stringToEnum(keybind.CursorShape, conf.default_cursor) orelse .default;
@ -1104,7 +1109,7 @@ pub fn config() *const @import("config") {
} }
pub fn highlight_columns() []const u16 { pub fn highlight_columns() []const u16 {
return &current().highlight_columns_; return current().highlight_columns_;
} }
pub fn config_mut() *@import("config") { pub fn config_mut() *@import("config") {