diff options
author | Jakob Kaivo <jkk@ung.org> | 2022-04-18 20:39:06 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2022-04-18 20:39:06 -0400 |
commit | c76a9e403ab6b0759261b5211a370e8314fb4c94 (patch) | |
tree | e3016f2df3e1a0d14b2c8781dd64948868c812fc | |
parent | 9d6384a67dd6c2e86bbd060871644e06211cae16 (diff) |
better editor support
-rw-r--r-- | more.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -95,7 +95,7 @@ static struct more_file more_invoke_editor(struct more_file *mf) } char line[64]; - snprintf(line, sizeof(line), "%zd", mf->topline); + snprintf(line, sizeof(line), "%zd", mf->topline + 1); char *argv[] = { editor, "-c", line, mf->path, NULL }; char *base = editor; @@ -116,11 +116,18 @@ static struct more_file more_invoke_editor(struct more_file *mf) pid_t pid; if (posix_spawnp(&pid, editor, NULL, NULL, argv, environ) == 0) { char *path = strdup(mf->path); + size_t line = mf->topline; more_close(mf); + waitpid(pid, NULL, 0); + ret = more_open(path); + ret.topline = line; free(path); + } else { + wprintw(more_status, "%s %s: %s\n", editor, mf->path, strerror(errno)); } + reset_prog_mode(); return ret; @@ -314,7 +321,7 @@ static int more(const char *path) break; case 'v': - more_invoke_editor(&mf); + mf = more_invoke_editor(&mf); break; case '=': |