forked from sebastianbiallas/ht
-
Notifications
You must be signed in to change notification settings - Fork 0
/
htapp.h
377 lines (315 loc) · 8.29 KB
/
htapp.h
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
/*
* HT Editor
* htapp.h
*
* Copyright (C) 1999-2002 Stefan Weyergraf
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __HTAPP_H__
#define __HTAPP_H__
#include "htctrl.h"
#include "htdialog.h"
#include "htformat.h"
// file open modes
#define FOM_AUTO 0
#define FOM_BIN 1
#define FOM_TEXT 2
//
#define VIEWERGROUP_NAME "viewergroup"
/*
* CLASS ht_status
*/
#define STATUS_DEFAULT_FORMAT "%a %L %t %d"
#define STATUS_ESCAPE '%'
#define STATUS_ANALY_ACTIVE 'a'
#define STATUS_ANALY_LINES 'L'
#define STATUS_TIME 't'
#define STATUS_DATE 'd'
#define STATUS_WORKBUFLEN 80
/*
* CLASS ht_status
*/
class ht_status: public ht_view {
protected:
int idle_count;
char *format;
char workbuf[STATUS_WORKBUFLEN];
int clear_len;
int analy_ani;
public:
void init(Bounds *b);
virtual void done();
virtual void draw();
virtual void handlemsg(htmsg *msg);
virtual bool idle();
virtual void getminbounds(int *width, int *height);
private:
void render();
virtual const char *defaultpalette();
};
/*
* CLASS ht_keyline
*/
class ht_keyline: public ht_view {
public:
void init(Bounds *b);
virtual void done();
/* overwritten */
virtual void draw();
virtual const char *defaultpalette();
virtual void getminbounds(int *width, int *height);
};
/*
* CLASS ht_desktop
*/
class ht_desktop: public ht_view {
public:
void init(Bounds *b);
/* overwritten */
virtual void draw();
virtual const char *defaultpalette();
};
/*
* CLASS ht_logviewer
*/
class ht_log_msg: public Object {
public:
vcp color;
char *msg;
ht_log_msg(vcp Color, char *Msg);
~ht_log_msg();
};
typedef unsigned int LogColor;
class ht_log: public Array {
protected:
uint maxlinecount;
void deletefirstline();
void insertline(LogColor c, char *line);
public:
ht_log();
/* new */
void log(LogColor c, char *line);
};
class ht_logviewer: public ht_viewer {
private:
ht_log *lines;
bool own_lines;
int ofs, xofs;
ht_window *window;
/* new */
int cursor_up(int n);
int cursor_down(int n);
bool get_vscrollbar_pos(int *pstart, int *psize);
void update();
public:
void init(Bounds *b, ht_window *window, ht_log *log, bool own_log);
virtual void done();
/* overwritten */
virtual void draw();
virtual void handlemsg(htmsg *msg);
};
/*
* CLASS ht_vstate_history_entry
*/
class ht_vstate_history_entry: public Object {
public:
Object *data;
ht_view *view;
ht_vstate_history_entry(Object *data, ht_view *view);
~ht_vstate_history_entry();
};
/*
* CLASS ht_file_window
*/
class ht_file_window: public ht_window {
protected:
Array vstate_history;
int vstate_history_pos;
void add_vstate_history(ht_vstate_history_entry *e);
public:
File *file;
ht_file_window();
void init(Bounds *b, const char *desc, uint framestyle, uint number, File *file);
virtual void done();
/* overwritten */
virtual void handlemsg(htmsg *msg);
};
/*
* CLASS ht_project
*/
class ht_project: public AVLTree {
protected:
char *filename;
public:
explicit ht_project(const char *filename);
ht_project(BuildCtorArg &a): AVLTree(a) {};
virtual ~ht_project();
/* overwritten */
virtual void load(ObjectStream &s);
virtual ObjectID getObjectID() const;
virtual void store(ObjectStream &s) const;
/* new */
const char *get_filename();
};
/*
* CLASS ht_project_item
*/
class ht_project_item: public Object {
protected:
char *filename;
char *path;
public:
ht_project_item(const char *filename, const char *path);
ht_project_item(BuildCtorArg &a): Object(a) {};
virtual ~ht_project_item();
/* overwritten */
virtual void load(ObjectStream &s);
virtual ObjectID getObjectID() const;
virtual void store(ObjectStream &s) const;
virtual int compareTo(const Object *) const;
/* new */
const char *get_filename() const;
const char *get_path() const;
};
/*
* CLASS ht_project_listbox
*/
class ht_project_listbox: public ht_listbox {
protected:
ht_project *project;
uint colwidths[4];
public:
void init(Bounds *b, ht_project *project);
virtual int calcCount();
virtual void draw();
virtual void * getFirst();
virtual void * getLast();
virtual void * getNext(void *entry);
virtual void * getPrev(void *entry);
virtual const char *getStr(int col, void *entry);
virtual void handlemsg(htmsg *msg);
virtual int numColumns();
virtual void * quickfind(const char *s);
virtual char * quickfindCompletition(const char *s);
virtual bool selectEntry(void *entry);
/* new */
const char *func(uint i, bool execute);
void set_project(ht_project *project);
};
/*
* CLASS ht_project_window
*/
class ht_project_window: public ht_window {
protected:
ht_project **project;
ht_project_listbox *plb;
char wtitle[128];
public:
void init(Bounds *b, const char *desc, uint framestyle, uint number, ht_project **project);
virtual void done();
/* overwritten */
virtual void handlemsg(htmsg *msg);
};
/*
* CLASS ht_app_window_entry
*/
#define AWT_LOG 0
#define AWT_CLIPBOARD 1
#define AWT_HELP 2
#define AWT_FILE 3
#define AWT_OFM 4
#define AWT_PROJECT 5
#define AWT_TERM 6
class ht_app_window_entry: public Object {
public:
uint type;
ht_window *window;
bool minimized;
uint number;
bool isfile;
FileLayer *layer;
ht_app_window_entry(ht_window *window, uint number, uint type, bool minimized, bool isfile, FileLayer *layer);
virtual int compareTo(const Object *) const;
};
/*
* CLASS ht_app
*/
class ht_app: public ht_dialog {
protected:
Container *windows;
Container *syntax_lexers;
ht_keyline *keyline;
ht_desktop *desktop;
ht_group *battlefield;
bool exit_program;
/* new */
ht_window *create_window_file_bin(Bounds *b, FileLayer *file, const char *title, bool isfile);
ht_window *create_window_file_text(Bounds *b, FileLayer *file, const char *title, bool isfile);
bool accept_close_all_windows();
uint find_free_window_number();
uint get_window_number(ht_window *window);
ObjHandle get_window_listindex(ht_window *window);
void get_stdbounds_file(Bounds *b);
void get_stdbounds_tool(Bounds *b);
int popup_view_list_dump(ht_view *view, ht_text_listbox *listbox, List *structure, int depth, int *currenti, ht_view *currentv);
/* overwritten */
virtual const char *defaultpalette();
virtual const char *defaultpaletteclass();
public:
ht_view *menu;
ht_app() {};
ht_app(BuildCtorArg &a): ht_dialog(a) {};
void insert_window(ht_window *window, uint type, bool minimized, bool isfile, FileLayer *layer);
void init(Bounds *b);
virtual void done();
/* overwritten */
virtual void draw();
virtual bool focus(ht_view *view);
virtual const char *func(uint i, bool execute);
virtual void handlemsg(htmsg *msg);
virtual void load(ObjectStream &f);
virtual ObjectID getObjectID() const;
virtual int run(bool modal);
virtual void store(ObjectStream &f) const;
/* new */
ht_window *create_window_clipboard();
ht_window *create_window_file(const char *filename, uint mode, bool allow_duplicates);
ht_window *create_window_file_bin(const char *filename, bool allow_duplicates);
ht_window *create_window_file_text(const char *filename, bool allow_duplicates);
ht_window *create_window_help(const char *file, const char *node);
ht_window *create_window_log();
ht_window *create_window_ofm(const char *url1, const char *url2);
ht_window *create_window_project();
ht_window *create_window_term(const char *cmd);
void delete_window(ht_window *window);
ht_window *get_window_by_filename(const char *filename);
ht_window *get_window_by_number(uint number);
ht_window *get_window_by_type(uint type);
ht_view *popup_view_list(const char *dialog_title);
ht_window *popup_window_list(const char *dialog_title);
void project_opencreate(const char *filename);
void tile(bool vertical);
void modal_resize();
};
extern ht_log *loglines;
/*
* INIT
*/
bool init_app();
/*
* DONE
*/
void done_app();
#endif /* __HTAPP_H__ */