1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
/*
* Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*---------------------------------------------------------------------------
*
* isdntel - isdn4bsd telephone answering machine support
* ======================================================
*
* $Id: display.c,v 1.4 1998/12/05 18:03:55 hm Exp $
*
* last edit-date: [Sat Dec 5 18:15:40 1998]
*
*----------------------------------------------------------------------------*/
#include "defs.h"
static char *helpstr = "Enter Control-D to exit program or RETURN for command window";
/*---------------------------------------------------------------------------*
* init curses fullscreen display
*---------------------------------------------------------------------------*/
void
init_screen(void)
{
char buffer[512];
initscr(); /* curses init */
if((COLS < 80) || (LINES < 24))
fatal(0, "ERROR, minimal screensize must be 80x24, is %dx%d, terminating!", COLS, LINES);
if((main_w = newwin(LINES-START_O-2, COLS, START_O, 0)) == NULL)
fatal("ERROR, curses init main window, terminating!");
raw(); /* raw input */
noecho(); /* do not echo input */
keypad(stdscr, TRUE); /* use special keys */
keypad(main_w, TRUE); /* use special keys */
scrollok(main_w, TRUE);
sprintf(buffer, " isdntel %s.%s ", VERSION, REL);
move(0, 0);
standout();
hline(ACS_HLINE, 5);
move(0, 5);
addstr(buffer);
move(0, 5 + strlen(buffer));
hline(ACS_HLINE, 256);
standend();
move(1, 0);
addstr("Date Time Called Party Calling Party Alias Length");
/* 31.12.96 16:45:12 1234567890123456 1234567890123456 12345678901234567890 123456 */
move(2, 0);
hline(ACS_HLINE, 256);
move(LINES-2, 0);
hline(ACS_HLINE, 256);
mvaddstr(LINES-1, (COLS / 2) - (strlen(helpstr) / 2), helpstr);
refresh();
wrefresh(main_w);
curses_ready = 1;
}
/*---------------------------------------------------------------------------*
* curses menu for fullscreen command mode
*---------------------------------------------------------------------------*/
void
do_menu(void)
{
static char *menu[WMITEMS] =
{
"Play File",
#define PLAY 0
"Delete File",
#define DELETE 1
"Re-Read Spool",
#define REREAD 2
"Refresh Screen",
#define REFRESH 3
"Exit Program",
#define EXIT 4
};
WINDOW *menu_w;
int c;
int mpos;
/* create a new window in the lower screen area */
if((menu_w = newwin(WMENU_HGT, WMENU_LEN, WMENU_POSLN, WMENU_POSCO )) == NULL)
return;
keypad(menu_w, TRUE); /* use special keys */
/* draw border around the window */
box(menu_w, 0, 0);
/* add a title */
wstandout(menu_w);
mvwaddstr(menu_w, 0, (WMENU_LEN / 2) - (strlen(WMENU_TITLE) / 2), WMENU_TITLE);
wstandend(menu_w);
/* fill the window with the menu options */
for(mpos=0; mpos <= (WMITEMS-1); mpos++)
mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
/* highlight the first menu option */
mpos = 0;
wstandout(menu_w);
mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
wstandend(menu_w);
/* input loop */
for(;;)
{
wrefresh(menu_w);
c = wgetch(menu_w);
switch(c)
{
case TAB:
case KEY_DOWN: /* down-move cursor */
case ' ':
mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
mpos++;
if(mpos >= WMITEMS)
mpos = 0;
wstandout(menu_w);
mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
wstandend(menu_w);
break;
case KEY_UP: /* up-move cursor */
mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
if(mpos)
mpos--;
else
mpos = WMITEMS-1;
wstandout(menu_w);
mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
wstandend(menu_w);
break;
case 'R':
case 'r':
wrefresh(curscr);
goto mexit;
case 'E':
case 'e':
case 'Q':
case 'q':
case 'X':
case 'x':
do_quit(0);
goto mexit;
break;
case 'P':
case 'p':
play(cur_file);
goto mexit;
break;
case 'D':
case 'd':
delete(cur_file);
goto mexit;
break;
case CR:
case LF: /* exec highlighted option */
#ifdef KEY_ENTER
case KEY_ENTER:
#endif
switch(mpos)
{
case PLAY:
play(cur_file);
goto mexit;
break;
case DELETE:
delete(cur_file);
goto mexit;
break;
case REREAD:
reread();
goto mexit;
break;
case REFRESH:
wrefresh(curscr);
break;
case EXIT:
do_quit(0);
break;
}
goto mexit;
break;
default:
goto mexit;
break;
}
}
mexit:
/* delete the menu window */
delwin(menu_w);
/* re-display the original lower window contents */
touchwin(main_w);
wrefresh(main_w);
}
/* EOF */
|