Artifact 01fe62e14db6e5d6125c12d2fcd6f0f2176f7f3ea05bd50e730a6aeeb6247851:
- File
src/ui.c
— part of check-in
[58b6e98d51]
at
2014-01-06 11:10:08
on branch origin/tweaks
— Work-around for segfault & data corruption when secring is not available
A couple of things here:
1) I probably use PWMan in a way that wasn't intended: I only make my
secret key available to in temporarily, once authorised I delete the
secring.gpg file entirely so it isn't hanging about on a machine. So
when it times out I need to remember to copy my key back to the machine
before I try to re-authorise. Sometimes I forget and ...2) It seems that for reasons I don't have the inclination or ability to
figure out, PWMan segfaults on exit when the secring.gpg isn't available
or is 0 bytes (or, probably, doesn't contain the required secret key).
This on it's own isn't a bad thing, but when it does this it also seems
to have a nasty habit of corrupting the password database; not always in
an immediately obvious manner so I can end up "backing up" this
corrupted version.So as a workaround (for my usage circumstances), this fix checks whether
the secring file is 0 bytes and if it is waits until it isn't (I.e. I've
copied it back to the machine) before asking for re-authorisation.This isn't perfect as it only waits once. I.e. if it recognises the
secring is available it'll prompt for the password, but it is possible
that in this time I could get distracted and come back after the secring
file is removed again (since I remove it automatically) and forget and
cause a segfault, but then I've only my stupid self to blame. (user: base@atomicules.co.uk size: 13300) - File ui.c — part of check-in [91957153ef] at 2014-05-15 22:23:27 on branch origin/tweaks — Merge branch 'manualheaven' into tweaks (user: base@atomicules.co.uk size: 13300)
0000: 2f 2a 0a 20 2a 20 20 50 57 4d 61 6e 20 2d 20 70 /*. * PWMan - p
0010: 61 73 73 77 6f 72 64 20 6d 61 6e 61 67 65 6d 65 assword manageme
0020: 6e 74 20 61 70 70 6c 69 63 61 74 69 6f 6e 0a 20 nt application.
0030: 2a 0a 20 2a 20 20 43 6f 70 79 72 69 67 68 74 20 *. * Copyright
0040: 28 43 29 20 32 30 30 32 20 20 49 76 61 6e 20 4b (C) 2002 Ivan K
0050: 65 6c 6c 79 20 3c 69 76 61 6e 40 69 76 61 6e 6b elly <ivan@ivank
0060: 65 6c 6c 79 2e 6e 65 74 3e 0a 20 2a 0a 20 2a 20 elly.net>. *. *
0070: 20 54 68 69 73 20 70 72 6f 67 72 61 6d 20 69 73 This program is
0080: 20 66 72 65 65 20 73 6f 66 74 77 61 72 65 3b 20 free software;
0090: 79 6f 75 20 63 61 6e 20 72 65 64 69 73 74 72 69 you can redistri
00a0: 62 75 74 65 20 69 74 20 61 6e 64 2f 6f 72 20 6d bute it and/or m
00b0: 6f 64 69 66 79 0a 20 2a 20 20 69 74 20 75 6e 64 odify. * it und
00c0: 65 72 20 74 68 65 20 74 65 72 6d 73 20 6f 66 20 er the terms of
00d0: 74 68 65 20 47 4e 55 20 47 65 6e 65 72 61 6c 20 the GNU General
00e0: 50 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 20 61 Public License a
00f0: 73 20 70 75 62 6c 69 73 68 65 64 20 62 79 0a 20 s published by.
0100: 2a 20 20 74 68 65 20 46 72 65 65 20 53 6f 66 74 * the Free Soft
0110: 77 61 72 65 20 46 6f 75 6e 64 61 74 69 6f 6e 3b ware Foundation;
0120: 20 65 69 74 68 65 72 20 76 65 72 73 69 6f 6e 20 either version
0130: 32 20 6f 66 20 74 68 65 20 4c 69 63 65 6e 73 65 2 of the License
0140: 2c 20 6f 72 0a 20 2a 20 20 28 61 74 20 79 6f 75 , or. * (at you
0150: 72 20 6f 70 74 69 6f 6e 29 20 61 6e 79 20 6c 61 r option) any la
0160: 74 65 72 20 76 65 72 73 69 6f 6e 2e 0a 20 2a 0a ter version.. *.
0170: 20 2a 20 20 54 68 69 73 20 70 72 6f 67 72 61 6d * This program
0180: 20 69 73 20 64 69 73 74 72 69 62 75 74 65 64 20 is distributed
0190: 69 6e 20 74 68 65 20 68 6f 70 65 20 74 68 61 74 in the hope that
01a0: 20 69 74 20 77 69 6c 6c 20 62 65 20 75 73 65 66 it will be usef
01b0: 75 6c 2c 0a 20 2a 20 20 62 75 74 20 57 49 54 48 ul,. * but WITH
01c0: 4f 55 54 20 41 4e 59 20 57 41 52 52 41 4e 54 59 OUT ANY WARRANTY
01d0: 3b 20 77 69 74 68 6f 75 74 20 65 76 65 6e 20 74 ; without even t
01e0: 68 65 20 69 6d 70 6c 69 65 64 20 77 61 72 72 61 he implied warra
01f0: 6e 74 79 20 6f 66 0a 20 2a 20 20 4d 45 52 43 48 nty of. * MERCH
0200: 41 4e 54 41 42 49 4c 49 54 59 20 6f 72 20 46 49 ANTABILITY or FI
0210: 54 4e 45 53 53 20 46 4f 52 20 41 20 50 41 52 54 TNESS FOR A PART
0220: 49 43 55 4c 41 52 20 50 55 52 50 4f 53 45 2e 20 ICULAR PURPOSE.
0230: 20 53 65 65 20 74 68 65 0a 20 2a 20 20 47 4e 55 See the. * GNU
0240: 20 47 65 6e 65 72 61 6c 20 50 75 62 6c 69 63 20 General Public
0250: 4c 69 63 65 6e 73 65 20 66 6f 72 20 6d 6f 72 65 License for more
0260: 20 64 65 74 61 69 6c 73 2e 0a 20 2a 0a 20 2a 20 details.. *. *
0270: 20 59 6f 75 20 73 68 6f 75 6c 64 20 68 61 76 65 You should have
0280: 20 72 65 63 65 69 76 65 64 20 61 20 63 6f 70 79 received a copy
0290: 20 6f 66 20 74 68 65 20 47 4e 55 20 47 65 6e 65 of the GNU Gene
02a0: 72 61 6c 20 50 75 62 6c 69 63 20 4c 69 63 65 6e ral Public Licen
02b0: 73 65 0a 20 2a 20 20 61 6c 6f 6e 67 20 77 69 74 se. * along wit
02c0: 68 20 74 68 69 73 20 70 72 6f 67 72 61 6d 3b 20 h this program;
02d0: 69 66 20 6e 6f 74 2c 20 77 72 69 74 65 20 74 6f if not, write to
02e0: 20 74 68 65 20 46 72 65 65 20 53 6f 66 74 77 61 the Free Softwa
02f0: 72 65 0a 20 2a 20 20 46 6f 75 6e 64 61 74 69 6f re. * Foundatio
0300: 6e 2c 20 49 6e 63 2e 2c 20 35 39 20 54 65 6d 70 n, Inc., 59 Temp
0310: 6c 65 20 50 6c 61 63 65 2c 20 53 75 69 74 65 20 le Place, Suite
0320: 33 33 30 2c 20 42 6f 73 74 6f 6e 2c 20 4d 41 20 330, Boston, MA
0330: 20 30 32 31 31 31 2d 31 33 30 37 20 20 55 53 41 02111-1307 USA
0340: 0a 20 2a 2f 0a 0a 23 69 6e 63 6c 75 64 65 20 3c . */..#include <
0350: 70 77 6d 61 6e 2e 68 3e 0a 23 69 6e 63 6c 75 64 pwman.h>.#includ
0360: 65 20 3c 75 69 2e 68 3e 0a 23 69 6e 63 6c 75 64 e <ui.h>.#includ
0370: 65 20 3c 68 65 6c 70 2e 68 3e 0a 23 69 6e 63 6c e <help.h>.#incl
0380: 75 64 65 20 3c 74 69 6d 65 2e 68 3e 0a 23 69 6e ude <time.h>.#in
0390: 63 6c 75 64 65 20 3c 73 74 64 6c 69 62 2e 68 3e clude <stdlib.h>
03a0: 0a 23 69 6e 63 6c 75 64 65 20 3c 73 79 73 2f 73 .#include <sys/s
03b0: 74 61 74 2e 68 3e 0a 0a 63 68 61 72 20 2a 20 73 tat.h>..char * s
03c0: 74 61 74 75 73 6c 69 6e 65 5f 61 73 6b 5f 73 74 tatusline_ask_st
03d0: 72 28 63 68 61 72 20 2a 2c 20 63 68 61 72 2a 2c r(char *, char*,
03e0: 20 69 6e 74 29 3b 0a 50 77 20 2a 67 65 74 5f 68 int);.Pw *get_h
03f0: 69 67 68 6c 69 67 68 74 65 64 5f 69 74 65 6d 28 ighlighted_item(
0400: 29 3b 0a 0a 69 6e 74 20 73 68 6f 75 6c 64 5f 72 );..int should_r
0410: 65 73 69 7a 65 20 3d 20 46 41 4c 53 45 3b 0a 69 esize = FALSE;.i
0420: 6e 74 20 63 61 6e 5f 72 65 73 69 7a 65 20 3d 20 nt can_resize =
0430: 46 41 4c 53 45 3b 0a 0a 0a 57 49 4e 44 4f 57 20 FALSE;...WINDOW
0440: 2a 74 6f 70 20 3d 20 4e 55 4c 4c 2c 20 2a 62 6f *top = NULL, *bo
0450: 74 74 6f 6d 20 3d 20 4e 55 4c 4c 3b 0a 65 78 74 ttom = NULL;.ext
0460: 65 72 6e 20 69 6e 74 20 63 75 72 69 74 65 6d 2c ern int curitem,
0470: 20 6c 69 6e 65 73 3b 0a 65 78 74 65 72 6e 20 57 lines;.extern W
0480: 49 4e 44 4f 57 20 2a 6c 69 73 74 3b 0a 0a 69 6e INDOW *list;..in
0490: 74 0a 75 69 5f 64 72 61 77 5f 74 6f 70 28 29 0a t.ui_draw_top().
04a0: 7b 0a 09 77 65 72 61 73 65 28 74 6f 70 29 3b 0a {..werase(top);.
04b0: 09 6d 76 77 68 6c 69 6e 65 28 74 6f 70 2c 20 31 .mvwhline(top, 1
04c0: 2c 20 30 2c 20 41 43 53 5f 48 4c 49 4e 45 2c 20 , 0, ACS_HLINE,
04d0: 43 4f 4c 53 29 3b 0a 09 69 66 28 20 21 6f 70 74 COLS);..if( !opt
04e0: 69 6f 6e 73 2d 3e 72 65 61 64 6f 6e 6c 79 29 20 ions->readonly)
04f0: 7b 0a 09 09 6d 76 77 70 72 69 6e 74 77 28 74 6f {...mvwprintw(to
0500: 70 2c 20 30 2c 20 30 2c 20 22 25 73 20 7c 20 25 p, 0, 0, "%s | %
0510: 73 22 2c 20 50 41 43 4b 41 47 45 20 22 20 22 20 s", PACKAGE " "
0520: 56 45 52 53 49 4f 4e 2c 0a 09 09 09 20 20 4d 41 VERSION,.... MA
0530: 49 4e 5f 48 45 4c 50 4c 49 4e 45 29 3b 0a 09 7d IN_HELPLINE);..}
0540: 20 65 6c 73 65 20 7b 0a 09 09 6d 76 77 70 72 69 else {...mvwpri
0550: 6e 74 77 28 74 6f 70 2c 20 30 2c 20 30 2c 20 22 ntw(top, 0, 0, "
0560: 25 73 20 7c 20 25 73 20 7c 20 25 73 22 2c 20 50 %s | %s | %s", P
0570: 41 43 4b 41 47 45 20 22 20 22 20 56 45 52 53 49 ACKAGE " " VERSI
0580: 4f 4e 2c 0a 09 09 09 20 20 52 45 41 44 4f 4e 4c ON,.... READONL
0590: 59 5f 4d 53 47 2c 20 4d 41 49 4e 5f 48 45 4c 50 Y_MSG, MAIN_HELP
05a0: 4c 49 4e 45 29 3b 0a 09 7d 0a 09 0a 09 77 72 65 LINE);..}....wre
05b0: 66 72 65 73 68 28 74 6f 70 29 3b 0a 7d 0a 0a 69 fresh(top);.}..i
05c0: 6e 74 0a 75 69 5f 64 72 61 77 5f 62 6f 74 74 6f nt.ui_draw_botto
05d0: 6d 28 29 0a 7b 0a 09 77 65 72 61 73 65 28 62 6f m().{..werase(bo
05e0: 74 74 6f 6d 29 3b 0a 09 6d 76 77 68 6c 69 6e 65 ttom);..mvwhline
05f0: 28 62 6f 74 74 6f 6d 2c 20 30 2c 20 30 2c 20 41 (bottom, 0, 0, A
0600: 43 53 5f 48 4c 49 4e 45 2c 20 43 4f 4c 53 29 3b CS_HLINE, COLS);
0610: 0a 09 6d 76 77 68 6c 69 6e 65 28 62 6f 74 74 6f ..mvwhline(botto
0620: 6d 2c 20 32 2c 20 30 2c 20 41 43 53 5f 48 4c 49 m, 2, 0, ACS_HLI
0630: 4e 45 2c 20 43 4f 4c 53 29 3b 0a 0a 09 77 72 65 NE, COLS);...wre
0640: 66 72 65 73 68 28 62 6f 74 74 6f 6d 29 3b 0a 7d fresh(bottom);.}
0650: 0a 0a 69 6e 74 20 0a 75 69 5f 72 65 66 72 65 73 ..int .ui_refres
0660: 68 5f 77 69 6e 64 6f 77 73 28 29 0a 7b 0a 09 75 h_windows().{..u
0670: 69 5f 64 72 61 77 5f 74 6f 70 28 29 3b 0a 09 75 i_draw_top();..u
0680: 69 5f 64 72 61 77 5f 62 6f 74 74 6f 6d 28 29 3b i_draw_bottom();
0690: 0a 09 75 69 6c 69 73 74 5f 72 65 66 72 65 73 68 ..uilist_refresh
06a0: 28 29 3b 0a 0a 09 72 65 66 72 65 73 68 28 29 3b ();...refresh();
06b0: 0a 7d 0a 0a 69 6e 74 0a 75 69 5f 72 65 73 69 7a .}..int.ui_resiz
06c0: 65 5f 77 69 6e 64 6f 77 73 28 29 0a 7b 0a 09 77 e_windows().{..w
06d0: 72 65 73 69 7a 65 28 74 6f 70 2c 20 32 2c 20 43 resize(top, 2, C
06e0: 4f 4c 53 29 3b 0a 7d 0a 0a 73 74 61 74 69 63 20 OLS);.}..static
06f0: 76 6f 69 64 0a 75 69 5f 74 6f 6f 5f 73 6d 61 6c void.ui_too_smal
0700: 6c 5f 77 61 72 6e 69 6e 67 28 29 0a 7b 0a 09 63 l_warning().{..c
0710: 6c 65 61 72 28 29 3b 0a 09 61 74 74 72 6f 6e 28 lear();..attron(
0720: 41 5f 42 4f 4c 44 29 3b 0a 09 6d 76 70 72 69 6e A_BOLD);..mvprin
0730: 74 77 28 28 28 4c 49 4e 45 53 2d 32 29 2f 32 29 tw(((LINES-2)/2)
0740: 2c 30 2c 22 59 6f 75 72 20 77 69 6e 64 6f 77 20 ,0,"Your window
0750: 69 73 20 74 6f 6f 20 73 6d 61 6c 6c 5c 6e 5c 6e is too small\n\n
0760: 22 0a 09 09 09 22 4d 69 6e 69 6d 75 6d 20 73 69 "...."Minimum si
0770: 7a 65 20 69 73 20 25 64 78 25 64 5c 6e 5c 6e 22 ze is %dx%d\n\n"
0780: 0a 09 09 09 22 50 6c 65 61 73 65 20 72 65 73 69 ...."Please resi
0790: 7a 65 20 61 6e 64 20 70 72 65 73 73 20 61 6e 79 ze and press any
07a0: 20 6b 65 79 22 2c 20 4d 49 4e 5f 4c 49 4e 45 53 key", MIN_LINES
07b0: 2c 20 4d 49 4e 5f 43 4f 4c 53 29 3b 0a 09 61 74 , MIN_COLS);..at
07c0: 74 72 6f 66 66 28 41 5f 42 4f 4c 44 29 3b 0a 09 troff(A_BOLD);..
07d0: 67 65 74 63 68 28 29 3b 0a 7d 0a 0a 23 69 66 64 getch();.}..#ifd
07e0: 65 66 20 53 49 47 57 49 4e 43 48 0a 73 74 61 74 ef SIGWINCH.stat
07f0: 69 63 20 76 6f 69 64 0a 75 69 5f 72 65 73 69 7a ic void.ui_resiz
0800: 65 28 29 0a 7b 0a 09 73 74 72 75 63 74 20 77 69 e().{..struct wi
0810: 6e 73 69 7a 65 20 77 69 6e 73 7a 3b 0a 09 69 6f nsize winsz;..io
0820: 63 74 6c 20 28 30 2c 20 54 49 4f 43 47 57 49 4e ctl (0, TIOCGWIN
0830: 53 5a 2c 20 26 77 69 6e 73 7a 29 3b 0a 0a 09 72 SZ, &winsz);...r
0840: 65 73 69 7a 65 74 65 72 6d 28 77 69 6e 73 7a 2e esizeterm(winsz.
0850: 77 73 5f 72 6f 77 2c 20 77 69 6e 73 7a 2e 77 73 ws_row, winsz.ws
0860: 5f 63 6f 6c 29 3b 0a 09 69 66 28 28 77 69 6e 73 _col);..if((wins
0870: 7a 2e 77 73 5f 63 6f 6c 20 3c 20 4d 49 4e 5f 43 z.ws_col < MIN_C
0880: 4f 4c 53 29 20 7c 7c 20 28 77 69 6e 73 7a 2e 77 OLS) || (winsz.w
0890: 73 5f 72 6f 77 20 3c 20 4d 49 4e 5f 4c 49 4e 45 s_row < MIN_LINE
08a0: 53 29 29 20 7b 0a 09 09 0a 09 09 2f 2a 0a 09 09 S)) {....../*...
08b0: 20 2a 20 69 66 20 77 69 6e 64 6f 77 20 69 73 20 * if window is
08c0: 74 6f 6f 20 73 6d 61 6c 6c 20 6e 6f 74 69 66 79 too small notify
08d0: 20 75 73 65 72 20 0a 09 09 20 2a 20 75 6e 74 69 user ... * unti
08e0: 6c 20 68 65 20 63 68 61 6e 67 65 73 20 69 74 0a l he changes it.
08f0: 09 09 20 2a 2f 0a 09 09 64 6f 20 7b 0a 09 09 09 .. */...do {....
0900: 75 69 5f 74 6f 6f 5f 73 6d 61 6c 6c 5f 77 61 72 ui_too_small_war
0910: 6e 69 6e 67 28 29 3b 0a 09 09 09 69 6f 63 74 6c ning();....ioctl
0920: 20 28 30 2c 20 54 49 4f 43 47 57 49 4e 53 5a 2c (0, TIOCGWINSZ,
0930: 20 26 77 69 6e 73 7a 29 3b 0a 09 09 09 72 65 73 &winsz);....res
0940: 69 7a 65 74 65 72 6d 28 77 69 6e 73 7a 2e 77 73 izeterm(winsz.ws
0950: 5f 72 6f 77 2c 20 77 69 6e 73 7a 2e 77 73 5f 63 _row, winsz.ws_c
0960: 6f 6c 29 3b 0a 09 09 7d 20 77 68 69 6c 65 20 28 ol);...} while (
0970: 28 77 69 6e 73 7a 2e 77 73 5f 63 6f 6c 20 3c 20 (winsz.ws_col <
0980: 4d 49 4e 5f 43 4f 4c 53 29 20 7c 7c 20 28 77 69 MIN_COLS) || (wi
0990: 6e 73 7a 2e 77 73 5f 72 6f 77 20 3c 20 4d 49 4e nsz.ws_row < MIN
09a0: 5f 4c 49 4e 45 53 29 29 3b 0a 0a 09 7d 20 65 6c _LINES));...} el
09b0: 73 65 20 7b 0a 09 09 73 68 6f 75 6c 64 5f 72 65 se {...should_re
09c0: 73 69 7a 65 20 3d 20 46 41 4c 53 45 3b 0a 09 09 size = FALSE;...
09d0: 2f 2a 09 72 65 73 69 7a 65 5f 77 69 6e 64 6f 77 /*.resize_window
09e0: 73 28 29 3b 0a 09 09 72 65 73 69 7a 65 5f 6c 69 s();...resize_li
09f0: 73 74 28 29 3b 2a 2f 0a 09 09 75 69 5f 66 72 65 st();*/...ui_fre
0a00: 65 5f 77 69 6e 64 6f 77 73 28 29 3b 0a 09 09 75 e_windows();...u
0a10: 69 5f 69 6e 69 74 5f 77 69 6e 64 6f 77 73 28 29 i_init_windows()
0a20: 3b 0a 09 09 75 69 5f 72 65 66 72 65 73 68 5f 77 ;...ui_refresh_w
0a30: 69 6e 64 6f 77 73 28 29 3b 0a 09 7d 0a 7d 0a 23 indows();..}.}.#
0a40: 65 6e 64 69 66 0a 0a 73 74 61 74 69 63 20 76 6f endif..static vo
0a50: 69 64 0a 75 69 5f 77 69 6e 5f 63 68 61 6e 67 65 id.ui_win_change
0a60: 64 28 69 6e 74 20 69 29 0a 7b 0a 09 69 66 28 20 d(int i).{..if(
0a70: 63 61 6e 5f 72 65 73 69 7a 65 20 29 7b 0a 09 09 can_resize ){...
0a80: 75 69 5f 72 65 73 69 7a 65 28 29 3b 0a 09 09 75 ui_resize();...u
0a90: 69 5f 72 65 66 72 65 73 68 5f 77 69 6e 64 6f 77 i_refresh_window
0aa0: 73 28 29 3b 20 2f 2a 20 64 75 6e 6e 6f 20 77 68 s(); /* dunno wh
0ab0: 79 20 69 20 6e 65 65 64 20 74 68 69 73 20 62 75 y i need this bu
0ac0: 74 20 69 74 20 77 6f 6e 74 20 77 6f 72 6b 20 77 t it wont work w
0ad0: 69 74 68 6f 75 74 20 69 74 20 2a 2f 0a 09 7d 20 ithout it */..}
0ae0: 65 6c 73 65 20 7b 0a 09 09 73 68 6f 75 6c 64 5f else {...should_
0af0: 72 65 73 69 7a 65 20 3d 20 54 52 55 45 3b 0a 09 resize = TRUE;..
0b00: 7d 0a 7d 0a 0a 0a 69 6e 74 0a 75 69 5f 69 6e 69 }.}...int.ui_ini
0b10: 74 5f 77 69 6e 64 6f 77 73 28 29 0a 7b 0a 09 74 t_windows().{..t
0b20: 6f 70 20 3d 20 6e 65 77 77 69 6e 28 32 2c 20 43 op = newwin(2, C
0b30: 4f 4c 53 2c 30 2c 30 29 3b 0a 09 62 6f 74 74 6f OLS,0,0);..botto
0b40: 6d 20 3d 20 6e 65 77 77 69 6e 28 33 2c 20 43 4f m = newwin(3, CO
0b50: 4c 53 2c 20 4c 49 4e 45 53 20 2d 20 33 2c 20 30 LS, LINES - 3, 0
0b60: 29 3b 0a 0a 09 75 69 6c 69 73 74 5f 69 6e 69 74 );...uilist_init
0b70: 28 29 3b 0a 7d 0a 0a 69 6e 74 20 0a 75 69 5f 66 ();.}..int .ui_f
0b80: 72 65 65 5f 77 69 6e 64 6f 77 73 28 29 0a 7b 0a ree_windows().{.
0b90: 09 75 69 6c 69 73 74 5f 66 72 65 65 28 29 3b 0a .uilist_free();.
0ba0: 0a 09 65 72 61 73 65 28 29 3b 0a 09 64 65 6c 77 ..erase();..delw
0bb0: 69 6e 28 74 6f 70 29 3b 0a 09 64 65 6c 77 69 6e in(top);..delwin
0bc0: 28 62 6f 74 74 6f 6d 29 3b 0a 7d 0a 0a 69 6e 74 (bottom);.}..int
0bd0: 0a 75 69 5f 69 6e 69 74 28 29 0a 7b 0a 09 69 6e .ui_init().{..in
0be0: 69 74 73 63 72 28 29 3b 0a 09 63 62 72 65 61 6b itscr();..cbreak
0bf0: 28 29 3b 0a 09 6e 6f 65 63 68 6f 28 29 3b 0a 09 ();..noecho();..
0c00: 6e 6f 6e 6c 28 29 3b 0a 0a 09 69 6e 74 72 66 6c nonl();...intrfl
0c10: 75 73 68 28 73 74 64 73 63 72 2c 20 46 41 4c 53 ush(stdscr, FALS
0c20: 45 29 3b 0a 09 6b 65 79 70 61 64 28 73 74 64 73 E);..keypad(stds
0c30: 63 72 2c 20 54 52 55 45 29 3b 0a 0a 09 69 66 28 cr, TRUE);...if(
0c40: 28 4c 49 4e 45 53 20 3c 20 4d 49 4e 5f 4c 49 4e (LINES < MIN_LIN
0c50: 45 53 29 20 7c 7c 20 28 43 4f 4c 53 20 3c 20 4d ES) || (COLS < M
0c60: 49 4e 5f 43 4f 4c 53 29 29 7b 0a 09 09 63 6c 65 IN_COLS)){...cle
0c70: 61 72 28 29 3b 20 72 65 66 72 65 73 68 28 29 3b ar(); refresh();
0c80: 20 65 6e 64 77 69 6e 28 29 3b 0a 09 09 66 70 72 endwin();...fpr
0c90: 69 6e 74 66 28 73 74 64 65 72 72 2c 20 22 59 6f intf(stderr, "Yo
0ca0: 75 72 20 74 65 72 6d 69 6e 61 6c 20 69 73 20 74 ur terminal is t
0cb0: 6f 20 73 6d 61 6c 6c 5c 6e 22 29 3b 0a 09 09 66 o small\n");...f
0cc0: 70 72 69 6e 74 66 28 73 74 64 65 72 72 2c 20 22 printf(stderr, "
0cd0: 4d 69 6e 20 73 69 7a 65 20 69 73 20 25 64 78 25 Min size is %dx%
0ce0: 64 5c 6e 22 2c 20 4d 49 4e 5f 43 4f 4c 53 2c 20 d\n", MIN_COLS,
0cf0: 4d 49 4e 5f 4c 49 4e 45 53 29 3b 0a 0a 09 09 72 MIN_LINES);....r
0d00: 65 74 75 72 6e 20 31 3b 0a 09 7d 0a 0a 23 69 66 eturn 1;..}..#if
0d10: 64 65 66 20 53 49 47 57 49 4e 43 48 0a 09 73 69 def SIGWINCH..si
0d20: 67 6e 61 6c 28 53 49 47 57 49 4e 43 48 2c 20 75 gnal(SIGWINCH, u
0d30: 69 5f 77 69 6e 5f 63 68 61 6e 67 65 64 29 3b 0a i_win_changed);.
0d40: 23 65 6e 64 69 66 0a 0a 09 75 69 5f 69 6e 69 74 #endif...ui_init
0d50: 5f 77 69 6e 64 6f 77 73 28 29 3b 0a 09 75 69 5f _windows();..ui_
0d60: 72 65 66 72 65 73 68 5f 77 69 6e 64 6f 77 73 28 refresh_windows(
0d70: 29 3b 0a 7d 0a 0a 69 6e 74 0a 75 69 5f 72 75 6e );.}..int.ui_run
0d80: 28 29 0a 7b 0a 09 50 77 20 2a 63 75 72 72 65 6e ().{..Pw *curren
0d90: 74 5f 69 74 65 6d 3b 0a 09 69 6e 74 20 63 68 3b t_item;..int ch;
0da0: 0a 09 69 6e 74 20 69 20 3d 20 30 3b 0a 09 69 6e ..int i = 0;..in
0db0: 74 20 6c 6f 61 64 5f 77 6f 72 6b 65 64 20 3d 20 t load_worked =
0dc0: 30 3b 0a 09 69 6e 74 20 73 65 63 72 65 74 5f 6b 0;..int secret_k
0dd0: 65 79 5f 6d 65 73 73 61 67 65 20 3d 20 30 3b 0a ey_message = 0;.
0de0: 09 73 74 72 75 63 74 20 73 74 61 74 20 73 74 3b .struct stat st;
0df0: 0a 09 63 68 61 72 20 73 65 63 72 69 6e 67 5b 53 ..char secring[S
0e00: 54 52 49 4e 47 5f 4c 4f 4e 47 5d 3b 0a 09 73 74 TRING_LONG];..st
0e10: 72 63 70 79 28 73 65 63 72 69 6e 67 2c 20 67 65 rcpy(secring, ge
0e20: 74 65 6e 76 28 22 48 4f 4d 45 22 29 29 3b 0a 09 tenv("HOME"));..
0e30: 73 74 72 63 61 74 28 73 65 63 72 69 6e 67 2c 20 strcat(secring,
0e40: 22 2f 2e 67 6e 75 70 67 2f 73 65 63 72 69 6e 67 "/.gnupg/secring
0e50: 2e 67 70 67 22 29 3b 0a 23 69 66 64 65 66 20 44 .gpg");.#ifdef D
0e60: 45 42 55 47 0a 09 69 6e 74 20 64 65 62 75 67 5f EBUG..int debug_
0e70: 69 20 3d 20 30 3b 0a 23 65 6e 64 69 66 0a 09 63 i = 0;.#endif..c
0e80: 68 61 72 20 6d 73 67 5b 38 30 5d 3b 0a 0a 09 74 har msg[80];...t
0e90: 69 6d 65 5f 62 61 73 65 20 3d 20 74 69 6d 65 28 ime_base = time(
0ea0: 4e 55 4c 4c 29 3b 0a 0a 09 77 68 69 6c 65 28 31 NULL);...while(1
0eb0: 29 7b 0a 09 09 63 61 6e 5f 72 65 73 69 7a 65 20 ){...can_resize
0ec0: 3d 20 54 52 55 45 3b 0a 09 09 69 66 28 20 73 68 = TRUE;...if( sh
0ed0: 6f 75 6c 64 5f 72 65 73 69 7a 65 20 29 7b 0a 09 ould_resize ){..
0ee0: 09 09 75 69 5f 72 65 73 69 7a 65 28 29 3b 0a 09 ..ui_resize();..
0ef0: 09 7d 0a 09 09 63 68 20 3d 20 67 65 74 63 68 28 .}...ch = getch(
0f00: 29 3b 0a 09 09 75 69 5f 73 74 61 74 75 73 6c 69 );...ui_statusli
0f10: 6e 65 5f 63 6c 65 61 72 28 29 3b 0a 09 09 63 61 ne_clear();...ca
0f20: 6e 5f 72 65 73 69 7a 65 20 3d 20 46 41 4c 53 45 n_resize = FALSE
0f30: 3b 0a 0a 09 09 69 66 28 28 74 69 6d 65 5f 62 61 ;....if((time_ba
0f40: 73 65 20 3c 20 28 74 69 6d 65 28 4e 55 4c 4c 29 se < (time(NULL)
0f50: 20 2d 20 28 6f 70 74 69 6f 6e 73 2d 3e 70 61 73 - (options->pas
0f60: 73 70 68 72 61 73 65 5f 74 69 6d 65 6f 75 74 2a sphrase_timeout*
0f70: 36 30 29 29 29 0a 09 09 09 09 26 26 20 6f 70 74 60))).....&& opt
0f80: 69 6f 6e 73 2d 3e 70 61 73 73 70 68 72 61 73 65 ions->passphrase
0f90: 5f 74 69 6d 65 6f 75 74 20 21 3d 20 30 20 26 26 _timeout != 0 &&
0fa0: 20 74 6f 6c 6f 77 65 72 28 63 68 29 20 21 3d 20 tolower(ch) !=
0fb0: 27 71 27 29 7b 0a 09 09 09 70 77 6c 69 73 74 5f 'q'){....pwlist_
0fc0: 77 72 69 74 65 5f 66 69 6c 65 28 29 3b 0a 09 09 write_file();...
0fd0: 09 70 77 6c 69 73 74 5f 66 72 65 65 5f 61 6c 6c .pwlist_free_all
0fe0: 28 29 3b 0a 0a 09 09 09 75 69 5f 73 74 61 74 75 ();.....ui_statu
0ff0: 73 6c 69 6e 65 5f 6d 73 67 28 22 50 61 73 73 70 sline_msg("Passp
1000: 68 72 61 73 65 20 68 61 73 20 74 69 6d 65 64 20 hrase has timed
1010: 6f 75 74 20 61 6e 64 20 79 6f 75 20 6d 75 73 74 out and you must
1020: 20 65 6e 74 65 72 20 69 74 20 61 67 61 69 6e 2e enter it again.
1030: 22 29 3b 0a 09 09 09 67 65 74 63 68 28 29 3b 0a ");....getch();.
1040: 09 09 09 2f 2f 20 54 72 79 20 74 6f 20 61 76 6f ...// Try to avo
1050: 69 64 20 73 65 67 66 61 75 6c 74 20 69 66 20 73 id segfault if s
1060: 65 63 72 69 6e 67 20 69 73 6e 27 74 20 61 76 61 ecring isn't ava
1070: 69 6c 61 62 6c 65 0a 09 09 09 2f 2f 20 4e 65 65 ilable....// Nee
1080: 64 20 74 6f 20 63 68 65 63 6b 20 66 6f 72 20 30 d to check for 0
1090: 20 62 79 74 65 20 66 69 6c 65 20 73 69 7a 65 20 byte file size
10a0: 73 69 6e 63 65 20 73 6f 6d 65 74 68 69 6e 67 20 since something
10b0: 69 6e 20 70 77 6c 69 73 74 5f 77 72 69 74 65 5f in pwlist_write_
10c0: 66 69 6c 65 28 29 20 22 74 6f 75 63 68 65 73 22 file() "touches"
10d0: 20 69 74 0a 09 09 09 73 74 61 74 28 73 65 63 72 it....stat(secr
10e0: 69 6e 67 2c 20 26 73 74 29 3b 0a 09 09 09 77 68 ing, &st);....wh
10f0: 69 6c 65 20 28 20 73 74 2e 73 74 5f 73 69 7a 65 ile ( st.st_size
1100: 20 3d 3d 20 30 20 29 20 7b 0a 09 09 09 09 69 66 == 0 ) {.....if
1110: 20 28 73 65 63 72 65 74 5f 6b 65 79 5f 6d 65 73 (secret_key_mes
1120: 73 61 67 65 20 3d 3d 20 30 29 20 7b 0a 09 09 09 sage == 0) {....
1130: 09 09 75 69 5f 73 74 61 74 75 73 6c 69 6e 65 5f ..ui_statusline_
1140: 6d 73 67 28 22 53 65 63 72 65 74 20 6b 65 79 20 msg("Secret key
1150: 6e 6f 74 20 61 76 61 69 6c 61 62 6c 65 2e 2e 2e not available...
1160: 20 57 61 69 74 69 6e 67 20 75 6e 74 69 6c 20 69 Waiting until i
1170: 74 20 69 73 22 29 3b 0a 09 09 09 09 09 73 65 63 t is");......sec
1180: 72 65 74 5f 6b 65 79 5f 6d 65 73 73 61 67 65 20 ret_key_message
1190: 3d 20 31 3b 0a 09 09 09 09 7d 0a 09 09 09 09 73 = 1;.....}.....s
11a0: 74 61 74 28 73 65 63 72 69 6e 67 2c 20 26 73 74 tat(secring, &st
11b0: 29 3b 0a 09 09 09 09 73 6c 65 65 70 28 31 29 3b );.....sleep(1);
11c0: 0a 09 09 09 7d 0a 09 09 09 73 65 63 72 65 74 5f ....}....secret_
11d0: 6b 65 79 5f 6d 65 73 73 61 67 65 20 3d 20 30 3b key_message = 0;
11e0: 0a 09 09 09 0a 09 09 09 6c 6f 61 64 5f 77 6f 72 ........load_wor
11f0: 6b 65 64 20 3d 20 70 77 6c 69 73 74 5f 72 65 61 ked = pwlist_rea
1200: 64 5f 66 69 6c 65 28 29 3b 0a 09 09 09 69 66 28 d_file();....if(
1210: 6c 6f 61 64 5f 77 6f 72 6b 65 64 20 21 3d 20 30 load_worked != 0
1220: 29 20 7b 0a 09 09 09 09 75 69 5f 73 74 61 74 75 ) {.....ui_statu
1230: 73 6c 69 6e 65 5f 6d 73 67 28 22 45 72 72 6f 72 sline_msg("Error
1240: 20 2d 20 75 6e 61 62 6c 65 20 74 6f 20 72 65 2d - unable to re-
1250: 6c 6f 61 64 20 74 68 65 20 70 61 73 73 77 6f 72 load the passwor
1260: 64 20 66 69 6c 65 21 22 29 3b 0a 09 09 09 09 62 d file!");.....b
1270: 72 65 61 6b 3b 0a 09 09 09 09 2f 2f 20 49 74 20 reak;.....// It
1280: 73 65 67 66 61 75 6c 74 73 20 68 65 72 65 2e 0a segfaults here..
1290: 09 09 09 7d 0a 0a 09 09 09 74 69 6d 65 5f 62 61 ...}.....time_ba
12a0: 73 65 20 3d 20 74 69 6d 65 28 4e 55 4c 4c 29 3b se = time(NULL);
12b0: 0a 09 09 7d 0a 09 09 0a 09 09 73 77 69 74 63 68 ...}......switch
12c0: 28 63 68 29 7b 0a 09 09 09 63 61 73 65 20 27 51 (ch){....case 'Q
12d0: 27 3a 0a 09 09 09 63 61 73 65 20 27 71 27 3a 0a ':....case 'q':.
12e0: 09 09 09 09 69 66 28 73 65 61 72 63 68 5f 72 65 ....if(search_re
12f0: 73 75 6c 74 73 20 21 3d 20 4e 55 4c 4c 29 20 7b sults != NULL) {
1300: 0a 09 09 09 09 09 73 65 61 72 63 68 5f 72 65 6d ......search_rem
1310: 6f 76 65 28 29 3b 0a 09 09 09 09 7d 20 65 6c 73 ove();.....} els
1320: 65 20 7b 0a 09 09 09 09 09 69 66 28 61 63 74 69 e {......if(acti
1330: 6f 6e 5f 6c 69 73 74 5f 61 74 5f 74 6f 70 5f 6c on_list_at_top_l
1340: 65 76 65 6c 28 29 29 7b 0a 09 09 09 09 09 09 72 evel()){.......r
1350: 65 74 75 72 6e 20 30 3b 0a 09 09 09 09 09 7d 0a eturn 0;......}.
1360: 09 09 09 09 7d 0a 09 09 09 09 62 72 65 61 6b 3b ....}.....break;
1370: 0a 09 09 09 63 61 73 65 20 27 3f 27 3a 0a 09 09 ....case '?':...
1380: 09 09 75 69 5f 64 69 73 70 6c 61 79 5f 68 65 6c ..ui_display_hel
1390: 70 28 29 3b 0a 09 09 09 09 62 72 65 61 6b 3b 0a p();.....break;.
13a0: 09 09 09 63 61 73 65 20 4b 45 59 5f 50 50 41 47 ...case KEY_PPAG
13b0: 45 3a 0a 09 09 09 09 75 69 6c 69 73 74 5f 70 61 E:.....uilist_pa
13c0: 67 65 5f 75 70 28 29 3b 0a 09 09 09 09 62 72 65 ge_up();.....bre
13d0: 61 6b 3b 0a 09 09 09 63 61 73 65 20 4b 45 59 5f ak;....case KEY_
13e0: 4e 50 41 47 45 3a 0a 09 09 09 09 75 69 6c 69 73 NPAGE:.....uilis
13f0: 74 5f 70 61 67 65 5f 64 6f 77 6e 28 29 3b 0a 09 t_page_down();..
1400: 09 09 09 62 72 65 61 6b 3b 0a 09 09 09 63 61 73 ...break;....cas
1410: 65 20 4b 45 59 5f 55 50 3a 0a 09 09 09 63 61 73 e KEY_UP:....cas
1420: 65 20 27 6b 27 3a 0a 09 09 09 09 75 69 6c 69 73 e 'k':.....uilis
1430: 74 5f 75 70 28 29 3b 0a 09 09 09 09 62 72 65 61 t_up();.....brea
1440: 6b 3b 0a 09 09 09 63 61 73 65 20 4b 45 59 5f 44 k;....case KEY_D
1450: 4f 57 4e 3a 0a 09 09 09 63 61 73 65 20 27 6a 27 OWN:....case 'j'
1460: 3a 0a 09 09 09 09 75 69 6c 69 73 74 5f 64 6f 77 :.....uilist_dow
1470: 6e 28 29 3b 0a 09 09 09 09 62 72 65 61 6b 3b 0a n();.....break;.
1480: 09 09 09 63 61 73 65 20 27 41 27 3a 0a 09 09 09 ...case 'A':....
1490: 09 69 66 20 28 21 6f 70 74 69 6f 6e 73 2d 3e 72 .if (!options->r
14a0: 65 61 64 6f 6e 6c 79 29 7b 0a 09 09 09 09 09 61 eadonly){......a
14b0: 63 74 69 6f 6e 5f 6c 69 73 74 5f 61 64 64 5f 73 ction_list_add_s
14c0: 75 62 6c 69 73 74 28 29 3b 0a 09 09 09 09 7d 20 ublist();.....}
14d0: 65 6c 73 65 20 7b 0a 09 09 09 09 09 73 74 61 74 else {......stat
14e0: 75 73 6c 69 6e 65 5f 72 65 61 64 6f 6e 6c 79 28 usline_readonly(
14f0: 29 3b 0a 09 09 09 09 7d 0a 09 09 09 09 62 72 65 );.....}.....bre
1500: 61 6b 3b 0a 09 09 09 63 61 73 65 20 27 55 27 3a ak;....case 'U':
1510: 0a 09 09 09 09 61 63 74 69 6f 6e 5f 6c 69 73 74 .....action_list
1520: 5f 75 70 5f 6f 6e 65 5f 6c 65 76 65 6c 28 29 3b _up_one_level();
1530: 0a 09 09 09 09 62 72 65 61 6b 3b 0a 09 09 09 63 .....break;....c
1540: 61 73 65 20 27 72 27 3a 0a 09 09 09 09 69 66 20 ase 'r':.....if
1550: 28 21 6f 70 74 69 6f 6e 73 2d 3e 72 65 61 64 6f (!options->reado
1560: 6e 6c 79 29 7b 0a 09 09 09 09 09 61 63 74 69 6f nly){......actio
1570: 6e 5f 6c 69 73 74 5f 72 65 6e 61 6d 65 28 29 3b n_list_rename();
1580: 0a 09 09 09 09 09 70 77 6c 69 73 74 5f 77 72 69 ......pwlist_wri
1590: 74 65 5f 66 69 6c 65 28 29 3b 0a 09 09 09 09 7d te_file();.....}
15a0: 20 65 6c 73 65 20 7b 0a 09 09 09 09 09 73 74 61 else {......sta
15b0: 74 75 73 6c 69 6e 65 5f 72 65 61 64 6f 6e 6c 79 tusline_readonly
15c0: 28 29 3b 0a 09 09 09 09 7d 0a 09 09 09 09 62 72 ();.....}.....br
15d0: 65 61 6b 3b 0a 09 09 09 63 61 73 65 20 27 61 27 eak;....case 'a'
15e0: 3a 0a 09 09 09 09 69 66 20 28 21 6f 70 74 69 6f :.....if (!optio
15f0: 6e 73 2d 3e 72 65 61 64 6f 6e 6c 79 29 7b 0a 09 ns->readonly){..
1600: 09 09 09 09 61 63 74 69 6f 6e 5f 6c 69 73 74 5f ....action_list_
1610: 61 64 64 5f 70 77 28 29 3b 0a 09 09 09 09 09 70 add_pw();......p
1620: 77 6c 69 73 74 5f 77 72 69 74 65 5f 66 69 6c 65 wlist_write_file
1630: 28 29 3b 0a 09 09 09 09 7d 20 65 6c 73 65 20 7b ();.....} else {
1640: 0a 09 09 09 09 09 73 74 61 74 75 73 6c 69 6e 65 ......statusline
1650: 5f 72 65 61 64 6f 6e 6c 79 28 29 3b 0a 09 09 09 _readonly();....
1660: 09 7d 0a 09 09 09 09 62 72 65 61 6b 3b 0a 09 09 .}.....break;...
1670: 09 63 61 73 65 20 27 65 27 3a 0a 09 09 09 63 61 .case 'e':....ca
1680: 73 65 20 27 20 27 3a 0a 09 09 09 63 61 73 65 20 se ' ':....case
1690: 31 33 3a 20 2f 2a 20 72 65 74 75 72 6e 2f 65 6e 13: /* return/en
16a0: 74 65 72 20 6b 65 79 20 2a 2f 0a 09 09 09 09 61 ter key */.....a
16b0: 63 74 69 6f 6e 5f 6c 69 73 74 5f 73 65 6c 65 63 ction_list_selec
16c0: 74 5f 69 74 65 6d 28 29 3b 0a 09 09 09 09 2f 2a t_item();...../*
16d0: 63 75 72 72 65 6e 74 5f 69 74 65 6d 20 3d 20 67 current_item = g
16e0: 65 74 5f 63 75 72 72 65 6e 74 5f 69 74 65 6d 28 et_current_item(
16f0: 29 3b 0a 09 09 09 09 69 66 28 63 75 72 72 65 6e );.....if(curren
1700: 74 5f 69 74 65 6d 29 7b 0a 09 09 09 09 09 65 64 t_item){......ed
1710: 69 74 5f 70 77 28 63 75 72 72 65 6e 74 5f 69 74 it_pw(current_it
1720: 65 6d 29 3b 0a 09 09 09 09 7d 2a 2f 0a 09 09 09 em);.....}*/....
1730: 09 62 72 65 61 6b 3b 0a 09 09 09 63 61 73 65 20 .break;....case
1740: 27 64 27 3a 0a 09 09 09 63 61 73 65 20 30 78 31 'd':....case 0x1
1750: 34 41 3a 20 2f 2a 20 44 45 4c 20 6b 65 79 20 2a 4A: /* DEL key *
1760: 2f 0a 09 09 09 09 69 66 20 28 21 6f 70 74 69 6f /.....if (!optio
1770: 6e 73 2d 3e 72 65 61 64 6f 6e 6c 79 29 7b 0a 09 ns->readonly){..
1780: 09 09 09 09 61 63 74 69 6f 6e 5f 6c 69 73 74 5f ....action_list_
1790: 64 65 6c 65 74 65 5f 69 74 65 6d 28 29 3b 0a 09 delete_item();..
17a0: 09 09 09 7d 20 65 6c 73 65 20 7b 0a 09 09 09 09 ...} else {.....
17b0: 09 73 74 61 74 75 73 6c 69 6e 65 5f 72 65 61 64 .statusline_read
17c0: 6f 6e 6c 79 28 29 3b 0a 09 09 09 09 7d 0a 09 09 only();.....}...
17d0: 09 09 62 72 65 61 6b 3b 0a 09 09 09 63 61 73 65 ..break;....case
17e0: 20 27 6d 27 3a 0a 09 09 09 09 69 66 20 28 21 6f 'm':.....if (!o
17f0: 70 74 69 6f 6e 73 2d 3e 72 65 61 64 6f 6e 6c 79 ptions->readonly
1800: 29 7b 0a 09 09 09 09 09 61 63 74 69 6f 6e 5f 6c ){......action_l
1810: 69 73 74 5f 6d 6f 76 65 5f 69 74 65 6d 28 29 3b ist_move_item();
1820: 0a 09 09 09 09 7d 20 65 6c 73 65 20 7b 0a 09 09 .....} else {...
1830: 09 09 09 73 74 61 74 75 73 6c 69 6e 65 5f 72 65 ...statusline_re
1840: 61 64 6f 6e 6c 79 28 29 3b 0a 09 09 09 09 7d 0a adonly();.....}.
1850: 09 09 09 09 62 72 65 61 6b 3b 0a 09 09 09 63 61 ....break;....ca
1860: 73 65 20 27 4d 27 3a 0a 09 09 09 09 69 66 20 28 se 'M':.....if (
1870: 21 6f 70 74 69 6f 6e 73 2d 3e 72 65 61 64 6f 6e !options->readon
1880: 6c 79 29 7b 0a 09 09 09 09 09 61 63 74 69 6f 6e ly){......action
1890: 5f 6c 69 73 74 5f 6d 6f 76 65 5f 69 74 65 6d 5f _list_move_item_
18a0: 75 70 5f 6c 65 76 65 6c 28 29 3b 0a 09 09 09 09 up_level();.....
18b0: 7d 20 65 6c 73 65 20 7b 0a 09 09 09 09 09 73 74 } else {......st
18c0: 61 74 75 73 6c 69 6e 65 5f 72 65 61 64 6f 6e 6c atusline_readonl
18d0: 79 28 29 3b 0a 09 09 09 09 7d 0a 09 09 09 09 62 y();.....}.....b
18e0: 72 65 61 6b 3b 0a 09 09 09 63 61 73 65 20 27 68 reak;....case 'h
18f0: 27 3a 0a 09 09 09 09 68 69 64 65 5f 63 75 72 73 ':.....hide_curs
1900: 6f 72 28 29 3b 0a 09 09 09 09 62 72 65 61 6b 3b or();.....break;
1910: 0a 09 09 09 09 63 61 73 65 20 27 73 27 3a 0a 09 .....case 's':..
1920: 09 09 09 73 68 6f 77 5f 63 75 72 73 6f 72 28 29 ...show_cursor()
1930: 3b 0a 09 09 09 09 62 72 65 61 6b 3b 0a 09 09 09 ;.....break;....
1940: 63 61 73 65 20 27 6f 27 3a 0a 09 09 09 09 61 63 case 'o':.....ac
1950: 74 69 6f 6e 5f 65 64 69 74 5f 6f 70 74 69 6f 6e tion_edit_option
1960: 73 28 29 3b 0a 09 09 09 09 62 72 65 61 6b 3b 0a s();.....break;.
1970: 09 09 09 63 61 73 65 20 30 78 31 37 3a 20 2f 2a ...case 0x17: /*
1980: 20 63 6f 6e 74 72 6f 6c 2d 77 20 2a 2f 0a 09 09 control-w */...
1990: 09 09 69 66 20 28 21 6f 70 74 69 6f 6e 73 2d 3e ..if (!options->
19a0: 72 65 61 64 6f 6e 6c 79 29 7b 0a 09 09 09 09 09 readonly){......
19b0: 70 77 6c 69 73 74 5f 77 72 69 74 65 5f 66 69 6c pwlist_write_fil
19c0: 65 28 29 3b 0a 09 09 09 09 7d 20 65 6c 73 65 20 e();.....} else
19d0: 7b 0a 09 09 09 09 09 73 74 61 74 75 73 6c 69 6e {......statuslin
19e0: 65 5f 72 65 61 64 6f 6e 6c 79 28 29 3b 0a 09 09 e_readonly();...
19f0: 09 09 7d 0a 09 09 09 09 62 72 65 61 6b 3b 0a 09 ..}.....break;..
1a00: 09 09 63 61 73 65 20 30 78 31 32 3a 20 2f 2a 20 ..case 0x12: /*
1a10: 63 6f 6e 74 72 6f 6c 2d 72 20 2a 2f 0a 09 09 09 control-r */....
1a20: 09 61 63 74 69 6f 6e 5f 6c 69 73 74 5f 72 65 61 .action_list_rea
1a30: 64 5f 66 69 6c 65 28 29 3b 0a 09 09 09 09 62 72 d_file();.....br
1a40: 65 61 6b 3b 0a 09 09 09 63 61 73 65 20 30 78 30 eak;....case 0x0
1a50: 37 3a 20 2f 2a 20 63 6f 6e 74 72 6f 6c 2d 67 20 7: /* control-g
1a60: 2a 2f 0a 09 09 09 09 70 77 67 65 6e 5f 69 6e 64 */.....pwgen_ind
1a70: 65 70 28 29 3b 0a 09 09 09 09 62 72 65 61 6b 3b ep();.....break;
1a80: 0a 09 09 09 63 61 73 65 20 30 78 30 36 3a 20 2f ....case 0x06: /
1a90: 2a 20 63 6f 6e 74 72 6f 6c 2d 66 20 2a 2f 0a 09 * control-f */..
1aa0: 09 09 09 67 6e 75 70 67 5f 66 6f 72 67 65 74 5f ...gnupg_forget_
1ab0: 70 61 73 73 70 68 72 61 73 65 28 29 3b 0a 09 09 passphrase();...
1ac0: 09 09 62 72 65 61 6b 3b 0a 09 09 09 63 61 73 65 ..break;....case
1ad0: 20 30 78 30 43 3a 20 2f 2a 20 63 6f 6e 74 72 6f 0x0C: /* contro
1ae0: 6c 2d 6c 20 2a 2f 0a 09 09 09 09 75 69 5f 72 65 l-l */.....ui_re
1af0: 66 72 65 73 68 5f 77 69 6e 64 6f 77 73 28 29 3b fresh_windows();
1b00: 0a 09 09 09 09 62 72 65 61 6b 3b 0a 09 09 09 63 .....break;....c
1b10: 61 73 65 20 27 2f 27 3a 0a 09 09 09 63 61 73 65 ase '/':....case
1b20: 20 27 46 27 3a 0a 09 09 09 09 73 65 61 72 63 68 'F':.....search
1b30: 5f 67 65 74 28 29 3b 0a 09 09 09 09 62 72 65 61 _get();.....brea
1b40: 6b 3b 0a 09 09 09 63 61 73 65 20 27 66 27 3a 0a k;....case 'f':.
1b50: 09 09 09 09 66 69 6c 74 65 72 5f 67 65 74 28 29 ....filter_get()
1b60: 3b 0a 09 09 09 09 62 72 65 61 6b 3b 0a 09 09 09 ;.....break;....
1b70: 63 61 73 65 20 27 45 27 3a 0a 09 09 09 09 61 63 case 'E':.....ac
1b80: 74 69 6f 6e 5f 6c 69 73 74 5f 65 78 70 6f 72 74 tion_list_export
1b90: 28 29 3b 0a 09 09 09 09 62 72 65 61 6b 3b 0a 09 ();.....break;..
1ba0: 09 09 63 61 73 65 20 27 49 27 3a 0a 09 09 09 09 ..case 'I':.....
1bb0: 69 66 20 28 21 6f 70 74 69 6f 6e 73 2d 3e 72 65 if (!options->re
1bc0: 61 64 6f 6e 6c 79 29 7b 0a 09 09 09 09 09 70 77 adonly){......pw
1bd0: 6c 69 73 74 5f 69 6d 70 6f 72 74 5f 70 61 73 73 list_import_pass
1be0: 77 64 28 29 3b 0a 09 09 09 09 09 75 69 6c 69 73 wd();......uilis
1bf0: 74 5f 72 65 66 72 65 73 68 28 29 3b 0a 09 09 09 t_refresh();....
1c00: 09 7d 20 65 6c 73 65 20 7b 0a 09 09 09 09 09 73 .} else {......s
1c10: 74 61 74 75 73 6c 69 6e 65 5f 72 65 61 64 6f 6e tatusline_readon
1c20: 6c 79 28 29 3b 0a 09 09 09 09 7d 0a 09 09 09 09 ly();.....}.....
1c30: 62 72 65 61 6b 3b 0a 09 09 09 63 61 73 65 20 27 break;....case '
1c40: 4c 27 3a 0a 09 09 09 09 61 63 74 69 6f 6e 5f 6c L':.....action_l
1c50: 69 73 74 5f 6c 6f 63 61 74 65 28 29 3b 0a 09 09 ist_locate();...
1c60: 09 09 62 72 65 61 6b 3b 0a 09 09 09 63 61 73 65 ..break;....case
1c70: 20 27 6c 27 3a 0a 09 09 09 09 61 63 74 69 6f 6e 'l':.....action
1c80: 5f 6c 69 73 74 5f 6c 61 75 6e 63 68 28 29 3b 0a _list_launch();.
1c90: 09 09 09 09 62 72 65 61 6b 3b 0a 09 09 09 63 61 ....break;....ca
1ca0: 73 65 20 30 78 30 42 3a 20 2f 2a 20 63 6f 6e 74 se 0x0B: /* cont
1cb0: 72 6f 6c 2d 6b 20 28 75 70 29 20 2a 2f 0a 09 09 rol-k (up) */...
1cc0: 09 63 61 73 65 20 27 5b 27 3a 0a 09 09 09 09 61 .case '[':.....a
1cd0: 63 74 69 6f 6e 5f 6c 69 73 74 5f 6d 6f 76 65 5f ction_list_move_
1ce0: 69 74 65 6d 5f 75 70 28 29 3b 0a 09 09 09 09 62 item_up();.....b
1cf0: 72 65 61 6b 3b 0a 09 09 09 63 61 73 65 20 30 78 reak;....case 0x
1d00: 30 41 3a 20 2f 2a 20 63 6f 6e 74 72 6f 6c 2d 6a 0A: /* control-j
1d10: 20 28 64 6f 77 6e 29 20 2a 2f 0a 09 09 09 63 61 (down) */....ca
1d20: 73 65 20 27 5d 27 3a 0a 09 09 09 09 61 63 74 69 se ']':.....acti
1d30: 6f 6e 5f 6c 69 73 74 5f 6d 6f 76 65 5f 69 74 65 on_list_move_ite
1d40: 6d 5f 64 6f 77 6e 28 29 3b 0a 09 09 09 09 62 72 m_down();.....br
1d50: 65 61 6b 3b 0a 23 69 66 64 65 66 20 44 45 42 55 eak;.#ifdef DEBU
1d60: 47 0a 09 09 09 63 61 73 65 20 27 24 27 3a 0a 09 G....case '$':..
1d70: 09 09 09 64 65 62 75 67 5f 69 2b 2b 3b 0a 09 09 ...debug_i++;...
1d80: 09 09 73 6e 70 72 69 6e 74 66 28 6d 73 67 2c 20 ..snprintf(msg,
1d90: 38 30 2c 20 22 4e 61 6d 65 20 25 64 22 2c 20 64 80, "Name %d", d
1da0: 65 62 75 67 5f 69 29 3b 0a 09 09 09 09 09 0a 09 ebug_i);........
1db0: 09 09 09 70 77 6c 69 73 74 5f 61 64 64 28 63 75 ...pwlist_add(cu
1dc0: 72 72 65 6e 74 5f 70 77 5f 73 75 62 6c 69 73 74 rrent_pw_sublist
1dd0: 2c 20 6d 73 67 2c 20 22 6d 79 68 6f 73 74 22 2c , msg, "myhost",
1de0: 20 22 6d 79 75 73 65 72 22 2c 20 22 6d 79 70 61 "myuser", "mypa
1df0: 73 73 77 64 22 2c 20 22 6d 79 6c 61 75 63 6e 68 sswd", "mylaucnh
1e00: 22 29 3b 0a 09 09 09 09 75 69 6c 69 73 74 5f 72 ");.....uilist_r
1e10: 65 66 72 65 73 68 28 29 3b 0a 09 09 09 09 62 72 efresh();.....br
1e20: 65 61 6b 3b 0a 23 65 6e 64 69 66 0a 09 09 09 64 eak;.#endif....d
1e30: 65 66 61 75 6c 74 3a 0a 09 09 09 09 62 72 65 61 efault:.....brea
1e40: 6b 3b 0a 09 09 7d 0a 09 7d 0a 7d 0a 0a 69 6e 74 k;...}..}.}..int
1e50: 0a 75 69 5f 65 6e 64 28 29 0a 7b 0a 09 75 69 5f .ui_end().{..ui_
1e60: 66 72 65 65 5f 77 69 6e 64 6f 77 73 28 29 3b 0a free_windows();.
1e70: 09 63 6c 65 61 72 28 29 3b 0a 09 72 65 66 72 65 .clear();..refre
1e80: 73 68 28 29 3b 0a 09 65 6e 64 77 69 6e 28 29 3b sh();..endwin();
1e90: 0a 09 65 63 68 6f 28 29 3b 0a 7d 0a 0a 69 6e 74 ..echo();.}..int
1ea0: 20 0a 75 69 5f 73 74 61 74 75 73 6c 69 6e 65 5f .ui_statusline_
1eb0: 6d 73 67 28 63 68 61 72 20 2a 20 6d 73 67 29 0a msg(char * msg).
1ec0: 7b 0a 09 75 69 5f 73 74 61 74 75 73 6c 69 6e 65 {..ui_statusline
1ed0: 5f 63 6c 65 61 72 28 29 3b 0a 09 6d 76 77 61 64 _clear();..mvwad
1ee0: 64 73 74 72 28 62 6f 74 74 6f 6d 2c 20 31 2c 20 dstr(bottom, 1,
1ef0: 30 2c 20 6d 73 67 29 3b 0a 09 72 65 66 72 65 73 0, msg);..refres
1f00: 68 28 29 3b 0a 09 77 72 65 66 72 65 73 68 28 62 h();..wrefresh(b
1f10: 6f 74 74 6f 6d 29 3b 0a 7d 0a 0a 69 6e 74 20 0a ottom);.}..int .
1f20: 75 69 5f 73 74 61 74 75 73 6c 69 6e 65 5f 63 6c ui_statusline_cl
1f30: 65 61 72 28 29 0a 7b 0a 09 77 6d 6f 76 65 28 62 ear().{..wmove(b
1f40: 6f 74 74 6f 6d 2c 20 31 2c 20 30 29 3b 0a 09 77 ottom, 1, 0);..w
1f50: 63 6c 72 74 6f 65 6f 6c 28 62 6f 74 74 6f 6d 29 clrtoeol(bottom)
1f60: 3b 0a 09 77 72 65 66 72 65 73 68 28 62 6f 74 74 ;..wrefresh(bott
1f70: 6f 6d 29 3b 0a 09 72 65 66 72 65 73 68 28 29 3b om);..refresh();
1f80: 0a 7d 0a 0a 76 6f 69 64 0a 75 69 5f 73 74 61 74 .}..void.ui_stat
1f90: 75 73 6c 69 6e 65 5f 61 73 6b 5f 6e 75 6d 28 63 usline_ask_num(c
1fa0: 68 61 72 20 2a 6d 73 67 2c 20 69 6e 74 20 2a 69 har *msg, int *i
1fb0: 29 0a 7b 0a 09 69 6e 74 20 78 20 3d 20 73 74 72 ).{..int x = str
1fc0: 6c 65 6e 28 6d 73 67 29 20 2b 20 35 3b 0a 09 63 len(msg) + 5;..c
1fd0: 68 61 72 20 69 6e 70 75 74 5b 53 54 52 49 4e 47 har input[STRING
1fe0: 5f 53 48 4f 52 54 5d 3b 0a 0a 09 75 69 5f 73 74 _SHORT];...ui_st
1ff0: 61 74 75 73 6c 69 6e 65 5f 63 6c 65 61 72 28 29 atusline_clear()
2000: 3b 0a 09 75 69 5f 73 74 61 74 75 73 6c 69 6e 65 ;..ui_statusline
2010: 5f 6d 73 67 28 6d 73 67 29 3b 0a 0a 09 65 63 68 _msg(msg);...ech
2020: 6f 28 29 3b 0a 09 73 68 6f 77 5f 63 75 72 73 6f o();..show_curso
2030: 72 28 29 3b 0a 0a 09 6d 76 77 67 65 74 6e 73 74 r();...mvwgetnst
2040: 72 28 62 6f 74 74 6f 6d 2c 20 31 2c 20 78 2c 20 r(bottom, 1, x,
2050: 69 6e 70 75 74 2c 20 53 54 52 49 4e 47 5f 53 48 input, STRING_SH
2060: 4f 52 54 29 3b 0a 09 2a 69 20 3d 20 61 74 6f 69 ORT);..*i = atoi
2070: 28 69 6e 70 75 74 29 3b 0a 09 0a 09 6e 6f 65 63 (input);....noec
2080: 68 6f 28 29 3b 0a 09 68 69 64 65 5f 63 75 72 73 ho();..hide_curs
2090: 6f 72 28 29 3b 0a 0a 09 75 69 5f 73 74 61 74 75 or();...ui_statu
20a0: 73 6c 69 6e 65 5f 63 6c 65 61 72 28 29 3b 0a 7d sline_clear();.}
20b0: 0a 0a 76 6f 69 64 0a 75 69 5f 73 74 61 74 75 73 ..void.ui_status
20c0: 6c 69 6e 65 5f 61 73 6b 5f 63 68 61 72 28 63 68 line_ask_char(ch
20d0: 61 72 20 2a 6d 73 67 2c 20 63 68 61 72 20 2a 63 ar *msg, char *c
20e0: 2c 20 63 68 61 72 2a 20 76 61 6c 69 64 29 0a 7b , char* valid).{
20f0: 0a 09 69 6e 74 20 78 20 3d 20 73 74 72 6c 65 6e ..int x = strlen
2100: 28 6d 73 67 29 20 2b 20 35 3b 0a 09 63 68 61 72 (msg) + 5;..char
2110: 20 69 6e 70 75 74 5b 53 54 52 49 4e 47 5f 53 48 input[STRING_SH
2120: 4f 52 54 5d 3b 0a 0a 09 2a 63 20 3d 20 30 3b 0a ORT];...*c = 0;.
2130: 09 64 6f 20 7b 0a 09 09 75 69 5f 73 74 61 74 75 .do {...ui_statu
2140: 73 6c 69 6e 65 5f 63 6c 65 61 72 28 29 3b 0a 09 sline_clear();..
2150: 09 69 66 28 2a 63 20 21 3d 20 30 29 7b 0a 09 09 .if(*c != 0){...
2160: 09 75 69 5f 73 74 61 74 75 73 6c 69 6e 65 5f 6d .ui_statusline_m
2170: 73 67 28 22 42 61 64 20 63 68 6f 69 63 65 2c 20 sg("Bad choice,
2180: 70 72 65 73 73 20 61 6e 79 20 6b 65 79 20 74 6f press any key to
2190: 20 74 72 79 20 61 67 61 69 6e 22 29 3b 0a 09 09 try again");...
21a0: 09 67 65 74 63 68 28 29 3b 0a 09 09 09 75 69 5f .getch();....ui_
21b0: 73 74 61 74 75 73 6c 69 6e 65 5f 63 6c 65 61 72 statusline_clear
21c0: 28 29 3b 0a 09 09 7d 0a 09 09 75 69 5f 73 74 61 ();...}...ui_sta
21d0: 74 75 73 6c 69 6e 65 5f 6d 73 67 28 6d 73 67 29 tusline_msg(msg)
21e0: 3b 0a 0a 09 09 65 63 68 6f 28 29 3b 0a 09 09 73 ;....echo();...s
21f0: 68 6f 77 5f 63 75 72 73 6f 72 28 29 3b 0a 0a 09 how_cursor();...
2200: 09 2a 63 20 3d 20 6d 76 77 67 65 74 63 68 28 62 .*c = mvwgetch(b
2210: 6f 74 74 6f 6d 2c 20 31 2c 20 78 29 3b 0a 0a 09 ottom, 1, x);...
2220: 09 6e 6f 65 63 68 6f 28 29 3b 0a 09 09 68 69 64 .noecho();...hid
2230: 65 5f 63 75 72 73 6f 72 28 29 3b 0a 09 09 0a 09 e_cursor();.....
2240: 7d 20 77 68 69 6c 65 20 28 20 21 73 74 72 63 68 } while ( !strch
2250: 72 28 76 61 6c 69 64 2c 20 2a 63 29 20 29 3b 0a r(valid, *c) );.
2260: 09 0a 09 75 69 5f 73 74 61 74 75 73 6c 69 6e 65 ...ui_statusline
2270: 5f 63 6c 65 61 72 28 29 3b 0a 7d 0a 0a 63 68 61 _clear();.}..cha
2280: 72 20 2a 0a 75 69 5f 73 74 61 74 75 73 6c 69 6e r *.ui_statuslin
2290: 65 5f 61 73 6b 5f 73 74 72 28 63 68 61 72 20 2a e_ask_str(char *
22a0: 6d 73 67 2c 20 63 68 61 72 20 2a 69 6e 70 75 74 msg, char *input
22b0: 2c 20 69 6e 74 20 6c 65 6e 29 0a 7b 0a 09 63 68 , int len).{..ch
22c0: 61 72 20 2a 74 6d 70 3b 0a 09 63 68 61 72 20 2a ar *tmp;..char *
22d0: 74 6d 70 32 3b 0a 09 63 68 61 72 20 2a 74 6d 70 tmp2;..char *tmp
22e0: 33 3b 0a 09 63 68 61 72 20 2a 6f 6c 64 69 6e 70 3;..char *oldinp
22f0: 75 74 3b 0a 09 69 6e 74 20 78 20 3d 20 73 74 72 ut;..int x = str
2300: 6c 65 6e 28 6d 73 67 29 20 2b 20 35 3b 0a 0a 09 len(msg) + 5;...
2310: 6f 6c 64 69 6e 70 75 74 20 3d 20 6d 61 6c 6c 6f oldinput = mallo
2320: 63 28 73 74 72 6c 65 6e 28 69 6e 70 75 74 29 2b c(strlen(input)+
2330: 31 29 3b 0a 09 2f 2f 42 61 63 6b 2d 75 70 20 74 1);..//Back-up t
2340: 68 65 20 6f 6c 64 20 76 61 6c 75 65 09 0a 09 73 he old value...s
2350: 74 72 63 70 79 28 6f 6c 64 69 6e 70 75 74 2c 20 trcpy(oldinput,
2360: 69 6e 70 75 74 29 3b 0a 0a 09 69 66 28 69 6e 70 input);...if(inp
2370: 75 74 20 3d 3d 20 4e 55 4c 4c 29 7b 0a 09 09 69 ut == NULL){...i
2380: 6e 70 75 74 20 3d 20 6d 61 6c 6c 6f 63 28 6c 65 nput = malloc(le
2390: 6e 29 3b 0a 09 7d 0a 09 75 69 5f 73 74 61 74 75 n);..}..ui_statu
23a0: 73 6c 69 6e 65 5f 63 6c 65 61 72 28 29 3b 0a 09 sline_clear();..
23b0: 75 69 5f 73 74 61 74 75 73 6c 69 6e 65 5f 6d 73 ui_statusline_ms
23c0: 67 28 6d 73 67 29 3b 0a 0a 09 65 63 68 6f 28 29 g(msg);...echo()
23d0: 3b 0a 09 73 68 6f 77 5f 63 75 72 73 6f 72 28 29 ;..show_cursor()
23e0: 3b 0a 09 6d 76 77 67 65 74 6e 73 74 72 28 62 6f ;..mvwgetnstr(bo
23f0: 74 74 6f 6d 2c 20 31 2c 20 78 2c 20 69 6e 70 75 ttom, 1, x, inpu
2400: 74 2c 20 6c 65 6e 29 3b 0a 09 6e 6f 65 63 68 6f t, len);..noecho
2410: 28 29 3b 0a 09 68 69 64 65 5f 63 75 72 73 6f 72 ();..hide_cursor
2420: 28 29 3b 0a 0a 09 75 69 5f 73 74 61 74 75 73 6c ();...ui_statusl
2430: 69 6e 65 5f 63 6c 65 61 72 28 29 3b 0a 0a 09 2f ine_clear();.../
2440: 2f 49 66 20 6a 75 73 74 20 72 65 74 75 72 6e 20 /If just return
2450: 65 6e 74 65 72 65 64 2c 20 64 6f 6e 27 74 20 6f entered, don't o
2460: 76 65 72 77 72 69 74 65 20 6f 6c 64 20 76 61 6c verwrite old val
2470: 75 65 0a 09 69 66 28 73 74 72 6c 65 6e 28 69 6e ue..if(strlen(in
2480: 70 75 74 29 20 3d 3d 20 30 29 7b 0a 09 09 73 74 put) == 0){...st
2490: 72 63 70 79 28 69 6e 70 75 74 2c 20 6f 6c 64 69 rcpy(input, oldi
24a0: 6e 70 75 74 29 3b 0a 09 7d 0a 0a 09 2f 2f 20 54 nput);..}...// T
24b0: 61 62 73 20 64 6f 6e 27 74 20 70 6c 61 79 20 6e abs don't play n
24c0: 69 63 65 6c 79 20 77 69 74 68 20 6e 63 75 72 73 icely with ncurs
24d0: 65 73 20 6f 72 20 78 6d 6c 0a 09 2f 2f 20 53 6f es or xml..// So
24e0: 2c 20 73 77 61 70 20 61 6e 79 20 66 6f 72 20 28 , swap any for (
24f0: 61 20 73 69 6e 67 6c 65 29 20 73 70 61 63 65 0a a single) space.
2500: 09 74 6d 70 20 3d 20 69 6e 70 75 74 3b 0a 09 77 .tmp = input;..w
2510: 68 69 6c 65 28 2a 74 6d 70 20 21 3d 20 30 29 20 hile(*tmp != 0)
2520: 7b 0a 09 09 69 66 28 2a 74 6d 70 20 3d 3d 20 39 {...if(*tmp == 9
2530: 29 20 2a 74 6d 70 20 3d 20 27 20 27 3b 0a 09 09 ) *tmp = ' ';...
2540: 74 6d 70 2b 2b 3b 0a 09 7d 0a 0a 09 2f 2f 20 49 tmp++;..}...// I
2550: 6e 20 73 6f 6d 65 20 63 61 73 65 73 20 28 65 67 n some cases (eg
2560: 20 77 68 65 6e 20 69 6e 73 69 64 65 20 73 63 72 when inside scr
2570: 65 65 6e 29 2c 20 74 68 65 20 62 61 63 6b 73 70 een), the backsp
2580: 61 63 65 0a 09 2f 2f 20 63 6f 6d 65 73 20 74 68 ace..// comes th
2590: 72 6f 75 67 68 20 74 6f 20 75 73 2e 20 48 61 6e rough to us. Han
25a0: 64 6c 65 20 69 74 20 68 65 72 65 20 69 66 20 6e dle it here if n
25b0: 65 65 64 65 64 0a 09 74 6d 70 20 3d 20 69 6e 70 eeded..tmp = inp
25c0: 75 74 3b 0a 09 77 68 69 6c 65 28 2a 74 6d 70 20 ut;..while(*tmp
25d0: 21 3d 20 30 29 20 7b 0a 09 09 69 66 28 2a 74 6d != 0) {...if(*tm
25e0: 70 20 3d 3d 20 38 29 20 7b 0a 20 20 20 20 20 20 p == 8) {.
25f0: 20 20 20 2f 2f 20 74 6d 70 32 20 69 73 20 77 68 // tmp2 is wh
2600: 65 72 65 20 74 6f 20 63 6f 70 79 20 74 6f 2c 20 ere to copy to,
2610: 74 6d 70 33 20 69 73 20 77 68 65 72 65 20 74 6f tmp3 is where to
2620: 20 63 6f 70 79 20 66 72 6f 6d 0a 20 20 20 20 20 copy from.
2630: 20 20 20 20 74 6d 70 33 20 3d 20 74 6d 70 20 2b tmp3 = tmp +
2640: 20 31 3b 0a 20 20 20 20 20 20 20 20 20 69 66 28 1;. if(
2650: 74 6d 70 20 3d 3d 20 69 6e 70 75 74 29 20 7b 0a tmp == input) {.
2660: 20 20 20 20 20 20 20 20 20 20 20 20 74 6d 70 32 tmp2
2670: 20 3d 20 74 6d 70 3b 0a 20 20 20 20 20 20 20 20 = tmp;.
2680: 20 7d 20 65 6c 73 65 20 7b 0a 20 20 20 20 20 20 } else {.
2690: 20 20 20 20 20 20 74 6d 70 32 20 3d 20 74 6d 70 tmp2 = tmp
26a0: 20 2d 20 31 3b 0a 20 20 20 20 20 20 20 20 20 7d - 1;. }
26b0: 0a 0a 20 20 20 20 20 20 20 20 20 2f 2f 20 57 68 .. // Wh
26c0: 65 6e 20 77 65 27 72 65 20 64 6f 6e 65 2c 20 73 en we're done, s
26d0: 74 61 72 74 20 66 72 6f 6d 20 74 68 65 20 63 68 tart from the ch
26e0: 61 72 61 63 74 65 72 0a 20 20 20 20 20 20 20 20 aracter.
26f0: 20 2f 2f 20 20 77 65 20 63 6f 70 69 65 64 20 69 // we copied i
2700: 6e 20 74 6f 0a 20 20 20 20 20 20 20 20 20 74 6d n to. tm
2710: 70 20 3d 20 74 6d 70 32 3b 0a 0a 20 20 20 20 20 p = tmp2;..
2720: 20 20 20 20 2f 2f 20 50 72 6f 63 65 73 73 20 66 // Process f
2730: 6f 72 77 61 72 64 0a 20 20 20 20 20 20 20 20 20 orward.
2740: 77 68 69 6c 65 28 2a 74 6d 70 33 20 21 3d 20 30 while(*tmp3 != 0
2750: 29 20 7b 0a 20 20 20 20 20 20 20 20 20 20 20 20 ) {.
2760: 2a 74 6d 70 32 20 3d 20 2a 74 6d 70 33 3b 0a 20 *tmp2 = *tmp3;.
2770: 20 20 20 20 20 20 20 20 20 20 20 74 6d 70 32 2b tmp2+
2780: 2b 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 74 +;. t
2790: 6d 70 33 2b 2b 3b 0a 20 20 20 20 20 20 20 20 20 mp3++;.
27a0: 7d 0a 20 20 20 20 20 20 20 20 20 2a 74 6d 70 32 }. *tmp2
27b0: 20 3d 20 30 3b 0a 20 20 20 20 20 20 7d 20 65 6c = 0;. } el
27c0: 73 65 20 7b 0a 20 20 20 09 09 74 6d 70 2b 2b 3b se {. ..tmp++;
27d0: 0a 20 20 20 20 20 20 7d 0a 09 7d 0a 09 0a 09 2f . }..}..../
27e0: 2f 20 41 6c 6c 20 64 6f 6e 65 0a 09 66 72 65 65 / All done..free
27f0: 28 6f 6c 64 69 6e 70 75 74 29 3b 0a 09 72 65 74 (oldinput);..ret
2800: 75 72 6e 20 69 6e 70 75 74 3b 0a 7d 0a 0a 63 68 urn input;.}..ch
2810: 61 72 20 2a 0a 75 69 5f 73 74 61 74 75 73 6c 69 ar *.ui_statusli
2820: 6e 65 5f 61 73 6b 5f 73 74 72 5f 77 69 74 68 5f ne_ask_str_with_
2830: 61 75 74 6f 67 65 6e 28 63 68 61 72 20 2a 6d 73 autogen(char *ms
2840: 67 2c 20 63 68 61 72 20 2a 69 6e 70 75 74 2c 20 g, char *input,
2850: 69 6e 74 20 6c 65 6e 2c 20 63 68 61 72 20 2a 28 int len, char *(
2860: 2a 61 75 74 6f 67 65 6e 29 28 63 68 61 72 20 2a *autogen)(char *
2870: 29 2c 20 69 6e 74 20 63 68 29 0a 7b 0a 09 69 6e ), int ch).{..in
2880: 74 20 69 20 3d 20 30 3b 0a 09 69 6e 74 20 63 3b t i = 0;..int c;
2890: 0a 09 63 68 61 72 20 2a 74 65 78 74 5b 32 5d 2c ..char *text[2],
28a0: 20 2a 73 3b 0a 09 63 68 61 72 20 2a 6f 6c 64 69 *s;..char *oldi
28b0: 6e 70 75 74 3b 0a 09 69 6e 74 20 78 3b 0a 0a 09 nput;..int x;...
28c0: 6f 6c 64 69 6e 70 75 74 20 3d 20 6d 61 6c 6c 6f oldinput = mallo
28d0: 63 28 73 74 72 6c 65 6e 28 69 6e 70 75 74 29 2b c(strlen(input)+
28e0: 31 29 3b 0a 09 2f 2f 42 61 63 6b 2d 75 70 20 74 1);..//Back-up t
28f0: 68 65 20 6f 6c 64 20 76 61 6c 75 65 09 0a 09 73 he old value...s
2900: 74 72 63 70 79 28 6f 6c 64 69 6e 70 75 74 2c 20 trcpy(oldinput,
2910: 69 6e 70 75 74 29 3b 0a 0a 09 69 66 28 69 6e 70 input);...if(inp
2920: 75 74 20 3d 3d 20 4e 55 4c 4c 29 7b 0a 09 09 69 ut == NULL){...i
2930: 6e 70 75 74 20 3d 20 6d 61 6c 6c 6f 63 28 6c 65 nput = malloc(le
2940: 6e 29 3b 0a 09 7d 0a 09 74 65 78 74 5b 30 5d 20 n);..}..text[0]
2950: 3d 20 6d 61 6c 6c 6f 63 28 53 54 52 49 4e 47 5f = malloc(STRING_
2960: 4d 45 44 49 55 4d 29 3b 0a 09 74 65 78 74 5b 31 MEDIUM);..text[1
2970: 5d 20 3d 20 6d 61 6c 6c 6f 63 28 53 54 52 49 4e ] = malloc(STRIN
2980: 47 5f 53 48 4f 52 54 29 3b 0a 09 0a 09 73 74 72 G_SHORT);....str
2990: 6e 63 70 79 28 74 65 78 74 5b 31 5d 2c 20 6d 73 ncpy(text[1], ms
29a0: 67 2c 20 53 54 52 49 4e 47 5f 53 48 4f 52 54 29 g, STRING_SHORT)
29b0: 3b 0a 09 69 66 28 73 20 3d 20 73 74 72 72 63 68 ;..if(s = strrch
29c0: 72 28 74 65 78 74 5b 31 5d 2c 20 27 3a 27 29 29 r(text[1], ':'))
29d0: 7b 0a 09 09 2a 73 20 3d 20 30 3b 0a 09 7d 0a 09 {...*s = 0;..}..
29e0: 73 6e 70 72 69 6e 74 66 28 74 65 78 74 5b 30 5d snprintf(text[0]
29f0: 2c 20 53 54 52 49 4e 47 5f 4d 45 44 49 55 4d 2c , STRING_MEDIUM,
2a00: 20 22 25 73 28 25 63 20 66 6f 72 20 61 75 74 6f "%s(%c for auto
2a10: 67 65 6e 29 3a 5c 74 22 2c 20 74 65 78 74 5b 31 gen):\t", text[1
2a20: 5d 2c 63 68 29 3b 0a 09 78 20 3d 20 73 74 72 6c ],ch);..x = strl
2a30: 65 6e 28 74 65 78 74 5b 30 5d 29 20 2b 20 35 3b en(text[0]) + 5;
2a40: 0a 0a 09 75 69 5f 73 74 61 74 75 73 6c 69 6e 65 ...ui_statusline
2a50: 5f 63 6c 65 61 72 28 29 3b 0a 09 75 69 5f 73 74 _clear();..ui_st
2a60: 61 74 75 73 6c 69 6e 65 5f 6d 73 67 28 74 65 78 atusline_msg(tex
2a70: 74 5b 30 5d 29 3b 0a 0a 09 73 68 6f 77 5f 63 75 t[0]);...show_cu
2a80: 72 73 6f 72 28 29 3b 0a 09 6e 6f 65 63 68 6f 28 rsor();..noecho(
2a90: 29 3b 0a 0a 09 77 6d 6f 76 65 28 62 6f 74 74 6f );...wmove(botto
2aa0: 6d 2c 20 31 2c 20 78 29 3b 0a 0a 09 77 68 69 6c m, 1, x);...whil
2ab0: 65 28 69 20 3c 20 6c 65 6e 29 7b 0a 09 09 63 20 e(i < len){...c
2ac0: 3d 20 77 67 65 74 63 68 28 62 6f 74 74 6f 6d 29 = wgetch(bottom)
2ad0: 3b 0a 09 09 69 66 28 63 20 3d 3d 20 30 78 37 66 ;...if(c == 0x7f
2ae0: 29 7b 0a 09 09 09 69 66 28 69 29 7b 0a 09 09 09 ){....if(i){....
2af0: 09 69 2d 2d 3b 0a 09 09 09 09 6d 76 77 61 64 64 .i--;.....mvwadd
2b00: 63 68 28 62 6f 74 74 6f 6d 2c 20 31 2c 20 78 2b ch(bottom, 1, x+
2b10: 69 2c 20 27 20 27 29 3b 0a 09 09 09 09 77 6d 6f i, ' ');.....wmo
2b20: 76 65 28 62 6f 74 74 6f 6d 2c 20 31 2c 20 78 2b ve(bottom, 1, x+
2b30: 69 29 3b 0a 09 09 09 7d 0a 09 09 7d 20 65 6c 73 i);....}...} els
2b40: 65 20 69 66 28 63 20 3d 3d 20 30 78 64 29 7b 0a e if(c == 0xd){.
2b50: 09 09 09 69 6e 70 75 74 5b 69 5d 20 3d 20 30 3b ...input[i] = 0;
2b60: 0a 09 09 09 62 72 65 61 6b 3b 0a 09 09 7d 20 65 ....break;...} e
2b70: 6c 73 65 20 69 66 28 63 20 3d 3d 20 63 68 29 7b lse if(c == ch){
2b80: 0a 09 09 09 69 6e 70 75 74 20 3d 20 61 75 74 6f ....input = auto
2b90: 67 65 6e 28 69 6e 70 75 74 29 3b 0a 09 09 09 62 gen(input);....b
2ba0: 72 65 61 6b 3b 0a 09 09 7d 20 65 6c 73 65 20 7b reak;...} else {
2bb0: 0a 09 09 09 69 6e 70 75 74 5b 69 5d 20 3d 20 63 ....input[i] = c
2bc0: 3b 0a 09 09 09 6d 76 77 61 64 64 63 68 28 62 6f ;....mvwaddch(bo
2bd0: 74 74 6f 6d 2c 20 31 2c 20 78 20 2b 20 69 2c 20 ttom, 1, x + i,
2be0: 63 29 3b 0a 09 09 09 69 2b 2b 3b 0a 09 09 7d 0a c);....i++;...}.
2bf0: 09 7d 0a 09 0a 09 68 69 64 65 5f 63 75 72 73 6f .}....hide_curso
2c00: 72 28 29 3b 0a 09 0a 09 75 69 5f 73 74 61 74 75 r();....ui_statu
2c10: 73 6c 69 6e 65 5f 63 6c 65 61 72 28 29 3b 0a 0a sline_clear();..
2c20: 09 2f 2f 49 66 20 6a 75 73 74 20 72 65 74 75 72 .//If just retur
2c30: 6e 20 65 6e 74 65 72 65 64 2c 20 64 6f 6e 27 74 n entered, don't
2c40: 20 6f 76 65 72 77 72 69 74 65 20 6f 6c 64 20 76 overwrite old v
2c50: 61 6c 75 65 0a 09 69 66 28 73 74 72 6c 65 6e 28 alue..if(strlen(
2c60: 69 6e 70 75 74 29 20 3d 3d 20 30 29 7b 0a 09 09 input) == 0){...
2c70: 73 74 72 63 70 79 28 69 6e 70 75 74 2c 20 6f 6c strcpy(input, ol
2c80: 64 69 6e 70 75 74 29 3b 0a 09 7d 0a 0a 09 66 72 dinput);..}...fr
2c90: 65 65 28 74 65 78 74 5b 30 5d 29 3b 0a 09 66 72 ee(text[0]);..fr
2ca0: 65 65 28 74 65 78 74 5b 31 5d 29 3b 0a 09 66 72 ee(text[1]);..fr
2cb0: 65 65 28 6f 6c 64 69 6e 70 75 74 29 3b 0a 0a 09 ee(oldinput);...
2cc0: 72 65 74 75 72 6e 20 69 6e 70 75 74 3b 0a 7d 0a return input;.}.
2cd0: 0a 63 68 61 72 20 2a 0a 75 69 5f 73 74 61 74 75 .char *.ui_statu
2ce0: 73 6c 69 6e 65 5f 61 73 6b 5f 70 61 73 73 77 64 sline_ask_passwd
2cf0: 28 63 68 61 72 20 2a 6d 73 67 2c 20 63 68 61 72 (char *msg, char
2d00: 20 2a 69 6e 70 75 74 2c 20 69 6e 74 20 6c 65 6e *input, int len
2d10: 2c 20 69 6e 74 20 63 61 6e 63 65 6c 29 0a 7b 0a , int cancel).{.
2d20: 09 69 6e 74 20 69 20 3d 20 30 3b 0a 09 69 6e 74 .int i = 0;..int
2d30: 20 63 3b 0a 09 69 6e 74 20 78 20 3d 20 73 74 72 c;..int x = str
2d40: 6c 65 6e 28 6d 73 67 29 20 2b 20 35 3b 0a 0a 09 len(msg) + 5;...
2d50: 69 66 28 21 69 6e 70 75 74 29 7b 0a 09 09 69 6e if(!input){...in
2d60: 70 75 74 20 3d 20 6d 61 6c 6c 6f 63 28 6c 65 6e put = malloc(len
2d70: 29 3b 0a 09 7d 0a 09 75 69 5f 73 74 61 74 75 73 );..}..ui_status
2d80: 6c 69 6e 65 5f 63 6c 65 61 72 28 29 3b 0a 09 75 line_clear();..u
2d90: 69 5f 73 74 61 74 75 73 6c 69 6e 65 5f 6d 73 67 i_statusline_msg
2da0: 28 6d 73 67 29 3b 0a 0a 09 73 68 6f 77 5f 63 75 (msg);...show_cu
2db0: 72 73 6f 72 28 29 3b 0a 09 6e 6f 65 63 68 6f 28 rsor();..noecho(
2dc0: 29 3b 0a 0a 09 77 6d 6f 76 65 28 62 6f 74 74 6f );...wmove(botto
2dd0: 6d 2c 20 31 2c 20 78 29 3b 0a 0a 09 77 68 69 6c m, 1, x);...whil
2de0: 65 28 69 20 3c 20 6c 65 6e 29 7b 0a 09 09 63 20 e(i < len){...c
2df0: 3d 20 77 67 65 74 63 68 28 62 6f 74 74 6f 6d 29 = wgetch(bottom)
2e00: 3b 0a 09 09 69 66 28 63 20 3d 3d 20 30 78 37 66 ;...if(c == 0x7f
2e10: 29 7b 20 2f 2a 20 30 78 37 66 20 3d 20 64 65 6c ){ /* 0x7f = del
2e20: 65 74 65 20 2a 2f 0a 09 09 09 69 66 28 69 29 7b ete */....if(i){
2e30: 0a 09 09 09 09 69 2d 2d 3b 0a 09 09 09 09 6d 76 .....i--;.....mv
2e40: 77 61 64 64 63 68 28 62 6f 74 74 6f 6d 2c 20 31 waddch(bottom, 1
2e50: 2c 20 78 2b 69 2c 20 27 20 27 29 3b 0a 09 09 09 , x+i, ' ');....
2e60: 09 77 6d 6f 76 65 28 62 6f 74 74 6f 6d 2c 20 31 .wmove(bottom, 1
2e70: 2c 20 78 2b 69 29 3b 0a 09 09 09 7d 0a 09 09 7d , x+i);....}...}
2e80: 20 65 6c 73 65 20 69 66 28 63 20 3d 3d 20 30 78 else if(c == 0x
2e90: 64 29 7b 20 2f 2a 20 30 78 64 20 3d 3d 20 65 6e d){ /* 0xd == en
2ea0: 74 65 72 2f 72 65 74 75 72 6e 20 2a 2f 0a 09 09 ter/return */...
2eb0: 09 69 6e 70 75 74 5b 69 5d 20 3d 20 30 3b 0a 09 .input[i] = 0;..
2ec0: 09 09 62 72 65 61 6b 3b 0a 09 09 7d 20 65 6c 73 ..break;...} els
2ed0: 65 20 69 66 28 63 20 3d 3d 20 63 61 6e 63 65 6c e if(c == cancel
2ee0: 29 7b 0a 09 09 09 66 72 65 65 28 69 6e 70 75 74 ){....free(input
2ef0: 29 3b 0a 09 09 09 69 6e 70 75 74 20 3d 20 4e 55 );....input = NU
2f00: 4c 4c 3b 0a 0a 09 09 09 72 65 74 75 72 6e 20 69 LL;.....return i
2f10: 6e 70 75 74 3b 0a 09 09 7d 20 65 6c 73 65 20 7b nput;...} else {
2f20: 0a 09 09 09 69 6e 70 75 74 5b 69 5d 20 3d 20 63 ....input[i] = c
2f30: 3b 0a 09 09 09 6d 76 77 61 64 64 63 68 28 62 6f ;....mvwaddch(bo
2f40: 74 74 6f 6d 2c 20 31 2c 20 78 20 2b 20 69 2c 20 ttom, 1, x + i,
2f50: 27 2a 27 29 3b 0a 09 09 09 69 2b 2b 3b 0a 09 09 '*');....i++;...
2f60: 7d 0a 09 7d 0a 09 0a 09 68 69 64 65 5f 63 75 72 }..}....hide_cur
2f70: 73 6f 72 28 29 3b 0a 09 0a 09 75 69 5f 73 74 61 sor();....ui_sta
2f80: 74 75 73 6c 69 6e 65 5f 63 6c 65 61 72 28 29 3b tusline_clear();
2f90: 0a 09 0a 09 72 65 74 75 72 6e 20 69 6e 70 75 74 ....return input
2fa0: 3b 0a 7d 0a 0a 69 6e 74 20 0a 75 69 5f 73 74 61 ;.}..int .ui_sta
2fb0: 74 75 73 6c 69 6e 65 5f 79 65 73 5f 6e 6f 28 63 tusline_yes_no(c
2fc0: 68 61 72 20 2a 6d 73 67 2c 20 69 6e 74 20 64 65 har *msg, int de
2fd0: 66 29 0a 7b 0a 09 69 6e 74 20 72 65 74 20 3d 20 f).{..int ret =
2fe0: 2d 31 2c 20 6c 65 6e 3b 0a 09 63 68 61 72 20 2a -1, len;..char *
2ff0: 6d 73 67 32 3b 0a 09 69 6e 74 20 63 68 3b 0a 09 msg2;..int ch;..
3000: 0a 09 6c 65 6e 20 3d 20 73 74 72 6c 65 6e 28 6d ..len = strlen(m
3010: 73 67 29 20 2b 20 31 30 3b 0a 09 6d 73 67 32 20 sg) + 10;..msg2
3020: 3d 20 6d 61 6c 6c 6f 63 28 6c 65 6e 29 3b 0a 0a = malloc(len);..
3030: 09 73 6e 70 72 69 6e 74 66 28 6d 73 67 32 2c 20 .snprintf(msg2,
3040: 6c 65 6e 2c 20 20 22 25 73 25 73 22 2c 20 6d 73 len, "%s%s", ms
3050: 67 2c 20 64 65 66 20 3f 20 22 20 28 59 2f 6e 29 g, def ? " (Y/n)
3060: 3f 22 20 3a 20 22 20 28 79 2f 4e 29 3f 22 2c 20 ?" : " (y/N)?",
3070: 4e 55 4c 4c 29 3b 0a 0a 09 77 68 69 6c 65 28 72 NULL);...while(r
3080: 65 74 20 3d 3d 20 2d 31 29 7b 0a 09 09 75 69 5f et == -1){...ui_
3090: 73 74 61 74 75 73 6c 69 6e 65 5f 6d 73 67 28 6d statusline_msg(m
30a0: 73 67 32 29 3b 0a 09 09 0a 09 09 63 68 20 3d 20 sg2);......ch =
30b0: 67 65 74 63 68 28 29 3b 0a 09 09 73 77 69 74 63 getch();...switc
30c0: 68 28 20 63 68 20 29 7b 0a 09 09 09 63 61 73 65 h( ch ){....case
30d0: 20 27 6e 27 3a 0a 09 09 09 63 61 73 65 20 27 4e 'n':....case 'N
30e0: 27 3a 0a 09 09 09 09 72 65 74 20 3d 20 46 41 4c ':.....ret = FAL
30f0: 53 45 3b 0a 09 09 09 09 62 72 65 61 6b 3b 0a 09 SE;.....break;..
3100: 09 09 63 61 73 65 20 27 79 27 3a 0a 09 09 09 63 ..case 'y':....c
3110: 61 73 65 20 27 59 27 3a 0a 09 09 09 09 72 65 74 ase 'Y':.....ret
3120: 20 3d 20 54 52 55 45 3b 0a 09 09 09 09 62 72 65 = TRUE;.....bre
3130: 61 6b 3b 0a 09 09 09 63 61 73 65 20 31 33 3a 0a ak;....case 13:.
3140: 09 09 09 09 72 65 74 20 3d 20 64 65 66 3b 0a 09 ....ret = def;..
3150: 09 09 09 62 72 65 61 6b 3b 0a 09 09 09 64 65 66 ...break;....def
3160: 61 75 6c 74 3a 0a 09 09 09 09 75 69 5f 73 74 61 ault:.....ui_sta
3170: 74 75 73 6c 69 6e 65 5f 6d 73 67 28 22 42 61 64 tusline_msg("Bad
3180: 20 6f 70 74 69 6f 6e 2c 20 74 72 79 20 61 67 61 option, try aga
3190: 69 6e 2e 22 29 3b 0a 09 09 09 09 67 65 74 63 68 in.");.....getch
31a0: 28 29 3b 0a 09 09 09 09 62 72 65 61 6b 3b 0a 09 ();.....break;..
31b0: 09 7d 0a 09 7d 0a 0a 09 66 72 65 65 28 6d 73 67 .}..}...free(msg
31c0: 32 29 3b 0a 09 75 69 5f 73 74 61 74 75 73 6c 69 2);..ui_statusli
31d0: 6e 65 5f 63 6c 65 61 72 28 29 3b 0a 0a 09 72 65 ne_clear();...re
31e0: 74 75 72 6e 20 72 65 74 3b 0a 7d 0a 0a 76 6f 69 turn ret;.}..voi
31f0: 64 0a 73 74 61 74 75 73 6c 69 6e 65 5f 72 65 61 d.statusline_rea
3200: 64 6f 6e 6c 79 28 29 0a 7b 0a 09 75 69 5f 73 74 donly().{..ui_st
3210: 61 74 75 73 6c 69 6e 65 5f 6d 73 67 28 22 50 61 atusline_msg("Pa
3220: 73 73 77 6f 72 64 20 66 69 6c 65 20 69 73 20 6f ssword file is o
3230: 70 65 6e 65 64 20 72 65 61 64 6f 6e 6c 79 22 29 pened readonly")
3240: 3b 0a 7d 0a 0a 69 6e 74 20 0a 75 69 5f 64 69 73 ;.}..int .ui_dis
3250: 70 6c 61 79 5f 68 65 6c 70 28 29 0a 7b 0a 09 69 play_help().{..i
3260: 6e 74 20 69 3b 0a 09 57 49 4e 44 4f 57 20 2a 68 nt i;..WINDOW *h
3270: 65 6c 70 77 69 6e 3b 0a 0a 09 68 65 6c 70 77 69 elpwin;...helpwi
3280: 6e 20 3d 20 6e 65 77 77 69 6e 28 4c 49 4e 45 53 n = newwin(LINES
3290: 20 2d 20 35 2c 20 43 4f 4c 53 20 2d 20 36 2c 20 - 5, COLS - 6,
32a0: 33 2c 20 33 29 3b 0a 09 75 69 6c 69 73 74 5f 63 3, 3);..uilist_c
32b0: 6c 65 61 72 28 29 3b 0a 0a 09 66 6f 72 28 69 20 lear();...for(i
32c0: 3d 20 30 3b 20 68 65 6c 70 5b 69 5d 20 21 3d 20 = 0; help[i] !=
32d0: 4e 55 4c 4c 3b 20 69 2b 2b 29 7b 0a 09 09 77 61 NULL; i++){...wa
32e0: 64 64 73 74 72 28 68 65 6c 70 77 69 6e 2c 20 68 ddstr(helpwin, h
32f0: 65 6c 70 5b 69 5d 29 3b 0a 09 09 69 66 28 20 21 elp[i]);...if( !
3300: 28 28 69 2b 31 29 20 25 20 28 4c 49 4e 45 53 20 ((i+1) % (LINES
3310: 2d 20 39 29 29 20 7c 7c 20 28 68 65 6c 70 5b 69 - 9)) || (help[i
3320: 2b 31 5d 20 3d 3d 20 4e 55 4c 4c 29 20 29 7b 0a +1] == NULL) ){.
3330: 09 2f 2a 09 09 72 65 66 72 65 73 68 28 29 3b 2a ./*..refresh();*
3340: 2f 0a 09 09 09 77 72 65 66 72 65 73 68 28 68 65 /....wrefresh(he
3350: 6c 70 77 69 6e 29 3b 0a 09 09 09 75 69 5f 73 74 lpwin);....ui_st
3360: 61 74 75 73 6c 69 6e 65 5f 6d 73 67 28 22 50 72 atusline_msg("Pr
3370: 65 73 73 20 61 6e 79 20 6b 65 79 20 74 6f 20 63 ess any key to c
3380: 6f 6e 74 69 6e 75 65 2e 2e 2e 22 29 3b 0a 09 09 ontinue...");...
3390: 09 67 65 74 63 68 28 29 3b 0a 09 09 09 77 63 6c .getch();....wcl
33a0: 65 61 72 28 68 65 6c 70 77 69 6e 29 3b 0a 09 09 ear(helpwin);...
33b0: 7d 0a 09 7d 0a 09 75 69 6c 69 73 74 5f 72 65 66 }..}..uilist_ref
33c0: 72 65 73 68 28 29 3b 0a 09 75 69 5f 73 74 61 74 resh();..ui_stat
33d0: 75 73 6c 69 6e 65 5f 63 6c 65 61 72 28 29 3b 0a usline_clear();.
33e0: 09 64 65 6c 77 69 6e 28 68 65 6c 70 77 69 6e 29 .delwin(helpwin)
33f0: 3b 0a 7d 0a ;.}.