begin supporting global marks
This commit is contained in:
parent
2d583fbd9e
commit
4765f47dd0
2 changed files with 35 additions and 0 deletions
|
@ -5130,6 +5130,30 @@ pub const Editor = struct {
|
|||
std.mem.sort(Diagnostic, self.diagnostics.items, {}, less_fn);
|
||||
}
|
||||
|
||||
pub fn goto_global_mark(self: *Self, ctx: Context) Result {
|
||||
try self.send_editor_jump_source();
|
||||
var mark_id: u8 = 0;
|
||||
if (!try ctx.args.match(.{tp.extract(&mark_id)}))
|
||||
return error.InvalidGotoLineArgument;
|
||||
const location = tui.get_global_marks()[mark_id] orelse return error.UndefinedGlobalMark;
|
||||
_ = location;
|
||||
|
||||
//TODO: figure out how to goto location in another file
|
||||
}
|
||||
pub const goto_global_mark_meta: Meta = .{ .arguments = &.{.integer} };
|
||||
|
||||
pub fn set_global_mark(self: *Self, ctx: Context) Result {
|
||||
var mark_id: u8 = 0;
|
||||
if (!try ctx.args.match(.{tp.extract(&mark_id)}))
|
||||
return error.InvalidGotoLineArgument;
|
||||
const primary = self.get_primary();
|
||||
const buf = self.buffer orelse return error.Stop;
|
||||
var location: tui.GlobalMarkLocation = .{ .row = primary.cursor.row, .col = primary.cursor.col };
|
||||
std.mem.copyForwards(u8, &location.filepath, buf.file_path);
|
||||
tui.get_global_marks()[mark_id] = location;
|
||||
}
|
||||
pub const set_global_mark_meta: Meta = .{ .arguments = &.{.integer} };
|
||||
|
||||
pub fn goto_mark(self: *Self, ctx: Context) Result {
|
||||
try self.send_editor_jump_source();
|
||||
var mark_id: u8 = 0;
|
||||
|
|
|
@ -20,6 +20,12 @@ const MainView = @import("mainview.zig");
|
|||
|
||||
const Allocator = std.mem.Allocator;
|
||||
|
||||
pub const GlobalMarkLocation = struct {
|
||||
row: usize,
|
||||
col: usize,
|
||||
filepath: [512]u8 = .{0} ** 512,
|
||||
};
|
||||
|
||||
allocator: Allocator,
|
||||
rdr_: renderer,
|
||||
config_: @import("config"),
|
||||
|
@ -62,6 +68,7 @@ fontfaces_: std.ArrayListUnmanaged([]const u8) = .{},
|
|||
enable_mouse_idle_timer: bool = false,
|
||||
query_cache_: *syntax.QueryCache,
|
||||
frames_rendered_: usize = 0,
|
||||
global_marks: [256]?GlobalMarkLocation = .{null} ** 256,
|
||||
|
||||
const keepalive = std.time.us_per_day * 365; // one year
|
||||
const idle_frames = 0;
|
||||
|
@ -1091,6 +1098,10 @@ fn current() *Self {
|
|||
return instance_ orelse @panic("tui call out of context");
|
||||
}
|
||||
|
||||
pub fn get_global_marks() *[256]?GlobalMarkLocation {
|
||||
return ¤t().global_marks;
|
||||
}
|
||||
|
||||
pub fn rdr() *renderer {
|
||||
return ¤t().rdr_;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue