]>
Commit | Line | Data |
---|---|---|
f9d450b2 | 1 | /* H/G text editor */ |
2 | #ifndef HED_H | |
3 | #define HED_H | |
4 | ||
5 | /* Maximum number of lines in buffer */ | |
6 | #define HED_BUFFER_LINES 16 | |
7 | ||
8 | #define HELPMOD_TEXT_DIR "./helpmod2/text" | |
135d6084 | 9 | #define HED_FILENAME_LENGTH 64 |
f9d450b2 | 10 | |
11 | /* Forward declarations */ | |
12 | struct hchannel_struct; | |
13 | struct huser_struct; | |
14 | ||
15 | typedef enum | |
16 | { | |
17 | HED_COMMAND, | |
18 | HED_INPUT_INSERT, | |
19 | HED_INPUT_APPEND | |
20 | } hed_state; | |
21 | ||
22 | typedef enum | |
23 | { | |
24 | HED_ERR_NO_ERROR, | |
25 | HED_ERR_NO_COMMAND, | |
26 | HED_ERR_SYNTAX_ERROR, | |
27 | HED_ERR_UNKNOWN_COMMAND, | |
28 | HED_ERR_COMMAND_NOT_SUPPORTED, | |
29 | HED_ERR_INVALID_ARGUMENT, | |
30 | HED_ERR_LINE_TOO_LONG, | |
31 | HED_ERR_BUFFER_FULL, | |
32 | HED_ERR_CLIPBOARD_EMPTY, | |
33 | HED_ERR_UNSAVED | |
34 | } hed_error; | |
35 | ||
36 | typedef enum | |
37 | { | |
38 | HED_FLAG_VERBOSE_ERRORS = 1 << 0, | |
39 | HED_FLAG_UNSAVED = 1 << 1 | |
40 | } hed_flag; | |
41 | ||
42 | #define HED_FLAGS_DEFAULT (0) | |
43 | ||
44 | typedef struct helpmod_editor_line_struct | |
45 | { | |
46 | char line[384]; | |
47 | struct helpmod_editor_line_struct *next; | |
48 | } hed_line; | |
49 | ||
50 | typedef struct helpmod_editor_struct | |
51 | { | |
135d6084 | 52 | char filename[HED_FILENAME_LENGTH]; |
f9d450b2 | 53 | hed_line buffers[HED_BUFFER_LINES]; |
54 | ||
55 | hed_line *start; | |
56 | hed_line *free_lines; | |
57 | hed_line *clipboard; | |
58 | ||
59 | int line; | |
60 | int flags; | |
61 | ||
62 | struct huser_struct *user; | |
63 | ||
64 | hed_state state; | |
65 | hed_error last_error; | |
66 | ||
67 | struct helpmod_editor_struct *next; | |
68 | } helpmod_editor; | |
69 | ||
70 | extern helpmod_editor *helpmod_editors; | |
71 | ||
72 | helpmod_editor *hed_open(struct huser_struct *, const char *); | |
73 | helpmod_editor *hed_close(helpmod_editor *); | |
74 | helpmod_editor *hed_write(helpmod_editor *); | |
75 | ||
76 | int hed_byte_count(helpmod_editor*); | |
77 | int hed_line_count(helpmod_editor*); | |
78 | int hed_is_valid_filename(const char *); | |
79 | ||
80 | /* Get by filename */ | |
81 | helpmod_editor *hed_get(const char *); | |
82 | ||
83 | void hed_command (struct huser_struct *sender, channel* returntype, char* ostr, int argc, char *argv[]); | |
84 | ||
85 | const char *hed_error_text(hed_error); | |
86 | ||
87 | char *hed_add_line(helpmod_editor *, int); | |
88 | void hed_del_line(helpmod_editor *, int); | |
89 | char *hed_get_line(helpmod_editor *, int); | |
90 | ||
91 | void hed_clear_clipboard(helpmod_editor *); | |
92 | void hed_paste(helpmod_editor *, int); | |
93 | ||
94 | #endif |