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.4 2009/04/16 05:56:33 lukem Exp $
34 * last edit-date: [Wed Jul 19 10:08:06 2000]
36 *----------------------------------------------------------------------------*/
40 static const char *helpstr
= "Enter Control-D to exit program or RETURN for command window";
42 /*---------------------------------------------------------------------------*
43 * init curses fullscreen display
44 *---------------------------------------------------------------------------*/
50 initscr(); /* curses init */
54 if ((COLS
< 80) || (LINES
< 24))
55 fatal("ERROR, minimal screensize must be 80x24, is %dx%d, terminating!", COLS
, LINES
);
58 if ((main_w
= newwin(LINES
-START_O
-2, COLS
, START_O
, 0)) == NULL
)
59 fatal("ERROR, curses init main window, terminating!");
61 raw(); /* raw input */
62 noecho(); /* do not echo input */
63 keypad(stdscr
, TRUE
); /* use special keys */
64 keypad(main_w
, TRUE
); /* use special keys */
65 scrollok(main_w
, TRUE
);
67 snprintf(buffer
, sizeof(buffer
), " isdntel %d.%d.%d ", VERSION
, REL
, STEP
);
74 move(0, 5 + strlen(buffer
));
75 hline(ACS_HLINE
, 256);
79 addstr("Date Time Called Party Calling Party Alias Length");
80 /* 31.12.96 16:45:12 1234567890123456 1234567890123456 12345678901234567890 123456 */
83 hline(ACS_HLINE
, 256);
86 hline(ACS_HLINE
, 256);
88 mvaddstr(LINES
-1, (COLS
/ 2) - (strlen(helpstr
) / 2), helpstr
);
95 /*---------------------------------------------------------------------------*
96 * curses menu for fullscreen command mode
97 *---------------------------------------------------------------------------*/
101 static const char *menu
[WMITEMS
] =
119 /* create a new window in the lower screen area */
121 if ((menu_w
= newwin(WMENU_HGT
, WMENU_LEN
, WMENU_POSLN
, WMENU_POSCO
)) == NULL
)
124 keypad(menu_w
, TRUE
); /* use special keys */
126 /* draw border around the window */
133 mvwaddstr(menu_w
, 0, (WMENU_LEN
/ 2) - (strlen(WMENU_TITLE
) / 2), WMENU_TITLE
);
136 /* fill the window with the menu options */
138 for (mpos
=0; mpos
<= (WMITEMS
-1); mpos
++)
139 mvwaddstr(menu_w
, mpos
+ 2, 2, menu
[mpos
]);
141 /* highlight the first menu option */
145 mvwaddstr(menu_w
, mpos
+ 2, 2, menu
[mpos
]);
159 case KEY_DOWN
: /* down-move cursor */
161 mvwaddstr(menu_w
, mpos
+ 2, 2, menu
[mpos
]);
166 mvwaddstr(menu_w
, mpos
+ 2, 2, menu
[mpos
]);
170 case KEY_UP
: /* up-move cursor */
171 mvwaddstr(menu_w
, mpos
+ 2, 2, menu
[mpos
]);
177 mvwaddstr(menu_w
, mpos
+ 2, 2, menu
[mpos
]);
209 case LF
: /* exec highlighted option */
244 /* delete the menu window */
248 /* re-display the original lower window contents */