1 /* Bluefish HTML Editor
2  * bluefish.h - global prototypes
3  *
4  * Copyright (C) 1998 Olivier Sessink and Chris Mazuc
5  * Copyright (C) 1999-2017 Olivier Sessink
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19  */
20 /* indented with indent -ts4 -kr -l110   */
21 
22 /*#define IDENTSTORING*/
23 
24 /* #define HL_PROFILING */
25 /* if you define DEBUG here you will get debug output from all Bluefish parts */
26 /* #define DEBUG */
27 
28 #ifndef __BLUEFISH_H_
29 #define __BLUEFISH_H_
30 
31 /*#define MEMORY_LEAK_DEBUG*/
32 /*#define DEBUG_PATHS*/
33 
34 #define ENABLEPLUGINS
35 
36 #include "config.h"
37 
38 #ifndef DEVELOPMENT
39 #define G_DISABLE_ASSERT
40 #endif
41 
42 #define BLUEFISH_SPLASH_FILENAME PKGDATADIR"/bluefish_splash.png"
43 
44 #ifdef WIN32
45 #include <windows.h>
46 #ifdef EXE_EXPORT_SYMBOLS
47 #define EXPORT __declspec(dllexport)
48 #else							/* EXE_EXPORT_SYMBOLS */
49 #define EXPORT __declspec(dllimport)
50 #endif							/* EXE_EXPORT_SYMBOLS */
51 #else							/* WIN32 */
52 #define EXPORT
53 #endif							/* WIN32 */
54 
55 #ifdef HAVE_SYS_MSG_H
56 #ifdef HAVE_MSGRCV
57 #ifdef HAVE_MSGSND
58 /*#define WITH_MSG_QUEUE*/
59 #endif
60 #endif
61 #endif
62 
63 #ifdef HAVE_LOCALE_H
64 #include <locale.h>
65 #endif
66 
67 #ifdef DEBUG
68 #define DEBUG_MSG g_print
69 #define DEBUG_MSG_C g_critical
70 #define DEBUG_MSG_E g_error
71 #define DEBUG_MSG_W g_warning
72 #else							/* not DEBUG */
73 #if defined(__GNUC__) || defined(__SUNPRO_C) && (__SUNPRO_C > 0x580)
74 #define DEBUG_MSG(args...)
75 #define DEBUG_MSG_C(args...)
76 #define DEBUG_MSG_E(args...)
77 #define DEBUG_MSG_W(args...)
78  /**/
79 #else							/* notdef __GNUC__ || __SUNPRO_C */
80 extern void g_none(char * first, ...);
81 #define DEBUG_MSG g_none
82 #define DEBUG_MSG_C g_none
83 #define DEBUG_MSG_E g_none
84 #define DEBUG_MSG_W g_none
85 #endif							/* __GNUC__ || __SUNPRO_C */
86 #endif							/* DEBUG */
87 
88 #ifdef DEBUG_PATHS
89 #define DEBUG_PATH g_print
90 #else
91 #if defined(__GNUC__) || defined(__SUNPRO_C)
92 #define DEBUG_PATH(args...)
93  /**/
94 #else							/* notdef __GNUC__ || __SUNPRO_C */
95 extern void g_none(gchar * first, ...);
96 #endif							/* __GNUC__ || __SUNPRO_C */
97 #endif							/* DEBUG */
98 
99 #ifdef ENABLE_NLS
100 #include <glib/gi18n.h>
101 #else							/* ENABLE_NLS */
102 #define _(String)(String)
103 #define N_(String)(String)
104 #define ngettext(Msgid1, Msgid2, N) \
105 	((N) == 1 \
106 	? ((void) (Msgid2), (const char *) (Msgid1)) \
107 	: ((void) (Msgid1), (const char *) (Msgid2)))
108 #endif							/* ENABLE_NLS */
109 
110 
111 #ifdef WIN32
112 #define DIRSTR "\\"
113 #define DIRCHR 92
114 #else							/* WIN32 */
115 #define DIRSTR "/"
116 #define DIRCHR '/'
117 #endif							/* WIN32 */
118 
119 #include <sys/types.h>
120 #include <sys/stat.h>
121 #include <unistd.h>
122 #include <gio/gio.h>
123 #include <gtk/gtk.h>
124 #include "compatibility.h"
125 
126 #define BF_FILEINFO "standard::name,standard::display-name,standard::size,standard::type,unix::mode,unix::uid,unix::gid,time::modified,time::modified-usec,etag::value,standard::fast-content-type"
127 #include "bftextview2.h"
128 
129 #ifndef G_GOFFSET_FORMAT
130 #define G_GOFFSET_FORMAT G_GINT64_FORMAT
131 #endif
132 
133 
134 /*************************************/
135 /*** priorities for the main loop ****/
136 /*************************************/
137 /* #define DEBUG_SIGNALS */
138 #ifdef DEBUG_SIGNALS
139 #define DEBUG_SIG g_print
140 #else
141 #if defined(__GNUC__) || defined(__SUNPRO_C) && (__SUNPRO_C > 0x580)
142 #define DEBUG_SIG(args...)
143  /**/
144 #else							/* notdef __GNUC__ || __SUNPRO_C */
145 extern void g_none(char * first, ...);
146 #define DEBUG_SIG g_none
147 #endif							/* __GNUC__ || __SUNPRO_C */
148 #endif							/* DEBUG_SIGNALS */
149 
150 /*
151 G_PRIORITY_HIGH -100 			Use this for high priority event sources. It is not used within GLib or GTK+.
152 G_PRIORITY_DEFAULT 0 			Use this for default priority event sources. In GLib this priority is used when adding
153 										timeout functions with g_timeout_add().
154 G_PRIORITY_HIGH_IDLE 100 		Use this for high priority idle functions.
155 G_PRIORITY_DEFAULT_IDLE 200 	Use this for default priority idle functions. In GLib this priority is used when adding idle
156 										functions with g_idle_add().
157 G_PRIORITY_LOW 300
158 
159 GDK  uses   0 for events from the X server.
160 GTK+ uses 110 for resizing operations
161 GTK+ uses 120 for redrawing operations. (This is done to ensure
162 										that any pending resizes are processed before any pending
163 										redraws, so that widgets are not redrawn twice unnecessarily.)
164 */
165 
166 /* inserting data into a GtkTextBuffer should be in a lower priority than
167 the drawing of the GUI, otherwise the bluefish GUI won't show when loading
168 large files from the commandline.
169 I don't understand what it interacts with, but 145 is a too high priority
170 so set it lower to 155 */
171 #define FILEINTODOC_PRIORITY 155
172 #define FILE2DOC_PRIORITY 155
173 /* doc activate will stop scanning for the old document and schedule
174 for the new document. Set it between the X event (0) and the normal
175 gtk events (100) */
176 #define NOTEBOOKCHANGED_DOCACTIVATE_PRIORITY 50
177 /* set between a X event (0) and a normal event (100) */
178 #define SCANNING_IDLE_PRIORITY 10
179 /* set idle after timeout scanning to 115.
180 		a higher priority (109 is too high) makes bluefish go greyed-out
181 		(it will not redraw if required while the loop is running)
182 	   and a much lower priority (199 is too low) will first draw
183 	   all textstyles on screen before the next burst of scanning is done */
184 #define SCANNING_IDLE_AFTER_TIMEOUT_PRIORITY 115
185 /*  make sure that we don't scan or spellcheck a file that will be scanned again we do timeout
186 scanning in a lower priority timeout than the language file notice
187 so a newly loaded language file uses a priority 113 event to notice all documents to be rescanned. */
188 #define BUILD_LANG_FINISHED_PRIORITY 113
189 
190 #define BFLANGSCAN_FINISHED_PRIORITY 101
191 
192 #define BLUEFISH_STARTUP_IN_IDLE_PRIORITY (G_PRIORITY_DEFAULT_IDLE-50)
193 
194 /*********************/
195 /* undo/redo structs */
196 /*********************/
197 typedef enum {
198 	UndoDelete = 1, UndoInsert
199 } undo_op_t;
200 
201 typedef struct {
202 	gpointer next, prev; /* should equal BF_ELIST_HEAD as defined in bf_lib.h */
203 	gpointer entries;				/* the list of entries that should be undone in one action */
204 	gint32 changed;				/* doc changed status at this undo node */
205 	guint32 action_id;
206 } unregroup_t;
207 
208 typedef struct {
209 	gpointer first;
210 	gpointer last;
211 	unregroup_t *current;
212 	gpointer redofirst;
213 	gint num_groups;
214 } unre_t;
215 
216 /*****************************************************/
217 /* filter struct - used in filebrowser2 and gtk_easy */
218 /*****************************************************/
219 typedef struct {
220 	gchar *name;
221 	GHashTable *filetypes;		/* hash table with mime types */
222 	GList *patterns;
223 	gushort refcount;
224 	gushort mode;				/* 0= hide matching files, 1=show matching files */
225 } Tfilter;
226 
227 /********************************************************************/
228 /* document struct, used everywhere, most importantly in document.c */
229 /********************************************************************/
230 #define BFWIN(var) ((Tbfwin *)(var))
231 #define DOCUMENT(var) ((Tdocument *)(var))
232 #define CURDOC(bfwin) ((Tdocument *)bfwin->current_document)
233 
234 typedef enum {
235 	DOC_STATUS_ERROR,
236 	DOC_STATUS_LOADING,
237 	DOC_STATUS_COMPLETE,
238 	DOC_CLOSING
239 } Tdocstatus;
240 
241 typedef struct {
242 	GFile *uri;
243 	GFileInfo *fileinfo;
244 	Tdocstatus status;			/* can be DOC_STATUS_ERROR, DOC_STATUS_LOADING, DOC_STATUS_COMPLETE, DOC_CLOSING */
245 	gchar *encoding;
246 	gint modified;
247 
248 	/* if an action is set, this action has to be executed after the document finishing closing/opening */
249 	gpointer save;				/* during document save */
250 	gpointer info;				/* during update of the fileinfo */
251 	gpointer checkmodified;		/* during check modified on disk checking */
252 	gpointer load;				/* during load */
253 	gint goto_line;
254 	gint goto_offset;
255 	gboolean align_center; /* how to align textview after offseting it */
256 	gint cursor_offset; /* cursor position in textview */
257 	gboolean load_first; /*sets priority of async loading */
258 	gushort close_doc;
259 	gushort close_window;
260 
261 	GList *need_autosave;		/* if autosave is needed, a direct pointer to main_v->need_autosave; */
262 	GList *autosave_progress;
263 	gpointer autosave_action;
264 	GList *autosaved;			/* NULL if no autosave registration, else this is a direct pointer into the main_v->autosave_journal list */
265 	GFile *autosave_uri;		/* if autosaved, the URI of the autosave location, else NULL */
266 	gint readonly;
267 	gboolean block_undo_reg; 	/* block the registration for undo */
268 	guint newdoc_autodetect_lang_id;	/* a timer function that runs for new documents to detect their mime type  */
269 	unre_t unre;
270 	GtkWidget *view;
271 	GtkWidget *slave; /* used in split view for the bottom view */
272 	GtkWidget *vsplit; /* used for split view */
273 	GtkWidget *tab_modlabel;
274 	GtkWidget *tab_label;
275 	GtkWidget *tab_eventbox;
276 	GtkWidget *tab_menu;
277 	GtkTextBuffer *buffer;
278 	gboolean in_paste_operation;
279 	gboolean highlightstate;	/* does this document use highlighting ? */
280 	gpointer floatingview;		/* a 2nd textview widget that has its own window */
281 	gpointer bfwin;
282 	GList *recentpos; 	/* this points to the list element in the recent used tabs (bfwin->recentdoclist) that points to this Tdocument */
283 	GtkTreeIter *bmark_parent;	/* if NULL this document doesn't have bookmarks, if
284 								   it does have bookmarks they are children of this GtkTreeIter */
285 } Tdocument;
286 
287 typedef struct {
288 	gchar *config_version; /* bluefish version string */
289 	gint check_for_modified_on_disk; /* 0= never, 1= periodically, 2=only during save */
290 	gchar *editor_font_string;	/* editor font */
291 	gint editor_smart_cursor;
292 	gint editor_tab_indent_sel; /* tab key will indent a selected block */
293 	gint editor_auto_close_brackets;
294 	gint editor_replace_unicode_quotes;
295 	gint editor_spacingtoclick;
296 	gint use_system_tab_font;
297 	gint max_shown_filename_len; /* the maximum length for the filename shown in the tab */
298 	gchar *tab_font_string;		/* notebook tabs font */
299 	gchar *tab_color_active;
300 	gchar *tab_color_modified;	/* tab text color when doc is modified and unsaved */
301 	gchar *tab_color_loading;	/* tab text color when doc is loading */
302 	gchar *tab_color_error;		/* tab text color when doc has errors */
303 	gint visible_ws_mode;
304 	/* new replacements: */
305 	GList *external_command;	/* array: name,command,is_default_browser */
306 	GList *external_filter;		/* array: name,command */
307 	GList *external_outputbox;	/* array:name,command,....... */
308 	/*gint defaulthighlight; *//* highlight documents by default */
309 	gint leave_to_window_manager;	/* don't set any dimensions, leave all to window manager */
310 	gint restore_dimensions;	/* use the dimensions as used the previous run */
311 	gint left_panel_left;		/* 1 = left, 0 = right */
312 	gint hide_bars_on_fullscreen;
313 	gint cursor_size;
314 	gint highlight_cursor;
315 	gint save_accelmap; 	/* save the accelerator map on exit */
316 	gint max_recent_files;		/* length of Open Recent list */
317 	gint max_dir_history;		/* length of directory history */
318 	gint backup_file;			/* wheather to use a backup file */
319 	gint show_long_line_warning;
320 	/* GIO has hardcoded backup file names */
321 /*	gchar *backup_suffix;  / * the string to append to the backup filename */
322 /*	gchar *backup_prefix;  / * the string to prepend to the backup filename (between the directory and the filename) */
323 	gint backup_abort_action;	/* if the backup fails, 0=continue save  , 1=abort save, 2=ask the user */
324 	gint backup_cleanuponclose;	/* remove the backupfile after close ? */
325 	gchar *image_thumbnailstring;	/* string to append to thumbnail filenames */
326 	gchar *image_thumbnailtype;	/* fileformat to use for thumbnails, "jpeg" or "png" can be handled by gdkpixbuf */
327 	gint modified_check_type;	/* 0=no check, 1=by mtime and size, 2=by mtime, 3=by size, 4,5,...not implemented (md5sum?) */
328 	gint num_undo_levels;		/* number of undo levels per document */
329 	gint clear_undo_on_save;	/* clear all undo information on file save */
330 	gchar *newfile_default_encoding;	/* if you open a new file, what encoding will it use */
331 	gint auto_set_encoding_meta;	/* auto set metatag for the encoding */
332 	gint auto_update_meta_author;	/* auto update author meta tag on save */
333 	gint auto_update_meta_date;	/* auto update date meta tag on save */
334 	gint auto_update_meta_generator;	/* auto update generator meta tag on save */
335 	gint strip_trailing_spaces_on_save;
336 	gint encoding_search_Nbytes;	/* number of bytes to look for the encoding meta tag */
337 	gint max_window_title; /* max. number of chars in the window title */
338 	gint document_tabposition;
339 	gint leftpanel_tabposition;
340 	gint switch_tabs_by_altx;
341 	gchar *project_suffix;
342 	/* not yet in use */
343 	gint allow_dep;				/* allow <FONT>... */
344 	gint format_by_context;		/* use <strong> instead of <b>, <emphasis instead of <i> etc. (W3C reccomendation) */
345 	gint smartindent;			/* add extra indent in certain situations */
346 	/* key conversion */
347 	gint open_in_running_bluefish;	/* open commandline documents in already running process */
348 	gint open_in_new_window;	/* open commandline files in a new window as opposed to an existing window */
349 #ifdef WIN32
350 	gint win32_ipcport;			/* tcpip port used for ipc on win32 */
351 #endif
352 	gint register_recent_mode; /* 0=none,1=all,2=project only*/
353 	gint recent_means_recently_closed;
354 	GList *plugin_config;		/* array, 0=filename, 1=enabled, 2=name */
355 	gint use_system_colors;
356 	gchar *btv_color_str[BTV_COLOR_COUNT];	/* editor colors */
357 	GList *textstyles;			/* text styles: name,foreground,background,weight,style */
358 	gint block_folding_mode;
359 	GList *highlight_styles;
360 	GList *bflang_options;		/* array with: lang_name, option_name, value */
361 #ifdef WIN32
362 	GList *file_association;	/* array, 0=ignored, 1=extension, 2=mimetype */
363 #endif
364 	gchar *autocomp_accel_string;
365 	gboolean load_reference;
366 	gboolean show_autocomp_reference;
367 	gboolean show_tooltip_reference;
368 	gboolean delay_full_scan;
369 	gint delay_scan_time;
370 	gint autocomp_popup_mode;	/* delayed or immediately */
371 	gint autocomp_min_prefix_len; /* minimum number of matching characters before autocomp is activated */
372 	gboolean reduced_scan_triggers;
373 	gint autosave;
374 	gint autosave_time;
375 	gint autosave_location_mode;	/* 0=~/.bluefish/autosave/, 1=original basedir */
376 	gchar *autosave_file_prefix;
377 	gchar *autosave_file_suffix;
378 	gchar *language;
379 	gint rcfile_from_old_version;
380 	gint right_margin_pos;
381 	gint adv_textview_right_margin; /* advanced option for the amount of whitespace inside the textview widget */
382 	gboolean wrap_on_right_margin; /* sets adv_textview_right_margin dynamically based on right_margin_pos */
383 	gint adv_textview_left_margin; /* advanced option for the amount of whitespace inside the textview widget */
384 	gint adv_smart_indent_mode; /* advanced option for advanced indent mode, normal=1, but if set to 2 the editor
385 											will outdent if the previous character was a closing bracket */
386 } Tproperties;
387 
388 /* the Tglobalsession contains all settings that can change
389 over every time you run Bluefish, so things that *need* to be
390 saved after every run! */
391 typedef struct {
392 	gint main_window_h;			/* main window height */
393 	gint main_window_w;			/* main window width */
394 	gint two_pane_filebrowser_height;	/* position of the pane separater on the two paned file browser */
395 	gint left_panel_width;		/* width of filelist */
396 	gint print_headers;
397 	gint print_linenumbers;
398 	gchar *print_fontstring;
399 	gint bookmarks_default_store;	/* 0= temporary by default, 1= permanent by default */
400 	gint image_thumbnail_refresh_quality;	/* 1=GDK_INTERP_BILINEAR, 0=GDK_INTERP_NEAREST */
401 	gint image_thumbnailsizing_type;	/* scaling ratio=0, fixed width=1, height=2, width+height (discard aspect ratio)=3 */
402 	gint image_thumbnailsizing_val1;	/* the width, height or ratio, depending on the value above */
403 	gint image_thumbnailsizing_val2;	/* height if the type=3 */
404 	gchar *image_thumnailformatstring;	/* like <a href="%r"><img src="%t"></a> or more advanced */
405 	gint filter_on_selection_mode; /* 0=ask, 1=selection, 2=text */
406 	gchar *last_project_dir;
407 	GList *filefilters;			/* filefilter.c file filtering */
408 	GList *reference_files;		/* all reference files */
409 	GList *recent_projects;
410 	GList *encodings;			/* all encodings you can choose from, array with 0=human name, 1=name, 2="0" or "1" if it should be user visible or not */
411 	GList *custombflangmime; /* bflang name - mime type name */
412 #ifdef WITH_MSG_QUEUE
413 	gint msg_queue_poll_time;	/* milliseconds, automatically tuned to your system */
414 #endif
415 } Tglobalsession;
416 
417 typedef struct {
418 	gint enable_syntax_scan; /* syntax scan by default */
419 	gint wrap_text_default;		/* by default wrap text */
420 	gint autoindent;			/* autoindent code */
421 	gint editor_tab_width;		/* editor tabwidth */
422 	gint editor_indent_wspaces;	/* indent with spaces, not tabs */
423 	gint view_line_numbers;		/* view line numbers on the left side by default */
424 	gint view_cline;			/* highlight current line by default */
425 	gint view_blocks;			/* show blocks on the left side by default */
426 	gint view_blockstack;
427 	gint autocomplete;			/* whether or not to enable autocomplete by default for each new document */
428 	gint show_mbhl;				/* show matching block begin-end by default */
429 
430 	/* snr3 advanced search and replace */
431 	gint snr3_type;
432 	gint snr3_replacetype;
433 	gint snr3_scope;
434 	gint snr3_casesens;
435 	gint snr3_showinoutputbox;
436 	gint snr3_ignorebackupfiles;
437 	gint snr3_escape_chars;
438 	gint snr3_dotmatchall;
439 	gint snr3_recursion_level;
440 	/* simplesearch options */
441 	gint ssearch_regex;
442 	gint ssearch_dotmatchall;
443 	gint ssearch_unescape;
444 	gint ssearch_casesens;
445 
446 	gint sync_delete_deprecated;
447 	gint sync_include_hidden;
448 	gint sync_include_backup;
449 	gint adv_open_matchname;
450 	gint adv_open_recursive;
451 	gint bookmarks_filename_mode;	/* 0=FULLPATH, 1=DIR FROM BASE 2=BASENAME */
452 	gint bookmarks_show_mode;	/* 0=both,1=name,2=content */
453 	gint bmarksearchmode;
454 	gint filebrowser_focus_follow;	/* have the directory of the current document in focus */
455 	gint filebrowser_show_backup_files;
456 	gint filebrowser_show_hidden_files;
457 	gint filebrowser_viewmode;	/* 0=tree, 1=dual or 2=flat */
458 	gint snr_position_x;
459 	gint snr_position_y;
460 	gint leftpanel_active_tab;
461 	gint view_left_panel;		/* view filebrowser/functionbrowser etc. */
462 	gint view_main_toolbar;		/* view main toolbar */
463 	gint view_statusbar;
464 	gint outputb_scroll_mode;	/* 0=none, 1=first line, 2= last line */
465 	gint outputb_show_all_output;
466 	gint convertcolumn_horizontally;
467 	gint display_right_margin;
468 	gint show_visible_spacing;
469 	/* 47 * sizeof(gint) */
470 	/* IF YOU EDIT THIS STRUCTURE PLEASE EDIT THE CODE IN PROJECT.C THAT COPIES
471 	   A Tsessionvar INTO A NEW Tsessionvar AND ADJUST THE SIZES!!!!!!!!!!!!!!!!!!!!!! */
472 #ifdef HAVE_LIBENCHANT
473 	gint spell_check_default;
474 	gint spell_insert_entities;
475 	gchar *spell_lang;
476 #endif
477 	/* if you add strings or lists to the session, please make sure they are free'ed
478 	in free_session() in project.c */
479 	gchar *snr3_filepattern;
480 	gchar *snr3_basedir;
481 	gchar *ssearch_text;
482 	gchar *default_mime_type;
483 	gchar *template;
484 	gchar *convertcolumn_separator;
485 	gchar *convertcolumn_fillempty;
486 	gchar *webroot;
487 	gchar *documentroot;
488 	gchar *encoding;
489 	gchar *last_filefilter;		/* last filelist filter type */
490 	gchar *opendir;
491 	gchar *savedir;
492 	gchar *sync_local_uri;
493 	gchar *sync_remote_uri;
494 	GList *bmarks;
495 	GList *classlist;
496 	GList *colorlist;
497 	GList *fontlist;
498 	GList *positionlist;		/* is this used ?? */
499 	GList *recent_dirs;
500 	GList *recent_files;
501 	GList *replacelist;			/* used in snr2 */
502 	GList *searchlist;			/* used in snr2 and for advanced_open */
503 	GList *filegloblist; /* file glob filters in advanced open and search in files */
504 	GList *snr3_basedir_history;
505 	GList *targetlist;
506 	GList *urllist;
507 } Tsessionvars;
508 
509 typedef struct {
510 	GFile *uri;
511 	gchar *name;
512 	GList *files;
513 	gpointer editor;
514 	Tsessionvars *session;
515 	gpointer bmarkdata;			/* project bookmarks */
516 	gboolean close;				/* if this is TRUE, it means the project is saved and all,
517 								   so after all documents are closed it just just be cleaned up and discarded */
518 } Tproject;
519 
520 typedef struct {
521 	Tsessionvars *session;		/* points to the global session, or to the project session */
522 	Tdocument *current_document;	/* one object out of the documentlist, the current visible document */
523 	gboolean focus_next_new_doc;	/* for documents loading in the background, switch to the first that is finished loading */
524 	gint num_docs_not_completed;	/* number of documents that are loading or closing */
525 	GList *documentlist;		/* document.c and others: all Tdocument objects in the order of the tabs */
526 	GList *recentdoclist; /* all Tdocument objects with the most recently used on top, every Tdocument has a pointer to it's own list element called doc->recentpos */
527 	Tdocument *last_activated_doc;
528 	Tproject *project;			/* might be NULL for a default project */
529 	GtkWidget *main_window;
530 	GtkWidget *toolbarbox;		/* vbox on top, with main and html toolbar */
531 
532 	/* Main Menus & toolbar */
533 	GtkUIManager *uimanager;
534 	GtkActionGroup *globalGroup;
535 	GtkActionGroup *documentGroup;
536 	GtkActionGroup *editGroup;
537 	GtkActionGroup *findReplaceGroup;
538 	GtkActionGroup *projectGroup;
539 	GtkActionGroup *undoGroup;
540 	GtkActionGroup *bookmarkGroup;
541 	GtkActionGroup *filebrowserGroup;
542 	guint filebrowser_merge_id;
543 
544 	GtkWidget *menubar;
545 	gint last_notebook_page;	/* a check to see if the notebook changed to a new page */
546 	guint notebook_changed_doc_activate_id;
547 	guint statusbar_pop_id;
548 	guint notebook_switch_signal;
549 	guint update_searchhistory_idle_id;
550 	GtkWidget *gotoline_entry;
551 	GtkWidget *simplesearch_combo;
552 	GtkWidget *simplesearch_regex;
553 	GtkWidget *simplesearch_casesens;
554 	GtkWidget *simplesearch_dotmatchall;
555 	GtkWidget *simplesearch_unescape;
556 	gpointer simplesearch_snr3run;
557 	GtkWidget *notebook;
558 	GtkWidget *notebook_fake;
559 	GtkWidget *notebook_box;	/* Container for notebook and notebook_fake */
560 	GtkWidget *middlebox;		/* holds the document notebook, OR the hpaned with the left panel AND the document notebook */
561 	GtkWidget *vpane;			/* holds the middlebox AND the outputbox (which might be NULL) */
562 	GtkWidget *hpane;			/* we need this to show/hide the filebrowser */
563 	GtkWidget *statusbar;
564 	GtkWidget *statusbar_lncol;	/* where we have the line number */
565 	GtkWidget *statusbar_insovr;	/* insert/overwrite indicator */
566 	GtkWidget *statusbar_editmode;	/* editor mode and doc encoding */
567 	/* the following list contains toolbar widgets we like to reference later on */
568 	GtkWidget *toolbar_quickbar;	/* the quickbar widget */
569 	GList *toolbar_quickbar_children;	/* this list is needed to remove widgets from the quickbar */
570 	/* following widgets are used to show/hide stuff */
571 	GtkWidget *main_toolbar_hb;
572 	GtkWidget *html_toolbar_hb;
573 	GtkWidget *leftpanel_notebook;
574 	GtkWidget *gotoline_frame;
575 	/* action based dynamic menus */
576 	GtkActionGroup *templates_group;
577 	guint templates_merge_id;
578 	GtkActionGroup *lang_mode_group;
579 	guint lang_mode_merge_id;
580 	GtkActionGroup *commands_group;
581 	guint commands_merge_id;
582 	GtkActionGroup *filters_group;
583 	guint filters_merge_id;
584 	GtkActionGroup *outputbox_group;
585 	guint outputbox_merge_id;
586 	GtkActionGroup *encodings_group;
587 	guint encodings_merge_id;
588 	GtkActionGroup *recent_group;
589 	GtkActionGroup *fb2_filters_group;
590 	guint fb2_filters_merge_id;
591 #ifdef HAVE_LIBENCHANT
592 	gpointer *ed;				/* EnchantDict */
593 #endif
594 	/* following is a new approach, that we have only a gpointer here, whioh is typecasted
595 	   in the file where it is needed */
596 	gpointer outputbox;
597 	gpointer bfspell;
598 	gpointer fb2;				/* filebrowser2 gui */
599 	gpointer snr2;
600 	GtkTreeView *bmark;
601 	GtkTreeModelFilter *bmarkfilter;
602 	gchar *bmark_search_prefix;
603 	gpointer bmarkdata;			/* a link to the global main_v->bmarkdata, OR project->bmarkdata */
604 #ifdef IDENTSTORING
605 	GHashTable *identifier_jump;
606 	GHashTable *identifier_ac;
607 #endif /* IDENTSTORING */
608 	GSList *curdoc_changed; /* register a CurdocChangedCallback function here that is called when the current document changes*/
609 	GSList *doc_insert_text; /* register a DocInsertTextCallback function here that is called when text is inserted into a document */
610 	GSList *doc_delete_range; /* register a DocDeleteRangeCallback function here that is called when text is deleted from a document */
611 	GSList *doc_destroy; /* register a DocDestroyCallback function here that is called when a document is destroyed  */
612 } Tbfwin;
613 
614 typedef struct {
615 	Tbfwin *firstbfwin;
616 	GList *filenames;
617 	guint state;
618 #ifdef MAC_INTEGRATION
619 	GMainLoop *startup_main_loop;
620 #endif
621 } Tstartup;
622 
623 typedef struct {
624 	Tproperties props;			/* preferences */
625 	gpointer prefdialog;		/* preferences window, there should be only 1 */
626 	Tglobalsession globses;		/* global session */
627 	GList *autosave_journal;	/* holds an arraylist with autosaved documents */
628 	gboolean autosave_need_journal_save;
629 	GList *need_autosave;		/* holds Tdocument pointers */
630 	GList *autosave_progress;	/* holds Tdocument pointers that are being saved right now */
631 	guint autosave_id;			/* used with g_timeout_add */
632 	guint periodic_check_id;	/* used with g_timeout_add */
633 	GList *bfwinlist;
634 	GHashTable *alldochash;			/* hash table with uri as key and Tdocument as value */
635 	Tsessionvars *session;		/* holds all session variables for non-project windows */
636 	gpointer fb2config;			/* filebrowser2config */
637 	GList *filefilters;			/* initialized by fb2config functions */
638 	GList *templates; 			/* loaded in rcfile.c */
639 	Tdocument *bevent_doc;
640 	gint bevent_charoffset; 	/* for example used in the spellcheck code to find on which
641 											word the user clicked */
642 	guint autocomp_accel_key;				 /* by default <ctrl><space> activates autocompletion */
643 	GdkModifierType autocomp_accel_mods; /* but this shortcut is also used to switch input languages for example by chinese users */
644 	gpointer bmarkdata;
645 	gint num_untitled_documents;
646 	gchar *securedir;			/* temporary rwx------ directory for secure file creation */
647 	GtkRecentManager *recentm;
648 	GSList *plugins;
649 	GSList *doc_view_populate_popup_cbs;	/* plugins can register functions here that need to
650 											   be called when the right-click menu in the document is populated */
651 	GSList *doc_view_button_press_cbs;	/* plugins can register functions here that are called on a button press
652 										   in a document */
653 	GSList *sidepanel_initgui;	/* plugins can register a function here that is called when the side pane
654 								   is initialized */
655 	GSList *sidepanel_destroygui;	/* plugins can register a function here that is called when the side pane
656 									   is destroyed */
657 	GSList *pref_initgui; /* register a PrefInitguiCallback function here to add a preferences panel */
658 	GSList *pref_apply; /* PrefApplyCallback */
659 #ifdef MAC_INTEGRATION
660 	gint osx_status; /* 0- normal operation, 1- osx app is terminating, 2-osx app is suspended (only app menu visible). */
661 #endif
662 } Tmain;
663 
664 extern EXPORT Tmain *main_v;
665 
666 /* public functions from bluefish.c */
667 void bluefish_exit_request(void);
668 
669 #endif							/* __BLUEFISH_H_ */
670