2 * Copyright (c) 1999 Hellmuth Michaelis. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 *---------------------------------------------------------------------------
27 * isdnphone - some display operations
28 * ===================================
30 * $Id: display.c,v 1.4 1999/12/13 21:25:26 hm Exp $
32 * $FreeBSD: src/usr.sbin/i4b/isdnphone/display.c,v 1.1.2.1 2001/08/01 17:45:06 obrien Exp $
33 * $DragonFly: src/usr.sbin/i4b/isdnphone/display.c,v 1.2 2003/06/17 06:29:55 dillon Exp $
35 * last edit-date: [Mon Dec 13 21:52:55 1999]
37 *----------------------------------------------------------------------------*/
41 /*---------------------------------------------------------------------------*
42 * init curses fullscreen display
43 *---------------------------------------------------------------------------*/
49 initscr(); /* curses init */
51 if((COLS
< 80) || (LINES
< 24))
52 fatal(0, "ERROR, minimal screensize must be 80x24, is %dx%d, terminating!", COLS
, LINES
);
55 if((main_w
= newwin(MW_HEIGHT
, MW_WIDTH
, MW_ROW
, MW_COL
)) == NULL
)
56 fatal("ERROR, curses init main window, terminating!");
60 if((dbg_w
= newwin(DB_HGT
, DB_WID
, DB_ROW
, DB_COL
)) == NULL
)
61 fatal("ERROR, curses init debug window, terminating!");
62 scrollok(dbg_w
, TRUE
);
65 raw(); /* raw input */
66 noecho(); /* do not echo input */
67 keypad(stdscr
, TRUE
); /* use special keys */
68 keypad(main_w
, TRUE
); /* use special keys */
72 sprintf(buffer
, "isdnphone %d.%d ", VERSION
, REL
);
75 mvwaddstr(main_w
, 0, (MW_WIDTH
/ 2) - (strlen(buffer
) / 2), buffer
);
78 mvwaddstr(main_w
, MW_STATEY
, MW_STATEX
, " state: ");
79 mvwprintw(main_w
, MW_STATEY
, MW_STX
, "%s", states
[state
]);
80 wmove(main_w
, MW_STATEY
+1, 1);
81 whline(main_w
, 0, MW_WIDTH
-2);
83 mvwaddstr(main_w
, MW_NUMY
, MW_NUMX
, " number: ");
84 wmove(main_w
, MW_NUMY
+1, 1);
85 whline(main_w
, 0, MW_WIDTH
-2);
87 mvwaddstr(main_w
, MW_MSGY
, MW_MSGX
, "message: ");
94 /*---------------------------------------------------------------------------*
95 * curses menu for fullscreen command mode
96 *---------------------------------------------------------------------------*/
100 static char *menu
[WMITEMS
] =
116 /* create a new window in the lower screen area */
118 if((menu_w
= newwin(WMENU_HGT
, WMENU_LEN
, WMENU_POSLN
, WMENU_POSCO
)) == NULL
)
121 keypad(menu_w
, TRUE
); /* use special keys */
123 /* draw border around the window */
130 mvwaddstr(menu_w
, 0, (WMENU_LEN
/ 2) - (strlen(WMENU_TITLE
) / 2), WMENU_TITLE
);
133 /* fill the window with the menu options */
135 for(mpos
=0; mpos
<= (WMITEMS
-1); mpos
++)
136 mvwaddstr(menu_w
, mpos
+ 2, 2, menu
[mpos
]);
138 /* highlight the first menu option */
142 mvwaddstr(menu_w
, mpos
+ 2, 2, menu
[mpos
]);
156 case KEY_DOWN
: /* down-move cursor */
158 mvwaddstr(menu_w
, mpos
+ 2, 2, menu
[mpos
]);
163 mvwaddstr(menu_w
, mpos
+ 2, 2, menu
[mpos
]);
167 case KEY_UP
: /* up-move cursor */
168 mvwaddstr(menu_w
, mpos
+ 2, 2, menu
[mpos
]);
174 mvwaddstr(menu_w
, mpos
+ 2, 2, menu
[mpos
]);
205 case LF
: /* exec highlighted option */
235 /* delete the menu window */
241 /* re-display the original lower window contents */