Artifact 51298907ede143625cfe47042d3e04658228b9d649c9035a07c9ff3d6615f7b4:
- File
src/uilist.c
— part of check-in
[f05023e8f3]
at
2011-02-15 22:24:16
on branch origin/tweaks
— Tweak search internals to always track the parent of items, and use this to allow locating of search entries
git-svn-id: https://pwman.svn.sourceforge.net/svnroot/pwman/trunk@121 db5f1c25-4851-472e-ac1e-5437d07aece1 (user: gagravarr@users.sourceforge.net size: 8173)
- File uilist.c — part of check-in [c14cf350df] at 2014-05-15 21:36:21 on branch manualheaven — Move src and doc files to top directory (user: base@atomicules.co.uk size: 8173)
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: 73 74 64 6c 69 62 2e 68 3e 0a 23 69 6e 63 6c 75 stdlib.h>.#inclu
0360: 64 65 20 3c 75 69 2e 68 3e 0a 23 69 6e 63 6c 75 de <ui.h>.#inclu
0370: 64 65 20 3c 70 77 6d 61 6e 2e 68 3e 0a 0a 57 49 de <pwman.h>..WI
0380: 4e 44 4f 57 20 2a 6c 69 73 74 20 3d 20 4e 55 4c NDOW *list = NUL
0390: 4c 3b 0a 69 6e 74 20 6c 69 6e 65 73 20 3d 20 30 L;.int lines = 0
03a0: 3b 0a 69 6e 74 20 66 69 72 73 74 5f 6c 69 73 74 ;.int first_list
03b0: 5f 69 74 65 6d 20 3d 20 30 3b 0a 2f 2f 69 6e 74 _item = 0;.//int
03c0: 20 63 75 72 69 74 65 6d 20 3d 20 30 3b 0a 0a 69 curitem = 0;..i
03d0: 6e 74 0a 75 69 6c 69 73 74 5f 69 6e 69 74 28 29 nt.uilist_init()
03e0: 0a 7b 0a 09 63 68 61 72 20 73 74 72 5b 38 30 5d .{..char str[80]
03f0: 3b 0a 09 6c 69 73 74 20 3d 20 6e 65 77 77 69 6e ;..list = newwin
0400: 28 4c 49 53 54 5f 4c 49 4e 45 53 2c 20 43 4f 4c (LIST_LINES, COL
0410: 53 2c 20 4c 49 53 54 5f 54 4f 50 2c 20 30 29 3b S, LIST_TOP, 0);
0420: 0a 09 0a 09 73 63 72 6f 6c 6c 6f 6b 28 6c 69 73 ....scrollok(lis
0430: 74 2c 20 54 52 55 45 29 3b 0a 7d 0a 2f 2a 0a 69 t, TRUE);.}./*.i
0440: 6e 74 0a 72 65 73 69 7a 65 5f 6c 69 73 74 28 29 nt.resize_list()
0450: 0a 7b 0a 09 77 72 65 73 69 7a 65 28 6c 69 73 74 .{..wresize(list
0460: 2c 20 4c 49 53 54 5f 4c 49 4e 45 53 2c 20 43 4f , LIST_LINES, CO
0470: 4c 53 29 3b 0a 7d 0a 2a 2f 0a 0a 69 6e 74 0a 75 LS);.}.*/..int.u
0480: 69 6c 69 73 74 5f 66 72 65 65 28 29 0a 7b 0a 09 ilist_free().{..
0490: 64 65 6c 77 69 6e 28 6c 69 73 74 29 3b 0a 09 6c delwin(list);..l
04a0: 69 73 74 20 3d 20 4e 55 4c 4c 3b 0a 7d 0a 0a 69 ist = NULL;.}..i
04b0: 6e 74 20 0a 75 69 6c 69 73 74 5f 68 69 67 68 6c nt .uilist_highl
04c0: 69 67 68 74 5f 6c 69 6e 65 28 69 6e 74 20 6c 69 ight_line(int li
04d0: 6e 65 29 0a 7b 0a 09 77 73 74 61 6e 64 6f 75 74 ne).{..wstandout
04e0: 28 6c 69 73 74 29 3b 0a 2f 2a 09 6d 76 77 63 68 (list);./*.mvwch
04f0: 67 61 74 28 6c 69 73 74 2c 20 69 2c 20 30 2c 20 gat(list, i, 0,
0500: 2d 31 2c 20 41 5f 53 54 41 4e 44 4f 55 54 2c 20 -1, A_STANDOUT,
0510: 30 2c 20 4e 55 4c 4c 29 3b 2a 2f 0a 20 20 20 20 0, NULL);*/.
0520: 20 20 20 20 73 63 72 6f 6c 6c 6f 6b 28 6c 69 73 scrollok(lis
0530: 74 2c 20 46 41 4c 53 45 29 3b 0a 09 20 20 20 20 t, FALSE);..
0540: 20 20 20 20 7b 0a 20 20 20 20 20 20 20 20 20 20 {.
0550: 20 20 20 20 20 20 69 6e 74 20 69 3b 0a 20 20 20 int i;.
0560: 20 20 20 20 20 20 20 20 20 20 20 20 20 77 6d 6f wmo
0570: 76 65 28 6c 69 73 74 2c 20 6c 69 6e 65 2c 20 30 ve(list, line, 0
0580: 29 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 );.
0590: 20 20 20 66 6f 72 28 69 20 3d 20 30 3b 20 69 20 for(i = 0; i
05a0: 3c 20 43 4f 4c 53 3b 20 69 2b 2b 29 0a 20 20 20 < COLS; i++).
05b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
05c0: 20 20 20 20 20 77 61 64 64 63 68 28 6c 69 73 74 waddch(list
05d0: 2c 20 27 20 27 29 3b 0a 09 20 20 20 20 20 20 20 , ' ');..
05e0: 20 2f 2a 77 61 74 74 72 73 65 74 28 77 69 6e 2c /*wattrset(win,
05f0: 20 30 29 3b 2a 2f 0a 20 20 20 20 20 20 20 20 7d 0);*/. }
0600: 0a 20 20 20 20 20 20 20 20 73 63 72 6f 6c 6c 6f . scrollo
0610: 6b 28 6c 69 73 74 2c 20 54 52 55 45 29 3b 0a 7d k(list, TRUE);.}
0620: 0a 0a 50 57 53 65 61 72 63 68 52 65 73 75 6c 74 ..PWSearchResult
0630: 20 2a 0a 75 69 6c 69 73 74 5f 67 65 74 5f 68 69 *.uilist_get_hi
0640: 67 68 6c 69 67 68 74 65 64 5f 73 65 61 72 63 68 ghlighted_search
0650: 72 65 73 75 6c 74 28 29 20 7b 0a 09 50 57 53 65 result() {..PWSe
0660: 61 72 63 68 52 65 73 75 6c 74 20 2a 73 72 63 68 archResult *srch
0670: 69 74 65 72 3b 0a 09 69 6e 74 20 69 20 3d 20 2d iter;..int i = -
0680: 31 3b 0a 0a 09 66 6f 72 28 73 72 63 68 69 74 65 1;...for(srchite
0690: 72 20 3d 20 73 65 61 72 63 68 5f 72 65 73 75 6c r = search_resul
06a0: 74 73 3b 20 28 73 72 63 68 69 74 65 72 20 21 3d ts; (srchiter !=
06b0: 20 4e 55 4c 4c 29 3b 20 73 72 63 68 69 74 65 72 NULL); srchiter
06c0: 20 3d 20 73 72 63 68 69 74 65 72 2d 3e 6e 65 78 = srchiter->nex
06d0: 74 29 20 7b 0a 09 09 69 2b 2b 3b 0a 09 09 69 66 t) {...i++;...if
06e0: 28 69 20 3d 3d 20 63 75 72 72 65 6e 74 5f 70 77 (i == current_pw
06f0: 5f 73 75 62 6c 69 73 74 2d 3e 63 75 72 72 65 6e _sublist->curren
0700: 74 5f 69 74 65 6d 29 7b 0a 09 09 09 62 72 65 61 t_item){....brea
0710: 6b 3b 0a 09 09 7d 0a 09 7d 0a 09 72 65 74 75 72 k;...}..}..retur
0720: 6e 20 73 72 63 68 69 74 65 72 3b 0a 7d 0a 0a 50 n srchiter;.}..P
0730: 57 4c 69 73 74 20 2a 0a 75 69 6c 69 73 74 5f 67 WList *.uilist_g
0740: 65 74 5f 68 69 67 68 6c 69 67 68 74 65 64 5f 73 et_highlighted_s
0750: 75 62 6c 69 73 74 28 29 0a 7b 0a 09 50 57 4c 69 ublist().{..PWLi
0760: 73 74 20 2a 69 74 65 72 3b 0a 09 69 6e 74 20 69 st *iter;..int i
0770: 20 3d 20 2d 31 3b 0a 0a 09 69 66 28 21 63 75 72 = -1;...if(!cur
0780: 72 65 6e 74 5f 70 77 5f 73 75 62 6c 69 73 74 29 rent_pw_sublist)
0790: 7b 20 72 65 74 75 72 6e 20 4e 55 4c 4c 3b 20 7d { return NULL; }
07a0: 0a 09 69 66 28 63 75 72 72 65 6e 74 5f 70 77 5f ..if(current_pw_
07b0: 73 75 62 6c 69 73 74 2d 3e 70 61 72 65 6e 74 29 sublist->parent)
07c0: 7b 20 69 2b 2b 3b 20 7d 0a 0a 09 66 6f 72 28 69 { i++; }...for(i
07d0: 74 65 72 20 3d 20 63 75 72 72 65 6e 74 5f 70 77 ter = current_pw
07e0: 5f 73 75 62 6c 69 73 74 2d 3e 73 75 62 6c 69 73 _sublist->sublis
07f0: 74 73 3b 20 69 74 65 72 20 21 3d 20 4e 55 4c 4c ts; iter != NULL
0800: 3b 20 69 74 65 72 20 3d 20 69 74 65 72 2d 3e 6e ; iter = iter->n
0810: 65 78 74 29 7b 0a 09 09 69 2b 2b 3b 0a 09 09 69 ext){...i++;...i
0820: 66 28 69 20 3d 3d 20 63 75 72 72 65 6e 74 5f 70 f(i == current_p
0830: 77 5f 73 75 62 6c 69 73 74 2d 3e 63 75 72 72 65 w_sublist->curre
0840: 6e 74 5f 69 74 65 6d 29 7b 0a 09 09 09 62 72 65 nt_item){....bre
0850: 61 6b 3b 0a 09 09 7d 0a 09 7d 0a 09 72 65 74 75 ak;...}..}..retu
0860: 72 6e 20 69 74 65 72 3b 0a 7d 0a 0a 50 77 20 2a rn iter;.}..Pw *
0870: 0a 75 69 6c 69 73 74 5f 67 65 74 5f 68 69 67 68 .uilist_get_high
0880: 6c 69 67 68 74 65 64 5f 69 74 65 6d 28 29 0a 7b lighted_item().{
0890: 09 0a 09 50 77 20 2a 69 74 65 72 3b 0a 09 50 57 ...Pw *iter;..PW
08a0: 4c 69 73 74 20 2a 6c 69 73 74 69 74 65 72 3b 0a List *listiter;.
08b0: 09 69 6e 74 20 69 20 3d 20 2d 31 3b 0a 0a 09 69 .int i = -1;...i
08c0: 66 28 63 75 72 72 65 6e 74 5f 70 77 5f 73 75 62 f(current_pw_sub
08d0: 6c 69 73 74 2d 3e 70 61 72 65 6e 74 29 7b 20 69 list->parent){ i
08e0: 2b 2b 3b 20 7d 0a 09 0a 09 66 6f 72 28 6c 69 73 ++; }....for(lis
08f0: 74 69 74 65 72 20 3d 20 63 75 72 72 65 6e 74 5f titer = current_
0900: 70 77 5f 73 75 62 6c 69 73 74 2d 3e 73 75 62 6c pw_sublist->subl
0910: 69 73 74 73 3b 20 6c 69 73 74 69 74 65 72 20 21 ists; listiter !
0920: 3d 20 4e 55 4c 4c 3b 20 6c 69 73 74 69 74 65 72 = NULL; listiter
0930: 20 3d 20 6c 69 73 74 69 74 65 72 2d 3e 6e 65 78 = listiter->nex
0940: 74 29 7b 0a 09 09 69 2b 2b 3b 0a 09 7d 0a 09 09 t){...i++;..}...
0950: 0a 09 66 6f 72 28 69 74 65 72 20 3d 20 63 75 72 ..for(iter = cur
0960: 72 65 6e 74 5f 70 77 5f 73 75 62 6c 69 73 74 2d rent_pw_sublist-
0970: 3e 6c 69 73 74 3b 20 69 74 65 72 20 21 3d 20 4e >list; iter != N
0980: 55 4c 4c 3b 20 69 74 65 72 20 3d 20 69 74 65 72 ULL; iter = iter
0990: 2d 3e 6e 65 78 74 29 7b 0a 09 09 69 66 28 20 66 ->next){...if( f
09a0: 69 6c 74 65 72 5f 61 70 70 6c 79 28 69 74 65 72 ilter_apply(iter
09b0: 2c 20 6f 70 74 69 6f 6e 73 2d 3e 66 69 6c 74 65 , options->filte
09c0: 72 29 20 29 7b 0a 09 09 09 69 2b 2b 3b 0a 09 09 r) ){....i++;...
09d0: 7d 0a 09 09 69 66 28 20 69 20 3d 3d 20 63 75 72 }...if( i == cur
09e0: 72 65 6e 74 5f 70 77 5f 73 75 62 6c 69 73 74 2d rent_pw_sublist-
09f0: 3e 63 75 72 72 65 6e 74 5f 69 74 65 6d 20 29 7b >current_item ){
0a00: 0a 09 09 09 64 65 62 75 67 28 22 67 65 74 5f 68 ....debug("get_h
0a10: 69 67 68 6c 69 67 68 74 65 64 5f 69 74 65 6d 3a ighlighted_item:
0a20: 20 66 6f 75 6e 64 20 25 64 2c 20 62 72 65 61 6b found %d, break
0a30: 20 6e 6f 77 22 2c 20 69 29 3b 0a 09 09 09 72 65 now", i);....re
0a40: 74 75 72 6e 20 69 74 65 72 3b 0a 09 09 7d 0a 09 turn iter;...}..
0a50: 7d 0a 2f 2a 09 66 70 72 69 6e 74 66 28 73 74 64 }./*.fprintf(std
0a60: 65 72 72 2c 20 22 25 64 2e 22 2c 20 63 75 72 69 err, "%d.", curi
0a70: 74 65 6d 29 3b 0a 09 66 6f 72 28 69 74 65 72 20 tem);..for(iter
0a80: 3d 20 70 77 6c 69 73 74 3b 20 28 69 74 65 72 20 = pwlist; (iter
0a90: 21 3d 20 4e 55 4c 4c 29 20 26 26 20 69 20 3c 3d != NULL) && i <=
0aa0: 20 63 75 72 69 74 65 6d 3b 20 69 74 65 72 20 3d curitem; iter =
0ab0: 20 69 74 65 72 2d 3e 6e 65 78 74 29 7b 0a 09 09 iter->next){...
0ac0: 69 66 28 20 61 70 70 6c 79 5f 66 69 6c 74 65 72 if( apply_filter
0ad0: 28 69 74 65 72 2c 20 6f 70 74 69 6f 6e 73 2d 3e (iter, options->
0ae0: 66 69 6c 74 65 72 29 20 29 7b 0a 09 09 09 69 2b filter) ){....i+
0af0: 2b 3b 09 0a 09 09 7d 09 0a 09 7d 2a 2f 0a 09 64 +;....}...}*/..d
0b00: 65 62 75 67 28 22 67 65 74 5f 68 69 67 68 6c 69 ebug("get_highli
0b10: 67 68 74 65 64 5f 69 74 65 6d 3a 20 6e 6f 74 68 ghted_item: noth
0b20: 69 6e 67 20 66 6f 75 6e 64 2c 20 72 65 74 75 72 ing found, retur
0b30: 6e 20 4e 55 4c 4c 22 29 3b 0a 09 72 65 74 75 72 n NULL");..retur
0b40: 6e 20 4e 55 4c 4c 3b 0a 7d 0a 0a 4c 49 53 54 5f n NULL;.}..LIST_
0b50: 49 54 45 4d 5f 54 59 50 45 0a 75 69 6c 69 73 74 ITEM_TYPE.uilist
0b60: 5f 67 65 74 5f 68 69 67 68 6c 69 67 68 74 65 64 _get_highlighted
0b70: 5f 74 79 70 65 28 29 0a 7b 0a 09 50 77 20 2a 69 _type().{..Pw *i
0b80: 74 65 72 3b 0a 09 50 57 4c 69 73 74 20 2a 6c 69 ter;..PWList *li
0b90: 73 74 69 74 65 72 3b 0a 09 69 6e 74 20 69 20 3d stiter;..int i =
0ba0: 20 2d 31 3b 0a 0a 09 69 66 28 63 75 72 72 65 6e -1;...if(curren
0bb0: 74 5f 70 77 5f 73 75 62 6c 69 73 74 2d 3e 70 61 t_pw_sublist->pa
0bc0: 72 65 6e 74 29 7b 0a 09 09 69 66 28 63 75 72 72 rent){...if(curr
0bd0: 65 6e 74 5f 70 77 5f 73 75 62 6c 69 73 74 2d 3e ent_pw_sublist->
0be0: 63 75 72 72 65 6e 74 5f 69 74 65 6d 20 3d 3d 20 current_item ==
0bf0: 30 29 7b 0a 09 09 09 72 65 74 75 72 6e 20 50 57 0){....return PW
0c00: 5f 55 50 4c 45 56 45 4c 3b 0a 09 09 7d 0a 09 09 _UPLEVEL;...}...
0c10: 69 2b 2b 3b 0a 09 7d 0a 09 66 6f 72 28 6c 69 73 i++;..}..for(lis
0c20: 74 69 74 65 72 20 3d 20 63 75 72 72 65 6e 74 5f titer = current_
0c30: 70 77 5f 73 75 62 6c 69 73 74 2d 3e 73 75 62 6c pw_sublist->subl
0c40: 69 73 74 73 3b 20 6c 69 73 74 69 74 65 72 20 21 ists; listiter !
0c50: 3d 20 4e 55 4c 4c 3b 20 6c 69 73 74 69 74 65 72 = NULL; listiter
0c60: 20 3d 20 6c 69 73 74 69 74 65 72 2d 3e 6e 65 78 = listiter->nex
0c70: 74 29 7b 0a 09 09 69 2b 2b 3b 0a 09 09 69 66 28 t){...i++;...if(
0c80: 69 20 3d 3d 20 63 75 72 72 65 6e 74 5f 70 77 5f i == current_pw_
0c90: 73 75 62 6c 69 73 74 2d 3e 63 75 72 72 65 6e 74 sublist->current
0ca0: 5f 69 74 65 6d 29 7b 0a 09 09 09 72 65 74 75 72 _item){....retur
0cb0: 6e 20 50 57 5f 53 55 42 4c 49 53 54 3b 0a 09 09 n PW_SUBLIST;...
0cc0: 7d 0a 09 7d 0a 09 09 0a 09 66 6f 72 28 69 74 65 }..}.....for(ite
0cd0: 72 20 3d 20 63 75 72 72 65 6e 74 5f 70 77 5f 73 r = current_pw_s
0ce0: 75 62 6c 69 73 74 2d 3e 6c 69 73 74 3b 20 69 74 ublist->list; it
0cf0: 65 72 20 21 3d 20 4e 55 4c 4c 3b 20 69 74 65 72 er != NULL; iter
0d00: 20 3d 20 69 74 65 72 2d 3e 6e 65 78 74 29 7b 0a = iter->next){.
0d10: 09 09 69 66 28 20 66 69 6c 74 65 72 5f 61 70 70 ..if( filter_app
0d20: 6c 79 28 69 74 65 72 2c 20 6f 70 74 69 6f 6e 73 ly(iter, options
0d30: 2d 3e 66 69 6c 74 65 72 29 20 29 7b 0a 09 09 09 ->filter) ){....
0d40: 69 2b 2b 3b 0a 09 09 7d 0a 09 09 69 66 28 20 69 i++;...}...if( i
0d50: 20 3d 3d 20 63 75 72 72 65 6e 74 5f 70 77 5f 73 == current_pw_s
0d60: 75 62 6c 69 73 74 2d 3e 63 75 72 72 65 6e 74 5f ublist->current_
0d70: 69 74 65 6d 20 29 7b 0a 09 09 09 72 65 74 75 72 item ){....retur
0d80: 6e 20 50 57 5f 49 54 45 4d 3b 0a 09 09 7d 0a 09 n PW_ITEM;...}..
0d90: 7d 0a 09 72 65 74 75 72 6e 20 50 57 5f 4e 55 4c }..return PW_NUL
0da0: 4c 3b 0a 7d 0a 0a 2f 2f 20 44 72 61 77 20 61 20 L;.}..// Draw a
0db0: 73 75 62 6c 69 73 74 20 6f 6e 20 74 68 65 20 73 sublist on the s
0dc0: 63 72 65 65 6e 0a 69 6e 74 0a 5f 75 69 6c 69 73 creen.int._uilis
0dd0: 74 5f 72 65 6e 64 65 72 5f 73 75 62 6c 69 73 74 t_render_sublist
0de0: 28 50 57 4c 69 73 74 20 2a 73 75 62 6c 69 73 74 (PWList *sublist
0df0: 2c 20 69 6e 74 20 69 2c 20 69 6e 74 20 6e 75 6d , int i, int num
0e00: 5f 73 68 6f 77 6e 29 0a 7b 0a 09 69 66 28 28 69 _shown).{..if((i
0e10: 20 3e 3d 20 66 69 72 73 74 5f 6c 69 73 74 5f 69 >= first_list_i
0e20: 74 65 6d 29 20 26 26 20 28 69 20 3c 3d 20 4c 41 tem) && (i <= LA
0e30: 53 54 5f 4c 49 53 54 5f 49 54 45 4d 29 29 7b 0a ST_LIST_ITEM)){.
0e40: 09 09 69 66 28 6c 69 6e 65 73 20 3d 3d 20 63 75 ..if(lines == cu
0e50: 72 72 65 6e 74 5f 70 77 5f 73 75 62 6c 69 73 74 rrent_pw_sublist
0e60: 2d 3e 63 75 72 72 65 6e 74 5f 69 74 65 6d 29 7b ->current_item){
0e70: 0a 09 09 09 75 69 6c 69 73 74 5f 68 69 67 68 6c ....uilist_highl
0e80: 69 67 68 74 5f 6c 69 6e 65 28 6e 75 6d 5f 73 68 ight_line(num_sh
0e90: 6f 77 6e 29 3b 0a 09 09 7d 20 65 6c 73 65 20 7b own);...} else {
0ea0: 0a 09 09 09 77 61 74 74 72 73 65 74 28 6c 69 73 ....wattrset(lis
0eb0: 74 2c 20 41 5f 42 4f 4c 44 29 3b 0a 09 09 7d 0a t, A_BOLD);...}.
0ec0: 09 09 6d 76 77 70 72 69 6e 74 77 28 6c 69 73 74 ..mvwprintw(list
0ed0: 2c 20 6e 75 6d 5f 73 68 6f 77 6e 2c 20 4e 41 4d , num_shown, NAM
0ee0: 45 50 4f 53 2c 20 22 25 73 20 2d 3e 22 2c 20 73 EPOS, "%s ->", s
0ef0: 75 62 6c 69 73 74 2d 3e 6e 61 6d 65 29 3b 0a 09 ublist->name);..
0f00: 09 77 61 74 74 72 73 65 74 28 6c 69 73 74 2c 20 .wattrset(list,
0f10: 41 5f 4e 4f 52 4d 41 4c 29 3b 0a 09 09 77 73 74 A_NORMAL);...wst
0f20: 61 6e 64 65 6e 64 28 6c 69 73 74 29 3b 0a 09 09 andend(list);...
0f30: 6e 75 6d 5f 73 68 6f 77 6e 2b 2b 3b 0a 09 7d 0a num_shown++;..}.
0f40: 09 72 65 74 75 72 6e 20 6e 75 6d 5f 73 68 6f 77 .return num_show
0f50: 6e 3b 0a 7d 0a 2f 2f 20 44 72 61 77 20 61 6e 20 n;.}.// Draw an
0f60: 65 6e 74 72 79 20 73 75 6d 6d 61 72 79 20 6f 6e entry summary on
0f70: 20 74 68 65 20 73 63 72 65 65 6e 0a 69 6e 74 0a the screen.int.
0f80: 5f 75 69 6c 69 73 74 5f 72 65 6e 64 65 72 5f 65 _uilist_render_e
0f90: 6e 74 72 79 28 50 77 20 2a 65 6e 74 72 79 2c 20 ntry(Pw *entry,
0fa0: 69 6e 74 20 69 2c 20 69 6e 74 20 6e 75 6d 5f 73 int i, int num_s
0fb0: 68 6f 77 6e 29 0a 7b 0a 09 69 66 28 28 69 20 3e hown).{..if((i >
0fc0: 3d 20 66 69 72 73 74 5f 6c 69 73 74 5f 69 74 65 = first_list_ite
0fd0: 6d 29 20 26 26 20 28 69 20 3c 3d 20 4c 41 53 54 m) && (i <= LAST
0fe0: 5f 4c 49 53 54 5f 49 54 45 4d 29 29 7b 0a 09 09 _LIST_ITEM)){...
0ff0: 69 66 28 6c 69 6e 65 73 20 3d 3d 20 63 75 72 72 if(lines == curr
1000: 65 6e 74 5f 70 77 5f 73 75 62 6c 69 73 74 2d 3e ent_pw_sublist->
1010: 63 75 72 72 65 6e 74 5f 69 74 65 6d 29 7b 0a 09 current_item){..
1020: 09 09 75 69 6c 69 73 74 5f 68 69 67 68 6c 69 67 ..uilist_highlig
1030: 68 74 5f 6c 69 6e 65 28 6e 75 6d 5f 73 68 6f 77 ht_line(num_show
1040: 6e 29 3b 0a 09 09 7d 0a 09 09 6d 76 77 61 64 64 n);...}...mvwadd
1050: 6e 73 74 72 28 6c 69 73 74 2c 20 6e 75 6d 5f 73 nstr(list, num_s
1060: 68 6f 77 6e 2c 20 4e 41 4d 45 50 4f 53 2c 20 65 hown, NAMEPOS, e
1070: 6e 74 72 79 2d 3e 6e 61 6d 65 2c 20 4e 41 4d 45 ntry->name, NAME
1080: 4c 45 4e 29 3b 0a 09 09 6d 76 77 61 64 64 6e 73 LEN);...mvwaddns
1090: 74 72 28 6c 69 73 74 2c 20 6e 75 6d 5f 73 68 6f tr(list, num_sho
10a0: 77 6e 2c 20 48 4f 53 54 50 4f 53 2c 20 65 6e 74 wn, HOSTPOS, ent
10b0: 72 79 2d 3e 68 6f 73 74 2c 20 48 4f 53 54 4c 45 ry->host, HOSTLE
10c0: 4e 29 3b 0a 09 09 6d 76 77 61 64 64 6e 73 74 72 N);...mvwaddnstr
10d0: 28 6c 69 73 74 2c 20 6e 75 6d 5f 73 68 6f 77 6e (list, num_shown
10e0: 2c 20 55 53 45 52 50 4f 53 2c 20 65 6e 74 72 79 , USERPOS, entry
10f0: 2d 3e 75 73 65 72 2c 20 55 53 45 52 4c 45 4e 29 ->user, USERLEN)
1100: 3b 0a 09 09 77 73 74 61 6e 64 65 6e 64 28 6c 69 ;...wstandend(li
1110: 73 74 29 3b 0a 09 09 6e 75 6d 5f 73 68 6f 77 6e st);...num_shown
1120: 2b 2b 3b 0a 09 7d 0a 09 72 65 74 75 72 6e 20 6e ++;..}..return n
1130: 75 6d 5f 73 68 6f 77 6e 3b 0a 7d 0a 0a 69 6e 74 um_shown;.}..int
1140: 0a 75 69 6c 69 73 74 5f 72 65 66 72 65 73 68 28 .uilist_refresh(
1150: 29 0a 7b 0a 09 50 77 20 2a 69 74 65 72 3b 0a 09 ).{..Pw *iter;..
1160: 50 57 4c 69 73 74 20 2a 6c 69 73 74 69 74 65 72 PWList *listiter
1170: 3b 0a 09 50 57 53 65 61 72 63 68 52 65 73 75 6c ;..PWSearchResul
1180: 74 20 2a 73 72 63 68 69 74 65 72 3b 0a 09 69 6e t *srchiter;..in
1190: 74 20 69 20 3d 20 30 3b 0a 09 69 6e 74 20 6e 75 t i = 0;..int nu
11a0: 6d 5f 73 68 6f 77 6e 20 3d 20 30 3b 0a 0a 09 64 m_shown = 0;...d
11b0: 65 62 75 67 28 22 72 65 66 72 65 73 68 5f 6c 69 ebug("refresh_li
11c0: 73 74 3a 20 72 65 66 72 65 73 68 69 6e 67 20 6c st: refreshing l
11d0: 69 73 74 22 29 3b 0a 09 69 66 28 6c 69 73 74 20 ist");..if(list
11e0: 3d 3d 20 4e 55 4c 4c 29 7b 0a 09 09 75 69 6c 69 == NULL){...uili
11f0: 73 74 5f 69 6e 69 74 28 29 3b 0a 09 7d 0a 09 69 st_init();..}..i
1200: 66 28 63 75 72 72 65 6e 74 5f 70 77 5f 73 75 62 f(current_pw_sub
1210: 6c 69 73 74 20 3d 3d 20 4e 55 4c 4c 29 7b 0a 09 list == NULL){..
1220: 09 72 65 74 75 72 6e 20 2d 31 3b 0a 09 7d 0a 0a .return -1;..}..
1230: 09 75 69 6c 69 73 74 5f 63 6c 65 61 72 28 29 3b .uilist_clear();
1240: 3b 0a 09 66 69 72 73 74 5f 6c 69 73 74 5f 69 74 ;..first_list_it
1250: 65 6d 20 3d 20 30 3b 0a 09 6c 69 6e 65 73 20 3d em = 0;..lines =
1260: 20 30 3b 0a 0a 09 75 69 6c 69 73 74 5f 68 65 61 0;...uilist_hea
1270: 64 65 72 6c 69 6e 65 28 29 3b 0a 0a 09 2f 2f 20 derline();...//
1280: 45 6e 73 75 72 65 20 77 65 20 64 6f 6e 27 74 20 Ensure we don't
1290: 65 6e 64 20 75 70 20 6f 66 66 20 74 68 65 20 73 end up off the s
12a0: 63 72 65 65 6e 0a 09 69 66 28 63 75 72 72 65 6e creen..if(curren
12b0: 74 5f 70 77 5f 73 75 62 6c 69 73 74 2d 3e 63 75 t_pw_sublist->cu
12c0: 72 72 65 6e 74 5f 69 74 65 6d 20 3c 20 30 29 7b rrent_item < 0){
12d0: 0a 09 09 63 75 72 72 65 6e 74 5f 70 77 5f 73 75 ...current_pw_su
12e0: 62 6c 69 73 74 2d 3e 63 75 72 72 65 6e 74 5f 69 blist->current_i
12f0: 74 65 6d 20 3d 20 30 3b 0a 09 7d 0a 09 69 66 28 tem = 0;..}..if(
1300: 63 75 72 72 65 6e 74 5f 70 77 5f 73 75 62 6c 69 current_pw_subli
1310: 73 74 2d 3e 63 75 72 72 65 6e 74 5f 69 74 65 6d st->current_item
1320: 20 3c 20 66 69 72 73 74 5f 6c 69 73 74 5f 69 74 < first_list_it
1330: 65 6d 29 7b 0a 09 09 66 69 72 73 74 5f 6c 69 73 em){...first_lis
1340: 74 5f 69 74 65 6d 20 3d 20 63 75 72 72 65 6e 74 t_item = current
1350: 5f 70 77 5f 73 75 62 6c 69 73 74 2d 3e 63 75 72 _pw_sublist->cur
1360: 72 65 6e 74 5f 69 74 65 6d 3b 09 09 0a 09 7d 20 rent_item;....}
1370: 65 6c 73 65 20 69 66 28 28 63 75 72 72 65 6e 74 else if((current
1380: 5f 70 77 5f 73 75 62 6c 69 73 74 2d 3e 63 75 72 _pw_sublist->cur
1390: 72 65 6e 74 5f 69 74 65 6d 20 3e 20 4c 41 53 54 rent_item > LAST
13a0: 5f 4c 49 53 54 5f 49 54 45 4d 29 29 7b 0a 09 09 _LIST_ITEM)){...
13b0: 66 69 72 73 74 5f 6c 69 73 74 5f 69 74 65 6d 20 first_list_item
13c0: 3d 20 63 75 72 72 65 6e 74 5f 70 77 5f 73 75 62 = current_pw_sub
13d0: 6c 69 73 74 2d 3e 63 75 72 72 65 6e 74 5f 69 74 list->current_it
13e0: 65 6d 20 2d 20 28 4c 49 53 54 5f 4c 49 4e 45 53 em - (LIST_LINES
13f0: 2d 31 29 3b 0a 09 7d 0a 0a 09 69 66 28 73 65 61 -1);..}...if(sea
1400: 72 63 68 5f 72 65 73 75 6c 74 73 20 3d 3d 20 4e rch_results == N
1410: 55 4c 4c 29 20 7b 0a 09 09 2f 2f 20 49 66 20 77 ULL) {...// If w
1420: 65 20 61 72 65 6e 27 74 20 61 74 20 74 68 65 20 e aren't at the
1430: 74 6f 70 20 6c 65 76 65 6c 2c 20 6f 66 66 20 74 top level, off t
1440: 68 65 20 22 55 70 20 4f 6e 65 20 4c 65 76 65 6c he "Up One Level
1450: 22 20 69 74 65 6d 0a 09 09 69 66 28 63 75 72 72 " item...if(curr
1460: 65 6e 74 5f 70 77 5f 73 75 62 6c 69 73 74 2d 3e ent_pw_sublist->
1470: 70 61 72 65 6e 74 20 26 26 20 73 65 61 72 63 68 parent && search
1480: 5f 72 65 73 75 6c 74 73 20 3d 3d 20 4e 55 4c 4c _results == NULL
1490: 29 7b 0a 09 09 09 69 66 28 28 69 20 3e 3d 20 66 ){....if((i >= f
14a0: 69 72 73 74 5f 6c 69 73 74 5f 69 74 65 6d 29 20 irst_list_item)
14b0: 26 26 20 28 69 20 3c 3d 20 4c 41 53 54 5f 4c 49 && (i <= LAST_LI
14c0: 53 54 5f 49 54 45 4d 29 29 7b 0a 09 09 09 09 69 ST_ITEM)){.....i
14d0: 66 28 6c 69 6e 65 73 20 3d 3d 20 63 75 72 72 65 f(lines == curre
14e0: 6e 74 5f 70 77 5f 73 75 62 6c 69 73 74 2d 3e 63 nt_pw_sublist->c
14f0: 75 72 72 65 6e 74 5f 69 74 65 6d 29 7b 0a 09 09 urrent_item){...
1500: 09 09 09 75 69 6c 69 73 74 5f 68 69 67 68 6c 69 ...uilist_highli
1510: 67 68 74 5f 6c 69 6e 65 28 6e 75 6d 5f 73 68 6f ght_line(num_sho
1520: 77 6e 29 3b 0a 09 09 09 09 7d 20 65 6c 73 65 20 wn);.....} else
1530: 7b 0a 09 09 09 09 09 77 61 74 74 72 73 65 74 28 {......wattrset(
1540: 6c 69 73 74 2c 20 41 5f 42 4f 4c 44 29 3b 0a 09 list, A_BOLD);..
1550: 09 09 09 7d 0a 09 09 09 09 6d 76 77 70 72 69 6e ...}.....mvwprin
1560: 74 77 28 6c 69 73 74 2c 20 6e 75 6d 5f 73 68 6f tw(list, num_sho
1570: 77 6e 2c 20 4e 41 4d 45 50 4f 53 2c 20 22 3c 55 wn, NAMEPOS, "<U
1580: 70 20 4f 6e 65 20 4c 65 76 65 6c 20 2d 20 5c 22 p One Level - \"
1590: 25 73 5c 22 3e 22 2c 20 63 75 72 72 65 6e 74 5f %s\">", current_
15a0: 70 77 5f 73 75 62 6c 69 73 74 2d 3e 70 61 72 65 pw_sublist->pare
15b0: 6e 74 2d 3e 6e 61 6d 65 29 3b 0a 09 09 09 09 77 nt->name);.....w
15c0: 61 74 74 72 73 65 74 28 6c 69 73 74 2c 20 41 5f attrset(list, A_
15d0: 4e 4f 52 4d 41 4c 29 3b 0a 09 09 09 09 77 73 74 NORMAL);.....wst
15e0: 61 6e 64 65 6e 64 28 6c 69 73 74 29 3b 0a 09 09 andend(list);...
15f0: 09 09 6e 75 6d 5f 73 68 6f 77 6e 2b 2b 3b 0a 09 ..num_shown++;..
1600: 09 09 7d 0a 09 09 09 69 2b 2b 3b 20 0a 09 09 09 ..}....i++; ....
1610: 6c 69 6e 65 73 2b 2b 3b 0a 09 09 7d 0a 09 09 2f lines++;...}.../
1620: 2f 20 44 72 61 77 20 6f 75 72 20 73 75 62 6c 69 / Draw our subli
1630: 73 74 73 0a 09 09 66 6f 72 28 6c 69 73 74 69 74 sts...for(listit
1640: 65 72 20 3d 20 63 75 72 72 65 6e 74 5f 70 77 5f er = current_pw_
1650: 73 75 62 6c 69 73 74 2d 3e 73 75 62 6c 69 73 74 sublist->sublist
1660: 73 3b 20 6c 69 73 74 69 74 65 72 20 21 3d 20 4e s; listiter != N
1670: 55 4c 4c 3b 20 6c 69 73 74 69 74 65 72 20 3d 20 ULL; listiter =
1680: 6c 69 73 74 69 74 65 72 2d 3e 6e 65 78 74 29 7b listiter->next){
1690: 0a 09 09 09 6e 75 6d 5f 73 68 6f 77 6e 20 3d 20 ....num_shown =
16a0: 5f 75 69 6c 69 73 74 5f 72 65 6e 64 65 72 5f 73 _uilist_render_s
16b0: 75 62 6c 69 73 74 28 6c 69 73 74 69 74 65 72 2c ublist(listiter,
16c0: 20 69 2c 20 6e 75 6d 5f 73 68 6f 77 6e 29 3b 0a i, num_shown);.
16d0: 09 09 09 6c 69 6e 65 73 2b 2b 3b 0a 09 09 09 69 ...lines++;....i
16e0: 2b 2b 3b 20 0a 09 09 7d 0a 09 09 2f 2f 20 44 72 ++; ...}...// Dr
16f0: 61 77 20 6f 75 72 20 65 6e 74 72 69 65 73 2c 20 aw our entries,
1700: 69 66 20 74 68 65 20 66 69 6c 74 65 72 20 73 61 if the filter sa
1710: 79 73 20 69 74 27 73 20 6f 6b 0a 09 09 66 6f 72 ys it's ok...for
1720: 28 69 74 65 72 20 3d 20 63 75 72 72 65 6e 74 5f (iter = current_
1730: 70 77 5f 73 75 62 6c 69 73 74 2d 3e 6c 69 73 74 pw_sublist->list
1740: 3b 20 28 69 74 65 72 20 21 3d 20 4e 55 4c 4c 29 ; (iter != NULL)
1750: 3b 20 69 74 65 72 20 3d 20 69 74 65 72 2d 3e 6e ; iter = iter->n
1760: 65 78 74 29 7b 0a 09 09 09 2f 2a 0a 09 09 09 20 ext){..../*....
1770: 2a 20 69 66 20 6c 69 6e 65 20 73 61 74 69 66 69 * if line satifi
1780: 65 73 20 66 69 6c 74 65 72 20 63 72 69 74 65 72 es filter criter
1790: 69 61 20 69 6e 63 72 65 6d 65 6e 74 20 69 20 61 ia increment i a
17a0: 6e 64 20 6c 69 6e 65 73 0a 09 09 09 20 2a 2f 0a nd lines.... */.
17b0: 09 09 09 69 66 28 20 66 69 6c 74 65 72 5f 61 70 ...if( filter_ap
17c0: 70 6c 79 28 69 74 65 72 2c 20 6f 70 74 69 6f 6e ply(iter, option
17d0: 73 2d 3e 66 69 6c 74 65 72 29 20 29 7b 0a 09 09 s->filter) ){...
17e0: 09 09 6e 75 6d 5f 73 68 6f 77 6e 20 3d 20 5f 75 ..num_shown = _u
17f0: 69 6c 69 73 74 5f 72 65 6e 64 65 72 5f 65 6e 74 ilist_render_ent
1800: 72 79 28 69 74 65 72 2c 20 69 2c 20 6e 75 6d 5f ry(iter, i, num_
1810: 73 68 6f 77 6e 29 3b 0a 09 09 09 09 6c 69 6e 65 shown);.....line
1820: 73 2b 2b 3b 0a 09 09 09 09 69 2b 2b 3b 09 0a 09 s++;.....i++;...
1830: 09 09 7d 0a 09 09 7d 0a 09 7d 20 65 6c 73 65 20 ..}...}..} else
1840: 7b 0a 09 09 66 6f 72 28 73 72 63 68 69 74 65 72 {...for(srchiter
1850: 20 3d 20 73 65 61 72 63 68 5f 72 65 73 75 6c 74 = search_result
1860: 73 3b 20 28 73 72 63 68 69 74 65 72 20 21 3d 20 s; (srchiter !=
1870: 4e 55 4c 4c 29 3b 20 73 72 63 68 69 74 65 72 20 NULL); srchiter
1880: 3d 20 73 72 63 68 69 74 65 72 2d 3e 6e 65 78 74 = srchiter->next
1890: 29 20 7b 0a 09 09 09 69 66 28 73 72 63 68 69 74 ) {....if(srchit
18a0: 65 72 2d 3e 65 6e 74 72 79 20 21 3d 20 4e 55 4c er->entry != NUL
18b0: 4c 29 20 7b 0a 09 09 09 09 6e 75 6d 5f 73 68 6f L) {.....num_sho
18c0: 77 6e 20 3d 20 5f 75 69 6c 69 73 74 5f 72 65 6e wn = _uilist_ren
18d0: 64 65 72 5f 65 6e 74 72 79 28 73 72 63 68 69 74 der_entry(srchit
18e0: 65 72 2d 3e 65 6e 74 72 79 2c 20 69 2c 20 6e 75 er->entry, i, nu
18f0: 6d 5f 73 68 6f 77 6e 29 3b 0a 09 09 09 7d 20 65 m_shown);....} e
1900: 6c 73 65 20 7b 0a 09 09 09 09 6e 75 6d 5f 73 68 lse {.....num_sh
1910: 6f 77 6e 20 3d 20 5f 75 69 6c 69 73 74 5f 72 65 own = _uilist_re
1920: 6e 64 65 72 5f 73 75 62 6c 69 73 74 28 73 72 63 nder_sublist(src
1930: 68 69 74 65 72 2d 3e 73 75 62 6c 69 73 74 2c 20 hiter->sublist,
1940: 69 2c 20 6e 75 6d 5f 73 68 6f 77 6e 29 3b 0a 09 i, num_shown);..
1950: 09 09 7d 0a 09 09 09 6c 69 6e 65 73 2b 2b 3b 0a ..}....lines++;.
1960: 09 09 09 69 2b 2b 3b 09 0a 09 09 7d 0a 09 7d 0a ...i++;....}..}.
1970: 0a 09 77 72 65 66 72 65 73 68 28 6c 69 73 74 29 ..wrefresh(list)
1980: 3b 0a 09 68 69 64 65 5f 63 75 72 73 6f 72 28 29 ;..hide_cursor()
1990: 3b 0a 0a 09 2f 2f 20 49 73 20 74 68 65 20 63 75 ;...// Is the cu
19a0: 72 73 6f 72 20 6f 66 66 20 74 68 65 20 73 63 72 rsor off the scr
19b0: 65 65 6e 2c 20 61 66 74 65 72 20 6d 6f 76 69 6e een, after movin
19c0: 67 20 75 70 20 6f 72 20 64 6f 77 6e 20 74 68 65 g up or down the
19d0: 20 74 72 65 65 3f 0a 09 2f 2f 20 28 44 6f 6e 27 tree?..// (Don'
19e0: 74 20 74 72 69 67 67 65 72 20 74 68 69 73 20 69 t trigger this i
19f0: 66 20 77 65 20 68 61 76 65 20 6e 6f 20 65 6e 74 f we have no ent
1a00: 72 69 65 73 20 79 65 74 29 0a 09 69 66 28 63 75 ries yet)..if(cu
1a10: 72 72 65 6e 74 5f 70 77 5f 73 75 62 6c 69 73 74 rrent_pw_sublist
1a20: 2d 3e 63 75 72 72 65 6e 74 5f 69 74 65 6d 29 20 ->current_item)
1a30: 7b 0a 09 09 69 66 28 28 6c 69 6e 65 73 2d 31 29 {...if((lines-1)
1a40: 20 3c 20 63 75 72 72 65 6e 74 5f 70 77 5f 73 75 < current_pw_su
1a50: 62 6c 69 73 74 2d 3e 63 75 72 72 65 6e 74 5f 69 blist->current_i
1a60: 74 65 6d 29 20 7b 0a 09 09 09 2f 2f 20 4a 75 73 tem) {....// Jus
1a70: 74 20 61 64 6a 75 73 74 2c 20 74 68 65 6e 20 72 t adjust, then r
1a80: 65 64 72 61 77 0a 09 09 09 63 75 72 72 65 6e 74 edraw....current
1a90: 5f 70 77 5f 73 75 62 6c 69 73 74 2d 3e 63 75 72 _pw_sublist->cur
1aa0: 72 65 6e 74 5f 69 74 65 6d 20 3d 20 6c 69 6e 65 rent_item = line
1ab0: 73 2d 31 3b 0a 09 09 09 75 69 6c 69 73 74 5f 72 s-1;....uilist_r
1ac0: 65 66 72 65 73 68 28 29 3b 0a 09 09 7d 0a 09 7d efresh();...}..}
1ad0: 0a 0a 09 2f 2f 20 49 66 20 77 65 20 68 61 76 65 ...// If we have
1ae0: 20 66 69 6c 74 65 72 69 6e 67 20 74 75 72 6e 65 filtering turne
1af0: 64 20 6f 6e 2c 20 74 68 65 6e 20 77 61 72 6e 20 d on, then warn
1b00: 74 68 65 20 75 73 65 72 20 6f 66 20 74 68 61 74 the user of that
1b10: 0a 09 69 66 28 6f 70 74 69 6f 6e 73 2d 3e 66 69 ..if(options->fi
1b20: 6c 74 65 72 29 20 7b 0a 09 09 66 69 6c 74 65 72 lter) {...filter
1b30: 5f 61 6c 65 72 74 28 6f 70 74 69 6f 6e 73 2d 3e _alert(options->
1b40: 66 69 6c 74 65 72 29 3b 0a 09 7d 0a 0a 09 2f 2f filter);..}...//
1b50: 20 49 66 20 77 65 20 68 61 76 65 20 73 65 61 72 If we have sear
1b60: 63 68 69 6e 67 20 61 63 74 69 76 65 2c 20 74 68 ching active, th
1b70: 65 6e 20 77 61 72 6e 20 74 68 65 20 75 73 65 72 en warn the user
1b80: 20 6f 66 20 74 68 61 74 0a 09 69 66 28 6f 70 74 of that..if(opt
1b90: 69 6f 6e 73 2d 3e 73 65 61 72 63 68 29 20 7b 0a ions->search) {.
1ba0: 09 09 73 65 61 72 63 68 5f 61 6c 65 72 74 28 6f ..search_alert(o
1bb0: 70 74 69 6f 6e 73 2d 3e 73 65 61 72 63 68 29 3b ptions->search);
1bc0: 0a 09 7d 0a 0a 09 64 65 62 75 67 28 22 72 65 66 ..}...debug("ref
1bd0: 72 65 73 68 5f 6c 69 73 74 3a 20 64 6f 6e 65 20 resh_list: done
1be0: 72 65 66 72 65 73 68 69 6e 67 20 6c 69 73 74 22 refreshing list"
1bf0: 29 3b 0a 7d 0a 0a 69 6e 74 0a 75 69 6c 69 73 74 );.}..int.uilist
1c00: 5f 63 6c 65 61 72 28 29 0a 7b 0a 09 69 6e 74 20 _clear().{..int
1c10: 69 3b 0a 09 0a 09 77 65 72 61 73 65 28 6c 69 73 i;....werase(lis
1c20: 74 29 3b 0a 09 66 6f 72 28 69 20 3d 20 30 3b 20 t);..for(i = 0;
1c30: 69 20 3c 20 43 4f 4c 53 3b 20 69 2b 2b 29 7b 0a i < COLS; i++){.
1c40: 09 09 6d 76 61 64 64 63 68 28 32 2c 20 69 2c 20 ..mvaddch(2, i,
1c50: 27 20 27 29 3b 0a 09 7d 0a 7d 0a 0a 69 6e 74 0a ' ');..}.}..int.
1c60: 75 69 6c 69 73 74 5f 68 65 61 64 65 72 6c 69 6e uilist_headerlin
1c70: 65 28 29 0a 7b 0a 09 69 6e 74 20 69 3b 0a 0a 09 e().{..int i;...
1c80: 73 68 6f 77 5f 63 75 72 73 6f 72 28 29 3b 0a 09 show_cursor();..
1c90: 61 74 74 72 73 65 74 28 41 5f 42 4f 4c 44 29 3b attrset(A_BOLD);
1ca0: 0a 0a 09 6d 76 61 64 64 6e 73 74 72 28 32 2c 20 ...mvaddnstr(2,
1cb0: 4e 41 4d 45 50 4f 53 2c 20 22 4e 61 6d 65 22 2c NAMEPOS, "Name",
1cc0: 20 4e 41 4d 45 4c 45 4e 29 3b 0a 09 6d 76 61 64 NAMELEN);..mvad
1cd0: 64 6e 73 74 72 28 32 2c 20 48 4f 53 54 50 4f 53 dnstr(2, HOSTPOS
1ce0: 2c 20 22 48 6f 73 74 22 2c 20 48 4f 53 54 4c 45 , "Host", HOSTLE
1cf0: 4e 29 3b 0a 09 6d 76 61 64 64 6e 73 74 72 28 32 N);..mvaddnstr(2
1d00: 2c 20 55 53 45 52 50 4f 53 2c 20 22 55 73 65 72 , USERPOS, "User
1d10: 6e 61 6d 65 22 2c 20 55 53 45 52 4c 45 4e 29 3b name", USERLEN);
1d20: 0a 0a 09 61 74 74 72 73 65 74 28 41 5f 4e 4f 52 ...attrset(A_NOR
1d30: 4d 41 4c 29 3b 0a 09 68 69 64 65 5f 63 75 72 73 MAL);..hide_curs
1d40: 6f 72 28 29 3b 0a 7d 0a 0a 69 6e 74 20 0a 75 69 or();.}..int .ui
1d50: 6c 69 73 74 5f 70 61 67 65 5f 75 70 28 29 0a 7b list_page_up().{
1d60: 0a 09 63 75 72 72 65 6e 74 5f 70 77 5f 73 75 62 ..current_pw_sub
1d70: 6c 69 73 74 2d 3e 63 75 72 72 65 6e 74 5f 69 74 list->current_it
1d80: 65 6d 20 2d 3d 20 28 4c 49 53 54 5f 4c 49 4e 45 em -= (LIST_LINE
1d90: 53 20 2d 20 31 29 3b 0a 0a 09 69 66 28 63 75 72 S - 1);...if(cur
1da0: 72 65 6e 74 5f 70 77 5f 73 75 62 6c 69 73 74 2d rent_pw_sublist-
1db0: 3e 63 75 72 72 65 6e 74 5f 69 74 65 6d 20 3c 20 >current_item <
1dc0: 31 29 7b 0a 09 09 63 75 72 72 65 6e 74 5f 70 77 1){...current_pw
1dd0: 5f 73 75 62 6c 69 73 74 2d 3e 63 75 72 72 65 6e _sublist->curren
1de0: 74 5f 69 74 65 6d 20 3d 20 30 3b 0a 09 7d 0a 09 t_item = 0;..}..
1df0: 75 69 6c 69 73 74 5f 72 65 66 72 65 73 68 28 29 uilist_refresh()
1e00: 3b 0a 7d 0a 0a 69 6e 74 0a 75 69 6c 69 73 74 5f ;.}..int.uilist_
1e10: 70 61 67 65 5f 64 6f 77 6e 28 29 0a 7b 0a 09 63 page_down().{..c
1e20: 75 72 72 65 6e 74 5f 70 77 5f 73 75 62 6c 69 73 urrent_pw_sublis
1e30: 74 2d 3e 63 75 72 72 65 6e 74 5f 69 74 65 6d 20 t->current_item
1e40: 2b 3d 20 28 4c 49 53 54 5f 4c 49 4e 45 53 20 2d += (LIST_LINES -
1e50: 20 31 29 3b 0a 0a 09 69 66 28 63 75 72 72 65 6e 1);...if(curren
1e60: 74 5f 70 77 5f 73 75 62 6c 69 73 74 2d 3e 63 75 t_pw_sublist->cu
1e70: 72 72 65 6e 74 5f 69 74 65 6d 20 3e 3d 20 28 6c rrent_item >= (l
1e80: 69 6e 65 73 20 2d 20 31 29 29 7b 0a 09 09 63 75 ines - 1)){...cu
1e90: 72 72 65 6e 74 5f 70 77 5f 73 75 62 6c 69 73 74 rrent_pw_sublist
1ea0: 2d 3e 63 75 72 72 65 6e 74 5f 69 74 65 6d 20 3d ->current_item =
1eb0: 20 6c 69 6e 65 73 20 2d 31 3b 0a 09 7d 0a 09 75 lines -1;..}..u
1ec0: 69 6c 69 73 74 5f 72 65 66 72 65 73 68 28 29 3b ilist_refresh();
1ed0: 0a 7d 0a 0a 69 6e 74 0a 75 69 6c 69 73 74 5f 75 .}..int.uilist_u
1ee0: 70 28 29 0a 7b 0a 09 69 66 28 63 75 72 72 65 6e p().{..if(curren
1ef0: 74 5f 70 77 5f 73 75 62 6c 69 73 74 2d 3e 63 75 t_pw_sublist->cu
1f00: 72 72 65 6e 74 5f 69 74 65 6d 20 3c 20 31 29 7b rrent_item < 1){
1f10: 0a 09 09 72 65 74 75 72 6e 3b 0a 09 7d 0a 0a 09 ...return;..}...
1f20: 63 75 72 72 65 6e 74 5f 70 77 5f 73 75 62 6c 69 current_pw_subli
1f30: 73 74 2d 3e 63 75 72 72 65 6e 74 5f 69 74 65 6d st->current_item
1f40: 2d 2d 3b 0a 09 0a 09 75 69 6c 69 73 74 5f 72 65 --;....uilist_re
1f50: 66 72 65 73 68 28 29 3b 0a 7d 0a 0a 69 6e 74 0a fresh();.}..int.
1f60: 75 69 6c 69 73 74 5f 64 6f 77 6e 28 29 0a 7b 0a uilist_down().{.
1f70: 09 69 66 28 63 75 72 72 65 6e 74 5f 70 77 5f 73 .if(current_pw_s
1f80: 75 62 6c 69 73 74 2d 3e 63 75 72 72 65 6e 74 5f ublist->current_
1f90: 69 74 65 6d 20 3e 3d 20 28 6c 69 6e 65 73 2d 31 item >= (lines-1
1fa0: 29 29 7b 0a 09 09 72 65 74 75 72 6e 3b 0a 09 7d )){...return;..}
1fb0: 0a 0a 09 63 75 72 72 65 6e 74 5f 70 77 5f 73 75 ...current_pw_su
1fc0: 62 6c 69 73 74 2d 3e 63 75 72 72 65 6e 74 5f 69 blist->current_i
1fd0: 74 65 6d 2b 2b 3b 0a 0a 09 75 69 6c 69 73 74 5f tem++;...uilist_
1fe0: 72 65 66 72 65 73 68 28 29 3b 0a 7d 0a refresh();.}.