feat: WIP add project manager service
The project manager service will provide fuzzy find, LRU, and similar background services for open projects.
This commit is contained in:
parent
a056a54104
commit
602a4dff01
5 changed files with 400 additions and 4 deletions
|
@ -4,6 +4,7 @@ const tp = @import("thespian");
|
|||
const tracy = @import("tracy");
|
||||
const root = @import("root");
|
||||
const location_history = @import("location_history");
|
||||
const project_manager = @import("project_manager");
|
||||
|
||||
const tui = @import("tui.zig");
|
||||
const command = @import("command.zig");
|
||||
|
@ -31,6 +32,7 @@ last_match_text: ?[]const u8 = null,
|
|||
logview_enabled: bool = false,
|
||||
|
||||
location_history: location_history,
|
||||
project_manager: project_manager,
|
||||
|
||||
const NavState = struct {
|
||||
time: i64 = 0,
|
||||
|
@ -42,6 +44,12 @@ const NavState = struct {
|
|||
};
|
||||
|
||||
pub fn create(a: std.mem.Allocator, n: nc.Plane) !Widget {
|
||||
const project_manager_ = try project_manager.create(a);
|
||||
tp.env.get().proc_set("project", project_manager_.pid.?.ref());
|
||||
var project_name_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
||||
const project_name = std.fs.cwd().realpath(".", &project_name_buf) catch "(none)";
|
||||
tp.env.get().str_set("project", project_name);
|
||||
// try project_manager_.open(project_name);
|
||||
const self = try a.create(Self);
|
||||
self.* = .{
|
||||
.a = a,
|
||||
|
@ -51,6 +59,7 @@ pub fn create(a: std.mem.Allocator, n: nc.Plane) !Widget {
|
|||
.floating_views = WidgetStack.init(a),
|
||||
.statusbar = undefined,
|
||||
.location_history = try location_history.create(),
|
||||
.project_manager = project_manager_,
|
||||
};
|
||||
try self.commands.init(self);
|
||||
const w = Widget.to(self);
|
||||
|
|
|
@ -33,7 +33,7 @@ const Self = @This();
|
|||
pub fn create(a: Allocator, parent: nc.Plane) !Widget {
|
||||
const self: *Self = try a.create(Self);
|
||||
self.* = try init(a, parent);
|
||||
self.show_cwd();
|
||||
self.show_project();
|
||||
return Widget.to(self);
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ pub fn receive(self: *Self, _: tp.pid_ref, m: tp.message) error{Exit}!bool {
|
|||
self.line = 0;
|
||||
self.column = 0;
|
||||
self.file_exists = true;
|
||||
self.show_cwd();
|
||||
self.show_project();
|
||||
}
|
||||
if (try m.match(.{ "B", nc.event_type.PRESS, nc.key.BUTTON1, tp.any, tp.any, tp.any, tp.any, tp.any })) {
|
||||
self.detailed = !self.detailed;
|
||||
|
@ -192,10 +192,12 @@ fn render_file_icon(self: *Self, _: *const Widget.Theme) void {
|
|||
self.plane.cursor_move_rel(0, 1) catch {};
|
||||
}
|
||||
|
||||
fn show_cwd(self: *Self) void {
|
||||
fn show_project(self: *Self) void {
|
||||
self.file_icon = "";
|
||||
self.file_color = 0x000001;
|
||||
self.name = std.fs.cwd().realpath(".", &self.name_buf) catch "(none)";
|
||||
const project_name = tp.env.get().str("project");
|
||||
@memcpy(self.name_buf[0..project_name.len], project_name);
|
||||
self.name = self.name_buf[0..project_name.len];
|
||||
self.abbrv_home();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue