1 /* 2 * Program source is Copyright 1993 Colten Edwards. 3 * Central Data Services is granted the right to use this source 4 * in thier product known as Quote Menu. They are also granted the right 5 * to modify this source in the advent of problems and or new features 6 * which they may want to add to the program. 7 */ 8 9 #include <stdlib.h> 10 #include <dirent.h> 11 #include <ncurses.h> 12 #define MAXPATH MAXNAMLEN 13 /* Defines for shadows. Used in the Box rountine. */ 14 15 #define NO_SHADOW 0 16 #define SINGLER_SHADOW 1 17 #define DOUBLER_SHADOW 2 18 #define SINGLEL_SHADOW 3 19 #define DOUBLEL_SHADOW 4 20 21 #define NO_LINE 0 22 #define SINGLE_LINE 1 23 #define DOUBLE_LINE 2 24 #define SINGLE_TOP 3 25 #define SINGLE_SIDE 4 26 #define SOLID_LINES 5 27 #define TOP_BOT_SLINE 6 28 #define TOP_BOT_DLINE 7 29 #define TOP_BOT_SOLID 8 30 31 #define NUM_KEYS 80 32 /* Number of color table entries */ 33 #define MAXC_TABLE 6 34 35 /* Number of User Defined Functions */ 36 #define MAXU_FUNCS 10 37 38 #define CURCOL 24 /* Starting edit cursor column */ 39 40 41 #define WRITE_FILE 0 42 #define READ_FILE 1 43 44 45 46 #define CURSOROFF 0x2000 47 48 /* A define used for the CONFIG entries on the max. path allowed.*/ 49 50 #define WILDCARD 0x01 51 #define EXTENSION 0x02 52 #define FILENAME 0x04 53 #define DIRECTORY 0x08 54 #define DRIVE 0x10 55 56 57 typedef struct { 58 char letter; 59 int return_answer; 60 } _default; 61 62 63 #define LOC_YN_Y 18 64 #define LOC_YN_X 24 65 66 67 extern struct _VIDEO { 68 unsigned char winleft; 69 unsigned char wintop; 70 unsigned char winright; 71 unsigned char winbottom; 72 unsigned char attribute; 73 unsigned char normattr; 74 unsigned char currmode; 75 unsigned char screenheight; 76 unsigned char screenwidth; 77 unsigned char graphics; 78 unsigned char needcgasync; 79 char *videobuffer; 80 } _video; 81 82 typedef struct dlistmem *dlistptr; 83 84 struct datainforec { 85 char *option; 86 char *help; 87 88 int other; 89 char *save; 90 int (*func)(); 91 int integer; 92 int type; 93 #if 0 94 long act_size; 95 int volume; 96 long pos_in_archive; 97 dev_t dev; 98 uid_t uid; 99 gid_t gid; 100 umode_t mode; 101 umode_t org_mode; 102 long size; 103 time_t atime; 104 time_t mtime; 105 time_t ctime; 106 time_t backup_time; 107 char name_len; 108 char compressed; 109 long checksum; 110 #endif 111 int mark; 112 }; 113 114 struct dlistmem { 115 struct datainforec datainfo; 116 dlistptr nextlistptr; 117 dlistptr prevlistptr; 118 }; 119 120 typedef struct cell 121 { 122 /* 123 * Possible Startup and Exit Procedures to use 124 */ 125 int (*ListEntryProc)(struct cell *cell ); 126 int (*ListExitProc)(struct cell *cell); 127 /* 128 * What to do on a key and the screen paint routine 129 * What to do on a special key 130 */ 131 int (*ListEventProc)(struct cell *cell); 132 int (*ListPaintProc)(struct cell *cell); 133 int (*OtherGetKeyProc)(struct cell *cell); 134 135 /* Possible actions to take with a keystroke. */ 136 /* 137 * The current line we are at. 138 */ 139 int (*current_event)(struct cell *cell); 140 141 int (*event1)(struct cell *cell); 142 int (*event2)(struct cell *cell); 143 144 int (*UpdateStatusProc)(struct cell *cell); 145 146 struct KeyTable *keytable; 147 struct FuncTable *func_table; 148 149 /* These are what start everything off. */ 150 /* start is the start of the list.*/ 151 /* end is the end of the list. */ 152 /* current is the current highlighted line on the screen*/ 153 154 dlistptr start; 155 dlistptr current; 156 dlistptr end; 157 /* 158 * Begin and end of the current display list. current should be somewhere 159 * between these. 160 */ 161 dlistptr list_start; 162 dlistptr list_end; 163 164 WINDOW *window; /* WINDOW from ncurses */ 165 166 int redraw; /* screen needs attention */ 167 int srow; /* window start row cordinate */ 168 int scol; /* Window start Column */ 169 int erow; /* Window Ending Row */ 170 int ecol; /* Window ending column */ 171 int max_cols; /* Max Columns on the screen */ 172 int max_rows; /* Max Rows on the screen */ 173 int save_row; /* save the cursor pos row */ 174 int save_col; /* save the cursor pos col */ 175 int cur_pos; /* current cursor column when using edit*/ 176 int cur_row; /* current cursor row when using edit */ 177 int desc_start; /* Used when editing large fields. */ 178 179 unsigned int termkey; /* this is cleared on enter, setting it to 180 * any value other than zero causes the 181 * function to return. Usually set to the 182 * key we terminate with. 183 */ 184 unsigned int special; /* Holds value for the current item function 185 * number 186 */ 187 188 189 unsigned int key; /* Current Keystroke */ 190 unsigned int other_getkey; /* set this to use other get_char routine */ 191 /* if supplied */ 192 193 unsigned int normcolor; /* Normal Text Screen Color*/ 194 unsigned int barcolor; /* Bar text Screen Color */ 195 196 int insert_mode; /* Insert/OverWrite Cursor Mode */ 197 198 int menu_bar; /* Set this if a menu at the bottom 199 * of the screen is needed 200 */ 201 int dest_src; 202 char *filename; 203 char **argv; 204 int argc; 205 } CELL; 206 207 208 typedef struct KeyTable 209 { 210 int key; 211 int func_num; 212 char desc[40]; 213 } KEYTABLE; 214 215 typedef struct UKeyTable 216 { 217 int key; 218 char desc[40]; 219 char program[MAXPATH+1]; 220 char params[40]; 221 } USERKEYTABLE; 222 223 typedef struct FuncTable 224 { 225 int key; 226 int (*func)(struct cell *c); 227 } FUNC_TABLE ; 228 229 struct COLOR { 230 unsigned char dosborder ; 231 unsigned char dostext ; 232 unsigned char background; 233 unsigned char back_text; 234 unsigned char menuborder ; 235 unsigned char menuback ; 236 unsigned char menutext ; 237 unsigned char menucursor ; 238 unsigned char menushadow ; 239 unsigned char fileborder; 240 unsigned char filebar; 241 unsigned char filetext; 242 }; 243 244 245 #define LS_END 0 246 #define LS_HOME 1 247 #define LS_PGUP 2 248 #define LS_PGDN 3 249 #define CURSOR_UP 4 250 #define CURSOR_DN 5 251 #define LS_QUIT 6 252 #define WRAP_CURSOR_DN 7 253 #define WRAP_CURSOR_UP 8 254 #define DO_SHELL 9 255 #define LS_ENTER 10 256 #define UPFUNC 11 257 #define TOGGLE 12 258 #define PLUS_IT 13 259 #define MINUS_IT 14 260 #define LS_CLEAR 15 261 #define LS_TOGGLE 16 262 #define RENAME_FILE 17 263 #define CHANGE_SRC 18 264 #define CHANGE_DEST 19 265 #define LS_PLAY 20 266