Skip to content

Commit

Permalink
Merge branch 'hide-cursor' of https://github.com/rolandwalker/tig
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas committed Jul 4, 2017
2 parents 23c2fde + 1b62768 commit 9c9a217
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ init_display(void)
nonl(); /* Disable conversion and detect newlines from input. */
raw(); /* Take input chars one at a time, no wait for \n */
noecho(); /* Don't echo input */
curs_set(0);
leaveok(stdscr, false);

init_colors();
Expand Down
9 changes: 9 additions & 0 deletions src/prompt.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ prompt_input(const char *prompt, struct input *input)

input->buf[0] = 0;

if (strlen(prompt) > 0)
curs_set(1);

while (status == INPUT_OK || status == INPUT_SKIP) {
int buf_length = strlen(input->buf) + promptlen;
int offset = pos || buf_length != last_buf_length ? pos + promptlen : -1;
Expand All @@ -52,6 +55,7 @@ prompt_input(const char *prompt, struct input *input)

if (pos + len >= sizeof(input->buf)) {
report("Input string too long");
curs_set(0);
return NULL;
}

Expand Down Expand Up @@ -89,6 +93,7 @@ prompt_input(const char *prompt, struct input *input)
input->buf[pos] = 0;
}

curs_set(0);
report_clear();

if (status == INPUT_CANCEL)
Expand Down Expand Up @@ -462,7 +467,9 @@ read_prompt(const char *prompt)
if (signal(SIGINT, sigint_absorb_handler) == SIG_ERR)
die("Failed to setup sigint handler");

curs_set(1);
line = readline(prompt);
curs_set(0);

if (signal(SIGINT, SIG_DFL) == SIG_ERR)
die("Failed to remove sigint handler");
Expand Down Expand Up @@ -542,6 +549,7 @@ prompt_menu(const char *prompt, const struct menu_item *items, int *selected)

assert(size > 0);

curs_set(1);
while (status == INPUT_OK) {
const struct menu_item *item = &items[*selected];
char hotkey[] = { '[', (char) item->hotkey, ']', ' ', 0 };
Expand Down Expand Up @@ -587,6 +595,7 @@ prompt_menu(const char *prompt, const struct menu_item *items, int *selected)
}
}
}
curs_set(0);

report_clear();

Expand Down

0 comments on commit 9c9a217

Please sign in to comment.