feat: add toggle_highlight_columns command (shift+f11)
This commit is contained in:
		
							parent
							
								
									ce2c370cfd
								
							
						
					
					
						commit
						df70384b7b
					
				
					 2 changed files with 12 additions and 1 deletions
				
			
		|  | @ -157,6 +157,7 @@ | ||||||
|             ["f9", "theme_prev"], |             ["f9", "theme_prev"], | ||||||
|             ["f10", "theme_next"], |             ["f10", "theme_next"], | ||||||
|             ["f11", "toggle_panel"], |             ["f11", "toggle_panel"], | ||||||
|  |             ["shift+f11", "toggle_highlight_columns"], | ||||||
|             ["ctrl+f11", "toggle_inspector_view"], |             ["ctrl+f11", "toggle_inspector_view"], | ||||||
|             ["f12", "goto_definition"], |             ["f12", "goto_definition"], | ||||||
|             ["f34", "toggle_whitespace_mode"], |             ["f34", "toggle_whitespace_mode"], | ||||||
|  |  | ||||||
|  | @ -24,6 +24,7 @@ allocator: Allocator, | ||||||
| rdr_: renderer, | rdr_: renderer, | ||||||
| config_: @import("config"), | config_: @import("config"), | ||||||
| highlight_columns_: []u16, | highlight_columns_: []u16, | ||||||
|  | highlight_columns_configured: []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, | ||||||
|  | @ -130,12 +131,14 @@ fn init(allocator: Allocator) InitError!*Self { | ||||||
|             idx += 1; |             idx += 1; | ||||||
|         break :blk idx; |         break :blk idx; | ||||||
|     }; |     }; | ||||||
|  |     const highlight_columns__ = try allocator.alloc(u16, hl_cols); | ||||||
| 
 | 
 | ||||||
|     var self = try allocator.create(Self); |     var self = try allocator.create(Self); | ||||||
|     self.* = .{ |     self.* = .{ | ||||||
|         .allocator = allocator, |         .allocator = allocator, | ||||||
|         .config_ = conf, |         .config_ = conf, | ||||||
|         .highlight_columns_ = try allocator.alloc(u16, hl_cols), |         .highlight_columns_ = highlight_columns__, | ||||||
|  |         .highlight_columns_configured = highlight_columns__, | ||||||
|         .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, | ||||||
|  | @ -221,6 +224,7 @@ fn init_delayed(self: *Self) command.Result { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| fn deinit(self: *Self) void { | fn deinit(self: *Self) void { | ||||||
|  |     self.allocator.free(self.highlight_columns_configured); | ||||||
|     if (self.mouse_idle_timer) |*t| { |     if (self.mouse_idle_timer) |*t| { | ||||||
|         t.cancel() catch {}; |         t.cancel() catch {}; | ||||||
|         t.deinit(); |         t.deinit(); | ||||||
|  | @ -788,6 +792,12 @@ const cmds = struct { | ||||||
|     } |     } | ||||||
|     pub const toggle_whitespace_mode_meta: Meta = .{ .description = "Next whitespace mode" }; |     pub const toggle_whitespace_mode_meta: Meta = .{ .description = "Next whitespace mode" }; | ||||||
| 
 | 
 | ||||||
|  |     pub fn toggle_highlight_columns(self: *Self, _: Ctx) Result { | ||||||
|  |         defer self.logger.print("highlight columns {s}", .{if (self.highlight_columns_.len > 0) "enabled" else "disabled"}); | ||||||
|  |         self.highlight_columns_ = if (self.highlight_columns_.len > 0) &.{} else self.highlight_columns_configured; | ||||||
|  |     } | ||||||
|  |     pub const toggle_highlight_columns_meta: Meta = .{ .description = "Toggle highlight columns" }; | ||||||
|  | 
 | ||||||
|     pub fn toggle_input_mode(self: *Self, _: Ctx) Result { |     pub fn toggle_input_mode(self: *Self, _: Ctx) Result { | ||||||
|         var it = std.mem.splitScalar(u8, self.config_.input_mode, '/'); |         var it = std.mem.splitScalar(u8, self.config_.input_mode, '/'); | ||||||
|         self.config_.input_mode = it.first(); |         self.config_.input_mode = it.first(); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue