Compare commits
3 commits
376ca8c9fc
...
05da3205b7
Author | SHA1 | Date | |
---|---|---|---|
05da3205b7 | |||
07a2c19b9d | |||
e3fee6a415 |
3 changed files with 23 additions and 14 deletions
|
@ -10,8 +10,8 @@ enable_terminal_cursor: bool = true,
|
|||
enable_terminal_color_scheme: bool = builtin.os.tag != .windows,
|
||||
highlight_current_line: bool = true,
|
||||
highlight_current_line_gutter: bool = true,
|
||||
highlight_columns: []const u8 = "",
|
||||
highlight_columns_alpha: u8 = 224,
|
||||
highlight_columns: []const u8 = "80 100 120",
|
||||
highlight_columns_alpha: u8 = 240,
|
||||
whitespace_mode: []const u8 = "none",
|
||||
inline_diagnostics: bool = true,
|
||||
animation_min_lag: usize = 0, //milliseconds
|
||||
|
|
|
@ -1137,7 +1137,11 @@ pub const Editor = struct {
|
|||
defer frame.deinit();
|
||||
const hl_cols: []const u16 = tui.highlight_columns();
|
||||
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|
|
||||
if (hl_col > 0 and hl_col <= col) {
|
||||
self.plane.cursor_move_yx(@intCast(row), @intCast(col)) catch return;
|
||||
|
|
|
@ -23,7 +23,7 @@ const Allocator = std.mem.Allocator;
|
|||
allocator: Allocator,
|
||||
rdr_: renderer,
|
||||
config_: @import("config"),
|
||||
highlight_columns_: [3]u16,
|
||||
highlight_columns_: []u16,
|
||||
frame_time: usize, // in microseconds
|
||||
frame_clock: tp.metronome,
|
||||
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_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);
|
||||
self.* = .{
|
||||
.allocator = allocator,
|
||||
.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),
|
||||
.frame_time = frame_time,
|
||||
.frame_clock = frame_clock,
|
||||
|
@ -144,15 +152,12 @@ fn init(allocator: Allocator) InitError!*Self {
|
|||
instance_ = self;
|
||||
defer instance_ = null;
|
||||
|
||||
if (conf.highlight_columns.len > 0) {
|
||||
var it = std.mem.splitScalar(u8, conf.highlight_columns, ' ');
|
||||
var idx: usize = 0;
|
||||
while (it.next()) |arg| {
|
||||
if (idx >= self.highlight_columns_.len) break;
|
||||
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.config_.default_cursor = @tagName(self.default_cursor);
|
||||
|
@ -1104,7 +1109,7 @@ pub fn config() *const @import("config") {
|
|||
}
|
||||
|
||||
pub fn highlight_columns() []const u16 {
|
||||
return ¤t().highlight_columns_;
|
||||
return current().highlight_columns_;
|
||||
}
|
||||
|
||||
pub fn config_mut() *@import("config") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue