~ubuntu-branches/ubuntu/quantal/clex/quantal

« back to all changes in this revision

Viewing changes to src/clex.h

  • Committer: Bazaar Package Importer
  • Author(s): Gabriel Puliatti
  • Date: 2006-10-10 21:00:45 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061010210045-ffvd59e6r74moead
Tags: 3.15-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 *
3
3
 * CLEX File Manager
4
4
 *
5
 
 * Copyright (C) 2001-2005 Vlado Potisk <vlado_potisk@clex.sk>
 
5
 * Copyright (C) 2001-2006 Vlado Potisk <vlado_potisk@clex.sk>
6
6
 *
7
7
 * CLEX is free software without warranty of any kind; see the
8
8
 * GNU General Public License as set out in the "COPYING" document
27
27
#define CH_ESC                  '\033'                                          /* ASCII escape */
28
28
#define CH_CTRL(X)              ((X) & 0x1F)                            /* ASCII ctrl-X */
29
29
#define IS_CHAR(X)              (((X) & 0xFF) == (X))           /* X is a char */
 
30
/* CMP: no overflow and result is an int even if V1 and V2 are not */
 
31
#define CMP(V1,V2) ((V1) == (V2) ? 0 : (V1) < (V2) ? -1 : 1)
30
32
/* you can't do this in one pass: */
31
33
#define STR(X)  STRINGIZE(X)
32
34
#define STRINGIZE(X)    #X
47
49
 * value 0 is reserved, it means mode unchanged in control_loop()
48
50
 *   and also mode not set during startup
49
51
 */
50
 
#define MODE_BM                                  1
 
52
#define MODE_BM_LIST                     1
51
53
#define MODE_BM_MANAGER                  2
52
54
#define MODE_BM_EDIT                     3
53
55
#define MODE_CFG                                 4
59
61
#define MODE_DIR                                10
60
62
#define MODE_DIR_SPLIT                  11
61
63
#define MODE_FILE                               12
62
 
#define MODE_HELP                               13
63
 
#define MODE_HIST                               14
64
 
#define MODE_P_LOCATE                   15      /* P = pattern */
65
 
#define MODE_S_LOCATE                   16      /* S = substring */
66
 
#define MODE_MAINMENU                   17
 
64
#define MODE_GROUP                              13
 
65
#define MODE_HELP                               14
 
66
#define MODE_HIST                               15
 
67
#define MODE_MAINMENU                   16
 
68
#define MODE_PASTE                              17
67
69
#define MODE_SELECT                             18
68
70
#define MODE_SORT                               19
 
71
#define MODE_USER                               20
69
72
/* pseudo-modes */
70
73
#define MODE_SPECIAL_QUIT               98
71
74
#define MODE_SPECIAL_RETURN             99
95
98
        int panlines;           /* number of lines in the panel area */
96
99
        int textline_area;      /* number of chars available for
97
100
                                                   the textline (including the prompt) */
98
 
        int date_len;           /* lenght of date/time field */
 
101
        int date_len;           /* length of date/time field */
99
102
} DISPLAY;
100
103
 
101
104
typedef struct {
102
105
        const char *login_at_host;      /* my name: user@host */
103
 
        const char *shell;                      /* my login shell */
 
106
        char *shell;                            /* my login shell */
104
107
        const char *homedir;            /* my home directory */
105
108
        pid_t pid;                                      /* process ID */
106
109
        mode_t umask;                           /* umask value */
107
110
        FLAG isroot;                            /* effective uid is 0(root) */
108
111
        FLAG admin;                                     /* admin mode: clex -a */
 
112
        CODE shelltype;                         /* Bourne shell (0), C-shell (1), other (2) */
109
113
} CLEX_DATA;
110
114
 
111
115
/* description of an editing operation */
144
148
        EDIT_OP last_op;                /* last editing operation */
145
149
} TEXTLINE;
146
150
 
 
151
/* minimalistic version of TEXTLINE */
 
152
/* currently used only for panel filters */
 
153
#define INPUT_STR 25
 
154
typedef struct {
 
155
        char line[INPUT_STR];   /* user's input */
 
156
        int size;                               /* number of chars in the line */
 
157
        int curs;                               /* cursor position from 0 to 'size' */
 
158
        FLAG changed;                   /* 'line' has been modified */
 
159
} INPUTLINE;
 
160
 
147
161
/********************************************************************/
148
162
 
149
163
/*
152
166
 * the draw_panel_line() in inout.c
153
167
 */
154
168
#define PANEL_TYPE_BM                    0
155
 
#define PANEL_TYPE_BM_MANAGER    1
156
 
#define PANEL_TYPE_CFG                   2
157
 
#define PANEL_TYPE_CFG_ADMIN     3
158
 
#define PANEL_TYPE_COMPARE               4
159
 
#define PANEL_TYPE_COMPL                 5
160
 
#define PANEL_TYPE_DIR                   6
161
 
#define PANEL_TYPE_DIR_SPLIT     7
162
 
#define PANEL_TYPE_FILE                  8
163
 
#define PANEL_TYPE_HELP                  9
164
 
#define PANEL_TYPE_HIST                 10
165
 
