mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-22 05:33:45 -04:00
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.
This commit is contained in:
parent
a484a65fef
commit
016bde1bd4
2 changed files with 14 additions and 0 deletions
13
terminal.c
13
terminal.c
|
|
@ -601,8 +601,18 @@ term_init(const struct config *conf, struct fdm *fdm, struct wayland *wayl,
|
||||||
.shutdown_cb = shutdown_cb,
|
.shutdown_cb = shutdown_cb,
|
||||||
.shutdown_data = shutdown_data,
|
.shutdown_data = shutdown_data,
|
||||||
.foot_exe = strdup(foot_exe),
|
.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);
|
initialize_color_cube(term);
|
||||||
if (!initialize_render_workers(term))
|
if (!initialize_render_workers(term))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
@ -831,7 +841,9 @@ term_destroy(struct terminal *term)
|
||||||
free(it->item.data);
|
free(it->item.data);
|
||||||
tll_free(term->ptmx_buffer);
|
tll_free(term->ptmx_buffer);
|
||||||
tll_free(term->tab_stops);
|
tll_free(term->tab_stops);
|
||||||
|
|
||||||
free(term->foot_exe);
|
free(term->foot_exe);
|
||||||
|
free(term->cwd);
|
||||||
|
|
||||||
int ret = EXIT_SUCCESS;
|
int ret = EXIT_SUCCESS;
|
||||||
|
|
||||||
|
|
@ -1672,6 +1684,7 @@ term_spawn_new(const struct terminal *term)
|
||||||
if (pid2 == 0) {
|
if (pid2 == 0) {
|
||||||
/* Child */
|
/* Child */
|
||||||
close(pipe_fds[0]);
|
close(pipe_fds[0]);
|
||||||
|
chdir(term->cwd);
|
||||||
execlp(term->foot_exe, term->foot_exe, NULL);
|
execlp(term->foot_exe, term->foot_exe, NULL);
|
||||||
write(pipe_fds[1], &errno, sizeof(errno));
|
write(pipe_fds[1], &errno, sizeof(errno));
|
||||||
_exit(errno);
|
_exit(errno);
|
||||||
|
|
|
||||||
|
|
@ -316,6 +316,7 @@ struct terminal {
|
||||||
void *shutdown_data;
|
void *shutdown_data;
|
||||||
|
|
||||||
char *foot_exe;
|
char *foot_exe;
|
||||||
|
char *cwd;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct config;
|
struct config;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue