Artifact 0a773ab48ac6a97402139d5ba657686cf9dc4b1029d3a9ddbcdcf5ca2a0bdcce:
- File
src/ui.h
— part of check-in
[3acd4da2cc]
at
2011-02-15 22:04:30
on branch origin/tweaks
— added "Locate" support, which prints out the path in the tree of the current item
git-svn-id: https://pwman.svn.sourceforge.net/svnroot/pwman/trunk@120 db5f1c25-4851-472e-ac1e-5437d07aece1 (user: gagravarr@users.sourceforge.net size: 2546)
- File ui.h — 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: 2546)
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 66 6e 64 65 66 20 55 49 . */..#ifndef UI
0350: 5f 48 0a 23 64 65 66 69 6e 65 20 55 49 5f 48 0a _H.#define UI_H.
0360: 0a 23 69 6e 63 6c 75 64 65 20 3c 63 75 72 73 65 .#include <curse
0370: 73 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 3c 73 s.h>.#include <s
0380: 69 67 6e 61 6c 2e 68 3e 0a 23 69 6e 63 6c 75 64 ignal.h>.#includ
0390: 65 20 3c 63 74 79 70 65 2e 68 3e 0a 0a 23 69 66 e <ctype.h>..#if
03a0: 64 65 66 20 48 41 56 45 5f 54 45 52 4d 49 4f 53 def HAVE_TERMIOS
03b0: 5f 48 0a 23 20 20 20 20 20 20 20 69 6e 63 6c 75 _H.# inclu
03c0: 64 65 20 3c 74 65 72 6d 69 6f 73 2e 68 3e 0a 23 de <termios.h>.#
03d0: 65 6c 73 65 20 20 20 0a 23 20 20 20 20 20 20 20 else .#
03e0: 69 66 64 65 66 20 48 41 56 45 5f 4c 49 4e 55 58 ifdef HAVE_LINUX
03f0: 5f 54 45 52 4d 49 4f 53 5f 48 0a 23 20 20 20 20 _TERMIOS_H.#
0400: 20 20 20 20 20 20 20 20 20 20 20 69 6e 63 6c 75 inclu
0410: 64 65 20 3c 6c 69 6e 75 78 2f 74 65 72 6d 69 6f de <linux/termio
0420: 73 2e 68 3e 0a 23 20 20 20 20 20 20 20 65 6e 64 s.h>.# end
0430: 69 66 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 66 if.#endif.#ifdef
0440: 20 48 41 56 45 5f 53 59 53 5f 49 4f 43 54 4c 5f HAVE_SYS_IOCTL_
0450: 48 0a 23 20 20 20 20 20 20 20 69 6e 63 6c 75 64 H.# includ
0460: 65 20 3c 73 79 73 2f 69 6f 63 74 6c 2e 68 3e 0a e <sys/ioctl.h>.
0470: 23 65 6e 64 69 66 0a 0a 23 64 65 66 69 6e 65 20 #endif..#define
0480: 4d 49 4e 5f 4c 49 4e 45 53 20 32 32 0a 23 64 65 MIN_LINES 22.#de
0490: 66 69 6e 65 20 4d 49 4e 5f 43 4f 4c 53 20 36 30 fine MIN_COLS 60
04a0: 0a 0a 23 64 65 66 69 6e 65 20 4c 49 53 54 5f 54 ..#define LIST_T
04b0: 4f 50 20 33 20 0a 23 64 65 66 69 6e 65 20 4c 49 OP 3 .#define LI
04c0: 53 54 5f 42 4f 54 54 4f 4d 20 28 4c 49 4e 45 53 ST_BOTTOM (LINES
04d0: 20 2d 33 29 0a 23 64 65 66 69 6e 65 20 4c 49 53 -3).#define LIS
04e0: 54 5f 4c 49 4e 45 53 20 28 4c 49 53 54 5f 42 4f T_LINES (LIST_BO
04f0: 54 54 4f 4d 2d 4c 49 53 54 5f 54 4f 50 29 0a 0a TTOM-LIST_TOP)..
0500: 23 64 65 66 69 6e 65 20 4c 41 53 54 5f 4c 49 53 #define LAST_LIS
0510: 54 5f 49 54 45 4d 20 28 66 69 72 73 74 5f 6c 69 T_ITEM (first_li
0520: 73 74 5f 69 74 65 6d 20 2b 20 4c 49 53 54 5f 4c st_item + LIST_L
0530: 49 4e 45 53 20 2d 20 31 29 0a 23 64 65 66 69 6e INES - 1).#defin
0540: 65 20 4e 41 4d 45 4c 45 4e 20 28 43 4f 4c 53 2f e NAMELEN (COLS/
0550: 33 29 2d 31 0a 23 64 65 66 69 6e 65 20 4e 41 4d 3)-1.#define NAM
0560: 45 50 4f 53 20 32 0a 0a 23 64 65 66 69 6e 65 20 EPOS 2..#define
0570: 48 4f 53 54 4c 45 4e 20 28 43 4f 4c 53 2f 33 29 HOSTLEN (COLS/3)
0580: 2d 31 0a 23 64 65 66 69 6e 65 20 48 4f 53 54 50 -1.#define HOSTP
0590: 4f 53 20 28 4e 41 4d 45 50 4f 53 20 2b 20 4e 41 OS (NAMEPOS + NA
05a0: 4d 45 4c 45 4e 20 2b 20 31 29 0a 0a 23 64 65 66 MELEN + 1)..#def
05b0: 69 6e 65 20 55 53 45 52 4c 45 4e 20 28 43 4f 4c ine USERLEN (COL
05c0: 53 2f 33 29 2d 31 0a 23 64 65 66 69 6e 65 20 55 S/3)-1.#define U
05d0: 53 45 52 50 4f 53 20 28 4e 41 4d 45 50 4f 53 20 SERPOS (NAMEPOS
05e0: 2b 20 4e 41 4d 45 4c 45 4e 20 2b 20 48 4f 53 54 + NAMELEN + HOST
05f0: 4c 45 4e 20 2b 20 32 29 0a 23 64 65 66 69 6e 65 LEN + 2).#define
0600: 20 68 69 64 65 5f 63 75 72 73 6f 72 28 29 20 63 hide_cursor() c
0610: 75 72 73 5f 73 65 74 28 30 29 0a 23 64 65 66 69 urs_set(0).#defi
0620: 6e 65 20 73 68 6f 77 5f 63 75 72 73 6f 72 28 29 ne show_cursor()
0630: 20 63 75 72 73 5f 73 65 74 28 31 29 0a 0a 23 64 curs_set(1)..#d
0640: 65 66 69 6e 65 20 4e 55 4d 5f 54 4f 5f 43 48 41 efine NUM_TO_CHA
0650: 52 28 6e 29 20 28 6e 20 2b 20 34 38 29 0a 23 64 R(n) (n + 48).#d
0660: 65 66 69 6e 65 20 43 48 41 52 5f 54 4f 5f 4e 55 efine CHAR_TO_NU
0670: 4d 28 6e 29 20 28 6e 20 2d 20 34 39 29 0a 0a 74 M(n) (n - 49)..t
0680: 79 70 65 64 65 66 20 65 6e 75 6d 20 7b 0a 09 53 ypedef enum {..S
0690: 54 52 49 4e 47 2c 20 20 20 20 20 2f 2f 20 41 20 TRING, // A
06a0: 72 65 67 75 6c 61 72 20 73 74 72 69 6e 67 0a 09 regular string..
06b0: 49 4e 54 2c 20 20 20 20 20 20 20 20 2f 2f 20 41 INT, // A
06c0: 6e 20 69 6e 74 65 67 65 72 0a 09 49 4e 46 4f 52 n integer..INFOR
06d0: 4d 41 54 49 4f 4e 20 2f 2f 20 4e 61 6d 65 20 6f MATION // Name o
06e0: 6e 6c 79 2c 20 6e 6f 20 76 61 6c 75 65 2c 20 73 nly, no value, s
06f0: 6f 20 72 65 61 64 20 6f 6e 6c 79 0a 7d 20 54 59 o read only.} TY
0700: 50 45 3b 0a 0a 74 79 70 65 64 65 66 20 65 6e 75 PE;..typedef enu
0710: 6d 20 7b 0a 09 50 57 5f 4e 55 4c 4c 2c 0a 09 50 m {..PW_NULL,..P
0720: 57 5f 49 54 45 4d 2c 0a 09 50 57 5f 53 55 42 4c W_ITEM,..PW_SUBL
0730: 49 53 54 2c 0a 09 50 57 5f 55 50 4c 45 56 45 4c IST,..PW_UPLEVEL
0740: 0a 7d 20 4c 49 53 54 5f 49 54 45 4d 5f 54 59 50 .} LIST_ITEM_TYP
0750: 45 3b 0a 0a 74 79 70 65 64 65 66 20 73 74 72 75 E;..typedef stru
0760: 63 74 20 7b 0a 09 63 68 61 72 20 2a 6e 61 6d 65 ct {..char *name
0770: 3b 0a 09 76 6f 69 64 20 2a 76 61 6c 75 65 3b 20 ;..void *value;
0780: 2f 2f 20 69 6e 74 2a 20 6f 72 20 63 68 61 72 2a // int* or char*
0790: 0a 09 69 6e 74 20 6d 61 78 5f 6c 65 6e 67 74 68 ..int max_length
07a0: 3b 0a 09 54 59 50 45 20 74 79 70 65 3b 0a 09 63 ;..TYPE type;..c
07b0: 68 61 72 20 2a 28 2a 61 75 74 6f 67 65 6e 29 28 har *(*autogen)(
07c0: 63 68 61 72 2a 29 3b 0a 7d 20 49 6e 70 75 74 46 char*);.} InputF
07d0: 69 65 6c 64 3b 0a 0a 69 6e 74 20 75 69 6c 69 73 ield;..int uilis
07e0: 74 5f 69 6e 69 74 28 29 3b 0a 69 6e 74 20 75 69 t_init();.int ui
07f0: 6c 69 73 74 5f 66 72 65 65 28 29 3b 0a 69 6e 74 list_free();.int
0800: 20 75 69 6c 69 73 74 5f 72 65 66 72 65 73 68 28 uilist_refresh(
0810: 29 3b 0a 69 6e 74 20 75 69 5f 73 74 61 74 75 73 );.int ui_status
0820: 6c 69 6e 65 5f 63 6c 65 61 72 28 29 3b 0a 0a 69 line_clear();..i
0830: 6e 74 20 76 69 65 77 5f 70 77 28 69 6e 74 20 69 nt view_pw(int i
0840: 29 3b 0a 0a 69 6e 74 20 75 69 5f 73 74 61 74 75 );..int ui_statu
0850: 73 6c 69 6e 65 5f 79 65 73 5f 6e 6f 28 63 68 61 sline_yes_no(cha
0860: 72 20 2a 2c 20 69 6e 74 29 3b 0a 69 6e 74 20 75 r *, int);.int u
0870: 69 5f 73 74 61 74 75 73 6c 69 6e 65 5f 6d 73 67 i_statusline_msg
0880: 28 63 68 61 72 20 2a 6d 73 67 29 3b 0a 76 6f 69 (char *msg);.voi
0890: 64 20 75 69 5f 73 74 61 74 75 73 6c 69 6e 65 5f d ui_statusline_
08a0: 61 73 6b 5f 6e 75 6d 28 63 68 61 72 20 2a 2c 20 ask_num(char *,
08b0: 69 6e 74 20 2a 29 3b 0a 76 6f 69 64 20 75 69 5f int *);.void ui_
08c0: 73 74 61 74 75 73 6c 69 6e 65 5f 61 73 6b 5f 63 statusline_ask_c
08d0: 68 61 72 28 63 68 61 72 20 2a 2c 20 63 68 61 72 har(char *, char
08e0: 20 2a 2c 20 63 68 61 72 2a 29 3b 0a 63 68 61 72 *, char*);.char
08f0: 20 2a 20 75 69 5f 73 74 61 74 75 73 6c 69 6e 65 * ui_statusline
0900: 5f 61 73 6b 5f 73 74 72 28 63 68 61 72 20 2a 2c _ask_str(char *,
0910: 20 63 68 61 72 20 2a 2c 20 69 6e 74 20 6c 65 6e char *, int len
0920: 29 3b 0a 63 68 61 72 20 2a 20 75 69 5f 73 74 61 );.char * ui_sta
0930: 74 75 73 6c 69 6e 65 5f 61 73 6b 5f 70 61 73 73 tusline_ask_pass
0940: 77 64 28 63 68 61 72 20 2a 2c 20 63 68 61 72 20 wd(char *, char
0950: 2a 2c 20 69 6e 74 2c 20 69 6e 74 29 3b 0a 63 68 *, int, int);.ch
0960: 61 72 20 2a 20 75 69 5f 73 74 61 74 75 73 6c 69 ar * ui_statusli
0970: 6e 65 5f 61 73 6b 5f 73 74 72 5f 77 69 74 68 5f ne_ask_str_with_
0980: 61 75 74 6f 67 65 6e 28 63 68 61 72 20 2a 6d 73 autogen(char *ms
0990: 67 2c 20 63 68 61 72 20 2a 69 6e 70 75 74 2c 20 g, char *input,
09a0: 69 6e 74 20 6c 65 6e 2c 20 63 68 61 72 20 2a 28 int len, char *(
09b0: 2a 61 75 74 6f 67 65 6e 29 28 63 68 61 72 20 2a *autogen)(char *
09c0: 29 2c 20 69 6e 74 20 63 68 29 3b 0a 0a 76 6f 69 ), int ch);..voi
09d0: 64 20 73 74 61 74 75 73 6c 69 6e 65 5f 72 65 61 d statusline_rea
09e0: 64 6f 6e 6c 79 28 29 3b 0a 23 65 6e 64 69 66 0a donly();.#endif.
09f0: 0a 0a ..