File: sort.c

package info (click to toggle)
ytree 1.94-1.1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 836 kB
  • ctags: 1,510
  • sloc: ansic: 15,271; makefile: 208
file content (81 lines) | stat: -rw-r--r-- 2,246 bytes parent folder | download | duplicates (8)
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
/***************************************************************************
 *
 * $Header: /usr/local/cvsroot/utils/ytree/sort.c,v 1.11 2001/04/16 13:34:26 werner Exp $
 *
 * Umschalten des Sortierkriteriums
 *
 ***************************************************************************/


#include "ytree.h"




void GetKindOfSort(void)
{
  int c;
  int s;
  int order;
  
  order = SORT_ASC; s=0;
  ClearHelp();
  PrintOptions( stdscr, LINES - 2, 1, 
            "Sort by (A)ccTime (C)hgTime (E)xtension (G)roup (M)odTime   (O)rder: [ascending]"
	  );
  PrintOptions( stdscr, LINES - 1, 2, "       (N)ame o(W)ner (S)ize" );

  RefreshWindow( stdscr );
  doupdate();
  do 
  {
        c = Getch();
	if(c == -1 || c == ESC)
	  return;

        c = toupper(c);

	if (c == 'Q')
	  return;

        switch( c )
        {
                case 'N': s = SORT_BY_NAME;
                        break;
                case 'E': s = SORT_BY_EXTENSION;
                        break;
                case 'M': s = SORT_BY_MOD_TIME;
                        break;
                case 'A': s = SORT_BY_ACC_TIME;
                        break;
                case 'C': s = SORT_BY_CHG_TIME;
                        break;
                case 'G': s = SORT_BY_GROUP;
                        break;
                case 'W': s = SORT_BY_OWNER;
                        break;
                case 'S': s = SORT_BY_SIZE;
                        break;
                case 'O': if (order == SORT_ASC)
                          {
                              PrintOptions( stdscr, LINES - 2, 58, "[descending]" );
                              order = SORT_DSC;
                          }
                          else
                          {
                                PrintOptions( stdscr, LINES - 2, 58, "[ascending] " );
                                order = SORT_ASC;
                          }
                        RefreshWindow( stdscr );
                        doupdate();
                        break;
                default : beep();
                        RefreshWindow( stdscr );
                        doupdate();
                        break;
        }
  } while( ! strchr("ACEGMNWS", c));
  SetKindOfSort(s + order);
}