Disable "maintain history on reload" by default
[geany-mirror.git] / src / filetypes.h
blobb9591a14019abdc08f9a9a7f17a944fe03f6ee43
1 /*
2 * filetypes.h - this file is part of Geany, a fast and lightweight IDE
4 * Copyright 2005-2012 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5 * Copyright 2006-2012 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
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 2 of the License, or
10 * (at your option) any later version.
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.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #ifndef GEANY_FILETYPES_H
24 #define GEANY_FILETYPES_H 1
26 #include "geany.h" /* for GEANY() macro */
27 #include "tm_source_file.h" /* for langType */
29 #include "gtkcompat.h" /* Needed by ScintillaWidget.h */
30 #include "Scintilla.h" /* Needed by ScintillaWidget.h */
31 #include "ScintillaWidget.h" /* for ScintillaObject */
33 #include <glib.h>
36 G_BEGIN_DECLS
38 /* Forward-declared to avoid including document.h since it includes this header */
39 struct GeanyDocument;
41 /* Do not change the order, only append. */
42 typedef enum
44 GEANY_FILETYPES_NONE = 0, /* first filetype is always None & must be 0 */
46 GEANY_FILETYPES_PHP,
47 GEANY_FILETYPES_BASIC, /* FreeBasic */
48 GEANY_FILETYPES_MATLAB,
49 GEANY_FILETYPES_RUBY,
50 GEANY_FILETYPES_LUA,
51 GEANY_FILETYPES_FERITE,
52 GEANY_FILETYPES_YAML,
53 GEANY_FILETYPES_C,
54 GEANY_FILETYPES_NSIS,
55 GEANY_FILETYPES_GLSL,
56 GEANY_FILETYPES_PO,
57 GEANY_FILETYPES_MAKE,
58 GEANY_FILETYPES_TCL,
59 GEANY_FILETYPES_XML,
60 GEANY_FILETYPES_CSS,
61 GEANY_FILETYPES_REST,
62 GEANY_FILETYPES_HASKELL,
63 GEANY_FILETYPES_JAVA,
64 GEANY_FILETYPES_CAML,
65 GEANY_FILETYPES_AS,
66 GEANY_FILETYPES_R,
67 GEANY_FILETYPES_DIFF,
68 GEANY_FILETYPES_HTML,
69 GEANY_FILETYPES_PYTHON,
70 GEANY_FILETYPES_CS,
71 GEANY_FILETYPES_PERL,
72 GEANY_FILETYPES_VALA,
73 GEANY_FILETYPES_PASCAL,
74 GEANY_FILETYPES_LATEX,
75 GEANY_FILETYPES_ASM,
76 GEANY_FILETYPES_CONF,
77 GEANY_FILETYPES_HAXE,
78 GEANY_FILETYPES_CPP,
79 GEANY_FILETYPES_SH,
80 GEANY_FILETYPES_FORTRAN,
81 GEANY_FILETYPES_SQL,
82 GEANY_FILETYPES_F77,
83 GEANY_FILETYPES_DOCBOOK,
84 GEANY_FILETYPES_D,
85 GEANY_FILETYPES_JS,
86 GEANY_FILETYPES_VHDL,
87 GEANY_FILETYPES_ADA,
88 GEANY_FILETYPES_CMAKE,
89 GEANY_FILETYPES_MARKDOWN,
90 GEANY_FILETYPES_TXT2TAGS,
91 GEANY_FILETYPES_ABC,
92 GEANY_FILETYPES_VERILOG,
93 GEANY_FILETYPES_FORTH,
94 GEANY_FILETYPES_LISP,
95 GEANY_FILETYPES_ERLANG,
96 GEANY_FILETYPES_COBOL,
97 GEANY_FILETYPES_OBJECTIVEC,
98 GEANY_FILETYPES_ASCIIDOC,
99 GEANY_FILETYPES_ABAQUS,
100 GEANY_FILETYPES_BATCH,
101 GEANY_FILETYPES_POWERSHELL,
102 GEANY_FILETYPES_RUST,
103 GEANY_FILETYPES_COFFEESCRIPT,
104 GEANY_FILETYPES_GO,
105 GEANY_FILETYPES_ZEPHIR,
106 /* ^ append items here */
107 GEANY_MAX_BUILT_IN_FILETYPES /* Don't use this, use filetypes_array->len instead */
109 filetype_id;
111 typedef enum
113 GEANY_FILETYPE_GROUP_NONE,
114 GEANY_FILETYPE_GROUP_COMPILED,
115 GEANY_FILETYPE_GROUP_SCRIPT,
116 GEANY_FILETYPE_GROUP_MARKUP,
117 GEANY_FILETYPE_GROUP_MISC,
118 GEANY_FILETYPE_GROUP_COUNT
120 GeanyFiletypeGroupID;
123 /* Safe wrapper to get the id field of a possibly NULL filetype pointer.
124 * This shouldn't be necessary since GeanyDocument::file_type is always non-NULL. */
125 #define FILETYPE_ID(filetype_ptr) \
126 (((filetype_ptr) != NULL) ? (filetype_ptr)->id : GEANY_FILETYPES_NONE)
128 /** Represents a filetype. */
129 typedef struct GeanyFiletype
131 filetype_id id; /**< Index in @c filetypes_array. */
132 /** Represents the langType of tagmanager (see the table
133 * in tagmanager/parsers.h), -1 represents all, -2 none. */
134 langType lang;
135 /** Untranslated short name, such as "C", "None".
136 * Must not be translated as it's used for hash table lookups - use
137 * filetypes_get_display_name() instead. */
138 gchar *name;
139 /** Shown in the file open dialog, such as "C source file". */
140 gchar *title;
141 gchar *extension; /**< Default file extension for new files, or @c NULL. */
142 gchar **pattern; /**< Array of filename-matching wildcard strings. */
143 gchar *context_action_cmd;
144 gchar *comment_open;
145 gchar *comment_close;
146 gboolean comment_use_indent;
147 GeanyFiletypeGroupID group;
148 gchar *error_regex_string;
149 struct GeanyFiletype *lexer_filetype;
150 gchar *mime_type;
151 GIcon *icon;
152 gchar *comment_single; /* single-line comment */
153 /* filetype indent settings, -1 if not set */
154 gint indent_type;
155 gint indent_width;
157 struct GeanyFiletypePrivate *priv; /* must be last, append fields before this item */
159 GeanyFiletype;
161 extern GPtrArray *filetypes_array;
163 /** Wraps filetypes_array so it can be used with C array syntax.
164 * Example: filetypes[GEANY_FILETYPES_C]->name = ...;
165 * @see filetypes_index(). */
166 #define filetypes ((GeanyFiletype **)GEANY(filetypes_array)->pdata)
169 GeanyFiletype *filetypes_detect_from_file(const gchar *utf8_filename);
171 GeanyFiletype *filetypes_lookup_by_name(const gchar *name);
173 GeanyFiletype *filetypes_index(gint idx);
175 const gchar *filetypes_get_display_name(GeanyFiletype *ft);
177 const GSList *filetypes_get_sorted_by_name(void);
180 #ifdef GEANY_PRIVATE
182 extern GSList *filetypes_by_title;
185 GeanyFiletype *filetypes_find(GCompareFunc predicate, gpointer user_data);
188 void filetypes_init(void);
190 void filetypes_init_types(void);
192 void filetypes_reload_extensions(void);
194 void filetypes_reload(void);
197 GeanyFiletype *filetypes_detect_from_document(struct GeanyDocument *doc);
199 GeanyFiletype *filetypes_detect_from_extension(const gchar *utf8_filename);
201 void filetypes_free_types(void);
203 void filetypes_load_config(guint ft_id, gboolean reload);
205 void filetypes_save_commands(GeanyFiletype *ft);
207 void filetypes_select_radio_item(const GeanyFiletype *ft);
209 GtkFileFilter *filetypes_create_file_filter(const GeanyFiletype *ft);
211 GtkFileFilter *filetypes_create_file_filter_all_source(void);
213 gboolean filetype_has_tags(GeanyFiletype *ft);
215 gboolean filetypes_parse_error_message(GeanyFiletype *ft, const gchar *message,
216 gchar **filename, gint *line);
218 gboolean filetype_get_comment_open_close(const GeanyFiletype *ft, gboolean single_first,
219 const gchar **co, const gchar **cc);
221 #endif /* GEANY_PRIVATE */
223 G_END_DECLS
225 #endif /* GEANY_FILETYPES_H */