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 $
34 * last edit-date: [Mon Dec 13 21:52:55 1999]
36 *----------------------------------------------------------------------------*/
40 /*---------------------------------------------------------------------------*
41 * init curses fullscreen display
42 *---------------------------------------------------------------------------*/
48 initscr(); /* curses init */
50 if((COLS < 80) || (LINES < 24))
51 fatal(0, "ERROR, minimal screensize must be 80x24, is %dx%d, terminating!", COLS, LINES);
54 if((main_w = newwin(MW_HEIGHT, MW_WIDTH, MW_ROW, MW_COL)) == NULL)
55 fatal("ERROR, curses init main window, terminating!");
59 if((dbg_w = newwin(DB_HGT, DB_WID, DB_ROW, DB_COL)) == NULL)
60 fatal("ERROR, curses init debug window, terminating!");
61 scrollok(dbg_w, TRUE);
64 raw(); /* raw input */
65 noecho(); /* do not echo input */
66 keypad(stdscr, TRUE); /* use special keys */
67 keypad(main_w, TRUE); /* use special keys */
71 sprintf(buffer, "isdnphone %d.%d ", VERSION, REL);
74 mvwaddstr(main_w, 0, (MW_WIDTH / 2) - (strlen(buffer) / 2), buffer);
77 mvwaddstr(main_w, MW_STATEY, MW_STATEX, " state: ");
78 mvwprintw(main_w, MW_STATEY, MW_STX, "%s", states[state]);
79 wmove(main_w, MW_STATEY+1, 1);
80 whline(main_w, 0, MW_WIDTH-2);
82 mvwaddstr(main_w, MW_NUMY, MW_NUMX, " number: ");
83 wmove(main_w, MW_NUMY+1, 1);
84 whline(main_w, 0, MW_WIDTH-2);
86 mvwaddstr(main_w, MW_MSGY, MW_MSGX, "message: ");
93 /*---------------------------------------------------------------------------*
94 * curses menu for fullscreen command mode
95 *---------------------------------------------------------------------------*/
99 static char *menu[WMITEMS] =
115 /* create a new window in the lower screen area */
117 if((menu_w = newwin(WMENU_HGT, WMENU_LEN, WMENU_POSLN, WMENU_POSCO )) == NULL)
120 keypad(menu_w, TRUE); /* use special keys */
122 /* draw border around the window */
129 mvwaddstr(menu_w, 0, (WMENU_LEN / 2) - (strlen(WMENU_TITLE) / 2), WMENU_TITLE);
132 /* fill the window with the menu options */
134 for(mpos=0; mpos <= (WMITEMS-1); mpos++)
135 mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
137 /* highlight the first menu option */
141 mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
155 case KEY_DOWN: /* down-move cursor */
157 mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
162 mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
166 case KEY_UP: /* up-move cursor */
167 mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
173 mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
204 case LF: /* exec highlighted option */
234 /* delete the menu window */
240 /* re-display the original lower window contents */