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 */
38 /* Forward-declared to avoid including document.h since it includes this header */
41 /* Do not change the order, only append. */
44 GEANY_FILETYPES_NONE
= 0, /* first filetype is always None & must be 0 */
47 GEANY_FILETYPES_BASIC
, /* FreeBasic */
48 GEANY_FILETYPES_MATLAB
,
51 GEANY_FILETYPES_FERITE
,
62 GEANY_FILETYPES_HASKELL
,
69 GEANY_FILETYPES_PYTHON
,
73 GEANY_FILETYPES_PASCAL
,
74 GEANY_FILETYPES_LATEX
,
80 GEANY_FILETYPES_FORTRAN
,
83 GEANY_FILETYPES_DOCBOOK
,
88 GEANY_FILETYPES_CMAKE
,
89 GEANY_FILETYPES_MARKDOWN
,
90 GEANY_FILETYPES_TXT2TAGS
,
92 GEANY_FILETYPES_VERILOG
,
93 GEANY_FILETYPES_FORTH
,
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 /* ^ append items here */
104 GEANY_MAX_BUILT_IN_FILETYPES
/* Don't use this, use filetypes_array->len instead */
110 GEANY_FILETYPE_GROUP_NONE
,
111 GEANY_FILETYPE_GROUP_COMPILED
,
112 GEANY_FILETYPE_GROUP_SCRIPT
,
113 GEANY_FILETYPE_GROUP_MARKUP
,
114 GEANY_FILETYPE_GROUP_MISC
,
115 GEANY_FILETYPE_GROUP_COUNT
117 GeanyFiletypeGroupID
;
120 /* Safe wrapper to get the id field of a possibly NULL filetype pointer.
121 * This shouldn't be necessary since GeanyDocument::file_type is always non-NULL. */
122 #define FILETYPE_ID(filetype_ptr) \
123 (((filetype_ptr) != NULL) ? (filetype_ptr)->id : GEANY_FILETYPES_NONE)
125 /** Represents a filetype. */
126 typedef struct GeanyFiletype
128 filetype_id id
; /**< Index in @c filetypes_array. */
129 /** Represents the langType of tagmanager (see the table
130 * in tagmanager/parsers.h), -1 represents all, -2 none. */
132 /** Untranslated short name, such as "C", "None".
133 * Must not be translated as it's used for hash table lookups - use
134 * filetypes_get_display_name() instead. */
136 /** Shown in the file open dialog, such as "C source file". */
138 gchar
*extension
; /**< Default file extension for new files, or @c NULL. */
139 gchar
**pattern
; /**< Array of filename-matching wildcard strings. */
140 gchar
*context_action_cmd
;
142 gchar
*comment_close
;
143 gboolean comment_use_indent
;
144 GeanyFiletypeGroupID group
;
145 gchar
*error_regex_string
;
146 struct GeanyFiletype
*lexer_filetype
;
149 gchar
*comment_single
; /* single-line comment */
150 /* filetype indent settings, -1 if not set */
154 struct GeanyFiletypePrivate
*priv
; /* must be last, append fields before this item */
158 extern GPtrArray
*filetypes_array
;
160 /** Wraps filetypes_array so it can be used with C array syntax.
161 * Example: filetypes[GEANY_FILETYPES_C]->name = ...;
162 * @see filetypes_index(). */
163 #define filetypes ((GeanyFiletype **)GEANY(filetypes_array)->pdata)
166 GeanyFiletype
*filetypes_detect_from_file(const gchar
*utf8_filename
);
168 GeanyFiletype
*filetypes_lookup_by_name(const gchar
*name
);
170 GeanyFiletype
*filetypes_index(gint idx
);
172 const gchar
*filetypes_get_display_name(GeanyFiletype
*ft
);
174 const GSList
*filetypes_get_sorted_by_name(void);
179 extern GSList
*filetypes_by_title
;
182 GeanyFiletype
*filetypes_find(GCompareFunc predicate
, gpointer user_data
);
185 void filetypes_init(void);
187 void filetypes_init_types(void);
189 void filetypes_reload_extensions(void);
191 void filetypes_reload(void);
194 GeanyFiletype
*filetypes_detect_from_document(struct GeanyDocument
*doc
);
196 GeanyFiletype
*filetypes_detect_from_extension(const gchar
*utf8_filename
);
198 void filetypes_free_types(void);
200 void filetypes_load_config(guint ft_id
, gboolean reload
);
202 void filetypes_save_commands(GeanyFiletype
*ft
);
204 void filetypes_select_radio_item(const GeanyFiletype
*ft
);
206 GtkFileFilter
*filetypes_create_file_filter(const GeanyFiletype
*ft
);
208 GtkFileFilter
*filetypes_create_file_filter_all_source(void);
210 gboolean
filetype_has_tags(GeanyFiletype
*ft
);
212 gboolean
filetypes_parse_error_message(GeanyFiletype
*ft
, const gchar
*message
,
213 gchar
**filename
, gint
*line
);
215 gboolean
filetype_get_comment_open_close(const GeanyFiletype
*ft
, gboolean single_first
,
216 const gchar
**co
, const gchar
**cc
);
218 #endif /* GEANY_PRIVATE */
222 #endif /* GEANY_FILETYPES_H */