installer: Correct typo in a comment.
[dragonfly.git] / usr.sbin / i4b / isdntel / display.c
blob22f7da738a99658078743b7858b881d6e3dfcf99
1 /*
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
6 * are met:
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
23 * SUCH DAMAGE.
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 *----------------------------------------------------------------------------*/
39 #include "defs.h"
41 static char *helpstr = "Enter Control-D to exit program or RETURN for command window";
43 /*---------------------------------------------------------------------------*
44 * init curses fullscreen display
45 *---------------------------------------------------------------------------*/
46 void
47 init_screen(void)
49 char buffer[512];
51 initscr(); /* curses init */
53 curses_ready = 1;
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);
70 move(0, 0);
71 standout();
72 hline(ACS_HLINE, 5);
73 move(0, 5);
74 addstr(buffer);
75 move(0, 5 + strlen(buffer));
76 hline(ACS_HLINE, 256);
77 standend();
79 move(1, 0);
80 addstr("Date Time Called Party Calling Party Alias Length");
81 /* 31.12.96 16:45:12 1234567890123456 1234567890123456 12345678901234567890 123456 */
83 move(2, 0);
84 hline(ACS_HLINE, 256);
86 move(LINES-2, 0);
87 hline(ACS_HLINE, 256);
89 mvaddstr(LINES-1, (COLS / 2) - (strlen(helpstr) / 2), helpstr);
91 refresh();
93 wrefresh(main_w);
96 /*---------------------------------------------------------------------------*
97 * curses menu for fullscreen command mode
98 *---------------------------------------------------------------------------*/
99 void
100 do_menu(void)
102 static char *menu[WMITEMS] =
104 "Play File",
105 #define PLAY 0
106 "Delete File",
107 #define DELETE 1
108 "Re-Read Spool",
109 #define REREAD 2
110 "Refresh Screen",
111 #define REFRESH 3
112 "Exit Program",
113 #define EXIT 4
116 WINDOW *menu_w;
117 int c;
118 int mpos;
120 /* create a new window in the lower screen area */
122 if((menu_w = newwin(WMENU_HGT, WMENU_LEN, WMENU_POSLN, WMENU_POSCO )) == NULL)
123 return;
125 keypad(menu_w, TRUE); /* use special keys */
127 /* draw border around the window */
129 box(menu_w, 0, 0);
131 /* add a title */
133 wstandout(menu_w);
134 mvwaddstr(menu_w, 0, (WMENU_LEN / 2) - (strlen(WMENU_TITLE) / 2), WMENU_TITLE);
135 wstandend(menu_w);
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 */
144 mpos = 0;
145 wstandout(menu_w);
146 mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
147 wstandend(menu_w);
149 /* input loop */
151 for(;;)
153 wrefresh(menu_w);
155 c = wgetch(menu_w);
157 switch(c)
159 case TAB:
160 case KEY_DOWN: /* down-move cursor */
161 case ' ':
162 mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
163 mpos++;
164 if(mpos >= WMITEMS)
165 mpos = 0;
166 wstandout(menu_w);
167 mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
168 wstandend(menu_w);
169 break;
171 case KEY_UP: /* up-move cursor */
172 mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
173 if(mpos)
174 mpos--;
175 else
176 mpos = WMITEMS-1;
177 wstandout(menu_w);
178 mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
179 wstandend(menu_w);
180 break;
182 case 'R':
183 case 'r':
184 wrefresh(curscr);
185 goto mexit;
187 case 'E':
188 case 'e':
189 case 'Q':
190 case 'q':
191 case 'X':
192 case 'x':
193 do_quit(0);
194 goto mexit;
195 break;
197 case 'P':
198 case 'p':
199 play(cur_file);
200 goto mexit;
201 break;
203 case 'D':
204 case 'd':
205 delete(cur_file);
206 goto mexit;
207 break;
209 case CR:
210 case LF: /* exec highlighted option */
211 #ifdef KEY_ENTER
212 case KEY_ENTER:
213 #endif
214 switch(mpos)
216 case PLAY:
217 play(cur_file);
218 goto mexit;
219 break;
220 case DELETE:
221 delete(cur_file);
222 goto mexit;
223 break;
224 case REREAD:
225 reread();
226 goto mexit;
227 break;
228 case REFRESH:
229 wrefresh(curscr);
230 break;
231 case EXIT:
232 do_quit(0);
233 break;
235 goto mexit;
236 break;
238 default:
239 goto mexit;
240 break;
244 mexit:
245 /* delete the menu window */
247 delwin(menu_w);
249 /* re-display the original lower window contents */
251 touchwin(main_w);
252 wrefresh(main_w);
255 /* EOF */