Skip to content

Commit

Permalink
Allow exit of command-line mode
Browse files Browse the repository at this point in the history
  • Loading branch information
coditva committed Nov 22, 2017
1 parent baab60e commit e14dd4f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ command_t * get_command_line()

command = (command_t *) malloc(sizeof(command_t));
line = interface_input_command();
if (line == NULL) {
return 0;
}

if (!strcmp(line, "quit") || !strcmp(line, "q")) {
command -> type = COMMAND_QUIT;
Expand Down
12 changes: 9 additions & 3 deletions src/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,16 @@ char * interface_input_command()
case KEY_BACKSPACE:
case KEY_DC:
case 127:
if (i) {
mvwprintw(command_window, 0, i, " ");
line[--i] = '\0';
if (!i) { /* exit out of command-line command */
free(line);
curs_set(0);
noecho();
wclear(command_window);
wrefresh(command_window);
return NULL;
}

line[--i] = '\0';
mvwprintw(command_window, 0, i + 1, " ");
break;

Expand Down

0 comments on commit e14dd4f

Please sign in to comment.