-
Notifications
You must be signed in to change notification settings - Fork 4
/
gtk_appdata.h
318 lines (282 loc) · 11.7 KB
/
gtk_appdata.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
#ifndef _gtk_appdata_h_
#define _gtk_appdata_h_ 1
#define MAXLE 32
#include <glib.h>
#include <gtk/gtk.h>
#if GLIB_MAJOR_VERSION >= 2
#if GLIB_MINOR_VERSION >= 46
#define GLIB246 1
#endif
#if GLIB_MINOR_VERSION >= 40
#define GLIB240 1
#define HAVEKEYFILE 1
#endif
#if GLIB_MINOR_VERSION >= 36
#define GLIB236 1
#endif
#if GLIB_MINOR_VERSION >= 30
#define GLIB230 1
#endif
#endif
#ifndef CHAR_BIT
# define CHAR_BIT 8
#endif
#ifdef WGTKSOURCEVIEW2
#include <gtksourceview/gtksourceview.h>
#include <gtksourceview/gtksourcelanguagemanager.h>
#elif defined WGTKSOURCEVIEW3
#include <gtksourceview/gtksource.h>
#elif defined WGTKSOURCEVIEW4
#include <gtksourceview/gtksource.h>
#endif
#if defined (WGTKSOURCEVIEW2) || defined (WGTKSOURCEVIEW3) || defined (WGTKSOURCEVIEW4)
#define HAVESOURCEVIEW 1
#define APPSTR "GTKwrite Text Editor"
#define APPSHORT "GTKwrite"
#else
#define APPSTR "GTKedit Text Editor"
#define APPSHORT "GTKedit"
#endif
#if defined (_WIN32) || defined (_WIN64) || defined (_WINNT)
#define HAVEMSWIN 1
#endif
#define VER "0.2.5"
#define SITE "https://www.rankinlawfirm.com"
#define LICENSE "gpl-2.0.txt"
#define CFGDIR "gtkwrite"
#define CFGFILE "gtkwrite.cfg"
#define IMGDIR "img"
#define LOGO "gtkwrite.png"
#define ICON "gtkwrite.ico"
#define RCFILE "gtkrc-2.0_gtkwrite"
/* TODO: dynamically strip 'Program Files' from from app->exename
* and replace with progra~1 or progra~2 below to preserve correct
* logo display for 'portable' installs.
*/
#define WINPRG "c:/progra~1/gtkwrite"
#define WINPRG86 "c:/progra~2/gtkwrite"
#define NIXSHARE "/usr/share/gtkwrite"
#define EOL_LF "\n"
#define EOL_CR "\r"
#define EOL_CRLF "\r\n"
#define EOL_NO 3
#define EOLNM_LF "LF"
#define EOLNM_CR "CR"
#define EOLNM_CRLF "CRLF"
/* added for settings dialog */
#define EOLTXT_LF "Linux / Unix / OSX"
#define EOLTXT_CRLF "DOS / Windows"
#define EOLTXT_CR "Macintosh (pre-OSX)"
#define EOLTXT_FILE "Use EOL from File"
#define EOLTXT_OS "Use OS Default"
#define EOLTXT_NO 5
enum eolorder { LF, CRLF, CR, FILE_EOL, OS_EOL };
enum { IBAR_VISIBLE = 0x1,
IBAR_LABEL_SELECT = 0x2,
IBAR_VIEW_SENSITIVE = 0x4 }; /* infobar flags */
enum { LEFT, RIGHT, STKMAX = 0x4 }; /* boolean stack constants */
/* TODO:
* look at adding app->status to remove include gtk_statusbar.h
* dependency in gtk_filebuf.h.
*/
typedef struct {
gchar *exename; /* executable name */
const gchar *user; /* current username */
gchar *usrdatadir; /* user data dir */
gchar *sysdatadir; /* system data dir */
gchar *imgdir; /* image directory */
GtkWidget *window; /* main window */
GtkWidget *view; /* text_view */
GtkWidget *menubar; /* menubar */
GtkWidget *toolbar; /* toolbar */
GtkWidget *tbappearMi; /* toolbar Menu vis */
GtkWidget *ibarvbox; /* vbox for infobar */
GtkWidget *statusbar; /* window statusbar */
GtkTextTagTable *tagtable; /* buffer tagtable */
guchar ibflags; /* infobar bitfield */
gchar *appname; /* application name */
gchar *appshort; /* short app name */
gchar *filename; /* filename w/path */
gchar *fname; /* filename only */
gchar *fext; /* file extension */
gchar *fpath; /* file path */
gsize fsize; /* file size */
guint filemode; /* file mode */
guint fileuid; /* file UID */
guint filegid; /* file GID */
gboolean modified; /* buffer modified */
gboolean showtoolbar; /* toolbar visible */
guint cid; /* sb kwinst id */
guint dlgid; /* dialog id */
gint winwidth; /* window width */
gint winheight; /* window height */
gboolean winrestore; /* restore win size */
gboolean winszsaved; /* win size saved */
gint nrecent; /* n recent files */
/* text view settings */
/*
gint indent;
PangoTabArray *tabs;
*/
gchar *fontname;
#ifdef HAVESOURCEVIEW
GtkSourceBuffer *buffer;
GtkSourceLanguageManager *langmgr;
GtkSourceLanguage *language;
GtkSourceCompletion *completion;
gboolean enablecmplt; /* enable word-completion */
guint cmplwordsz; /* completion minimum-word-size */
const gchar *langname; /* name of language from sourceview guess */
// GtkSourceStyleSchemeManager *schememgr;
// const gchar * const *schemeids;
GtkWidget *stylelist;
GtkWidget *hghltmenu;
gboolean highlight;
gboolean lineno;
gboolean linehghlt; /* current line highlight */
gboolean showmargin; /* show right margin */
gint marginwidth; /* column width for margin */
gchar *laststyle;
const gchar *comment_single; /* single line comment */
const gchar *comment_blk_beg; /* blobk comment begin */
const gchar *comment_blk_end; /* block comment end */
#else
GtkTextBuffer *buffer;
#endif
GtkTextMark *cursor;
GtkWidget *eolLFMi; /* radio button references */
GtkWidget *eolCRLFMi; /* for EOL tools-menu */
GtkWidget *eolCRMi;
gint eol; /* end-of-line */
gint oeol; /* original eol */
gint eolos; /* operating system default eol */
gint eoldefault; /* default to override OS or file eol */
gboolean eolchg; /* flag to prevent firing during UI init */
gchar *eolnm[EOL_NO]; /* ptrs to eol names */
gchar *eolstr[EOL_NO]; /* ptrs to eol strings */
gchar *eoltxt[EOLTXT_NO]; /* ptrs to eol descriptions */
gint bom; /* Byte Order Mark */
/* UTF-8 bom: 0xEF 0xBB 0xBF (24-bit)
* UTF-16 bom: U+FEFF FE FF (16-bit Big Endian)
* FF FE (14-bit Little Endian)
* (see definitions in gtk_appdata.c)
*/
gint line;
gint lines;
gint col;
gint indent;
gint indentpl;
gint indentlevel;
gint tabstop;
gint softtab;
gchar *tabstring;
gboolean expandtab;
gboolean overwrite;
gboolean smartbs;
gboolean smarthe;
gboolean kphome;
gboolean showtabs;
gboolean dynwrap;
gboolean showdwrap;
gboolean wraptxtcsr;
gboolean pgudmvscsr;
gboolean indentwspc;
gboolean indentmixd;
gboolean indentauto;
gboolean posixeof;
gboolean trimendws;
gboolean poscurend;
// gboolean tabkeyindt; /* TODO: tab key indents */
gchar *comment; /* comment string */
GtkWidget *cmtentry; /* comment entry */
gboolean cmtusesingle; /* use single-line instead of block comment */
/* word completion keycnt, and cmpltnchars setting the number where completion dlg shown */
gint cmpltnchars; /* number of chars typed before completion win activates */
gint keycnt; /* counter tracking no. of keypress to reach cmpltnchars */
gboolean wrdcmpltn; /* settings flag to enable/disable word completion */
/* custom key handler flags */
gboolean ctrl_shift_right_fix; /* select only whitespace or char */
/* find replace dailog data */
GtkWidget *findrepwin; /* main window */
GtkWidget *entryfind; /* find entry combo */
GtkWidget *entryreplace; /* replace combo */
GtkWidget *btnregex;
GtkWidget *btnplace;
GtkWidget *btnfind; /* to allow set sensitive */
GtkWidget *btnreplace;
GtkWidget *chkregex;
GtkWidget *chkplace;
GtkWidget *chkcase;
GtkWidget *chkwhole;
GtkWidget *chkfrom;
GtkWidget *chkback;
GtkWidget *chkselect;
GtkWidget *chkprompt;
gchar **findtext; /* search term */
gchar **reptext; /* replace term */
guint nfentries;
guint nrentries;
guint fmax;
guint rmax;
gboolean optregex;
gboolean optplace;
gboolean optcase;
gboolean optwhole;
gboolean optfrom;
gboolean optback;
gboolean optselect;
gboolean optprompt;
gboolean findcbchgd; /* find combo box changed */
gboolean replcbchgd; /* replace combo box changed */
/* find/replace placeholders - TODO move to find/replace data struct */
GtkTextMark *markfrom, /* operation from mark */
*selstart, /* selection start/end */
*selend;
/* find replace results */
gboolean txtfound; /* prev search found text */
GtkTextMark *last_pos; /* position of last match in buf */
/* settings dialog */
GtkWidget *settingswin; /* settings notebook window */
/* print data */
GtkPrintSettings *printsettings;
GtkPageSetup *printpgsetup;
gdouble margintop; /* top print margin */
gdouble marginbottom; /* bottom print margin */
gdouble marginleft; /* left print margin */
gdouble marginright; /* right print margin */
/* variables for monitoring file
* changed by foreign process
*/
GFileMonitor *filemon; /* a pointer to the file monitor instance */
gchar *filemonfn; /* filename monitored, compare on save-as */
gboolean mfp_savecmd; /* flag causing change events ignored */
gulong mfp_handler; /* holding the file monitor hadler ID */
/* config data */
gchar *cfgdir; /* user config dir */
gchar *cfgfile; /* user config file */
GKeyFile *keyfile; /* key_file for config */
/* boolean stack implementation
* to provide keypress history.
*/
guint bstack[STKMAX]; /* sizeof guint * CHAR_BIT * STKMAX bits */
guint bindex; /* bit index */
} kwinst;
void context_init (kwinst *app, char **argv);
void findrep_init (kwinst *app);
void context_destroy (kwinst *app);
void split_fname (kwinst *app);
void findrep_destroy (kwinst *app);
void app_free_filename (kwinst *app);
gchar *uri_to_filename (const gchar *uri);
char *get_user_cfgfile (kwinst *app);
void delete_mark_last_pos (kwinst *app);
gchar *get_posix_filename (const gchar *fn);
gboolean create_new_editor_inst (kwinst *app, gchar *fn);
/* boolean stack functions */
void bstack_clear (kwinst *app);
int bstack_push (kwinst *app, int v);
int bstack_pop (kwinst *app);
int bstack_last (kwinst *app);
/* date & time functions */
gchar *get_local_datetime (void);
#endif