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.
25 #ifndef GEANY_FILETYPES_H
26 #define GEANY_FILETYPES_H 1
28 #include "Scintilla.h"
29 #include "ScintillaWidget.h"
38 GEANY_FILETYPES_NONE
= 0, /* first filetype is always None & must be 0 */
41 GEANY_FILETYPES_BASIC
, /* FreeBasic */
42 GEANY_FILETYPES_MATLAB
,
45 GEANY_FILETYPES_FERITE
,
56 GEANY_FILETYPES_HASKELL
,
63 GEANY_FILETYPES_PYTHON
,
67 GEANY_FILETYPES_PASCAL
,
68 GEANY_FILETYPES_LATEX
,
74 GEANY_FILETYPES_FORTRAN
,
77 GEANY_FILETYPES_DOCBOOK
,
82 GEANY_FILETYPES_CMAKE
,
83 GEANY_FILETYPES_MARKDOWN
,
84 GEANY_FILETYPES_TXT2TAGS
,
86 GEANY_FILETYPES_VERILOG
,
87 /* ^ append items here */
88 GEANY_MAX_BUILT_IN_FILETYPES
/* Don't use this, use filetypes_array->len instead */
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. */
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. */
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
;
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 */
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
;
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
);