feat: add recent files request to project manager
This commit is contained in:
parent
28178d8871
commit
01d53bb079
1 changed files with 14 additions and 0 deletions
|
@ -103,6 +103,8 @@ const Process = struct {
|
||||||
});
|
});
|
||||||
} else if (try m.match(.{ "open", tp.extract(&project_directory) })) {
|
} else if (try m.match(.{ "open", tp.extract(&project_directory) })) {
|
||||||
self.open(project_directory) catch |e| return from.send_raw(tp.exit_message(e));
|
self.open(project_directory) catch |e| return from.send_raw(tp.exit_message(e));
|
||||||
|
} else if (try m.match(.{ "request_recent_files", tp.extract(&project_directory) })) {
|
||||||
|
self.request_recent_files(from, project_directory) catch |e| return from.send_raw(tp.exit_message(e));
|
||||||
} else if (try m.match(.{"shutdown"})) {
|
} else if (try m.match(.{"shutdown"})) {
|
||||||
return tp.exit_normal();
|
return tp.exit_normal();
|
||||||
} else if (try m.match(.{ "exit", "normal" })) {
|
} else if (try m.match(.{ "exit", "normal" })) {
|
||||||
|
@ -121,6 +123,11 @@ const Process = struct {
|
||||||
try walk_tree_async(self.a, project_directory);
|
try walk_tree_async(self.a, project_directory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn request_recent_files(self: *Process, from: tp.pid_ref, project_directory: []const u8) error{ OutOfMemory, Exit }!void {
|
||||||
|
const project = if (self.projects.get(project_directory)) |p| p else return tp.exit("No project");
|
||||||
|
return project.request_recent_files(from);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const Project = struct {
|
const Project = struct {
|
||||||
|
@ -151,6 +158,13 @@ const Project = struct {
|
||||||
if (self.files.get(path) != null) return;
|
if (self.files.get(path) != null) return;
|
||||||
try self.files.put(try self.a.dupe(u8, path), {});
|
try self.files.put(try self.a.dupe(u8, path), {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn request_recent_files(self: *Project, from: tp.pid_ref) error{ OutOfMemory, Exit }!void {
|
||||||
|
var i = self.files.iterator();
|
||||||
|
while (i.next()) |file| {
|
||||||
|
try from.send(.{ "PRJ", "recent", file.key_ptr.* });
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fn walk_tree_async(a_: std.mem.Allocator, root_path_: []const u8) tp.result {
|
fn walk_tree_async(a_: std.mem.Allocator, root_path_: []const u8) tp.result {
|
||||||
|
|
Loading…
Add table
Reference in a new issue