2005-11-22 12:26:26 +00:00
|
|
|
/*
|
|
|
|
* filetypes.h - this file is part of Geany, a fast and lightweight IDE
|
|
|
|
*
|
2012-06-18 01:13:05 +02:00
|
|
|
* Copyright 2005-2012 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
|
|
|
* Copyright 2006-2012 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
|
2005-11-22 12:26:26 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
2012-08-24 19:25:57 +02:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2005-11-22 12:26:26 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef GEANY_FILETYPES_H
|
|
|
|
#define GEANY_FILETYPES_H 1
|
|
|
|
|
2014-05-18 17:07:50 -07:00
|
|
|
#include <glib.h>
|
2006-08-20 20:39:59 +00:00
|
|
|
#include "Scintilla.h"
|
|
|
|
#include "ScintillaWidget.h"
|
2009-10-26 13:06:51 +00:00
|
|
|
|
2014-05-18 16:20:25 -07:00
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
/* Forward-declared to avoid including document.h here */
|
|
|
|
struct GeanyDocument;
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2010-10-06 17:10:15 +00:00
|
|
|
/* Do not change the order, only append. */
|
2007-01-03 16:21:44 +00:00
|
|
|
typedef enum
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2009-08-24 12:39:13 +00:00
|
|
|
GEANY_FILETYPES_NONE = 0, /* first filetype is always None & must be 0 */
|
2009-03-20 16:18:32 +00:00
|
|
|
|
2009-03-27 15:33:52 +00:00
|
|
|
GEANY_FILETYPES_PHP,
|
2008-02-27 13:17:29 +00:00
|
|
|
GEANY_FILETYPES_BASIC, /* FreeBasic */
|
2008-11-07 14:39:45 +00:00
|
|
|
GEANY_FILETYPES_MATLAB,
|
2006-08-15 17:57:41 +00:00
|
|
|
GEANY_FILETYPES_RUBY,
|
2009-03-27 15:33:52 +00:00
|
|
|
GEANY_FILETYPES_LUA,
|
|
|
|
GEANY_FILETYPES_FERITE,
|
|
|
|
GEANY_FILETYPES_YAML,
|
|
|
|
GEANY_FILETYPES_C,
|
|
|
|
GEANY_FILETYPES_NSIS,
|
|
|
|
GEANY_FILETYPES_GLSL,
|
|
|
|
GEANY_FILETYPES_PO,
|
|
|
|
GEANY_FILETYPES_MAKE,
|
2007-08-14 15:11:54 +00:00
|
|
|
GEANY_FILETYPES_TCL,
|
2008-11-29 12:51:50 +00:00
|
|
|
GEANY_FILETYPES_XML,
|
2009-03-27 15:33:52 +00:00
|
|
|
GEANY_FILETYPES_CSS,
|
|
|
|
GEANY_FILETYPES_REST,
|
|
|
|
GEANY_FILETYPES_HASKELL,
|
|
|
|
GEANY_FILETYPES_JAVA,
|
|
|
|
GEANY_FILETYPES_CAML,
|
|
|
|
GEANY_FILETYPES_AS,
|
|
|
|
GEANY_FILETYPES_R,
|
2006-08-27 17:39:34 +00:00
|
|
|
GEANY_FILETYPES_DIFF,
|
2009-03-27 15:33:52 +00:00
|
|
|
GEANY_FILETYPES_HTML,
|
|
|
|
GEANY_FILETYPES_PYTHON,
|
|
|
|
GEANY_FILETYPES_CS,
|
|
|
|
GEANY_FILETYPES_PERL,
|
|
|
|
GEANY_FILETYPES_VALA,
|
|
|
|
GEANY_FILETYPES_PASCAL,
|
2007-08-14 15:11:54 +00:00
|
|
|
GEANY_FILETYPES_LATEX,
|
2009-03-27 15:33:52 +00:00
|
|
|
GEANY_FILETYPES_ASM,
|
|
|
|
GEANY_FILETYPES_CONF,
|
|
|
|
GEANY_FILETYPES_HAXE,
|
|
|
|
GEANY_FILETYPES_CPP,
|
|
|
|
GEANY_FILETYPES_SH,
|
|
|
|
GEANY_FILETYPES_FORTRAN,
|
2007-08-14 15:11:54 +00:00
|
|
|
GEANY_FILETYPES_SQL,
|
2009-03-27 15:33:52 +00:00
|
|
|
GEANY_FILETYPES_F77,
|
|
|
|
GEANY_FILETYPES_DOCBOOK,
|
|
|
|
GEANY_FILETYPES_D,
|
|
|
|
GEANY_FILETYPES_JS,
|
|
|
|
GEANY_FILETYPES_VHDL,
|
|
|
|
GEANY_FILETYPES_ADA,
|
|
|
|
GEANY_FILETYPES_CMAKE,
|
2009-07-30 11:29:53 +00:00
|
|
|
GEANY_FILETYPES_MARKDOWN,
|
2009-09-06 20:57:42 +00:00
|
|
|
GEANY_FILETYPES_TXT2TAGS,
|
2009-09-20 18:46:56 +00:00
|
|
|
GEANY_FILETYPES_ABC,
|
2009-12-07 17:51:37 +00:00
|
|
|
GEANY_FILETYPES_VERILOG,
|
2010-09-30 16:59:22 +00:00
|
|
|
GEANY_FILETYPES_FORTH,
|
2010-10-06 17:10:15 +00:00
|
|
|
GEANY_FILETYPES_LISP,
|
2010-10-20 15:45:25 +00:00
|
|
|
GEANY_FILETYPES_ERLANG,
|
2011-01-30 15:03:51 +00:00
|
|
|
GEANY_FILETYPES_COBOL,
|
2011-11-13 00:45:12 +01:00
|
|
|
GEANY_FILETYPES_OBJECTIVEC,
|
2012-11-01 11:14:55 +11:00
|
|
|
GEANY_FILETYPES_ASCIIDOC,
|
2012-12-03 15:17:43 +01:00
|
|
|
GEANY_FILETYPES_ABAQUS,
|
2013-08-12 21:51:00 +02:00
|
|
|
GEANY_FILETYPES_BATCH,
|
2013-04-10 20:54:59 +03:00
|
|
|
GEANY_FILETYPES_POWERSHELL,
|
2013-10-17 20:07:18 -04:00
|
|
|
GEANY_FILETYPES_RUST,
|
2009-03-20 16:18:32 +00:00
|
|
|
/* ^ append items here */
|
|
|
|
GEANY_MAX_BUILT_IN_FILETYPES /* Don't use this, use filetypes_array->len instead */
|
|
|
|
}
|
|
|
|
filetype_id;
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2008-08-27 16:16:50 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GEANY_FILETYPE_GROUP_NONE,
|
|
|
|
GEANY_FILETYPE_GROUP_COMPILED,
|
|
|
|
GEANY_FILETYPE_GROUP_SCRIPT,
|
|
|
|
GEANY_FILETYPE_GROUP_MARKUP,
|
2009-03-27 15:52:38 +00:00
|
|
|
GEANY_FILETYPE_GROUP_MISC,
|
|
|
|
GEANY_FILETYPE_GROUP_COUNT
|
2008-08-27 16:16:50 +00:00
|
|
|
}
|
|
|
|
GeanyFiletypeGroupID;
|
|
|
|
|
|
|
|
|
2009-06-17 10:46:43 +00:00
|
|
|
/* Safe wrapper to get the id field of a possibly NULL filetype pointer.
|
|
|
|
* This shouldn't be necessary since GeanyDocument::file_type is always non-NULL. */
|
2006-11-14 16:03:25 +00:00
|
|
|
#define FILETYPE_ID(filetype_ptr) \
|
2008-05-07 13:54:21 +00:00
|
|
|
(((filetype_ptr) != NULL) ? (filetype_ptr)->id : GEANY_FILETYPES_NONE)
|
2006-11-14 16:03:25 +00:00
|
|
|
|
2008-07-23 14:44:27 +00:00
|
|
|
/** Represents a filetype. */
|
2014-05-18 16:20:25 -07:00
|
|
|
typedef struct GeanyFiletype
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-07-23 14:44:27 +00:00
|
|
|
filetype_id id; /**< Index in @c filetypes_array. */
|
|
|
|
/** Represents the langType of tagmanager (see the table
|
|
|
|
* in tagmanager/parsers.h), -1 represents all, -2 none. */
|
|
|
|
langType lang;
|
2010-11-04 18:06:09 +00:00
|
|
|
/** Untranslated short name, such as "C", "None".
|
|
|
|
* Must not be translated as it's used for hash table lookups - use
|
|
|
|
* filetypes_get_display_name() instead. */
|
|
|
|
gchar *name;
|
|
|
|
/** Shown in the file open dialog, such as "C source file". */
|
|
|
|
gchar *title;
|
2009-08-12 11:19:54 +00:00
|
|
|
gchar *extension; /**< Default file extension for new files, or @c NULL. */
|
2008-07-23 14:44:27 +00:00
|
|
|
gchar **pattern; /**< Array of filename-matching wildcard strings. */
|
2009-08-11 13:22:42 +00:00
|
|
|
gchar *context_action_cmd;
|
|
|
|
gchar *comment_open;
|
|
|
|
gchar *comment_close;
|
|
|
|
gboolean comment_use_indent;
|
2009-08-24 12:39:13 +00:00
|
|
|
GeanyFiletypeGroupID group;
|
2008-09-23 16:12:40 +00:00
|
|
|
gchar *error_regex_string;
|
2014-05-18 16:20:25 -07:00
|
|
|
struct GeanyFiletype *lexer_filetype;
|
2010-10-26 16:02:30 +00:00
|
|
|
gchar *mime_type;
|
2013-10-15 15:56:44 +02:00
|
|
|
GIcon *icon;
|
2011-03-20 15:02:22 +00:00
|
|
|
gchar *comment_single; /* single-line comment */
|
2011-08-25 20:14:17 +00:00
|
|
|
/* filetype indent settings, -1 if not set */
|
|
|
|
gint indent_type;
|
|
|
|
gint indent_width;
|
2008-09-19 17:19:34 +00:00
|
|
|
|
|
|
|
struct GeanyFiletypePrivate *priv; /* must be last, append fields before this item */
|
2014-05-18 16:20:25 -07:00
|
|
|
}
|
|
|
|
GeanyFiletype;
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2008-05-01 17:25:18 +00:00
|
|
|
extern GPtrArray *filetypes_array;
|
|
|
|
|
2010-03-12 18:15:48 +00:00
|
|
|
/** Wraps filetypes_array so it can be used with C array syntax.
|
2009-07-14 13:05:51 +00:00
|
|
|
* Example: filetypes[GEANY_FILETYPES_C]->name = ...;
|
|
|
|
* @see filetypes_index(). */
|
|
|
|
#define filetypes ((GeanyFiletype **)GEANY(filetypes_array)->pdata)
|
2008-04-28 14:41:09 +00:00
|
|
|
|
2009-04-02 15:00:17 +00:00
|
|
|
extern GSList *filetypes_by_title;
|
2009-03-31 14:32:03 +00:00
|
|
|
|
2008-04-28 14:41:09 +00:00
|
|
|
|
2008-05-16 14:17:54 +00:00
|
|
|
GeanyFiletype *filetypes_lookup_by_name(const gchar *name);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2009-03-27 14:06:11 +00:00
|
|
|
GeanyFiletype *filetypes_find(GCompareFunc predicate, gpointer user_data);
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2008-02-20 11:24:23 +00:00
|
|
|
void filetypes_init(void);
|
2007-04-25 15:01:14 +00:00
|
|
|
|
2008-02-20 11:24:23 +00:00
|
|
|
void filetypes_init_types(void);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2011-04-26 15:01:04 +00:00
|
|
|
void filetypes_reload_extensions(void);
|
2008-11-26 16:09:48 +00:00
|
|
|
|
2009-09-14 11:53:08 +00:00
|
|
|
void filetypes_reload(void);
|
|
|
|
|
|
|
|
|
2008-12-03 18:03:54 +00:00
|
|
|
GeanyFiletype *filetypes_index(gint idx);
|
|
|
|
|
2011-03-29 18:06:26 +00:00
|
|
|
const GSList *filetypes_get_sorted_by_name(void);
|
|
|
|
|
2010-11-04 18:06:09 +00:00
|
|
|
const gchar *filetypes_get_display_name(GeanyFiletype *ft);
|
|
|
|
|
2014-05-18 16:20:25 -07:00
|
|
|
GeanyFiletype *filetypes_detect_from_document(struct GeanyDocument *doc);
|
2007-04-18 12:12:51 +00:00
|
|
|
|
2008-05-16 14:17:54 +00:00
|
|
|
GeanyFiletype *filetypes_detect_from_extension(const gchar *utf8_filename);
|
2008-03-05 17:09:57 +00:00
|
|
|
|
2008-07-23 14:44:27 +00:00
|
|
|
GeanyFiletype *filetypes_detect_from_file(const gchar *utf8_filename);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2008-02-20 11:24:23 +00:00
|
|
|
void filetypes_free_types(void);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2011-11-06 01:12:42 +01:00
|
|
|
void filetypes_load_config(guint ft_id, gboolean reload);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2011-05-03 16:08:23 +00:00
|
|
|
void filetypes_save_commands(GeanyFiletype *ft);
|
2006-10-01 16:14:45 +00:00
|
|
|
|
2008-05-16 14:17:54 +00:00
|
|
|
void filetypes_select_radio_item(const GeanyFiletype *ft);
|
2006-08-03 22:17:10 +00:00
|
|
|
|
2008-05-16 14:17:54 +00:00
|
|
|
GtkFileFilter *filetypes_create_file_filter(const GeanyFiletype *ft);
|
2006-08-20 20:39:59 +00:00
|
|
|
|
2008-02-20 11:24:23 +00:00
|
|
|
GtkFileFilter *filetypes_create_file_filter_all_source(void);
|
2007-03-01 22:38:31 +00:00
|
|
|
|
2008-05-16 14:17:54 +00:00
|
|
|
gboolean filetype_has_tags(GeanyFiletype *ft);
|
2007-05-26 12:13:53 +00:00
|
|
|
|
2008-09-23 16:12:40 +00:00
|
|
|
gboolean filetypes_parse_error_message(GeanyFiletype *ft, const gchar *message,
|
|
|
|
gchar **filename, gint *line);
|
|
|
|
|
2011-12-04 00:16:31 +01:00
|
|
|
gboolean filetype_get_comment_open_close(const GeanyFiletype *ft, gboolean single_first,
|
|
|
|
const gchar **co, const gchar **cc);
|
|
|
|
|
2012-03-28 22:50:18 -07:00
|
|
|
G_END_DECLS
|
|
|
|
|
2014-05-18 17:07:50 -07:00
|
|
|
#endif /* GEANY_FILETYPES_H */
|