#define PANEL_TYPE_LOCATE               11
166
 
#define PANEL_TYPE_MAINMENU             12
167
 
#define PANEL_TYPE_SORT                 13
 
169
#define PANEL_TYPE_CFG                   1
 
170
#define PANEL_TYPE_COMPARE               2
 
171
#define PANEL_TYPE_COMPL                 3
 
172
#define PANEL_TYPE_DIR                   4
 
173
#define PANEL_TYPE_DIR_SPLIT     5
 
174
#define PANEL_TYPE_FILE                  6
 
175
#define PANEL_TYPE_GROUP                 7
 
176
#define PANEL_TYPE_HELP                  8
 
177
#define PANEL_TYPE_HIST                  9
 
178
#define PANEL_TYPE_MAINMENU             10
 
179
#define PANEL_TYPE_PASTE                11
 
180
#define PANEL_TYPE_SORT                 12
 
181
#define PANEL_TYPE_USER                 13
168
182
#define PANEL_TYPE_NONE                 99      /* not set (only during startup) */
169
183
 
 
184
/*
 
185
 * extra lines appear in a panel before the real first line,
 
186
 * extra lines:  -MIN .. -1
 
187
 * real lines:      0 .. MAX
 
188
 */
 
189
typedef struct {
 
190
        const char *text;               /* text to be displayed in the panel */
 
191
                                                        /* default (if null): "Leave this panel" */
 
192
        const char *info;               /* text to be displayed in the info line */
 
193
        /* when this extra line is selected: */
 
194
        CODE mode_next;                 /* set next_mode to this mode and then ... */
 
195
        void (*fn)(void);               /* ... invoke this function */
 
196
} EXTRA_LINE;
 
197
 
170
198
/* description of a panel */
171
199
typedef struct {
172
 
        int cnt, top;           /* panel lines: total count, top of the screen */
173
 
        int curs, min;          /* panel lines: cursor bar, top of the panel */
 
200
        int cnt, top;   /* panel lines: total count, top of the screen */
 
201
        int curs, min;  /* panel lines: cursor bar, top of the panel */
174
202
        /*
175
 
         * panel line 'min' is used to insert extra lines
176
 
     * before the actual first line which is always line number 0;
177
 
         * to insert N extra lines set 'min' to -N;
178
 
         * the number of extra lines is not included in 'cnt' 
 
203
         * 'min' is used to insert extra lines before the real first line
 
204
     * which is always line number 0; to insert N extra lines set
 
205
         * 'min' to -N; the number of extra lines is not included in 'cnt' 
179
206
         */
180
 
        CODE type;                      /* panel type: one of PANEL_TYPE_XXX */
181
 
        FLAG norev;                     /* do not show the current line in reverse video */
 
207
        CODE type;              /* panel type: one of PANEL_TYPE_XXX */
 
208
        FLAG norev;             /* do not show the current line in reversed video */
 
209
        EXTRA_LINE *extra;      /* extra panel lines */
 
210
        INPUTLINE *filter;      /* filter (if applicable to this panel type) */
 
211
        CODE filtering;         /* filter: 0 = off */
 
212
                                                /* 1 = on - focus on the filter string */
 
213
                                                /* 2 = on - focus on the command line */
182
214
} PANEL_DESC;
183
215
 
 
216
#define VALID_CURSOR(P) ((P)->cnt > 0 && (P)->curs >= 0 && (P)->curs < (P)->cnt)
 
217
 
184
218
/********************************************************************/
185
219
 
186
220
/*
215
249
/* text buffer sizes */                 /* examples: */
216
250
#define FE_LINKS_STR     4              /* 1  999  max  */
217
251
#define FE_TIME_STR             12              /* 12:34am  1.01.04  01-jan-2004 */
218
 
#define FE_SIZE_DEV_STR 12              /* 122.351k  3.222.891K */
 
252
#define FE_SIZE_DEV_STR 12              /* 3.222.891Ki */
219
253
#define FE_MODE_STR      5              /* 0644 */
220
 
#define FE_OWNER_STR    18              /* root:mail */
 
254
#define FE_NAME_STR             10              /* root */
 
255
#define FE_OWNER_STR    (2 * FE_NAME_STR)       /* root:mail */
221
256
 
222
257
/*
223
258
 * file description - exhausting, isn't it ?
231
266
        off_t size;                             /* file size */
232
267
        dev_t devnum;                   /* major/minor numbers (devices only) */
233
268
        CODE file_type;                 /* one of FT_XXX */
234
 
        uid_t uid, gid;                 /* owner & group */
 
269
        uid_t uid, gid;                 /* owner and group */
235
270
        short int mode12;               /* file mode - low 12 bits */
236
271
        unsigned int select:1;          /* flag: this entry is selected */
237
272
        unsigned int symlink:1;         /* flag: it is a symbolic link */
238
273
        unsigned int dotdir:2;          /* . (1) or .. (2) directory */
 
274
        unsigned int fmatch:1;          /* flag: matches the filter */
239
275
        /*
240
276
         * note: the structure members below are used
241
277
         * only when the file panel layout requires them
257
293
        struct ppanel_file *other;      /* primary <--> secondary panel ptr */
