diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2015-06-28 09:16:24 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2015-06-28 09:16:24 +0200 |
commit | 7fabe8c2a28d973b24e7d952562bdfb340cbb541 (patch) | |
tree | 73f175319d3a74d7199e08e23c7622d1746316cd /src/gui/curses | |
parent | d9acb2b97ad91f9c9d4ad4b7f8eb3cd31d773da6 (diff) | |
download | weechat-7fabe8c2a28d973b24e7d952562bdfb340cbb541.zip |
core: allow ctrl-C to exit WeeChat when the passphrase is asked on startup (closes #452)
Diffstat (limited to 'src/gui/curses')
-rw-r--r-- | src/gui/curses/gui-curses-main.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c index e01fa20bf..f83d8324a 100644 --- a/src/gui/curses/gui-curses-main.c +++ b/src/gui/curses/gui-curses-main.c @@ -74,22 +74,26 @@ int gui_term_lines = 0; /* number of lines in terminal */ */ void -gui_main_get_password (const char *prompt1, const char *prompt2, - const char *prompt3, - char *password, int size) +gui_main_get_password (const char **prompt, char *password, int size) { - int i, ch; + int line, i, ch; initscr (); cbreak (); noecho (); + raw (); clear(); - mvaddstr (0, 0, prompt1); - mvaddstr (1, 0, prompt2); - mvaddstr (2, 0, prompt3); - mvaddstr (3, 0, "=> "); + line = 0; + + while (prompt[line]) + { + mvaddstr (line, 0, prompt[line]); + line++; + } + + mvaddstr (line, 0, "=> "); refresh (); memset (password, '\0', size); @@ -97,22 +101,30 @@ gui_main_get_password (const char *prompt1, const char *prompt2, while (i < size - 1) { ch = getch (); + /* enter */ if (ch == '\n') break; + /* ctrl-C */ + if (ch == 3) + { + password[0] = 3; + i = 1; + break; + } if (ch == 127) { if (i > 0) { i--; password[i] = '\0'; - mvaddstr (3, 3 + i, " "); - move (3, 3 + i); + mvaddstr (line, 3 + i, " "); + move (line, 3 + i); } } else { password[i] = ch; - mvaddstr (3, 3 + i, "*"); + mvaddstr (line, 3 + i, "*"); i++; } refresh (); |