2 * Copyright (c) 1997, 2000 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 * isdntel - isdn4bsd telephone answering machine support
28 * ======================================================
30 * $Id: display.c,v 1.9 2000/07/19 08:56:24 hm Exp $
32 * $FreeBSD: src/usr.sbin/i4b/isdntel/display.c,v 1.6.2.1 2001/08/01 17:45:06 obrien Exp $
33 * $DragonFly: src/usr.sbin/i4b/isdntel/display.c,v 1.2 2003/06/17 04:29:55 dillon Exp $
35 * last edit-date: [Wed Jul 19 10:08:06 2000]
37 *----------------------------------------------------------------------------*/
41 static char *helpstr = "Enter Control-D to exit program or RETURN for command window";
43 /*---------------------------------------------------------------------------*
44 * init curses fullscreen display
45 *---------------------------------------------------------------------------*/
51 initscr(); /* curses init */
55 if((COLS < 80) || (LINES < 24))
56 fatal("ERROR, minimal screensize must be 80x24, is %dx%d, terminating!", COLS, LINES);
59 if((main_w = newwin(LINES-START_O-2, COLS, START_O, 0)) == NULL)
60 fatal("ERROR, curses init main window, terminating!");
62 raw(); /* raw input */
63 noecho(); /* do not echo input */
64 keypad(stdscr, TRUE); /* use special keys */
65 keypad(main_w, TRUE); /* use special keys */
66 scrollok(main_w, TRUE);
68 sprintf(buffer, " isdntel %d.%d.%d ", VERSION, REL, STEP);
75 move(0, 5 + strlen(buffer));
76 hline(ACS_HLINE, 256);
80 addstr("Date Time Called Party Calling Party Alias Length");
81 /* 31.12.96 16:45:12 1234567890123456 1234567890123456 12345678901234567890 123456 */
84 hline(ACS_HLINE, 256);
87 hline(ACS_HLINE, 256);
89 mvaddstr(LINES-1, (COLS / 2) - (strlen(helpstr) / 2), helpstr);
96 /*---------------------------------------------------------------------------*
97 * curses menu for fullscreen command mode
98 *---------------------------------------------------------------------------*/
102 static char *menu[WMITEMS] =
120 /* create a new window in the lower screen area */
122 if((menu_w = newwin(WMENU_HGT, WMENU_LEN, WMENU_POSLN, WMENU_POSCO )) == NULL)
125 keypad(menu_w, TRUE); /* use special keys */
127 /* draw border around the window */
134 mvwaddstr(menu_w, 0, (WMENU_LEN / 2) - (strlen(WMENU_TITLE) / 2), WMENU_TITLE);
137 /* fill the window with the menu options */
139 for(mpos=0; mpos <= (WMITEMS-1); mpos++)
140 mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
142 /* highlight the first menu option */
146 mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
160 case KEY_DOWN: /* down-move cursor */
162 mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
167 mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
171 case KEY_UP: /* up-move cursor */
172 mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
178 mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
210 case LF: /* exec highlighted option */
245 /* delete the menu window */
249 /* re-display the original lower window contents */