Compare commits

..

No commits in common. "6f82b4aaf36176f5adeea6e2dfebabe896ccfdce" and "0ce522828d825e1dde5c3e5d7fbc471665201a1a" have entirely different histories.

3 changed files with 11 additions and 51 deletions

View file

@ -249,14 +249,6 @@
"inherit": "project", "inherit": "project",
"on_match_failure": "ignore", "on_match_failure": "ignore",
"press": [ "press": [
["f", "find_file"],
["e", "find_file"],
["n", "create_new_file"],
["o", "open_file"],
["r", "open_recent_project"],
["p", "open_command_palette"],
["t", "change_theme"],
["a", "add_task"],
["c", "open_config"], ["c", "open_config"],
["g", "open_gui_config"], ["g", "open_gui_config"],
["k", "open_keybind_config"], ["k", "open_keybind_config"],
@ -264,9 +256,6 @@
["ctrl+f ctrl+f ctrl+f ctrl+f ctrl+f", "home_sheeran"], ["ctrl+f ctrl+f ctrl+f ctrl+f ctrl+f", "home_sheeran"],
["ctrl+shift+r", "restart"], ["ctrl+shift+r", "restart"],
["f6", "open_config"], ["f6", "open_config"],
["v", "open_version_info"],
["ctrl+q", "quit"],
["q", "quit"],
["up", "home_menu_up"], ["up", "home_menu_up"],
["down", "home_menu_down"], ["down", "home_menu_down"],
["enter", "home_menu_activate"] ["enter", "home_menu_activate"]

View file

@ -44,7 +44,6 @@ pub fn create(
.on_click = on_click, .on_click = on_click,
.on_layout = layout, .on_layout = layout,
.on_render = render, .on_render = render,
.on_receive = receive,
.on_event = event_handler, .on_event = event_handler,
}); });
} }
@ -61,30 +60,9 @@ pub fn ctx_deinit(self: *Self) void {
if (self.behind) |p| self.allocator.free(p); if (self.behind) |p| self.allocator.free(p);
} }
fn on_click(self: *Self, _: *Button.State(Self)) void { fn on_click(_: *Self, _: *Button.State(Self)) void {
self.refresh_git_status();
command.executeName("show_git_status", .{}) catch {};
}
fn refresh_git_status(_: *Self) void {
git.status(0) catch {}; git.status(0) catch {};
} command.executeName("show_git_status", .{}) catch {};
pub fn receive(self: *Self, _: *Button.State(Self), _: tp.pid_ref, m: tp.message) error{Exit}!bool {
if (try m.match(.{ "E", tp.more }))
return self.process_event(m);
if (try m.match(.{ "PRJ", "open" }))
self.refresh_git_status();
return false;
}
fn process_event(self: *Self, m: tp.message) error{Exit}!bool {
if (try m.match(.{ tp.any, "dirty", tp.more }) or
try m.match(.{ tp.any, "save", tp.more }) or
try m.match(.{ tp.any, "open", tp.more }) or
try m.match(.{ tp.any, "close" }))
self.refresh_git_status();
return false;
} }
fn receive_git(self: *Self, _: tp.pid_ref, m: tp.message) MessageFilter.Error!bool { fn receive_git(self: *Self, _: tp.pid_ref, m: tp.message) MessageFilter.Error!bool {

View file

@ -200,34 +200,24 @@ fn render_terminal_title(self: *Self) void {
} }
pub fn receive(self: *Self, _: *Button.State(Self), _: tp.pid_ref, m: tp.message) error{Exit}!bool { pub fn receive(self: *Self, _: *Button.State(Self), _: tp.pid_ref, m: tp.message) error{Exit}!bool {
if (try m.match(.{ "E", tp.more }))
return self.process_event(m);
if (try m.match(.{ "PRJ", "open" })) {
if (!self.file)
self.show_project();
}
return false;
}
fn process_event(self: *Self, m: tp.message) error{Exit}!bool {
var file_path: []const u8 = undefined; var file_path: []const u8 = undefined;
var file_type: []const u8 = undefined; var file_type: []const u8 = undefined;
var file_icon: []const u8 = undefined; var file_icon: []const u8 = undefined;
var file_dirty: bool = undefined; var file_dirty: bool = undefined;
var eol_mode: Buffer.EolModeTag = @intFromEnum(Buffer.EolMode.lf); var eol_mode: Buffer.EolModeTag = @intFromEnum(Buffer.EolMode.lf);
if (try m.match(.{ tp.any, "pos", tp.extract(&self.lines), tp.extract(&self.line), tp.extract(&self.column) })) if (try m.match(.{ "E", "pos", tp.extract(&self.lines), tp.extract(&self.line), tp.extract(&self.column) }))
return false; return false;
if (try m.match(.{ tp.any, "dirty", tp.extract(&file_dirty) })) { if (try m.match(.{ "E", "dirty", tp.extract(&file_dirty) })) {
self.file_dirty = file_dirty; self.file_dirty = file_dirty;
} else if (try m.match(.{ tp.any, "eol_mode", tp.extract(&eol_mode), tp.extract(&self.utf8_sanitized) })) { } else if (try m.match(.{ "E", "eol_mode", tp.extract(&eol_mode), tp.extract(&self.utf8_sanitized) })) {
self.eol_mode = @enumFromInt(eol_mode); self.eol_mode = @enumFromInt(eol_mode);
} else if (try m.match(.{ tp.any, "save", tp.extract(&file_path) })) { } else if (try m.match(.{ "E", "save", tp.extract(&file_path) })) {
@memcpy(self.name_buf[0..file_path.len], file_path); @memcpy(self.name_buf[0..file_path.len], file_path);
self.name = self.name_buf[0..file_path.len]; self.name = self.name_buf[0..file_path.len];
self.file_exists = true; self.file_exists = true;
self.file_dirty = false; self.file_dirty = false;
self.name = project_manager.abbreviate_home(&self.name_buf, self.name); self.name = project_manager.abbreviate_home(&self.name_buf, self.name);
} else if (try m.match(.{ tp.any, "open", tp.extract(&file_path), tp.extract(&self.file_exists), tp.extract(&file_type), tp.extract(&file_icon), tp.extract(&self.file_color) })) { } else if (try m.match(.{ "E", "open", tp.extract(&file_path), tp.extract(&self.file_exists), tp.extract(&file_type), tp.extract(&file_icon), tp.extract(&self.file_color) })) {
self.eol_mode = .lf; self.eol_mode = .lf;
@memcpy(self.name_buf[0..file_path.len], file_path); @memcpy(self.name_buf[0..file_path.len], file_path);
self.name = self.name_buf[0..file_path.len]; self.name = self.name_buf[0..file_path.len];
@ -239,7 +229,7 @@ fn process_event(self: *Self, m: tp.message) error{Exit}!bool {
self.file_dirty = false; self.file_dirty = false;
self.name = project_manager.abbreviate_home(&self.name_buf, self.name); self.name = project_manager.abbreviate_home(&self.name_buf, self.name);
self.file = true; self.file = true;
} else if (try m.match(.{ tp.any, "close" })) { } else if (try m.match(.{ "E", "close" })) {
self.name = ""; self.name = "";
self.lines = 0; self.lines = 0;
self.line = 0; self.line = 0;
@ -248,6 +238,9 @@ fn process_event(self: *Self, m: tp.message) error{Exit}!bool {
self.file = false; self.file = false;
self.eol_mode = .lf; self.eol_mode = .lf;
self.show_project(); self.show_project();
} else if (try m.match(.{ "PRJ", "open" })) {
if (!self.file)
self.show_project();
} }
return false; return false;
} }