refactor: change `spawn_terminal` to take in the terminal name directly instead of wm instance
Browse files
+2 −4 src/main.zig
| @@ -535,7 +535,7 @@ fn handle_key_press(event: *xlib.XKeyEvent, wm: *WindowManager) void { | ||
| 535 | 535 | |
| 536 | 536 | fn execute_action(action: config_mod.Action, int_arg: i32, str_arg: ?[]const u8, wm: *WindowManager) void { |
| 537 | 537 | switch (action) { |
| 538 | - .spawn_terminal => spawn_terminal(wm), | |
| 538 | + .spawn_terminal => spawn_terminal(wm.config.terminal), | |
| 539 | 539 | .spawn => { |
| 540 | 540 | if (str_arg) |cmd| spawn_command(cmd); |
| 541 | 541 | }, |
| @@ -623,13 +623,11 @@ fn spawn_command(cmd: []const u8) void { | ||
| 623 | 623 | } |
| 624 | 624 | } |
| 625 | 625 | |
| 626 | -// TODO: take in the terminal cmd directly. | |
| 627 | -fn spawn_terminal(wm: *WindowManager) void { | |
| 626 | +fn spawn_terminal(terminal: []const u8) void { | |
| 628 | 627 | const pid = std.posix.fork() catch return; |
| 629 | 628 | if (pid == 0) { |
| 630 | 629 | spawn_child_setup(); |
| 631 | 630 | var term_buf: [256]u8 = undefined; |
| 632 | - const terminal = wm.config.terminal; | |
| 633 | 631 | if (terminal.len >= term_buf.len) { |
| 634 | 632 | std.posix.exit(1); |
| 635 | 633 | } |