Improve API docs for editor_insert_text_block().
[geany-mirror.git] / src / filetypes.h
blobffcdfcd5aa61b3ae9e067ff8189a9ed3a44d75c0
1 /*
2 * filetypes.h - this file is part of Geany, a fast and lightweight IDE
4 * Copyright 2005-2010 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5 * Copyright 2006-2010 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
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * $Id$
25 #ifndef GEANY_FILETYPES_H
26 #define GEANY_FILETYPES_H 1
28 #include "Scintilla.h"
29 #include "ScintillaWidget.h"
31 #ifdef GEANY_PRIVATE
32 #include "build.h"
33 #endif
36 typedef enum
38 GEANY_FILETYPES_NONE = 0, /* first filetype is always None & must be 0 */
40 GEANY_FILETYPES_PHP,
41 GEANY_FILETYPES_BASIC, /* FreeBasic */
42 GEANY_FILETYPES_MATLAB,
43 GEANY_FILETYPES_RUBY,
44 GEANY_FILETYPES_LUA,
45 GEANY_FILETYPES_FERITE,
46 GEANY_FILETYPES_YAML,
47 GEANY_FILETYPES_C,
48 GEANY_FILETYPES_NSIS,
49 GEANY_FILETYPES_GLSL,
50 GEANY_FILETYPES_PO,
51 GEANY_FILETYPES_MAKE,
52 GEANY_FILETYPES_TCL,
53 GEANY_FILETYPES_XML,
54 GEANY_FILETYPES_CSS,
55 GEANY_FILETYPES_REST,
56 GEANY_FILETYPES_HASKELL,
57 GEANY_FILETYPES_JAVA,
58 GEANY_FILETYPES_CAML,
59 GEANY_FILETYPES_AS,
60 GEANY_FILETYPES_R,
61 GEANY_FILETYPES_DIFF,
62 GEANY_FILETYPES_HTML,
63 GEANY_FILETYPES_PYTHON,
64 GEANY_FILETYPES_CS,
65 GEANY_FILETYPES_PERL,
66 GEANY_FILETYPES_VALA,
67 GEANY_FILETYPES_PASCAL,
68 GEANY_FILETYPES_LATEX,
69 GEANY_FILETYPES_ASM,
70 GEANY_FILETYPES_CONF,
71 GEANY_FILETYPES_HAXE,
72 GEANY_FILETYPES_CPP,
73 GEANY_FILETYPES_SH,
74 GEANY_FILETYPES_FORTRAN,
75 GEANY_FILETYPES_SQL,
76 GEANY_FILETYPES_F77,
77 GEANY_FILETYPES_DOCBOOK,
78 GEANY_FILETYPES_D,
79 GEANY_FILETYPES_JS,
80 GEANY_FILETYPES_VHDL,
81 GEANY_FILETYPES_ADA,
82 GEANY_FILETYPES_CMAKE,
83 GEANY_FILETYPES_MARKDOWN,
84 GEANY_FILETYPES_TXT2TAGS,
85 GEANY_FILETYPES_ABC,
86 GEANY_FILETYPES_VERILOG,
87 /* ^ append items here */
88 GEANY_MAX_BUILT_IN_FILETYPES /* Don't use this, use filetypes_array->len instead */
90 filetype_id;
92 typedef enum
94 GEANY_FILETYPE_GROUP_NONE,
95 GEANY_FILETYPE_GROUP_COMPILED,
96 GEANY_FILETYPE_GROUP_SCRIPT,
97 GEANY_FILETYPE_GROUP_MARKUP,
98 GEANY_FILETYPE_GROUP_MISC,
99 GEANY_FILETYPE_GROUP_CUSTOM,
100 GEANY_FILETYPE_GROUP_COUNT
102 GeanyFiletypeGroupID;
105 /* Safe wrapper to get the id field of a possibly NULL filetype pointer.
106 * This shouldn't be necessary since GeanyDocument::file_type is always non-NULL. */
107 #define FILETYPE_ID(filetype_ptr) \
108 (((filetype_ptr) != NULL) ? (filetype_ptr)->id : GEANY_FILETYPES_NONE)
110 /** Represents a filetype. */
111 struct GeanyFiletype
113 filetype_id id; /**< Index in @c filetypes_array. */
114 /** Represents the langType of tagmanager (see the table
115 * in tagmanager/parsers.h), -1 represents all, -2 none. */
116 langType lang;
117 gchar *name; /**< Short name, e.g. "C". */
118 gchar *title; /**< Shown in the file open dialog. E.g. "C source file". */
119 gchar *extension; /**< Default file extension for new files, or @c NULL. */
120 gchar **pattern; /**< Array of filename-matching wildcard strings. */
121 gchar *context_action_cmd;
122 gchar *comment_open;
123 gchar *comment_close;
124 gboolean comment_use_indent;
125 GeanyFiletypeGroupID group;
126 gchar *error_regex_string;
127 GeanyFiletype *lexer_filetype;
129 struct GeanyFiletypePrivate *priv; /* must be last, append fields before this item */
130 #ifdef GEANY_PRIVATE
131 /* Do not use following fields in plugins */
132 GeanyBuildCommand *filecmds; /* these need to be visible since used in build.c so not in private part */
133 GeanyBuildCommand *ftdefcmds; /* filetype dependent defaults for non_ft commands */
134 GeanyBuildCommand *execcmds;
135 GeanyBuildCommand *homefilecmds;
136 GeanyBuildCommand *homeexeccmds;
137 GeanyBuildCommand *projfilecmds;
138 GeanyBuildCommand *projexeccmds;
139 gint project_list_entry;
140 gchar *projerror_regex_string;
141 gchar *homeerror_regex_string;
142 gboolean home_save_needed;
143 #endif
146 extern GPtrArray *filetypes_array;
148 /** Wraps filetypes_array so it can be used with C array syntax.
149 * Example: filetypes[GEANY_FILETYPES_C]->name = ...;
150 * @see filetypes_index(). */
151 #define filetypes ((GeanyFiletype **)GEANY(filetypes_array)->pdata)
153 extern GSList *filetypes_by_title;
156 GeanyFiletype *filetypes_lookup_by_name(const gchar *name);
158 GeanyFiletype *filetypes_find(GCompareFunc predicate, gpointer user_data);
161 void filetypes_init(void);
163 void filetypes_init_types(void);
165 void filetypes_read_extensions(void);
167 void filetypes_reload(void);
170 GeanyFiletype *filetypes_index(gint idx);
172 GeanyFiletype *filetypes_detect_from_document(GeanyDocument *doc);
174 GeanyFiletype *filetypes_detect_from_extension(const gchar *utf8_filename);
176 GeanyFiletype *filetypes_detect_from_file(const gchar *utf8_filename);
178 void filetypes_free_types(void);
180 void filetypes_load_config(gint ft_id, gboolean reload);
182 void filetypes_save_commands(void);
184 void filetypes_select_radio_item(const GeanyFiletype *ft);
186 GtkFileFilter *filetypes_create_file_filter(const GeanyFiletype *ft);
188 GtkFileFilter *filetypes_create_file_filter_all_source(void);
190 gchar *filetypes_get_conf_extension(gint filetype_idx);
192 gboolean filetype_has_tags(GeanyFiletype *ft);
194 gboolean filetypes_parse_error_message(GeanyFiletype *ft, const gchar *message,
195 gchar **filename, gint *line);
197 #endif