258
294
        int selected;                   /* number of selected entries */
259
295
        FLAG expired;                   /* expiration: panel needs re-read */
 
296
        FLAG filtype;                   /* filter type: 0 = substring, 1 = pattern */
 
297
        int filt_cnt;                   /* saved number of entries while filtering is on */
 
298
        int filt_sel;                   /* selected entries NOT matched by the filter */
260
299
        int fe_alloc;                   /* allocated FILE_ENTRies in 'files' below */
261
300
        FILE_ENTRY **files;             /* main part: list of files in panel's
262
301
                                                           working directory 'dir' */
263
302
} PANEL_FILE;
 
303
/*
 
304
 * filter off: 0 .. cnt-1     = all file entries
 
305
 * filter on:  0 .. cnt-1     = entries matching the filter expression
 
306
 *           cnt .. filtcnt-1 = saved entries not matching the filter
 
307
 */
264
308
 
265
309
/********************************************************************/
266
310
 
271
315
 
272
316
/********************************************************************/
273
317
 
274
 
typedef struct {
275
 
        PANEL_DESC *pd;
276
 
        int fe_alloc;                   /* same meaning as in PANEL_FILE above */
277
 
        FILE_ENTRY **files;
278
 
} PANEL_LOCATE;
279
 
 
280
 
/********************************************************************/
281
 
 
282
318
/*
283
319
 * file sort order - if you change this, you must also update
284
320
 * panel initization in start.c and descriptions in inout.c
299
335
/********************************************************************/
300
336
 
301
337
typedef struct {
302
 
        const char *name;               /* directory name (see also shlen) */
303
 
        int shlen;                              /* PANEL_DIR: length of the repeating name part
304
 
                                                             used for fancy formatting
305
 
                                                           PANEL_DIR_SPLIT: length of the string 'name'
306
 
                                                                 which is NOT null terminated */
 
338
        const char *name;       /* directory name (see also shlen) */
 
339
        int shlen;                      /* PANEL_DIR: length of the repeating name part
 
340
                                                         (used for fancy formatting)
 
341
                                                   PANEL_DIR_SPLIT: length of the string 'name'
 
342
                                                         which is NOT null terminated */
307
343
} DIR_ENTRY;
308
344
 
309
345
typedef struct {
357
393
#define CFG_D_SIZE                      32
358
394
#define CFG_H_SIZE                      33
359
395
 
360
 
/* max string lenghts */
 
396
/* max string lengths */
361
397
#define CFGVAR_LEN              16      /* name */
362
398
#define CFGVALUE_LEN    60      /* string value */
363
399
 
425
461
 
426
462
/********************************************************************/
427
463
 
 
464
typedef struct {
 
465
        uid_t uid;
 
466
        const char *login;
 
467
        const char *gecos;
 
468
} USER_ENTRY;
 
469
        
 
470
typedef struct {
 
471
        PANEL_DESC *pd;
 
472
        USER_ENTRY *users;
 
473
        int usr_alloc;                  /* allocated entries in 'users' */
 
474
} PANEL_USER;
 
475
 
 
476
typedef struct {
 
477
        gid_t gid;
 
478
        const char *group;
 
479
} GROUP_ENTRY;
 
480
        
 
481
typedef struct {
 
482
        PANEL_DESC *pd;
 
483
        GROUP_ENTRY *groups;
 
484
        int grp_alloc;          /* allocated entries in 'groups' */
 
485
} PANEL_GROUP;
 
486
 
 
487
/********************************************************************/
 
488
 
428
489
/* global variables */
429
490
 
430
491
extern const void *pcfg[CFG_VARIABLES];
431
492
 
432
493
extern DISPLAY display;
433
494
extern CLEX_DATA clex_data;
434
 
extern TEXTLINE *textline;              /* --> active line */
 
495
extern TEXTLINE *textline;              /* -> active line */
435
496
extern TEXTLINE line_cmd, line_dir, line_tmp;
436
 
extern PANEL_DESC *panel;               /* --> description of the active panel */
 
497
extern PANEL_DESC *panel;               /* -> description of the active panel */
437
498
extern PANEL_FILE *ppanel_file;
438
499
extern PANEL_CFG panel_cfg;
439
 
extern PANEL_BM panel_bm;
 
500
extern PANEL_BM panel_bm_lst, panel_bm_mng;
440
501
extern PANEL_COMPL panel_compl;
441
502
extern PANEL_DIR panel_dir;     
442
503
extern PANEL_DIR_SPLIT panel_dir_split; 
 
504
extern PANEL_GROUP panel_group;
443
505
extern PANEL_HELP panel_help;
444
506
extern PANEL_HIST panel_hist;
445
 
extern PANEL_LOCATE panel_locate;
446
 
extern PANEL_MENU panel_mainmenu, panel_compare;
 
507
extern PANEL_MENU panel_mainmenu, panel_compare, panel_paste;
447
508
extern PANEL_SORT panel_sort;
 
509
extern PANEL_USER panel_user;
448
510
extern CODE next_mode;                  /* see control.c comments */