2005-11-22 12:26:26 +00:00
|
|
|
/*
|
|
|
|
* document.h - this file is part of Geany, a fast and lightweight IDE
|
|
|
|
*
|
2006-01-11 18:38:17 +00:00
|
|
|
* Copyright 2006 Enrico Troeger <enrico.troeger@uvena.de>
|
2005-11-22 12:26:26 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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
|
2006-05-10 23:06:47 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-11-22 12:26:26 +00:00
|
|
|
*
|
2005-12-29 19:50:50 +00:00
|
|
|
* $Id$
|
2005-11-22 12:26:26 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef GEANY_DOCUMENT_H
|
|
|
|
#define GEANY_DOCUMENT_H 1
|
|
|
|
|
2006-08-20 20:39:59 +00:00
|
|
|
#ifndef PLAT_GTK
|
|
|
|
# define PLAT_GTK 1 // needed for ScintillaWidget.h
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "Scintilla.h"
|
|
|
|
#include "ScintillaWidget.h"
|
|
|
|
|
2006-08-20 15:47:18 +00:00
|
|
|
#include "geany.h"
|
2006-08-20 20:39:59 +00:00
|
|
|
#include "filetypes.h"
|
|
|
|
|
2006-09-02 20:49:11 +00:00
|
|
|
|
|
|
|
#define DOC_IDX_VALID(idx) \
|
2006-08-20 20:39:59 +00:00
|
|
|
((idx) >= 0 && (idx) < GEANY_MAX_OPEN_FILES && doc_list[idx].is_valid)
|
|
|
|
|
2006-08-20 15:47:18 +00:00
|
|
|
|
|
|
|
/* structure for representing an open tab with all its related stuff. */
|
|
|
|
typedef struct document
|
|
|
|
{
|
|
|
|
gboolean is_valid;
|
|
|
|
gboolean has_tags;
|
|
|
|
// the filename is encoded in UTF-8, but every GLibC function expect the locale representation
|
|
|
|
gchar *file_name;
|
|
|
|
gchar *encoding;
|
|
|
|
gboolean has_bom;
|
|
|
|
filetype *file_type;
|
|
|
|
TMWorkObject *tm_file;
|
|
|
|
ScintillaObject *sci;
|
|
|
|
GtkWidget *tab_label;
|
|
|
|
GtkWidget *tabmenu_label;
|
|
|
|
GtkWidget *tag_tree;
|
|
|
|
GtkTreeStore *tag_store;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gboolean readonly;
|
|
|
|
gboolean changed;
|
|
|
|
gboolean do_overwrite;
|
|
|
|
gboolean line_breaking;
|
|
|
|
gboolean use_auto_indention;
|
|
|
|
time_t last_check; // to remember the last disk check
|
|
|
|
time_t mtime;
|
|
|
|
} document;
|
|
|
|
|
|
|
|
|
|
|
|
/* array of document elements to hold all information of the notebook tabs */
|
|
|
|
document doc_list[GEANY_MAX_OPEN_FILES];
|
|
|
|
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
/* returns the index of the notebook page which has the given filename */
|
2006-06-07 21:24:15 +00:00
|
|
|
gint document_find_by_filename(const gchar*, gboolean is_tm_filename);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* returns the index of the notebook page which has sci */
|
|
|
|
gint document_find_by_sci(ScintillaObject*);
|
|
|
|
|
|
|
|
|
|
|
|
/* returns the index of the current notebook page in the document list */
|
2006-09-02 20:49:11 +00:00
|
|
|
gint document_get_cur_idx();
|
|
|
|
|
|
|
|
/* returns NULL if no documents are open */
|
|
|
|
document *document_get_current();
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* returns the index of the given notebook page in the document list */
|
2006-01-11 18:38:17 +00:00
|
|
|
gint document_get_n_idx(guint);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* returns the next free place(i.e. index) in the document list
|
|
|
|
* If there is for any reason no free place, -1 is returned */
|
2006-09-02 20:49:11 +00:00
|
|
|
gint document_get_new_idx();
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* changes the color of the tab text according to the status */
|
|
|
|
void document_change_tab_color(gint);
|
|
|
|
|
|
|
|
|
|
|
|
void document_set_text_changed(gint);
|
|
|
|
|
|
|
|
|
2006-01-11 18:38:17 +00:00
|
|
|
/* sets in all document structs the flag is_valid to FALSE and initializes some members to NULL,
|
|
|
|
* to mark it uninitialized. The flag is_valid is set to TRUE in document_create_new_sci(). */
|
2006-09-02 20:49:11 +00:00
|
|
|
void document_init_doclist();
|
2006-01-11 18:38:17 +00:00
|
|
|
|
|
|
|
|
2006-08-01 13:24:58 +00:00
|
|
|
// Apply just the prefs that can change in the Preferences dialog
|
|
|
|
void document_apply_update_prefs(ScintillaObject *sci);
|
|
|
|
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
/* creates a new tab in the notebook and does all related stuff
|
|
|
|
* finally it returns the index of the created document */
|
|
|
|
gint document_create_new_sci(const gchar*);
|
|
|
|
|
|
|
|
|
|
|
|
/* removes the given notebook tab and clears the related entry in the document
|
|
|
|
* list */
|
2006-01-11 18:38:17 +00:00
|
|
|
gboolean document_remove(guint);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* This creates a new document, by clearing the text widget and setting the
|
|
|
|
current filename to NULL. */
|
|
|
|
void document_new_file(filetype *ft);
|
|
|
|
|
|
|
|
|
|
|
|
/* If idx is set to -1, it creates a new tab, opens the file from filename and
|
|
|
|
* set the cursor to pos.
|
|
|
|
* If idx is greater than -1, it reloads the file in the tab corresponding to
|
2006-06-11 22:39:11 +00:00
|
|
|
* idx and set the cursor to position 0. In this case, filename should be NULL
|
|
|
|
* It returns the idx of the opened file or -1 if an error occurred.
|
2005-11-22 12:26:26 +00:00
|
|
|
*/
|
2006-07-22 02:06:30 +00:00
|
|
|
int document_open_file(gint, const gchar*, gint, gboolean, filetype*, const gchar*);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2006-07-22 02:06:30 +00:00
|
|
|
int document_reload_file(gint idx, const gchar *forced_enc);
|
2006-06-20 11:55:34 +00:00
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2006-08-02 10:50:53 +00:00
|
|
|
/* This saves the file.
|
|
|
|
* When force is set then it is always saved, even if it is unchanged(useful when using Save As) */
|
|
|
|
void document_save_file(gint, gboolean force);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2006-07-20 21:19:18 +00:00
|
|
|
/* special search function, used from the find entry in the toolbar */
|
|
|
|
void document_find_next(gint, const gchar*, gint, gboolean, gboolean);
|
|
|
|
|
|
|
|
/* General search function, used from the find dialog.
|
|
|
|
* Returns -1 on failure or the start position of the matching text. */
|
|
|
|
gint document_find_text(gint idx, const gchar *text, gint flags, gboolean search_backwards);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
void document_replace_text(gint, const gchar*, const gchar*, gint, gboolean);
|
|
|
|
|
2006-09-02 23:28:34 +00:00
|
|
|
void document_replace_all(gint, const gchar*, const gchar*, gint, gboolean);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2006-09-02 23:28:34 +00:00
|
|
|
void document_replace_sel(gint, const gchar*, const gchar*, gint, gboolean);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2006-06-13 19:37:21 +00:00
|
|
|
void document_set_font(gint, const gchar*, gint);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2006-05-10 23:06:47 +00:00
|
|
|
void document_update_tag_list(gint, gboolean);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
void document_set_filetype(gint, filetype*);
|
|
|
|
|
|
|
|
gchar *document_get_eol_mode(gint);
|
|
|
|
|
|
|
|
gchar *document_prepare_template(filetype *ft);
|
|
|
|
|
2006-02-26 18:19:28 +00:00
|
|
|
void document_fold_all(gint idx);
|
|
|
|
|
|
|
|
void document_unfold_all(gint idx);
|
|
|
|
|
2006-06-13 19:37:21 +00:00
|
|
|
void document_set_indicator(gint idx, gint line);
|
|
|
|
|
|
|
|
void document_clear_indicators(gint idx);
|
|
|
|
|
2006-06-29 17:14:52 +00:00
|
|
|
/* simple file print */
|
|
|
|
void document_print(gint idx);
|
|
|
|
|
2006-07-17 10:42:26 +00:00
|
|
|
void document_replace_tabs(gint idx);
|
|
|
|
|
|
|
|
void document_strip_trailing_spaces(gint idx);
|
|
|
|
|
|
|
|
void document_ensure_final_newline(gint idx);
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
#endif
|