Compare commits
2 commits
d67e01086c
...
5835f5b8f7
Author | SHA1 | Date | |
---|---|---|---|
5835f5b8f7 | |||
462ce7b792 |
1 changed files with 56 additions and 49 deletions
19
ccc.c
19
ccc.c
|
@ -173,7 +173,7 @@ int main(int argc, char **argv)
|
||||||
/* go back */
|
/* go back */
|
||||||
case BACKSPACE:
|
case BACKSPACE:
|
||||||
case ARROW_LEFT:
|
case ARROW_LEFT:
|
||||||
case 'h':;
|
case 'h':
|
||||||
/* get parent directory */
|
/* get parent directory */
|
||||||
strcpy(p_cwd, cwd);
|
strcpy(p_cwd, cwd);
|
||||||
char *last_slash = strrchr(cwd, '/');
|
char *last_slash = strrchr(cwd, '/');
|
||||||
|
@ -1002,8 +1002,19 @@ void edit_file(void)
|
||||||
char command[length];
|
char command[length];
|
||||||
|
|
||||||
snprintf(command, length, "%s %s", editor, filename);
|
snprintf(command, length, "%s %s", editor, filename);
|
||||||
system(command);
|
pid_t pid = fork();
|
||||||
|
if (pid == 0) {
|
||||||
|
/* Child process */
|
||||||
|
execlp(editor, editor, filename, NULL);
|
||||||
|
_exit(1); /* Exit if exec fails */
|
||||||
|
} else if (pid > 0) {
|
||||||
|
/* Parent process */
|
||||||
|
waitpid(pid, NULL, 0);
|
||||||
list_files();
|
list_files();
|
||||||
|
} else {
|
||||||
|
/* Fork failed */
|
||||||
|
wpprintw("fork failed: %s", strerror(errno));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1242,10 +1253,6 @@ int read_key(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *f = fopen("/home/night/a", "a");
|
|
||||||
fprintf(f, "c: %d\n", c);
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
if (c == '\033') {
|
if (c == '\033') {
|
||||||
char seq[3];
|
char seq[3];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue