1 /***************************************************************************
2 *
3 * $Header: /usr/local/cvsroot/utils/ytree/disp.c,v 1.21 2016/09/04 14:41:12 werner Exp $
4 *
5 * Menue-Geruest anzeigen
6 *
7 ***************************************************************************/
8
9
10 #include "ytree.h"
11 #include "patchlev.h"
12
13
14 static void PrintMenuLine(WINDOW *win, int y, int x, char *line);
15 static void PrintLine(WINDOW *win, int y, int x, char *line, int len);
16 static void DisplayVersion(void);
17
18
19
20 static char *mask[] = {
21 "5-----------------------2",
22 "|FILE: |",
23 "6-----------------------7",
24 "|DISK: |",
25 "| Avail |",
26 "6-----------------------7",
27 "|DISK Statistics |",
28 "|[Total] |",
29 "| Files: |",
30 "| Bytes: |",
31 "|[Matching] |",
32 "| Files: |",
33 "| Bytes: |",
34 "|[Tagged] |",
35 "| Files: |",
36 "| Bytes: |",
37 "|[Current Directory] |",
38 "| |",
39 "| Bytes: |"
40 };
41
42
43 static char *logo[] = {
44 " # ",
45 " ## ",
46 " ## ## ##### ## ### #### ####",
47 " ## ## ## ## ## ## ## ## ##",
48 " ## ## ## ## ## ###### ###### ",
49 " ##### ## # ## ## ## ",
50 " ## ### #### #### #### ",
51 "##### "
52 };
53
54 static char *extended_line = "| | |";
55
56
57 static char *last_line = "3-8-----------------------4";
58 static char *first_line ="1-5";
59
60
61 static char dir_help_disk_mode_0[] = "DIR (A)ttribute (D)elete (F)ilespec (G)roup (L)og (M)akedir (Q)uit";
62 static char dir_help_disk_mode_1[] = "COMMANDS (O)wner (R)ename (S)howall (^S)how-tagged (T)ag (U)ntag e(X)ecute (^F) dirmode";
63 static char *dir_help[MAX_MODES][2] =
64 {
65 { /* DISK_MODE */
66 dir_help_disk_mode_0,
67 dir_help_disk_mode_1
68 },
69 { /* LL_FILE_MODE */
70 "DIR (F)ilespec (L)ogin (S)howall (T)ag (U)ntag e(X)ecute (^F) dirmode (Q)uit ",
71 "COMMANDS "
72 },
73 { /* TAR_FILE_MODE */
74 "TAR-DIR (F)ilespec (L)og (S)howall (T)ag (U)ntag e(X)ecute (^F) dirmode (Q)uit ",
75 "COMMANDS "
76 },
77 { /* ZOO_FILE_MODE */
78 "ZOO-DIR (F)ilespec (L)og (S)howall (T)ag (U)ntag e(X)ecute (^F) dirmode (Q)uit ",
79 "COMMANDS "
80 },
81 { /* ZIP_FILE_MODE */
82 "ZIP-DIR (F)ilespec (L)og (S)howall (T)ag (U)ntag e(X)ecute (^F) dirmode (Q)uit ",
83 "COMMANDS "
84 },
85 { /* LHA_FILE_MODE */
86 "LHA-DIR (F)ilespec (L)og (S)howall (T)ag (U)ntag e(X)ecute (^F) dirmode (Q)uit ",
87 "COMMANDS "
88 },
89 { /* ARC_FILE_MODE */
90 "ARC-DIR (F)ilespec (L)og (S)howall (T)ag (U)ntag e(X)ecute (^F) dirmode (Q)uit ",
91 "COMMANDS "
92 },
93 { /* RPM_FILE_MODE */
94 "RPM-DIR (F)ilespec (L)og (S)howall (T)ag (U)ntag e(X)ecute (^F) dirmode (Q)uit ",
95 "COMMANDS "
96 },
97 { /* RAR_FILE_MODE */
98 "RAR-DIR (F)ilespec (L)og (S)howall (T)ag (U)ntag e(X)ecute (^F) dirmode (Q)uit ",
99 "COMMANDS "
100 },
101 { /* TAPE_MODE */
102 "TAPE-DIR (F)ilespec (L)og (S)howall (T)ag (U)ntag e(X)ecute (^F) dirmode (Q)uit ",
103 "COMMANDS "
104 },
105 { /* USER_MODE */
106 dir_help_disk_mode_0, /* Default unless changed by user prefs */
107 dir_help_disk_mode_1
108 }
109 };
110
111
112 static char file_help_disk_mode_0[] = "FILE (A)ttribute (C)opy (D)elete (E)dit (F)ilespec (G)roup (H)ex (L)ogin (M)ove (Q)uit ";
113 static char file_help_disk_mode_1[] = "COMMANDS (O)wner (P)ipe (R)ename (S)ort (T)ag (U)ntag (V)iew e(X)ecute pathcop(Y) (^F)ilemode ";
114 static char *file_help[MAX_MODES][2] =
115 {
116 { /* DISK_MODE */
117 file_help_disk_mode_0,
118 file_help_disk_mode_1
119 },
120 { /* LL_FILE_MODE */
121 "FILE (F)ilespec (L)ogin (S)ort (T)ag (U)ntag e(X)ecute (^F)ilemode (Q)uit ",
122 "COMMANDS "
123 },
124 { /* TAR_FILE_MODE */
125 "TAR-FILE (C)opy (F)ilespec (H)ex (P)ipe (S)ort (T)ag (U)ntag (V)iew pathcop(Y) (Q)uit ",
126 "COMMANDS (^F)ilemode "
127 },
128 { /* ZOO_FILE_MODE */
129 "ZOO-FILE (C)opy (F)ilespec (H)ex (P)ipe (S)ort (T)ag (U)ntag (V)iew pathcop(Y) (Q)uit ",
130 "COMMANDS (^F)ilemode "
131 },
132 { /* ZIP_FILE_MODE */
133 "ZIP-FILE (C)opy (F)ilespec (H)ex (P)ipe (S)ort (T)ag (U)ntag (V)iew pathcop(Y) (Q)uit ",
134 "COMMANDS (^F)ilemode "
135 },
136 { /* LHA_FILE_MODE */
137 "LHA-FILE (C)opy (F)ilespec (H)ex (P)ipe (S)ort (T)ag (U)ntag (V)iew pathcop(Y) (Q)uit ",
138 "COMMANDS (^F)ilemode "
139 },
140 { /* ARC_FILE_MODE */
141 "ARC-FILE (C)opy (F)ilespec (H)ex (P)ipe (S)ort (T)ag (U)ntag (V)iew pathcop(Y) (Q)uit ",
142 "COMMANDS (^F)ilemode "
143 },
144 { /* RPM_FILE_MODE */
145 "RPM-FILE (C)opy (F)ilespec (H)ex (P)ipe (S)ort (T)ag (U)ntag (V)iew pathcop(Y) (Q)uit ",
146 "COMMANDS (^F)ilemode "
147 },
148 { /* RAR_FILE_MODE */
149 "RAR-FILE (C)opy (F)ilespec (H)ex (P)ipe (S)ort (T)ag (U)ntag (V)iew pathcop(Y) (Q)uit ",
150 "COMMANDS (^F)ilemode "
151 },
152 { /* TAPE_MODE */
153 "TAPE-FILE (C)opy (F)ilespec (H)ex (P)ipe (S)ort (T)ag (U)ntag (V)iew pathcop(Y) (Q)uit ",
154 "COMMANDS (^F)ilemode "
155 },
156 { /* USER_MODE */
157 file_help_disk_mode_0, /* Default unless changed by user prefs */
158 file_help_disk_mode_1
159 }
160 };
161
162
163
164
165
DisplayVersion(void)166 static void DisplayVersion(void)
167 {
168 static char version[80];
169
170 ClearHelp();
171 (void) sprintf( version,
172 "ytree Version %sPL%d %s (Werner Bregulla)",
173 VERSION,
174 PATCHLEVEL,
175 VERSIONDATE
176 );
177 MvAddStr( LINES - 2, (unsigned) (COLS - strlen( version )) >> 1, version );
178 }
179
180
181
182
DisplayDirHelp(void)183 void DisplayDirHelp(void)
184 {
185 int i;
186 char *cptr;
187
188 if (mode == USER_MODE) {
189 if (dir_help[mode][0] == dir_help_disk_mode_0 && (cptr = DIR1) != NULL)
190 dir_help[mode][0] = cptr;
191 if (dir_help[mode][1] == dir_help_disk_mode_1 && (cptr = DIR2) != NULL)
192 dir_help[mode][1] = cptr;
193 }
194 for( i=0; i < (int)(sizeof(dir_help[mode]) / sizeof(dir_help[mode][0])); i++) {
195 PrintOptions( stdscr, LINES - 2 + i, 0, dir_help[mode][i] );
196 clrtoeol();
197 }
198 }
199
200
201
DisplayFileHelp(void)202 void DisplayFileHelp(void)
203 {
204 int i;
205 char *cptr;
206
207 if (mode == USER_MODE) {
208 if (file_help[mode][0] == file_help_disk_mode_0 && (cptr = FILE1) != NULL)
209 file_help[mode][0] = cptr;
210 if (file_help[mode][1] == file_help_disk_mode_1 && (cptr = FILE2) != NULL)
211 file_help[mode][1] = cptr;
212 }
213 for( i=0; i < (int)(sizeof(file_help[mode]) / sizeof(file_help[mode][0])); i++) {
214 PrintOptions( stdscr, LINES - 2 + i, 0, file_help[mode][i] );
215 clrtoeol();
216 }
217 }
218
219
220
ClearHelp(void)221 void ClearHelp(void)
222 {
223 int i;
224
225 for( i=0; i < 3; i++ )
226 {
227 wmove( stdscr, LINES - 3 + i, 0 ); clrtoeol();
228 }
229 }
230
231
232
DisplayMenu(void)233 void DisplayMenu(void)
234 {
235 int y;
236 int l, c;
237
238
239 PrintSpecialString( stdscr, 0, 0, "Path: ", MENU_COLOR );
240 #ifdef COLOR_SUPPORT
241 clrtoeol();
242 #endif
243
244 werase( dir_window );
245 werase( big_file_window );
246 werase( small_file_window );
247
248 for( y=1; y <= (int)(sizeof(mask) / sizeof(mask[0])); y++){
249 PrintOptions( stdscr, y, 0, "|");
250 PrintOptions( stdscr, y, COLS - 25 , mask[y-1] );
251 }
252 for( ; y < LINES - 4; y++ )
253 PrintMenuLine( stdscr, y, 0, extended_line );
254 PrintLine( stdscr, DIR_WINDOW_HEIGHT + 2, 0, "6-7", COLS - 25 );
255 PrintLine( stdscr, 1, 0, first_line, COLS - 25);
256 PrintMenuLine( stdscr, y, 0, last_line );
257
258 l = sizeof(logo) / sizeof(logo[0]);
259 c = strlen( logo[0] );
260
261 for( y=0; y < l; y++ )
262 {
263 MvWAddStr( dir_window,
264 y + ((DIR_WINDOW_HEIGHT - l) >> 1),
265 (DIR_WINDOW_WIDTH - c) >> 1,
266 logo[y]
267 );
268 }
269 DisplayVersion();
270
271 touchwin( dir_window );
272 /* refresh(); */
273 }
274
275
276
SwitchToSmallFileWindow(void)277 void SwitchToSmallFileWindow(void)
278 {
279 werase( file_window );
280 PrintLine( stdscr, DIR_WINDOW_HEIGHT + 2, 0, "6-7", COLS - 25 );
281 file_window = small_file_window;
282 RefreshWindow( stdscr );
283 }
284
285
SwitchToBigFileWindow(void)286 void SwitchToBigFileWindow(void)
287 {
288 werase( file_window );
289 RefreshWindow( file_window );
290 #ifdef COLOR_SUPPORT
291 mvaddch(DIR_WINDOW_Y + DIR_WINDOW_HEIGHT, DIR_WINDOW_X - 1,
292 ACS_VLINE | COLOR_PAIR(MENU_COLOR)| A_BOLD);
293 mvaddch(DIR_WINDOW_Y + DIR_WINDOW_HEIGHT, DIR_WINDOW_X + DIR_WINDOW_WIDTH,
294 ACS_VLINE | COLOR_PAIR(MENU_COLOR)| A_BOLD);
295
296 #else
297 mvwaddch( stdscr, DIR_WINDOW_Y + DIR_WINDOW_HEIGHT,
298 DIR_WINDOW_X - 1,
299 ACS_VLINE
300 );
301 mvwaddch( stdscr, DIR_WINDOW_Y + DIR_WINDOW_HEIGHT,
302 DIR_WINDOW_X + DIR_WINDOW_WIDTH,
303 ACS_VLINE
304 );
305 #endif /* COLOR_SUPPORT */
306 file_window = big_file_window;
307 RefreshWindow( stdscr );
308 }
309
310
MapF2Window(void)311 void MapF2Window(void)
312 {
313 char *buffer;
314
315 if( ( buffer = (char *)malloc( F2_WINDOW_WIDTH + 1 ) ) == NULL )
316 {
317 ERROR_MSG( "Malloc failed*ABORT" );
318 exit( 1 );
319 }
320 werase( f2_window );
321 memset(buffer, '=', F2_WINDOW_WIDTH);
322 buffer[F2_WINDOW_WIDTH] = '\0';
323
324 PrintSpecialString( f2_window, F2_WINDOW_HEIGHT - 1, 0, buffer, HST_COLOR );
325 RefreshWindow( f2_window );
326 free(buffer);
327 }
328
329
UnmapF2Window(void)330 void UnmapF2Window(void)
331 {
332 werase( f2_window );
333 if(file_window == big_file_window)
334 {
335 #ifdef COLOR_SUPPORT
336 mvaddch(DIR_WINDOW_Y + DIR_WINDOW_HEIGHT, DIR_WINDOW_X - 1,
337 ACS_VLINE | COLOR_PAIR(MENU_COLOR)| A_BOLD);
338 mvaddch(DIR_WINDOW_Y + DIR_WINDOW_HEIGHT, DIR_WINDOW_X + DIR_WINDOW_WIDTH,
339 ACS_VLINE | COLOR_PAIR(MENU_COLOR)| A_BOLD);
340
341 #else
342 mvwaddch( stdscr, DIR_WINDOW_Y + DIR_WINDOW_HEIGHT,
343 DIR_WINDOW_X - 1,
344 ACS_VLINE
345 );
346
347 mvwaddch( stdscr, DIR_WINDOW_Y + DIR_WINDOW_HEIGHT,
348 DIR_WINDOW_X + DIR_WINDOW_WIDTH,
349 ACS_VLINE
350 );
351 #endif /* COLOR_SUPPORT */
352 }
353 touchwin(stdscr);
354 }
355
356
357
PrintMenuLine(WINDOW * win,int y,int x,char * line)358 static void PrintMenuLine(WINDOW *win, int y, int x, char *line)
359 {
360 int i;
361 int p, l;
362 char *buffer;
363 if (strchr(line,'('))
364 p = 2;
365 else
366 p = 0;
367 l = COLS + 2 + p;
368 if( ( buffer = (char *)malloc( l ) ) == NULL )
369 {
370 ERROR_MSG( "Malloc failed*ABORT" );
371 exit( 1 );
372 }
373 buffer[0] = line[0];
374 if (p == 0)
375 p = COLS - 25;
376 else
377 p = COLS - 27;
378 for(i=1; i < p; i++)
379 buffer[i] = line[1];
380 (void) strncpy( &buffer[i], &line[2], l - i );
381 buffer[l-1] = '\0';
382 PrintOptions( stdscr, y, x , buffer );
383 free( buffer );
384 }
385
386
387
PrintLine(WINDOW * win,int y,int x,char * line,int len)388 static void PrintLine(WINDOW *win, int y, int x, char *line, int len)
389 {
390 int i;
391 char *buffer;
392
393 if(len > 0) {
394 if( ( buffer = (char *)malloc( len + 2 ) ) == NULL )
395 {
396 ERROR_MSG( "Malloc failed*ABORT" );
397 exit( 1 );
398 }
399 buffer[0] = line[0];
400 for(i=1; i < (len); i++)
401 buffer[i] = line[1];
402 (void) strcpy( &buffer[i], &line[2] );
403 PrintOptions( stdscr, y, x , buffer );
404 free( buffer );
405 }
406 }
407
RefreshWindow(WINDOW * win)408 void RefreshWindow(WINDOW *win)
409 {
410 wnoutrefresh(win);
411 }
412
413