feat: add configurable editor idle actions hover and highlight_references
closes #370
This commit is contained in:
parent
06e967a69d
commit
6e78564599
3 changed files with 18 additions and 2 deletions
|
|
@ -19,6 +19,8 @@ inline_diagnostics: bool = true,
|
||||||
animation_min_lag: usize = 0, //milliseconds
|
animation_min_lag: usize = 0, //milliseconds
|
||||||
animation_max_lag: usize = 50, //milliseconds
|
animation_max_lag: usize = 50, //milliseconds
|
||||||
hover_time_ms: usize = 500, //milliseconds
|
hover_time_ms: usize = 500, //milliseconds
|
||||||
|
input_idle_time_ms: usize = 150, //milliseconds
|
||||||
|
idle_actions: []IdleAction = &.{},
|
||||||
enable_format_on_save: bool = false,
|
enable_format_on_save: bool = false,
|
||||||
restore_last_cursor_position: bool = true,
|
restore_last_cursor_position: bool = true,
|
||||||
follow_cursor_on_buffer_switch: bool = false, //scroll cursor into view on buffer switch
|
follow_cursor_on_buffer_switch: bool = false, //scroll cursor into view on buffer switch
|
||||||
|
|
@ -46,6 +48,11 @@ lsp_output: enum { quiet, verbose } = .quiet,
|
||||||
|
|
||||||
include_files: []const u8 = "",
|
include_files: []const u8 = "",
|
||||||
|
|
||||||
|
pub const IdleAction = enum {
|
||||||
|
hover,
|
||||||
|
highlight_references,
|
||||||
|
};
|
||||||
|
|
||||||
pub const DigitStyle = enum {
|
pub const DigitStyle = enum {
|
||||||
ascii,
|
ascii,
|
||||||
digital,
|
digital,
|
||||||
|
|
|
||||||
|
|
@ -6376,6 +6376,16 @@ pub const EditorWidget = struct {
|
||||||
self.update_hover_timer(.fired);
|
self.update_hover_timer(.fired);
|
||||||
if (self.hover_y >= 0 and self.hover_x >= 0 and self.hover_mouse_event)
|
if (self.hover_y >= 0 and self.hover_x >= 0 and self.hover_mouse_event)
|
||||||
try self.editor.hover_at_abs(@intCast(self.hover_y), @intCast(self.hover_x));
|
try self.editor.hover_at_abs(@intCast(self.hover_y), @intCast(self.hover_x));
|
||||||
|
} else if (try m.match(.{"input_idle"})) {
|
||||||
|
for (tui.config().idle_actions) |action| switch (action) {
|
||||||
|
.hover => {
|
||||||
|
try self.editor.hover(.{});
|
||||||
|
},
|
||||||
|
.highlight_references => {
|
||||||
|
if (self.editor.cursels.items.len == 1 and self.editor.get_primary().selection == null)
|
||||||
|
try self.editor.highlight_references(.{});
|
||||||
|
},
|
||||||
|
};
|
||||||
} else if (try m.match(.{ "whitespace_mode", tp.extract(&bytes) })) {
|
} else if (try m.match(.{ "whitespace_mode", tp.extract(&bytes) })) {
|
||||||
self.editor.render_whitespace = Editor.from_whitespace_mode(bytes);
|
self.editor.render_whitespace = Editor.from_whitespace_mode(bytes);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,6 @@ pub const ClipboardEntry = struct {
|
||||||
|
|
||||||
const keepalive = std.time.us_per_day * 365; // one year
|
const keepalive = std.time.us_per_day * 365; // one year
|
||||||
const idle_frames = 0;
|
const idle_frames = 0;
|
||||||
const input_idle_time_milliseconds = 500;
|
|
||||||
const mouse_idle_time_milliseconds = 3000;
|
const mouse_idle_time_milliseconds = 3000;
|
||||||
|
|
||||||
const init_delay = 1; // ms
|
const init_delay = 1; // ms
|
||||||
|
|
@ -313,7 +312,7 @@ fn update_input_idle_timer(self: *Self) void {
|
||||||
_ = self.send_widgets(tp.self_pid(), m) catch {};
|
_ = self.send_widgets(tp.self_pid(), m) catch {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const delay = std.time.us_per_ms * @as(u64, input_idle_time_milliseconds);
|
const delay = std.time.us_per_ms * @as(u64, self.config_.input_idle_time_ms);
|
||||||
if (self.input_idle_timer) |*t| {
|
if (self.input_idle_timer) |*t| {
|
||||||
t.cancel() catch {};
|
t.cancel() catch {};
|
||||||
t.deinit();
|
t.deinit();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue