From 57de9feaa508fdd83c0d08c499232187c5f4b6c1 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sat, 21 Dec 2019 15:27:17 +0100 Subject: term: term_spawn_new(): new function, spawns a new foot/footclient process Bind ctrl+shift+return to it --- terminal.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'terminal.h') diff --git a/terminal.h b/terminal.h index 4d82aeaa..b7a92be4 100644 --- a/terminal.h +++ b/terminal.h @@ -314,12 +314,14 @@ struct terminal { bool is_shutting_down; void (*shutdown_cb)(void *data, int exit_code); void *shutdown_data; + + char *foot_exe; }; struct config; struct terminal *term_init( const struct config *conf, struct fdm *fdm, struct wayland *wayl, - const char *term_env, int argc, char *const *argv, + const char *term_env, const char *foot_exe, int argc, char *const *argv, void (*shutdown_cb)(void *data, int exit_code), void *shutdown_data); bool term_shutdown(struct terminal *term); @@ -379,3 +381,4 @@ void term_xcursor_update(struct terminal *term); void term_set_window_title(struct terminal *term, const char *title); void term_flash(struct terminal *term, unsigned duration_ms); +bool term_spawn_new(const struct terminal *term); -- cgit v1.3 From 016bde1bd4135a4a7d48e1c864a223cc6cedaf0e Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sat, 21 Dec 2019 15:35:54 +0100 Subject: term: wip: track current working directory This sets the initial current working directory, as it is when the terminal is instantiated. We chdir() to it just before spawning a new terminal. --- terminal.c | 13 +++++++++++++ terminal.h | 1 + 2 files changed, 14 insertions(+) (limited to 'terminal.h') diff --git a/terminal.c b/terminal.c index bd79bd08..f7f98407 100644 --- a/terminal.c +++ b/terminal.c @@ -601,8 +601,18 @@ term_init(const struct config *conf, struct fdm *fdm, struct wayland *wayl, .shutdown_cb = shutdown_cb, .shutdown_data = shutdown_data, .foot_exe = strdup(foot_exe), + .cwd = NULL, }; + { + size_t buf_len = 1024; + do { + term->cwd = realloc(term->cwd, buf_len); + getcwd(term->cwd, buf_len); + buf_len *= 2; + } while (errno == ERANGE); + } + initialize_color_cube(term); if (!initialize_render_workers(term)) goto err; @@ -831,7 +841,9 @@ term_destroy(struct terminal *term) free(it->item.data); tll_free(term->ptmx_buffer); tll_free(term->tab_stops); + free(term->foot_exe); + free(term->cwd); int ret = EXIT_SUCCESS; @@ -1672,6 +1684,7 @@ term_spawn_new(const struct terminal *term) if (pid2 == 0) { /* Child */ close(pipe_fds[0]); + chdir(term->cwd); execlp(term->foot_exe, term->foot_exe, NULL); write(pipe_fds[1], &errno, sizeof(errno)); _exit(errno); diff --git a/terminal.h b/terminal.h index b7a92be4..0fe4c4dc 100644 --- a/terminal.h +++ b/terminal.h @@ -316,6 +316,7 @@ struct terminal { void *shutdown_data; char *foot_exe; + char *cwd; }; struct config; -- cgit v1.3