Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add special call to clear the status window after user input #650

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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