feat: add cli option to open the log view on startup

This commit is contained in:
CJ van den Berg 2024-03-21 22:48:49 +01:00
parent 4970f29905
commit a056a54104
2 changed files with 8 additions and 0 deletions

View file

@ -25,6 +25,7 @@ pub fn main() anyerror!void {
\\--no-trace Do not enable internal tracing.
\\--restore-session Restore restart session.
\\--show-input Open the input view on start.
\\--show-log Open the log view on start.
\\-l, --language <str> Force the language of the file to be opened.
\\<str>... File to open.
\\ Add +<LINE> to the command line or append
@ -85,6 +86,7 @@ pub fn main() anyerror!void {
env.set("restore-session", (res.args.@"restore-session" != 0));
env.set("no-alternate", (res.args.@"no-alternate" != 0));
env.set("show-input", (res.args.@"show-input" != 0));
env.set("show-log", (res.args.@"show-log" != 0));
env.set("no-sleep", (res.args.@"no-sleep" != 0));
env.set("dump-stack-trace", (res.args.@"debug-dump-on-error" != 0));
if (res.args.@"frame-rate") |s| env.num_set("frame-rate", @intCast(s));

View file

@ -62,6 +62,8 @@ pub fn create(a: std.mem.Allocator, n: nc.Plane) !Widget {
self.resize();
if (tp.env.get().is("show-input"))
self.toggle_inputview_async();
if (tp.env.get().is("show-log"))
self.toggle_logview_async();
return w;
}
@ -339,6 +341,10 @@ fn create_editor(self: *Self) tp.result {
self.resize();
}
fn toggle_logview_async(_: *Self) void {
tp.self_pid().send(.{ "cmd", "toggle_logview" }) catch return;
}
fn toggle_inputview_async(_: *Self) void {
tp.self_pid().send(.{ "cmd", "toggle_inputview" }) catch return;
}