Compare commits
4 commits
d67e01086c
...
3fe500d761
Author | SHA1 | Date | |
---|---|---|---|
3fe500d761 | |||
34254a9fe4 | |||
5835f5b8f7 | |||
462ce7b792 |
1 changed files with 56 additions and 54 deletions
24
ccc.c
24
ccc.c
|
@ -152,7 +152,6 @@ int main(int argc, char **argv)
|
|||
int ch, ch2;
|
||||
int run = 1;
|
||||
while (run) {
|
||||
|
||||
ch = read_key();
|
||||
switch (ch) {
|
||||
/* quit */
|
||||
|
@ -173,7 +172,7 @@ int main(int argc, char **argv)
|
|||
/* go back */
|
||||
case BACKSPACE:
|
||||
case ARROW_LEFT:
|
||||
case 'h':;
|
||||
case 'h':
|
||||
/* get parent directory */
|
||||
strcpy(p_cwd, cwd);
|
||||
char *last_slash = strrchr(cwd, '/');
|
||||
|
@ -997,13 +996,20 @@ void edit_file(void)
|
|||
return;
|
||||
} else {
|
||||
char *filename = files->items[sel_file].path;
|
||||
/* 1 for space 1 for null */
|
||||
int length = strlen(editor) + strlen(filename) + 2;
|
||||
char command[length];
|
||||
|
||||
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();
|
||||
} else {
|
||||
/* Fork failed */
|
||||
wpprintw("fork failed: %s", strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1242,10 +1248,6 @@ int read_key(void)
|
|||
}
|
||||
}
|
||||
|
||||
FILE *f = fopen("/home/night/a", "a");
|
||||
fprintf(f, "c: %d\n", c);
|
||||
fclose(f);
|
||||
|
||||
if (c == '\033') {
|
||||
char seq[3];
|
||||
|
||||
|
|
Loading…
Reference in a new issue