1 /***************************************************************************
2 *
3 * $Header: /usr/local/cvsroot/utils/ytree/dirwin.c,v 1.27 2016/09/04 14:41:12 werner Exp $
4 *
5 * Funktionen zur Handhabung des DIR-Windows
6 *
7 ***************************************************************************/
8
9
10 #include "ytree.h"
11
12
13 static DirEntryList *dir_entry_list;
14 static int current_dir_entry;
15 static int total_dirs;
16 static int window_height, window_width;
17
18 static void ReadDirList(DirEntry *dir_entry);
19 static void PrintDirEntry(WINDOW *win, int entry_no, int y, unsigned char hilight);
20 static void BuildDirEntryList(DirEntry *dir_entry);
21
22 static int dir_mode;
23
24
BuildDirEntryList(DirEntry * dir_entry)25 static void BuildDirEntryList(DirEntry *dir_entry)
26 {
27 if( dir_entry_list )
28 {
29 free( dir_entry_list );
30 dir_entry_list = NULL;
31 }
32
33 /* fuer !ANSI-Systeme.. */
34 /*----------------------*/
35
36 if( statistic.disk_total_directories == 0 )
37 {
38 dir_entry_list = NULL;
39 }
40 else
41 {
42 if( ( dir_entry_list = ( DirEntryList *)
43 calloc( statistic.disk_total_directories,
44 sizeof( DirEntryList )
45 ) ) == NULL )
46 {
47 ERROR_MSG( "Calloc Failed*ABORT" );
48 exit( 1 );
49 }
50 }
51
52 current_dir_entry = 0;
53
54 ReadDirList( dir_entry );
55
56 total_dirs = current_dir_entry;
57
58 }
59
RotateDirMode(void)60 static void RotateDirMode(void)
61 {
62 switch( dir_mode )
63 {
64 case MODE_1: dir_mode = MODE_2 ; break;
65 case MODE_2: dir_mode = MODE_4 ; break;
66 case MODE_3: dir_mode = MODE_1 ; break;
67 case MODE_4: dir_mode = MODE_3 ; break;
68 }
69 if( (mode != DISK_MODE && mode != USER_MODE ) &&
70 dir_mode == MODE_4 ) RotateDirMode();
71 }
72
73
74
ReadDirList(DirEntry * dir_entry)75 static void ReadDirList(DirEntry *dir_entry)
76 {
77 DirEntry *de_ptr;
78 static int level = 0;
79 static unsigned long indent = 0L;
80
81 for( de_ptr = dir_entry; de_ptr; de_ptr = de_ptr->next )
82 {
83 indent &= ~( 1L << level );
84 if( de_ptr->next ) indent |= ( 1L << level );
85
86 dir_entry_list[current_dir_entry].dir_entry = de_ptr;
87 dir_entry_list[current_dir_entry].level = (unsigned short) level;
88 dir_entry_list[current_dir_entry].indent = indent;
89
90 current_dir_entry++;
91
92 if( !de_ptr->not_scanned && de_ptr->sub_tree )
93 {
94 level++;
95 ReadDirList( de_ptr->sub_tree );
96 level--;
97 }
98 }
99 }
100
101
102
103
104
PrintDirEntry(WINDOW * win,int entry_no,int y,unsigned char hilight)105 static void PrintDirEntry(WINDOW *win,
106 int entry_no,
107 int y,
108 unsigned char hilight)
109 {
110 unsigned int j, l1, l2;
111 int n;
112 int aux=0;
113 int color, hi_color;
114 char buffer[32*3+PATH_LENGTH+1];
115 char format[60];
116 char *line_buffer = NULL;
117 char *dir_name;
118 char attributes[11];
119 char modify_time[13];
120 char change_time[13];
121 char access_time[13];
122 char owner[OWNER_NAME_MAX + 1];
123 char group[GROUP_NAME_MAX + 1];
124 char *owner_name_ptr;
125 char *group_name_ptr;
126 DirEntry *de_ptr;
127 BOOL suppress_output = FALSE;
128
129
130 if(win == f2_window) {
131 color = HST_COLOR;
132 hi_color = HIHST_COLOR;
133 } else {
134 color = DIR_COLOR;
135 hi_color = HIDIR_COLOR;
136 }
137 buffer[0] = '\0';
138
139 for(j=0; j < dir_entry_list[entry_no].level; j++)
140 {
141 if( dir_entry_list[entry_no].indent & ( 1L << j ) )
142 (void) strcat( buffer, "| " );
143 else
144 (void) strcat( buffer, " " );
145 }
146 de_ptr = dir_entry_list[entry_no].dir_entry;
147 if( de_ptr->next )
148 (void) strcat( buffer, "6-" );
149 else
150 (void) strcat( buffer, "3-" );
151
152 switch( dir_mode )
153 {
154 case MODE_1 :
155 (void)GetAttributes(de_ptr->stat_struct.st_mode, attributes);
156 (void)CTime( de_ptr->stat_struct.st_mtime, modify_time );
157 if ((line_buffer = (char *) malloc(38)) == NULL)
158 {
159 ERROR_MSG("malloc() Failed*Abort");
160 exit(1);
161 }
162 #ifdef HAS_LONGLONG
163 (void) strcpy( format, "%10s %3d %8lld %12s");
164
165 (void) sprintf( line_buffer, format, attributes,
166 de_ptr->stat_struct.st_nlink,
167 (LONGLONG) de_ptr->stat_struct.st_size,
168 modify_time
169 );
170 #else
171 (void) strcpy( format, "%10s %3d %8d %12s");
172 (void) sprintf( line_buffer, format, attributes,
173 de_ptr->stat_struct.st_nlink,
174 de_ptr->stat_struct.st_size,
175 modify_time
176 );
177 #endif
178 break;
179 case MODE_2 :
180 (void)GetAttributes(de_ptr->stat_struct.st_mode, attributes);
181 owner_name_ptr = GetDisplayPasswdName(de_ptr->stat_struct.st_uid);
182 group_name_ptr = GetDisplayGroupName(de_ptr->stat_struct.st_gid);
183 if( owner_name_ptr == NULL )
184 {
185 (void)sprintf(owner,"%d",(int)de_ptr->stat_struct.st_uid);
186 owner_name_ptr = owner;
187 }
188 if( group_name_ptr == NULL )
189 {
190 (void) sprintf( group, "%d", (int) de_ptr->stat_struct.st_gid );
191 group_name_ptr = group;
192 }
193 if ((line_buffer = (char *) malloc(40)) == NULL)
194 {
195 ERROR_MSG("malloc() Failed*Abort");
196 exit(1);
197 }
198 (void) strcpy( format, "%12u %-12s %-12s");
199 (void) sprintf( line_buffer, format,
200 /*attributes, */
201 de_ptr->stat_struct.st_ino,
202 owner_name_ptr,
203 group_name_ptr);
204 break;
205 case MODE_3 : break;
206 case MODE_4 :
207 (void) CTime( de_ptr->stat_struct.st_ctime, change_time );
208 (void) CTime( de_ptr->stat_struct.st_atime, access_time );
209 (void) strcpy( format, "Chg.: %12s Acc.: %12s");
210 if ((line_buffer = (char *) malloc(40)) == NULL)
211 {
212 ERROR_MSG("malloc() Failed*Abort");
213 exit(1);
214 }
215 (void)sprintf(line_buffer, format, change_time, access_time);
216 break;
217 }
218
219 if(window_width == 1)
220 suppress_output = TRUE;
221
222 aux = 0;
223 /* Output optional Attributes */
224 if (!suppress_output) {
225 WbkgdSet(win, COLOR_PAIR(color)| A_BOLD );
226 if(line_buffer) {
227 aux = strlen(line_buffer);
228 if(window_width <= aux) {
229 line_buffer[window_width - 1] = '\0';
230 suppress_output = TRUE;
231 }
232 mvwaddstr(win, y, 0, line_buffer );
233 }
234 }
235
236 if(!suppress_output) {
237 /* Output Graph */
238 l1 = strlen(buffer);
239 n = window_width - aux;
240 if((int)l1 > n) {
241 buffer[MAXIMUM(n-1, 0)] = '\0';
242 suppress_output = TRUE;
243 }
244 PrintSpecialString( win, y, aux, buffer, color );
245 }
246
247 if(!suppress_output) {
248
249 /* Output Dirname */
250
251 dir_name = de_ptr->name;
252 (void) strcpy( buffer, ( *dir_name ) ? dir_name : "." );
253 if( de_ptr->not_scanned ) {
254 (void) strcat( buffer, "/" );
255 }
256
257 #ifdef NO_HIGHLIGHT
258 (void) strcat( buffer, (hilight) ? " <" : " " );
259 #else /* NO_HIGHLIGHT */
260 #ifdef COLOR_SUPPORT
261 if( hilight )
262 WbkgdSet(win, COLOR_PAIR(hi_color)|A_BOLD);
263 else
264 WbkgdSet(win, COLOR_PAIR(color));
265
266 n = window_width - aux - l1;
267 l2 = strlen(buffer);
268 if((int)l2 > n)
269 buffer[MAXIMUM(n-1, 0)] = '\0';
270
271 /* waddstr( win, buffer );*/
272 mvwaddstr( win, y, aux + l1, buffer);
273 WbkgdSet(win, COLOR_PAIR(color)|A_BOLD);
274
275 #else
276 if( hilight ) wattrset( win, A_REVERSE );
277 /* waddstr( win, buffer );*/
278 mvwaddstr( win, y, aux + l1, buffer);
279
280 if( hilight ) wattrset( win, 0 );
281 #endif /* COLOR_SUPPORT */
282 #endif /* NO_HIGHLIGHT */
283 }
284
285 if (line_buffer)
286 free(line_buffer);
287 }
288
289
290
291
DisplayTree(WINDOW * win,int start_entry_no,int hilight_no)292 void DisplayTree(WINDOW *win, int start_entry_no, int hilight_no)
293 {
294 int i, y;
295 int width, height;
296
297 y = -1;
298 GetMaxYX(win, &height, &width);
299 if(win == dir_window) {
300 window_width = width;
301 window_height = height;
302 }
303 for(i=0; i < height; i++)
304 {
305 wmove(win, i, 0);
306 wclrtoeol(win);
307 }
308
309 for(i=0; i < height; i++)
310 {
311 if( start_entry_no + i >= (int)statistic.disk_total_directories ) break;
312
313 if( start_entry_no + i != hilight_no )
314 PrintDirEntry( win, start_entry_no + i, i, FALSE );
315 else
316 y = i;
317 }
318
319 if( y >= 0 ) PrintDirEntry( win, start_entry_no + y, y, TRUE );
320
321 }
322
Movedown(int * disp_begin_pos,int * cursor_pos,DirEntry ** dir_entry)323 static void Movedown(int *disp_begin_pos, int *cursor_pos, DirEntry **dir_entry)
324 {
325 if( *disp_begin_pos + *cursor_pos + 1 >= total_dirs )
326 {
327 /* Element nicht vorhanden */
328 /*-------------------------*/
329 beep();
330 }
331 else
332 {
333 /* Element vorhanden */
334 /*-------------------*/
335 if( *cursor_pos + 1 < window_height )
336 {
337 /* Element ist ohne scrollen erreichbar */
338 /*--------------------------------------*/
339 PrintDirEntry( dir_window,
340 *disp_begin_pos + *cursor_pos,
341 *cursor_pos,
342 FALSE
343 );
344 (*cursor_pos)++;
345 PrintDirEntry( dir_window,
346 *disp_begin_pos + *cursor_pos,
347 *cursor_pos,
348 TRUE
349 );
350 }
351 else
352 {
353 /* Es muss gescrollt werden */
354 /*--------------------------*/
355 PrintDirEntry( dir_window,
356 *disp_begin_pos + *cursor_pos,
357 *cursor_pos,
358 FALSE
359 );
360 scroll( dir_window );
361 (*disp_begin_pos)++;
362 PrintDirEntry( dir_window,
363 *disp_begin_pos + *cursor_pos,
364 *cursor_pos,
365 TRUE
366 );
367 }
368 *dir_entry = dir_entry_list[*disp_begin_pos + *cursor_pos].dir_entry;
369 (*dir_entry)->start_file = 0;
370 (*dir_entry)->cursor_pos = -1;
371 DisplayFileWindow( *dir_entry );
372 RefreshWindow( file_window );
373 }
374 return;
375 }
376
377
Moveup(int * disp_begin_pos,int * cursor_pos,DirEntry ** dir_entry)378 static void Moveup(int *disp_begin_pos, int *cursor_pos, DirEntry **dir_entry)
379 {
380 if( *disp_begin_pos + *cursor_pos - 1 < 0 )
381 {
382 /* Element nicht vorhanden */
383 /*-------------------------*/
384 beep();
385 }
386 else
387 {
388 /* Element vorhanden */
389 /*-------------------*/
390 if( *cursor_pos - 1 >= 0 )
391 {
392 /* Element ist ohne scrollen erreichbar */
393 /*--------------------------------------*/
394 PrintDirEntry( dir_window,
395 *disp_begin_pos + *cursor_pos,
396 *cursor_pos,
397 FALSE
398 );
399 (*cursor_pos)--;
400 PrintDirEntry( dir_window,
401 *disp_begin_pos + *cursor_pos,
402 *cursor_pos,
403 TRUE
404 );
405 }
406 else
407 {
408 /* Es muss gescrollt werden */
409 /*--------------------------*/
410 PrintDirEntry( dir_window,
411 *disp_begin_pos + *cursor_pos,
412 *cursor_pos,
413 FALSE
414 );
415 wmove( dir_window, 0, 0 );
416 winsertln( dir_window );
417 (*disp_begin_pos)--;
418 PrintDirEntry( dir_window,
419 *disp_begin_pos + *cursor_pos,
420 *cursor_pos,
421 TRUE
422 );
423 }
424 *dir_entry = dir_entry_list[*disp_begin_pos + *cursor_pos].dir_entry;
425 (*dir_entry)->start_file = 0;
426 (*dir_entry)->cursor_pos = -1;
427 DisplayFileWindow( *dir_entry );
428 RefreshWindow( file_window );
429 }
430 return;
431 }
432
433
Movenpage(int * disp_begin_pos,int * cursor_pos,DirEntry ** dir_entry)434 static void Movenpage(int *disp_begin_pos, int *cursor_pos, DirEntry **dir_entry)
435 {
436 if( *disp_begin_pos + *cursor_pos >= total_dirs - 1 )
437 {
438 /* Letzte Position */
439 /*-----------------*/
440 beep();
441 }
442 else
443 {
444 if( *cursor_pos < window_height - 1 )
445 {
446 /* Cursor steht nicht auf letztem Eintrag
447 * der Seite
448 */
449 PrintDirEntry( dir_window,
450 *disp_begin_pos + *cursor_pos,
451 *cursor_pos,
452 FALSE
453 );
454 if( *disp_begin_pos + window_height > total_dirs - 1 )
455 *cursor_pos = total_dirs - *disp_begin_pos - 1;
456 else
457 *cursor_pos = window_height - 1;
458 *dir_entry = dir_entry_list[*disp_begin_pos + *cursor_pos].dir_entry;
459 (*dir_entry)->start_file = 0;
460 (*dir_entry)->cursor_pos = -1;
461 DisplayFileWindow( *dir_entry );
462 RefreshWindow( file_window );
463 PrintDirEntry( dir_window,
464 *disp_begin_pos + *cursor_pos,
465 *cursor_pos,
466 TRUE
467 );
468 }
469 else
470 {
471 /* Scrollen */
472 /*----------*/
473 if( *disp_begin_pos + *cursor_pos + window_height < total_dirs )
474 {
475 *disp_begin_pos += window_height;
476 *cursor_pos = window_height - 1;
477 }
478 else
479 {
480 *disp_begin_pos = total_dirs - window_height;
481 if( *disp_begin_pos < 0 ) *disp_begin_pos = 0;
482 *cursor_pos = total_dirs - *disp_begin_pos - 1;
483 }
484 *dir_entry = dir_entry_list[*disp_begin_pos + *cursor_pos].dir_entry;
485 (*dir_entry)->start_file = 0;
486 (*dir_entry)->cursor_pos = -1;
487 DisplayFileWindow( *dir_entry );
488 RefreshWindow( file_window );
489 DisplayTree(dir_window,*disp_begin_pos,*disp_begin_pos+*cursor_pos);
490 }
491 }
492 return;
493 }
494
Moveppage(int * disp_begin_pos,int * cursor_pos,DirEntry ** dir_entry)495 static void Moveppage(int *disp_begin_pos, int *cursor_pos, DirEntry **dir_entry)
496 {
497 if( *disp_begin_pos + *cursor_pos <= 0 )
498 {
499 /* Erste Position */
500 /*----------------*/
501 beep();
502 }
503 else
504 {
505 if( *cursor_pos > 0 )
506 {
507 /* Cursor steht nicht auf erstem Eintrag
508 * der Seite
509 */
510 PrintDirEntry( dir_window,
511 *disp_begin_pos + *cursor_pos,
512 *cursor_pos,
513 FALSE
514 );
515 *cursor_pos = 0;
516 *dir_entry = dir_entry_list[*disp_begin_pos + *cursor_pos].dir_entry;
517 (*dir_entry)->start_file = 0;
518 (*dir_entry)->cursor_pos = -1;
519 DisplayFileWindow( *dir_entry );
520 RefreshWindow( file_window );
521 PrintDirEntry( dir_window,
522 *disp_begin_pos + *cursor_pos,
523 *cursor_pos,
524 TRUE
525 );
526 }
527 else
528 {
529 /* Scrollen */
530 /*----------*/
531 if( (*disp_begin_pos -= window_height) < 0 )
532 {
533 *disp_begin_pos = 0;
534 }
535 *cursor_pos = 0;
536 *dir_entry = dir_entry_list[*disp_begin_pos + *cursor_pos].dir_entry;
537 (*dir_entry)->start_file = 0;
538 (*dir_entry)->cursor_pos = -1;
539 DisplayFileWindow( *dir_entry );
540 RefreshWindow( file_window );
541 DisplayTree(dir_window,*disp_begin_pos,*disp_begin_pos+*cursor_pos);
542 }
543 }
544 return;
545 }
546
MoveEnd(DirEntry ** dir_entry)547 void MoveEnd(DirEntry **dir_entry)
548 {
549 statistic.disp_begin_pos = MAXIMUM(0, total_dirs - window_height);
550 statistic.cursor_pos = total_dirs - statistic.disp_begin_pos - 1;
551 *dir_entry = dir_entry_list[statistic.disp_begin_pos + statistic.cursor_pos].dir_entry;
552 (*dir_entry)->start_file = 0;
553 (*dir_entry)->cursor_pos = -1;
554 DisplayFileWindow( *dir_entry );
555 RefreshWindow( file_window );
556 DisplayTree( dir_window, statistic.disp_begin_pos,
557 statistic.disp_begin_pos + statistic.cursor_pos);
558 return;
559 }
560
MoveHome(DirEntry ** dir_entry)561 void MoveHome(DirEntry **dir_entry)
562 {
563 if( statistic.disp_begin_pos == 0 && statistic.cursor_pos == 0 )
564 { /* Position 1 bereits errecht */
565 /*----------------------------*/
566 beep();
567 }
568 else
569 {
570 statistic.disp_begin_pos = 0;
571 statistic.cursor_pos = 0;
572 *dir_entry = dir_entry_list[statistic.disp_begin_pos + statistic.cursor_pos].dir_entry;
573 (*dir_entry)->start_file = 0;
574 (*dir_entry)->cursor_pos = -1;
575 DisplayFileWindow( *dir_entry );
576 RefreshWindow( file_window );
577 DisplayTree( dir_window, statistic.disp_begin_pos,
578 statistic.disp_begin_pos + statistic.cursor_pos);
579 }
580 return;
581 }
582
HandlePlus(DirEntry * dir_entry,DirEntry * de_ptr,char * new_login_path,DirEntry * start_dir_entry,BOOL * need_dsp_help)583 void HandlePlus(DirEntry *dir_entry, DirEntry *de_ptr, char *new_login_path,
584 DirEntry *start_dir_entry, BOOL *need_dsp_help)
585 {
586 if( !dir_entry->not_scanned ) {
587 beep();
588 } else {
589 for( de_ptr=dir_entry->sub_tree; de_ptr; de_ptr=de_ptr->next) {
590 GetPath( de_ptr, new_login_path );
591 ReadTree( de_ptr, new_login_path, 0 );
592 SetMatchingParam( de_ptr );
593 }
594 dir_entry->not_scanned = FALSE;
595 BuildDirEntryList( start_dir_entry );
596 DisplayTree( dir_window, statistic.disp_begin_pos,
597 statistic.disp_begin_pos + statistic.cursor_pos );
598 DisplayDiskStatistic();
599 DisplayAvailBytes();
600 *need_dsp_help = TRUE;
601 }
602 }
603
HandleReadSubTree(DirEntry * dir_entry,DirEntry * start_dir_entry,BOOL * need_dsp_help)604 void HandleReadSubTree(DirEntry *dir_entry, DirEntry *start_dir_entry,
605 BOOL *need_dsp_help)
606 {
607 ScanSubTree( dir_entry );
608 BuildDirEntryList( start_dir_entry );
609 DisplayTree( dir_window, statistic.disp_begin_pos,
610 statistic.disp_begin_pos + statistic.cursor_pos );
611 DisplayDiskStatistic();
612 DisplayAvailBytes();
613 *need_dsp_help = TRUE;
614 }
615
HandleUnreadSubTree(DirEntry * dir_entry,DirEntry * de_ptr,DirEntry * start_dir_entry,BOOL * need_dsp_help)616 void HandleUnreadSubTree(DirEntry *dir_entry, DirEntry *de_ptr,
617 DirEntry *start_dir_entry, BOOL *need_dsp_help)
618 {
619 if( dir_entry->not_scanned || (dir_entry->sub_tree == NULL) ) {
620 beep();
621 } else {
622 for( de_ptr=dir_entry->sub_tree; de_ptr; de_ptr=de_ptr->next) {
623 UnReadTree( de_ptr );
624 }
625 dir_entry->not_scanned = TRUE;
626 BuildDirEntryList( start_dir_entry );
627 DisplayTree( dir_window, statistic.disp_begin_pos,
628 statistic.disp_begin_pos + statistic.cursor_pos );
629 DisplayAvailBytes();
630 *need_dsp_help = TRUE;
631 }
632 return;
633 }
634
HandleTagDir(DirEntry * dir_entry,BOOL value)635 void HandleTagDir(DirEntry *dir_entry, BOOL value)
636 {
637 FileEntry *fe_ptr;
638 for(fe_ptr=dir_entry->file; fe_ptr; fe_ptr=fe_ptr->next)
639 {
640 if( (fe_ptr->matching) && (fe_ptr->tagged != value ))
641 {
642 fe_ptr->tagged = value;
643 if (value)
644 {
645 dir_entry->tagged_files++;
646 dir_entry->tagged_bytes += fe_ptr->stat_struct.st_size;
647 statistic.disk_tagged_files++;
648 statistic.disk_tagged_bytes += fe_ptr->stat_struct.st_size;
649 }else{
650 dir_entry->tagged_files--;
651 dir_entry->tagged_bytes -= fe_ptr->stat_struct.st_size;
652 statistic.disk_tagged_files--;
653 statistic.disk_tagged_bytes -= fe_ptr->stat_struct.st_size;
654 }
655 }
656 }
657 dir_entry->start_file = 0;
658 dir_entry->cursor_pos = -1;
659 DisplayFileWindow( dir_entry );
660 RefreshWindow( file_window );
661 DisplayDiskStatistic();
662 return;
663 }
664
HandleTagAllDirs(DirEntry * dir_entry,BOOL value)665 void HandleTagAllDirs(DirEntry *dir_entry, BOOL value )
666 {
667 FileEntry *fe_ptr;
668 long i;
669 for(i=0; i < total_dirs; i++)
670 {
671 for(fe_ptr=dir_entry_list[i].dir_entry->file; fe_ptr; fe_ptr=fe_ptr->next)
672 {
673 if( (fe_ptr->matching) && (fe_ptr->tagged != value) )
674 {
675 if (value)
676 {
677 fe_ptr->tagged = value;
678 dir_entry->tagged_files++;
679 dir_entry->tagged_bytes += fe_ptr->stat_struct.st_size;
680 statistic.disk_tagged_files++;
681 statistic.disk_tagged_bytes += fe_ptr->stat_struct.st_size;
682 }else{
683 fe_ptr->tagged = value;
684 dir_entry->tagged_files--;
685 dir_entry->tagged_bytes -= fe_ptr->stat_struct.st_size;
686 statistic.disk_tagged_files--;
687 statistic.disk_tagged_bytes -= fe_ptr->stat_struct.st_size;
688 }
689 }
690 }
691 }
692 dir_entry->start_file = 0;
693 dir_entry->cursor_pos = -1;
694 DisplayFileWindow( dir_entry );
695 RefreshWindow( file_window );
696 DisplayDiskStatistic();
697 return;
698 }
699
HandleShowAllTagged(DirEntry * dir_entry,DirEntry * start_dir_entry,BOOL * need_dsp_help,int * ch)700 void HandleShowAllTagged(DirEntry *dir_entry,DirEntry *start_dir_entry, BOOL *need_dsp_help, int *ch)
701 {
702 if( statistic.disk_tagged_files )
703 {
704 if(dir_entry->login_flag)
705 {
706 dir_entry->login_flag = FALSE;
707 } else {
708 dir_entry->big_window = TRUE;
709 dir_entry->global_flag = TRUE;
710 dir_entry->tagged_flag = TRUE;
711 dir_entry->start_file = 0;
712 dir_entry->cursor_pos = 0;
713 }
714 if( HandleFileWindow(dir_entry) != LOGIN_ESC )
715 {
716 DisplayDiskStatistic();
717 dir_entry->start_file = 0;
718 dir_entry->cursor_pos = -1;
719 DisplayFileWindow( dir_entry );
720 RefreshWindow( small_file_window );
721 RefreshWindow( big_file_window );
722 BuildDirEntryList( start_dir_entry );
723 DisplayTree( dir_window, statistic.disp_begin_pos,
724 statistic.disp_begin_pos + statistic.cursor_pos);
725 }else{
726 BuildDirEntryList( statistic.tree );
727 DisplayTree( dir_window, statistic.disp_begin_pos,
728 statistic.disp_begin_pos + statistic.cursor_pos);
729 *ch = 'L';
730 }
731 }else{
732 dir_entry->login_flag = FALSE;
733 beep();
734 }
735 *need_dsp_help = TRUE;
736 return;
737 }
738
HandleShowAll(DirEntry * dir_entry,DirEntry * start_dir_entry,BOOL * need_dsp_help,int * ch)739 void HandleShowAll(DirEntry *dir_entry, DirEntry *start_dir_entry, BOOL *need_dsp_help, int *ch)
740 {
741 if( statistic.disk_matching_files )
742 {
743 if(dir_entry->login_flag)
744 {
745 dir_entry->login_flag = FALSE;
746 } else {
747 dir_entry->big_window = TRUE;
748 dir_entry->global_flag = TRUE;
749 dir_entry->tagged_flag = FALSE;
750 dir_entry->start_file = 0;
751 dir_entry->cursor_pos = 0;
752 }
753 if( HandleFileWindow(dir_entry) != LOGIN_ESC )
754 {
755 DisplayDiskStatistic();
756 dir_entry->start_file = 0;
757 dir_entry->cursor_pos = -1;
758 DisplayFileWindow( dir_entry );
759 RefreshWindow( small_file_window );
760 RefreshWindow( big_file_window );
761 BuildDirEntryList( start_dir_entry );
762 DisplayTree( dir_window, statistic.disp_begin_pos,
763 statistic.disp_begin_pos + statistic.cursor_pos);
764 } else {
765 BuildDirEntryList( statistic.tree );
766 DisplayTree( dir_window, statistic.disp_begin_pos,
767 statistic.disp_begin_pos + statistic.cursor_pos );
768 *ch = 'L';
769 }
770 } else {
771 dir_entry->login_flag = FALSE;
772 beep();
773 }
774 *need_dsp_help = TRUE;
775 return;
776 }
777
HandleSwitchWindow(DirEntry * dir_entry,DirEntry * start_dir_entry,BOOL * need_dsp_help,int * ch)778 void HandleSwitchWindow(DirEntry *dir_entry, DirEntry *start_dir_entry, BOOL *need_dsp_help, int *ch)
779 {
780 if( dir_entry->matching_files )
781 {
782 if(dir_entry->login_flag)
783 {
784 dir_entry->login_flag = FALSE;
785 } else {
786 dir_entry->global_flag = FALSE;
787 dir_entry->tagged_flag = FALSE;
788 dir_entry->big_window = bypass_small_window;
789 dir_entry->start_file = 0;
790 dir_entry->cursor_pos = 0;
791 }
792 if( HandleFileWindow( dir_entry ) != LOGIN_ESC )
793 {
794 dir_entry->start_file = 0;
795 dir_entry->cursor_pos = -1;
796 DisplayFileWindow( dir_entry );
797 RefreshWindow( small_file_window );
798 RefreshWindow( big_file_window );
799 BuildDirEntryList( start_dir_entry );
800 DisplayTree( dir_window, statistic.disp_begin_pos,
801 statistic.disp_begin_pos + statistic.cursor_pos);
802 DisplayDiskStatistic();
803 } else {
804 BuildDirEntryList( statistic.tree );
805 DisplayTree( dir_window, statistic.disp_begin_pos,
806 statistic.disp_begin_pos + statistic.cursor_pos);
807 *ch = 'L';
808 }
809 DisplayAvailBytes();
810 *need_dsp_help = TRUE;
811 } else {
812 dir_entry->login_flag = FALSE;
813 beep();
814 }
815 return;
816 }
817
818
HandleDirWindow(DirEntry * start_dir_entry)819 int HandleDirWindow(DirEntry *start_dir_entry)
820 {
821 DirEntry *dir_entry, *de_ptr;
822 int i, ch, unput_char;
823 BOOL need_dsp_help;
824 char new_name[PATH_LENGTH + 1];
825 char new_login_path[PATH_LENGTH + 1];
826 char *home, *p;
827
828 unput_char = 0;
829 de_ptr = NULL;
830
831 GetMaxYX(dir_window, &window_height, &window_width);
832
833 /* Merker loeschen */
834 /*-----------------*/
835
836 dir_mode = MODE_3;
837
838 need_dsp_help = TRUE;
839
840 BuildDirEntryList( start_dir_entry );
841 if ( initial_directory != NULL )
842 {
843 if ( !strcmp( initial_directory, "." ) ) /* Entry just a single "." */
844 {
845 statistic.disp_begin_pos = 0;
846 statistic.cursor_pos = 0;
847 unput_char = CR;
848 }
849 else
850 {
851 if ( *initial_directory == '.' ) { /* Entry of form "./alpha/beta" */
852 strcpy( new_login_path, start_dir_entry->name );
853 strcat( new_login_path, initial_directory+1 );
854 }
855 else if ( *initial_directory == '~' && ( home = getenv("HOME") ) ) {
856 /* Entry of form "~/alpha/beta" */
857 strcpy( new_login_path, home );
858 strcat( new_login_path, initial_directory+1 );
859 }
860 else { /* Entry of form "beta" or "/full/path/alpha/beta" */
861 strcpy(new_login_path, initial_directory);
862 }
863 for ( i = 0; i < (int)statistic.disk_total_directories; i++ )
864 {
865 if ( *new_login_path == FILE_SEPARATOR_CHAR )
866 GetPath( dir_entry_list[i].dir_entry, new_name );
867 else
868 strcpy( new_name, dir_entry_list[i].dir_entry->name );
869 if ( !strcmp( new_login_path, new_name ) )
870 {
871 statistic.disp_begin_pos = i;
872 statistic.cursor_pos = 0;
873 unput_char = CR;
874 break;
875 }
876 }
877 }
878 initial_directory = NULL;
879 }
880 dir_entry = dir_entry_list[statistic.disp_begin_pos + statistic.cursor_pos].dir_entry;
881
882 DisplayDiskStatistic();
883
884 if(!dir_entry->login_flag) {
885 dir_entry->start_file = 0;
886 dir_entry->cursor_pos = -1;
887 }
888 DisplayFileWindow( dir_entry );
889 RefreshWindow( file_window );
890 DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos );
891 touchwin(dir_window);
892
893 if( dir_entry->login_flag )
894 {
895 if( (dir_entry->global_flag ) || (dir_entry->tagged_flag) )
896 {
897 unput_char = 'S';
898 }
899 else
900 {
901 unput_char = CR;
902 }
903 }
904 do
905 {
906 if( need_dsp_help )
907 {
908 need_dsp_help = FALSE;
909 DisplayDirHelp();
910 }
911 DisplayDirParameter( dir_entry );
912 RefreshWindow( dir_window );
913 if( unput_char )
914 {
915 ch = unput_char;
916 unput_char = '\0';
917 }
918 else
919 {
920 doupdate();
921 ch = (resize_request) ? -1 : Getch();
922 if( ch == LF ) ch = CR;
923 }
924 #ifdef VI_KEYS
925 ch = ViKey( ch );
926 #endif /* VI_KEYS */
927
928
929 if(resize_request) {
930 ReCreateWindows();
931 DisplayMenu();
932 GetMaxYX(dir_window, &window_height, &window_width);
933 while(statistic.cursor_pos >= window_height) {
934 statistic.cursor_pos--;
935 statistic.disp_begin_pos++;
936 }
937 DisplayTree( dir_window, statistic.disp_begin_pos,
938 statistic.disp_begin_pos + statistic.cursor_pos
939 );
940 DisplayFileWindow(dir_entry);
941 DisplayDiskStatistic();
942 DisplayDirParameter( dir_entry );
943 need_dsp_help = TRUE;
944 DisplayAvailBytes();
945 DisplayFileSpec();
946 DisplayDiskName();
947 resize_request = FALSE;
948 }
949
950 if (mode == USER_MODE) { /* DirUserMode returns (possibly remapped) ch, or -1 if it handles ch */
951 ch = DirUserMode(dir_entry, ch);
952 }
953
954 switch( ch )
955 {
956
957 #ifdef KEY_RESIZE
958 case KEY_RESIZE: resize_request = TRUE;
959 break;
960 #endif
961
962 case -1: break;
963
964 case ' ': /*break; Quick-Key */
965 case KEY_DOWN: Movedown(&statistic.disp_begin_pos, &statistic.cursor_pos, &dir_entry);
966 break;
967 case KEY_UP : Moveup(&statistic.disp_begin_pos, &statistic.cursor_pos, &dir_entry);
968 break;
969 case KEY_NPAGE:Movenpage(&statistic.disp_begin_pos, &statistic.cursor_pos, &dir_entry);
970 break;
971 case KEY_PPAGE:Moveppage(&statistic.disp_begin_pos, &statistic.cursor_pos, &dir_entry);
972 break;
973 case KEY_HOME: MoveHome(&dir_entry);
974 break;
975 case KEY_END : MoveEnd(&dir_entry);
976 break;
977 case KEY_RIGHT:
978 case '+': HandlePlus(dir_entry, de_ptr, new_login_path,
979 start_dir_entry, &need_dsp_help);
980 break;
981 case '\t':
982 case '*': HandleReadSubTree(dir_entry, start_dir_entry,
983 &need_dsp_help);
984 break;
985 case KEY_LEFT:
986 case '-':
987 case KEY_BTAB: HandleUnreadSubTree(dir_entry, de_ptr, start_dir_entry,
988 &need_dsp_help);
989 break;
990 case 'F':
991 case 'f': if(ReadFileSpec() == 0) {
992 dir_entry->start_file = 0;
993 dir_entry->cursor_pos = -1;
994 DisplayFileWindow( dir_entry );
995 RefreshWindow( file_window );
996 DisplayDiskStatistic();
997 }
998 need_dsp_help = TRUE;
999 break;
1000 case 'T' :
1001 case 't' : HandleTagDir(dir_entry, TRUE);
1002 break;
1003
1004 case 'U' :
1005 case 'u' : HandleTagDir(dir_entry, FALSE);
1006 break;
1007 case 'T' & 0x1F :
1008 HandleTagAllDirs(dir_entry,TRUE);
1009 break;
1010 case 'U' & 0x1F :
1011 HandleTagAllDirs(dir_entry,FALSE);
1012 break;
1013 case 'F' & 0x1F :
1014 RotateDirMode();
1015 /*DisplayFileWindow( dir_entry, 0, -1 );*/
1016 DisplayTree( dir_window, statistic.disp_begin_pos,
1017 statistic.disp_begin_pos + statistic.cursor_pos
1018 );
1019 /*RefreshWindow( file_window );*/
1020 DisplayDiskStatistic();
1021 need_dsp_help = TRUE;
1022 break;
1023 case 'S' & 0x1F :
1024 HandleShowAllTagged(dir_entry, start_dir_entry, &need_dsp_help, &ch);
1025 break;
1026
1027 case 'S':
1028 case 's': HandleShowAll(dir_entry, start_dir_entry, &need_dsp_help, &ch);
1029 break;
1030 case LF :
1031 case CR : HandleSwitchWindow(dir_entry, start_dir_entry, &need_dsp_help, &ch);
1032 break;
1033 case 'X':
1034 case 'x': (void) Execute( dir_entry, NULL );
1035 need_dsp_help = TRUE;
1036 DisplayAvailBytes();
1037 break;
1038 case 'M':
1039 case 'm': if( !MakeDirectory( dir_entry ) )
1040 {
1041 BuildDirEntryList( start_dir_entry );
1042 DisplayTree( dir_window, statistic.disp_begin_pos,
1043 statistic.disp_begin_pos + statistic.cursor_pos
1044 );
1045 DisplayAvailBytes();
1046 }
1047 need_dsp_help = TRUE;
1048 break;
1049 case 'D':
1050 case 'd': if( !DeleteDirectory( dir_entry ) ) {
1051 if( statistic.disp_begin_pos + statistic.cursor_pos > 0 )
1052 {
1053 if( statistic.cursor_pos > 0 ) statistic.cursor_pos--;
1054 else statistic.disp_begin_pos--;
1055 }
1056 }
1057 /* Unabhaengig vom Erfolg aktualisieren */
1058 BuildDirEntryList( start_dir_entry );
1059 dir_entry = dir_entry_list[statistic.disp_begin_pos + statistic.cursor_pos].dir_entry;
1060 dir_entry->start_file = 0;
1061 dir_entry->cursor_pos = -1;
1062 DisplayFileWindow( dir_entry );
1063 RefreshWindow( file_window );
1064 DisplayTree( dir_window, statistic.disp_begin_pos,
1065 statistic.disp_begin_pos + statistic.cursor_pos
1066 );
1067 DisplayAvailBytes();
1068 need_dsp_help = TRUE;
1069 break;
1070 case 'r':
1071 case 'R': if( !GetRenameParameter( dir_entry->name, new_name ) )
1072 {
1073 if( !RenameDirectory( dir_entry, new_name ) )
1074 {
1075 /* Rename OK */
1076 /*-----------*/
1077 BuildDirEntryList( start_dir_entry );
1078 DisplayTree( dir_window, statistic.disp_begin_pos,
1079 statistic.disp_begin_pos + statistic.cursor_pos
1080 );
1081 DisplayAvailBytes();
1082 dir_entry = dir_entry_list[statistic.disp_begin_pos + statistic.cursor_pos].dir_entry;
1083 }
1084 }
1085 need_dsp_help = TRUE;
1086 break;
1087 case 'G':
1088 case 'g': (void) ChangeDirGroup( dir_entry );
1089 DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos );
1090 need_dsp_help = TRUE;
1091 break;
1092 case 'O':
1093 case 'o': (void) ChangeDirOwner( dir_entry );
1094 DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos );
1095 need_dsp_help = TRUE;
1096 break;
1097 case 'A':
1098 case 'a': (void) ChangeDirModus( dir_entry );
1099 DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos );
1100 need_dsp_help = TRUE;
1101 break;
1102
1103 case 'Q' & 0x1F:
1104 need_dsp_help = TRUE;
1105 QuitTo(dir_entry);
1106 break;
1107
1108 case 'Q':
1109 case 'q': need_dsp_help = TRUE;
1110 break;
1111
1112 #ifndef VI_KEYS
1113 case 'l':
1114 #endif /* VI_KEYS */
1115 case 'L': if( mode != DISK_MODE && mode != USER_MODE )
1116 (void) strcpy( new_login_path, disk_statistic.login_path );
1117 else
1118 (void) GetPath( dir_entry, new_login_path );
1119 if( !GetNewLoginPath( new_login_path ) )
1120 {
1121 DisplayMenu();
1122 doupdate();
1123 (void) LoginDisk( new_login_path );
1124 }
1125 need_dsp_help = TRUE;
1126 break;
1127 case 'L' & 0x1F:
1128 clearok( stdscr, TRUE );
1129 break;
1130
1131 case 'P': /* press 'p' or 'P' to log parent of current root */
1132 case 'p':
1133
1134 MoveHome(&dir_entry);
1135 (void) GetPath(dir_entry, new_login_path);
1136
1137 /* char *p; defined before this current switch */
1138 if((p = strrchr(new_login_path, FILE_SEPARATOR_CHAR)) == NULL)
1139 break;
1140
1141 /* p is now pointing to rightmost file separator */
1142 /* in new_login_path, just truncate this path */
1143
1144 *p='\0';
1145
1146 /* rightmost slash was first and only character? */
1147 if(!strlen(new_login_path))
1148 {
1149 new_login_path[0]=FILE_SEPARATOR_CHAR;
1150 new_login_path[1]='\0';
1151 }
1152
1153 /* following needed to ignore old tree in memory */
1154 *disk_statistic.login_path = '\0';
1155
1156 (void) LoginDisk(new_login_path);
1157 need_dsp_help = TRUE;
1158 return ch;
1159
1160 default : beep();
1161 break;
1162 } /* switch */
1163 } while( (ch != 'q') && (ch != 'Q') && (ch != 'l') && (ch != 'L') );
1164 return( ch );
1165 }
1166
1167
1168
ScanSubTree(DirEntry * dir_entry)1169 int ScanSubTree( DirEntry *dir_entry )
1170 {
1171 DirEntry *de_ptr;
1172 char new_login_path[PATH_LENGTH + 1];
1173
1174 if( dir_entry->not_scanned ) {
1175 for( de_ptr=dir_entry->sub_tree; de_ptr; de_ptr=de_ptr->next) {
1176 GetPath( de_ptr, new_login_path );
1177 ReadTree( de_ptr, new_login_path, 999 );
1178 SetMatchingParam( de_ptr );
1179 }
1180 dir_entry->not_scanned = FALSE;
1181 } else {
1182 for( de_ptr=dir_entry->sub_tree; de_ptr; de_ptr=de_ptr->next) {
1183 ScanSubTree( de_ptr );
1184 }
1185 }
1186 return( 0 );
1187 }
1188
1189
1190
1191
KeyF2Get(DirEntry * start_dir_entry,int disp_begin_pos,int cursor_pos,char * path)1192 int KeyF2Get(DirEntry *start_dir_entry,
1193 int disp_begin_pos,
1194 int cursor_pos,
1195 char *path)
1196 {
1197 int ch;
1198 int result = -1;
1199 int win_width, win_height;
1200
1201
1202 GetMaxYX(f2_window, &win_height, &win_width);
1203 MapF2Window();
1204 DisplayTree( f2_window, disp_begin_pos, disp_begin_pos + cursor_pos );
1205 do
1206 {
1207 RefreshWindow( f2_window );
1208 doupdate();
1209 ch = Getch();
1210 GetMaxYX(f2_window, &win_height, &win_width); /* Maybe changed... */
1211 if( ch == LF ) ch = CR;
1212
1213
1214 #ifdef VI_KEYS
1215
1216 ch = ViKey( ch );
1217
1218 #endif /* VI_KEYS */
1219
1220 switch( ch )
1221 {
1222 case -1: break;
1223 case ' ': break; /* Quick-Key */
1224 case KEY_DOWN: if( disp_begin_pos + cursor_pos + 1 >= total_dirs )
1225 {
1226 beep();
1227 }
1228 else
1229 {
1230 if( cursor_pos + 1 < win_height )
1231 {
1232 PrintDirEntry( f2_window,
1233 disp_begin_pos + cursor_pos,
1234 cursor_pos, FALSE);
1235 cursor_pos++;
1236
1237 PrintDirEntry( f2_window, disp_begin_pos + cursor_pos,
1238 cursor_pos, TRUE);
1239 }
1240 else
1241 {
1242 disp_begin_pos++;
1243 DisplayTree( f2_window, disp_begin_pos,
1244 disp_begin_pos + cursor_pos);
1245 }
1246 }
1247 break;
1248
1249 case KEY_UP : if( disp_begin_pos + cursor_pos - 1 < 0 )
1250 {
1251 beep();
1252 }
1253 else
1254 {
1255 if( cursor_pos - 1 >= 0 )
1256 {
1257 PrintDirEntry( f2_window,
1258 disp_begin_pos + cursor_pos,
1259 cursor_pos, FALSE );
1260 cursor_pos--;
1261 PrintDirEntry( f2_window,
1262 disp_begin_pos + cursor_pos,
1263 cursor_pos, TRUE );
1264 }
1265 else
1266 {
1267 disp_begin_pos--;
1268 DisplayTree( f2_window, disp_begin_pos,
1269 disp_begin_pos + cursor_pos);
1270 }
1271 }
1272 break;
1273
1274 case KEY_NPAGE:
1275 if( disp_begin_pos + cursor_pos >= total_dirs - 1 )
1276 {
1277 beep();
1278 }
1279 else
1280 {
1281 if( cursor_pos < win_height - 1 )
1282 {
1283 PrintDirEntry( f2_window,
1284 disp_begin_pos + cursor_pos,
1285 cursor_pos, FALSE );
1286 if( disp_begin_pos + win_height > total_dirs - 1 )
1287 cursor_pos = total_dirs - disp_begin_pos - 1;
1288 else
1289 cursor_pos = win_height - 1;
1290 PrintDirEntry( f2_window,
1291 disp_begin_pos + cursor_pos,
1292 cursor_pos, TRUE );
1293 }
1294 else
1295 {
1296 if( disp_begin_pos + cursor_pos + win_height < total_dirs )
1297 {
1298 disp_begin_pos += win_height;
1299 cursor_pos = win_height - 1;
1300 }
1301 else
1302 {
1303 disp_begin_pos = total_dirs - win_height;
1304 if( disp_begin_pos < 0 ) disp_begin_pos = 0;
1305 cursor_pos = total_dirs - disp_begin_pos - 1;
1306 }
1307 DisplayTree( f2_window, disp_begin_pos,
1308 disp_begin_pos + cursor_pos);
1309 }
1310 }
1311 break;
1312
1313 case KEY_PPAGE:
1314 if( disp_begin_pos + cursor_pos <= 0 )
1315 {
1316 beep();
1317 }
1318 else
1319 {
1320 if( cursor_pos > 0 )
1321 {
1322 PrintDirEntry( f2_window,
1323 disp_begin_pos + cursor_pos,
1324 cursor_pos, FALSE );
1325 cursor_pos = 0;
1326 PrintDirEntry( f2_window,
1327 disp_begin_pos + cursor_pos,
1328 cursor_pos, TRUE );
1329 }
1330 else
1331 {
1332 if( (disp_begin_pos -= win_height) < 0 )
1333 {
1334 disp_begin_pos = 0;
1335 }
1336 cursor_pos = 0;
1337 DisplayTree( f2_window, disp_begin_pos,
1338 disp_begin_pos + cursor_pos);
1339 }
1340 }
1341 break;
1342
1343 case KEY_HOME: if( disp_begin_pos == 0 && cursor_pos == 0 )
1344 { beep(); }
1345 else
1346 {
1347 disp_begin_pos = 0;
1348 cursor_pos = 0;
1349 DisplayTree( f2_window, disp_begin_pos,
1350 disp_begin_pos + cursor_pos);
1351 }
1352 break;
1353
1354 case KEY_END : disp_begin_pos = MAXIMUM(0, total_dirs - win_height);
1355 cursor_pos = total_dirs - disp_begin_pos - 1;
1356 DisplayTree( f2_window, disp_begin_pos,
1357 disp_begin_pos + cursor_pos);
1358 break;
1359
1360 case LF :
1361 case CR :
1362 GetPath(dir_entry_list[cursor_pos + disp_begin_pos].dir_entry, path);
1363 result = 0;
1364 break;
1365 case ESC:
1366 case 'Q':
1367 case 'q': break;
1368
1369 default : beep();
1370 break;
1371 } /* switch */
1372 } while( (ch != 'q') && (ch != ESC) && (ch != 'Q') && (ch != CR) && (ch != -1) );
1373
1374 UnmapF2Window();
1375 return( result );
1376 }
1377
1378
1379
RefreshDirWindow()1380 int RefreshDirWindow()
1381 {
1382 DirEntry *de_ptr;
1383 int i, n;
1384 int result = -1;
1385 int window_width, window_height;
1386
1387 de_ptr = dir_entry_list[statistic.disp_begin_pos + statistic.cursor_pos].dir_entry;
1388 BuildDirEntryList( dir_entry_list[0].dir_entry );
1389
1390 /* Search old entry */
1391 for(n=-1, i=0;i < total_dirs; i++) {
1392 if(dir_entry_list[i].dir_entry == de_ptr) {
1393 n = i;
1394 break;
1395 }
1396 }
1397
1398 if(n == -1) {
1399 /* Directory disapeared */
1400 ERROR_MSG( "Current directory disappeared" );
1401 result = -1;
1402 } else {
1403
1404 if( n != (statistic.disp_begin_pos + statistic.cursor_pos)) {
1405 /* Position changed */
1406 if((n - statistic.disp_begin_pos) >= 0) {
1407 statistic.cursor_pos = n - statistic.disp_begin_pos;
1408 } else {
1409 statistic.disp_begin_pos = n;
1410 statistic.cursor_pos = 0;
1411 }
1412 }
1413
1414 GetMaxYX(dir_window, &window_height, &window_width);
1415 while(statistic.cursor_pos >= window_height) {
1416 statistic.cursor_pos--;
1417 statistic.disp_begin_pos++;
1418 }
1419 DisplayTree( dir_window, statistic.disp_begin_pos,
1420 statistic.disp_begin_pos + statistic.cursor_pos
1421 );
1422
1423 DisplayAvailBytes();
1424 result = 0;
1425 }
1426
1427 return(result);
1428 }
1429
1430
1431