Merge pull request #4077 from LiquidCake/saveactions_persistent_temp_files_doc
[geany-mirror.git] / src / filetypes.h
blob2c2d01d790c23dd3b2fdeb3266eded76d892e800
1 /*
2 * filetypes.h - this file is part of Geany, a fast and lightweight IDE
4 * Copyright 2005 The Geany contributors
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef GEANY_FILETYPES_H
23 #define GEANY_FILETYPES_H 1
25 #include "geany.h" /* for GEANY() macro */
26 #include "tm_parser.h" /* for TMParserType */
28 #include "gtkcompat.h" /* Needed by ScintillaWidget.h */
29 #include "Scintilla.h" /* Needed by ScintillaWidget.h */
30 #include "ScintillaWidget.h" /* for ScintillaObject */
32 #include <glib.h>
35 G_BEGIN_DECLS
37 /* Forward-declared to avoid including document.h since it includes this header */
38 struct GeanyDocument;
40 /** IDs of known filetypes
42 * @ref filetypes will contain an item for each. Use GeanyData::filetypes_array to
43 * determine the known filetypes at runtime */
44 typedef enum
46 GEANY_FILETYPES_NONE = 0, /* first filetype is always None & must be 0 */
48 GEANY_FILETYPES_PHP,
49 GEANY_FILETYPES_BASIC, /* FreeBasic */
50 GEANY_FILETYPES_MATLAB,
51 GEANY_FILETYPES_RUBY,
52 GEANY_FILETYPES_LUA,
53 GEANY_FILETYPES_GDSCRIPT,
54 GEANY_FILETYPES_YAML,
55 GEANY_FILETYPES_C,
56 GEANY_FILETYPES_NSIS,
57 GEANY_FILETYPES_GLSL,
58 GEANY_FILETYPES_PO,
59 GEANY_FILETYPES_MAKE,
60 GEANY_FILETYPES_TCL,
61 GEANY_FILETYPES_XML,
62 GEANY_FILETYPES_CSS,
63 GEANY_FILETYPES_REST,
64 GEANY_FILETYPES_HASKELL,
65 GEANY_FILETYPES_JAVA,
66 GEANY_FILETYPES_CAML,
67 GEANY_FILETYPES_AS,
68 GEANY_FILETYPES_R,
69 GEANY_FILETYPES_DIFF,
70 GEANY_FILETYPES_HTML,
71 GEANY_FILETYPES_PYTHON,
72 GEANY_FILETYPES_CS,
73 GEANY_FILETYPES_PERL,
74 GEANY_FILETYPES_VALA,
75 GEANY_FILETYPES_PASCAL,
76 GEANY_FILETYPES_LATEX,
77 GEANY_FILETYPES_ASM,
78 GEANY_FILETYPES_CONF,
79 GEANY_FILETYPES_HAXE,
80 GEANY_FILETYPES_CPP,
81 GEANY_FILETYPES_SH,
82 GEANY_FILETYPES_FORTRAN,
83 GEANY_FILETYPES_SQL,
84 GEANY_FILETYPES_F77,
85 GEANY_FILETYPES_DOCBOOK,
86 GEANY_FILETYPES_D,
87 GEANY_FILETYPES_JS,
88 GEANY_FILETYPES_VHDL,
89 GEANY_FILETYPES_ADA,
90 GEANY_FILETYPES_CMAKE,
91 GEANY_FILETYPES_MARKDOWN,
92 GEANY_FILETYPES_TXT2TAGS,
93 GEANY_FILETYPES_ABC,
94 GEANY_FILETYPES_VERILOG,
95 GEANY_FILETYPES_FORTH,
96 GEANY_FILETYPES_LISP,
97 GEANY_FILETYPES_ERLANG,
98 GEANY_FILETYPES_COBOL,
99 GEANY_FILETYPES_OBJECTIVEC,
100 GEANY_FILETYPES_ASCIIDOC,
101 GEANY_FILETYPES_ABAQUS,
102 GEANY_FILETYPES_BATCH,
103 GEANY_FILETYPES_POWERSHELL,
104 GEANY_FILETYPES_RUST,
105 GEANY_FILETYPES_COFFEESCRIPT,
106 GEANY_FILETYPES_GO,
107 GEANY_FILETYPES_ZEPHIR,
108 GEANY_FILETYPES_BIBTEX,
109 GEANY_FILETYPES_SMALLTALK,
110 GEANY_FILETYPES_JULIA,
111 GEANY_FILETYPES_AU3,
112 GEANY_FILETYPES_RAKU,
113 GEANY_FILETYPES_CIL,
114 GEANY_FILETYPES_PROLOG,
115 GEANY_FILETYPES_NIM,
116 GEANY_FILETYPES_ZIG,
117 GEANY_FILETYPES_DART,
118 GEANY_FILETYPES_NIX,
119 /* ^ append items here */
120 GEANY_MAX_BUILT_IN_FILETYPES /* Don't use this, use filetypes_array->len instead */
122 GeanyFiletypeID;
125 /** @gironly
126 * Filetype categories
128 * These are used to provide submenus for each category in the GUI */
129 typedef enum
131 GEANY_FILETYPE_GROUP_NONE,
132 GEANY_FILETYPE_GROUP_OTHER,
133 GEANY_FILETYPE_GROUP_A_B,
134 GEANY_FILETYPE_GROUP_C,
135 GEANY_FILETYPE_GROUP_D_E_F,
136 GEANY_FILETYPE_GROUP_G_H_I,
137 GEANY_FILETYPE_GROUP_J_K_L,
138 GEANY_FILETYPE_GROUP_M_N_O,
139 GEANY_FILETYPE_GROUP_P_Q,
140 GEANY_FILETYPE_GROUP_R_S,
141 GEANY_FILETYPE_GROUP_T_U_V_W,
142 GEANY_FILETYPE_GROUP_X_Y_Z,
143 GEANY_FILETYPE_GROUP_COUNT
145 GeanyFiletypeGroupID;
148 /* Safe wrapper to get the id field of a possibly NULL filetype pointer.
149 * This shouldn't be necessary since GeanyDocument::file_type is always non-NULL. */
150 #define FILETYPE_ID(filetype_ptr) \
151 (((filetype_ptr) != NULL) ? (filetype_ptr)->id : GEANY_FILETYPES_NONE)
153 /** Represents a filetype. */
154 typedef struct GeanyFiletype
156 GeanyFiletypeID id; /**< Index in @ref filetypes. */
157 /* Represents the TMParserType of tagmanager (see the table
158 * in src/tagmanager/tm_parser.h). */
159 TMParserType lang;
160 /** Untranslated short name, such as "C", "None".
161 * Must not be translated as it's used for hash table lookups - use
162 * filetypes_get_display_name() instead. */
163 gchar *name;
164 /** Shown in the file open dialog, such as "C source file". */
165 gchar *title;
166 gchar *extension; /**< Default file extension for new files, or @c NULL. */
167 gchar **pattern; /**< Array of filename-matching wildcard strings. */
168 gchar *context_action_cmd;
169 gchar *comment_open;
170 gchar *comment_close;
171 gboolean comment_use_indent;
172 GeanyFiletypeGroupID group;
173 gchar *error_regex_string;
174 struct GeanyFiletype *lexer_filetype;
175 gchar *mime_type;
176 GIcon *icon;
177 gchar *comment_single; /* single-line comment */
178 /* filetype indent settings, -1 if not set */
179 gint indent_type;
180 gint indent_width;
182 struct GeanyFiletypePrivate *priv; /* must be last, append fields before this item */
184 GeanyFiletype;
186 /** Wraps @ref GeanyData::filetypes_array so it can be used with C array syntax.
187 * Example: filetypes[GEANY_FILETYPES_C]->name = ...;
188 * @see filetypes_index(). */
189 #define filetypes ((GeanyFiletype **)GEANY(filetypes_array)->pdata)
192 GeanyFiletype *filetypes_detect_from_file(const gchar *utf8_filename);
194 GeanyFiletype *filetypes_lookup_by_name(const gchar *name);
196 GeanyFiletype *filetypes_index(gint idx);
198 const gchar *filetypes_get_display_name(GeanyFiletype *ft);
200 const GSList *filetypes_get_sorted_by_name(void);
202 #define GEANY_TYPE_FILETYPE (filetype_get_type())
204 GType filetype_get_type (void);
206 #ifdef GEANY_PRIVATE
208 extern GPtrArray *filetypes_array;
210 extern GSList *filetypes_by_title;
213 void filetypes_init(void);
215 void filetypes_init_types(void);
217 void filetypes_reload_extensions(void);
219 void filetypes_reload(void);
222 GeanyFiletype *filetypes_detect_from_document(struct GeanyDocument *doc);
224 GeanyFiletype *filetypes_detect_from_extension(const gchar *utf8_filename);
226 void filetypes_free_types(void);
228 void filetypes_load_config(guint ft_id, gboolean reload);
230 void filetypes_save_commands(GeanyFiletype *ft);
232 void filetypes_select_radio_item(const GeanyFiletype *ft);
234 GtkFileFilter *filetypes_create_file_filter(const GeanyFiletype *ft);
236 GtkFileFilter *filetypes_create_file_filter_all_source(void);
238 gboolean filetype_has_tags(GeanyFiletype *ft);
240 gboolean filetypes_parse_error_message(GeanyFiletype *ft, const gchar *message,
241 gchar **filename, gint *line);
243 gboolean filetype_get_comment_open_close(const GeanyFiletype *ft, gboolean single_first,
244 const gchar **co, const gchar **cc);
246 #endif /* GEANY_PRIVATE */
248 G_END_DECLS
250 #endif /* GEANY_FILETYPES_H */