Remove unnecessary use of AH_TEMPLATE
[geany-mirror.git] / src / filetypes.h
blobaafac816cc1d493a950c70a88e41cce5a26b91b4
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_parser.h" /* for TMParserType */
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 /** IDs of known filetypes
43 * @ref filetypes will contain an item for each. Use GeanyData::filetypes_array to
44 * determine the known filetypes at runtime */
45 typedef enum
47 GEANY_FILETYPES_NONE = 0, /* first filetype is always None & must be 0 */
49 GEANY_FILETYPES_PHP,
50 GEANY_FILETYPES_BASIC, /* FreeBasic */
51 GEANY_FILETYPES_MATLAB,
52 GEANY_FILETYPES_RUBY,
53 GEANY_FILETYPES_LUA,
54 GEANY_FILETYPES_FERITE,
55 GEANY_FILETYPES_YAML,
56 GEANY_FILETYPES_C,
57 GEANY_FILETYPES_NSIS,
58 GEANY_FILETYPES_GLSL,
59 GEANY_FILETYPES_PO,
60 GEANY_FILETYPES_MAKE,
61 GEANY_FILETYPES_TCL,
62 GEANY_FILETYPES_XML,
63 GEANY_FILETYPES_CSS,
64 GEANY_FILETYPES_REST,
65 GEANY_FILETYPES_HASKELL,
66 GEANY_FILETYPES_JAVA,
67 GEANY_FILETYPES_CAML,
68 GEANY_FILETYPES_AS,
69 GEANY_FILETYPES_R,
70 GEANY_FILETYPES_DIFF,
71 GEANY_FILETYPES_HTML,
72 GEANY_FILETYPES_PYTHON,
73 GEANY_FILETYPES_CS,
74 GEANY_FILETYPES_PERL,
75 GEANY_FILETYPES_VALA,
76 GEANY_FILETYPES_PASCAL,
77 GEANY_FILETYPES_LATEX,
78 GEANY_FILETYPES_ASM,
79 GEANY_FILETYPES_CONF,
80 GEANY_FILETYPES_HAXE,
81 GEANY_FILETYPES_CPP,
82 GEANY_FILETYPES_SH,
83 GEANY_FILETYPES_FORTRAN,
84 GEANY_FILETYPES_SQL,
85 GEANY_FILETYPES_F77,
86 GEANY_FILETYPES_DOCBOOK,
87 GEANY_FILETYPES_D,
88 GEANY_FILETYPES_JS,
89 GEANY_FILETYPES_VHDL,
90 GEANY_FILETYPES_ADA,
91 GEANY_FILETYPES_CMAKE,
92 GEANY_FILETYPES_MARKDOWN,
93 GEANY_FILETYPES_TXT2TAGS,
94 GEANY_FILETYPES_ABC,
95 GEANY_FILETYPES_VERILOG,
96 GEANY_FILETYPES_FORTH,
97 GEANY_FILETYPES_LISP,
98 GEANY_FILETYPES_ERLANG,
99 GEANY_FILETYPES_COBOL,
100 GEANY_FILETYPES_OBJECTIVEC,
101 GEANY_FILETYPES_ASCIIDOC,
102 GEANY_FILETYPES_ABAQUS,
103 GEANY_FILETYPES_BATCH,
104 GEANY_FILETYPES_POWERSHELL,
105 GEANY_FILETYPES_RUST,
106 GEANY_FILETYPES_COFFEESCRIPT,
107 GEANY_FILETYPES_GO,
108 GEANY_FILETYPES_ZEPHIR,
109 /* ^ append items here */
110 GEANY_MAX_BUILT_IN_FILETYPES /* Don't use this, use filetypes_array->len instead */
112 GeanyFiletypeID;
114 #ifndef GEANY_DISABLE_DEPRECATED
115 /* compat define - should be removed in the future */
116 typedef GeanyFiletypeID filetype_id GEANY_DEPRECATED_FOR(GeanyFiletypeID);
117 #endif /* GEANY_DISABLE_DEPRECATED */
119 /** @gironly
120 * Filetype categories
122 * These are used to provide submenus for each category in the GUI */
123 typedef enum
125 GEANY_FILETYPE_GROUP_NONE,
126 GEANY_FILETYPE_GROUP_COMPILED,
127 GEANY_FILETYPE_GROUP_SCRIPT,
128 GEANY_FILETYPE_GROUP_MARKUP,
129 GEANY_FILETYPE_GROUP_MISC,
130 GEANY_FILETYPE_GROUP_COUNT
132 GeanyFiletypeGroupID;
135 /* Safe wrapper to get the id field of a possibly NULL filetype pointer.
136 * This shouldn't be necessary since GeanyDocument::file_type is always non-NULL. */
137 #define FILETYPE_ID(filetype_ptr) \
138 (((filetype_ptr) != NULL) ? (filetype_ptr)->id : GEANY_FILETYPES_NONE)
140 /** Represents a filetype. */
141 typedef struct GeanyFiletype
143 GeanyFiletypeID id; /**< Index in @ref filetypes. */
144 /* Represents the TMParserType of tagmanager (see the table
145 * in src/tagmanager/tm_parser.h). */
146 TMParserType lang;
147 /** Untranslated short name, such as "C", "None".
148 * Must not be translated as it's used for hash table lookups - use
149 * filetypes_get_display_name() instead. */
150 gchar *name;
151 /** Shown in the file open dialog, such as "C source file". */
152 gchar *title;
153 gchar *extension; /**< Default file extension for new files, or @c NULL. */
154 gchar **pattern; /**< Array of filename-matching wildcard strings. */
155 gchar *context_action_cmd;
156 gchar *comment_open;
157 gchar *comment_close;
158 gboolean comment_use_indent;
159 GeanyFiletypeGroupID group;
160 gchar *error_regex_string;
161 struct GeanyFiletype *lexer_filetype;
162 gchar *mime_type;
163 GIcon *icon;
164 gchar *comment_single; /* single-line comment */
165 /* filetype indent settings, -1 if not set */
166 gint indent_type;
167 gint indent_width;
169 struct GeanyFiletypePrivate *priv; /* must be last, append fields before this item */
171 GeanyFiletype;
173 /** Wraps @ref GeanyData::filetypes_array so it can be used with C array syntax.
174 * Example: filetypes[GEANY_FILETYPES_C]->name = ...;
175 * @see filetypes_index(). */
176 #define filetypes ((GeanyFiletype **)GEANY(filetypes_array)->pdata)
179 GeanyFiletype *filetypes_detect_from_file(const gchar *utf8_filename);
181 GeanyFiletype *filetypes_lookup_by_name(const gchar *name);
183 GeanyFiletype *filetypes_index(gint idx);
185 const gchar *filetypes_get_display_name(GeanyFiletype *ft);
187 const GSList *filetypes_get_sorted_by_name(void);
189 #define GEANY_TYPE_FILETYPE (filetype_get_type())
191 GType filetype_get_type (void);
193 #ifdef GEANY_PRIVATE
195 extern GPtrArray *filetypes_array;
197 extern GSList *filetypes_by_title;
200 GeanyFiletype *filetypes_find(GCompareFunc predicate, gpointer user_data);
203 void filetypes_init(void);
205 void filetypes_init_types(void);
207 void filetypes_reload_extensions(void);
209 void filetypes_reload(void);
212 GeanyFiletype *filetypes_detect_from_document(struct GeanyDocument *doc);
214 GeanyFiletype *filetypes_detect_from_extension(const gchar *utf8_filename);
216 void filetypes_free_types(void);
218 void filetypes_load_config(guint ft_id, gboolean reload);
220 void filetypes_save_commands(GeanyFiletype *ft);
222 void filetypes_select_radio_item(const GeanyFiletype *ft);
224 GtkFileFilter *filetypes_create_file_filter(const GeanyFiletype *ft);
226 GtkFileFilter *filetypes_create_file_filter_all_source(void);
228 gboolean filetype_has_tags(GeanyFiletype *ft);
230 gboolean filetypes_parse_error_message(GeanyFiletype *ft, const gchar *message,
231 gchar **filename, gint *line);
233 gboolean filetype_get_comment_open_close(const GeanyFiletype *ft, gboolean single_first,
234 const gchar **co, const gchar **cc);
236 #endif /* GEANY_PRIVATE */
238 G_END_DECLS
240 #endif /* GEANY_FILETYPES_H */