aboutsummaryrefslogtreecommitdiff
path: root/bb.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-05-21 22:41:22 -0700
committerBruce Hill <bruce@bruce-hill.com>2019-05-21 22:41:22 -0700
commitb7b6b6cc74a477a3745d06bce64e284e5b2dd880 (patch)
tree7eb0fbada09039ec8ffa5b0fb7895c625db8964f /bb.c
parentbff00bf75513cefc8e0814ba88777f13811c8a6d (diff)
Added ctrl-z for suspend and added a sort of hybrid mode for running
commands at the bottom of the screen instead of in a full terminal mode.
Diffstat (limited to 'bb.c')
-rw-r--r--bb.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/bb.c b/bb.c
index dcee840..27c3461 100644
--- a/bb.c
+++ b/bb.c
@@ -535,6 +535,12 @@ static void explore(char *path, int print_dir, int print_selection)
_exit(1);
return;
+ case KEY_CTRL_Z:
+ close_term();
+ raise(SIGTSTP);
+ init_term();
+ goto redraw;
+
case 'q': case 'Q':
goto done;
@@ -807,26 +813,29 @@ static void explore(char *path, int print_dir, int print_selection)
default:
for (int i = 0; bindings[i].key; i++) {
if (key == bindings[i].key) {
- if (!(bindings[i].flags & SILENT))
+ term_move(0, height-1);
+ if (!(bindings[i].flags & ONSCREEN))
close_term();
+ else {
+ // Show cursor:
+ writez(termfd, "\e[?25h");
+ tcsetattr(termfd, TCSAFLUSH, &orig_termios);
+ close(termfd);
+ }
- int fd;
+ int scriptinfd;
pid_t child;
- child = run_cmd(NULL, &fd, bindings[i].command);
-
+ child = run_cmd(NULL, &scriptinfd, bindings[i].command);
if (!(bindings[i].flags & NO_FILES)) {
if (state.nselected > 0) {
- write_selection(fd, state.firstselected);
+ write_selection(scriptinfd, state.firstselected);
} else if (strcmp(state.files[state.cursor]->d_name, "..") != 0) {
- write(fd, state.files[state.cursor]->d_name, state.files[state.cursor]->d_namlen);
+ write(scriptinfd, state.files[state.cursor]->d_name, state.files[state.cursor]->d_namlen);
}
}
-
- close(fd);
+ close(scriptinfd);
waitpid(child, NULL, 0);
-
- if (!(bindings[i].flags & SILENT))
- init_term();
+ init_term();
if (bindings[i].flags & CLEAR_SELECTION)
clear_selection(&state);