Skip to content

Commit

Permalink
Add special call to clear the status window after user input
Browse files Browse the repository at this point in the history
Follow-up to aa84d85 to fix performance
regression noted in #649. Also cleans up open_prompt to not clear the
status window.
  • Loading branch information
jonas committed Jul 6, 2017
1 parent 4c6c5d8 commit 4312b77
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
1 change: 1 addition & 0 deletions include/tig/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extern WINDOW *status_win;
void update_status(const char *msg, ...);
void report(const char *msg, ...) PRINTF_LIKE(1, 2);
void report_clear(void);
void status_clear(void);

/*
* Display management.
Expand Down
25 changes: 18 additions & 7 deletions src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,18 +424,29 @@ report(const char *msg, ...)
void
report_clear(void)
{
struct view *view = display[current_view];

if (!view)
if (input_mode)
return;

if (!input_mode && !status_empty) {
wclear(status_win);
wclrtoeol(status_win);
if (!status_empty) {
werase(status_win);
wnoutrefresh(status_win);
}
status_empty = true;
update_view_title(view);

update_view_title(display[current_view]);
}

void
status_clear(void)
{
if (input_mode)
return;

werase(status_win);
wclear(status_win);
wnoutrefresh(status_win);
status_empty = true;
update_view_title(display[current_view]);
}

static void
Expand Down
14 changes: 6 additions & 8 deletions src/prompt.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ prompt_input(const char *prompt, struct input *input)
}

curs_set(0);
report_clear();
status_clear();

if (status == INPUT_CANCEL)
return NULL;
Expand Down Expand Up @@ -470,6 +470,7 @@ read_prompt(const char *prompt)
curs_set(1);
line = readline(prompt);
curs_set(0);
status_clear();

if (signal(SIGINT, SIG_DFL) == SIG_ERR)
die("Failed to remove sigint handler");
Expand Down Expand Up @@ -596,8 +597,7 @@ prompt_menu(const char *prompt, const struct menu_item *items, int *selected)
}
}
curs_set(0);

report_clear();
status_clear();

return status != INPUT_CANCEL;
}
Expand Down Expand Up @@ -1043,13 +1043,11 @@ open_prompt(struct view *view)
const char *argv[SIZEOF_ARG] = { NULL };
int argc = 0;

if (cmd && !argv_from_string(argv, &argc, cmd)) {
report("Too many arguments");
if (!cmd)
return REQ_NONE;
}

if (!cmd) {
report_clear();
if (!argv_from_string(argv, &argc, cmd)) {
report("Too many arguments");
return REQ_NONE;
}

Expand Down

0 comments on commit 4312b77

Please sign in to comment.