Support {ob} and {cb} wildcards for snippets too (fixes #2937008).
[geany-mirror.git] / src / build.h
blobac87116d12cbd117e6257750b5135b1e84f8a055
1 /*
2 * build.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., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * $Id$
24 /* * @file build.h Interface to the Build menu functionality. */
26 #ifndef GEANY_BUILD_H
27 #define GEANY_BUILD_H 1
29 #define GEANY_BUILD_ERR_HIGHLIGHT_MAX 100
31 /* Order is important (see GBO_TO_GBG, GBO_TO_CMD below) */
32 /** Geany Known Build Commands.
33 * These commands are named after their default use.
34 * Only these commands can currently have keybindings.
35 **/
36 typedef enum
38 GEANY_GBO_COMPILE, /**< default compile file */
39 GEANY_GBO_BUILD, /**< default build file */
40 GEANY_GBO_MAKE_ALL, /**< default make */
41 GEANY_GBO_CUSTOM, /**< default make user specified target */
42 GEANY_GBO_MAKE_OBJECT, /**< default make object, make %e.o */
43 GEANY_GBO_EXEC, /**< default execute ./%e */
44 GEANY_GBO_COUNT /**< count of how many */
45 } GeanyBuildType;
47 /** Groups of Build menu items. */
48 typedef enum
50 GEANY_GBG_FT, /**< filetype items */
51 GEANY_GBG_NON_FT, /**< non filetype items.*/
52 GEANY_GBG_EXEC, /**< execute items */
53 GEANY_GBG_COUNT /**< count of groups. */
54 } GeanyBuildGroup;
56 /* include the fixed widgets in an array indexed by groups */
57 #define GBG_FIXED GEANY_GBG_COUNT
59 /** Convert @c GeanyBuildType to @c GeanyBuildGroup.
61 * This macro converts @c GeanyBuildType enum values (the "known" commands)
62 * to the group they are part of.
64 * @param gbo the @c GeanyBuildType value.
66 * @return the @c GeanyBuildGroup group that @a gbo is in.
68 * Note this is a macro so that it can be used in static initialisers.
69 **/
70 #define GBO_TO_GBG(gbo) ((gbo)>GEANY_GBO_EXEC?GEANY_GBG_COUNT:((gbo)>=GEANY_GBO_EXEC?GEANY_GBG_EXEC: \
71 ((gbo) >= GEANY_GBO_MAKE_ALL ? GEANY_GBG_NON_FT : GEANY_GBG_FT)))
73 /** Convert @c GeanyBuildType to command index.
75 * This macro converts @c GeanyBuildType enum values (the "known" commands)
76 * to the index within the group.
78 * @param gbo the @c GeanyBuildType value.
80 * @return the index of the @a gbo command in its group.
82 * Note this is a macro so that it can be used in static initialisers.
83 **/
84 #define GBO_TO_CMD(gbo) ((gbo)>=GEANY_GBO_COUNT?(gbo)-GEANY_GBO_COUNT:((gbo)>=GEANY_GBO_EXEC?(gbo)-GEANY_GBO_EXEC: \
85 ((gbo) >= GEANY_GBO_MAKE_ALL ? (gbo)-GEANY_GBO_MAKE_ALL : (gbo))))
87 enum GeanyBuildFixedMenuItems
89 GBF_NEXT_ERROR,
90 GBF_PREV_ERROR,
91 GBF_COMMANDS,
92 GBF_SEP_1,
93 GBF_SEP_2,
94 GBF_SEP_3,
95 GBF_SEP_4,
96 GBF_COUNT
99 /** Build menu item sources in increasing priority */
100 typedef enum
102 GEANY_BCS_DEF, /**< Default values. */
103 GEANY_BCS_FT, /**< System filetype values. */
104 GEANY_BCS_HOME_FT, /**< Filetypes in ~/.config/geany/filedefs */
105 GEANY_BCS_PREF, /**< Preferences file ~/.config/geany/geany.conf */
106 GEANY_BCS_PROJ_FT, /**< Project file filetype command */
107 GEANY_BCS_PROJ, /**< Project file if open. */
108 GEANY_BCS_COUNT /**< Count of sources. */
109 } GeanyBuildSource;
111 typedef struct GeanyBuildInfo
113 GeanyBuildGroup grp;
114 gint cmd;
115 GPid pid; /* process id of the spawned process */
116 gchar *dir;
117 guint file_type_id;
118 gchar *custom_target;
119 gint message_count;
120 } GeanyBuildInfo;
122 extern GeanyBuildInfo build_info;
124 /** The entries of a command for a menu item */
125 typedef enum GeanyBuildCmdEntries
127 GEANY_BC_LABEL, /**< The menu item label, _ marks mnemonic */
128 GEANY_BC_COMMAND, /**< The command to run. */
129 GEANY_BC_WORKING_DIR, /**< The directory to run in */
130 GEANY_BC_CMDENTRIES_COUNT, /**< Count of entries */
131 } GeanyBuildCmdEntries;
133 /** The command for a menu item. */
134 typedef struct GeanyBuildCommand
136 /** Pointers to g_string values of the command entries.
137 * Must be freed if the pointer is changed. */
138 gchar *entries[GEANY_BC_CMDENTRIES_COUNT];
139 gboolean exists; /**< If the entries have valid values. */
140 gboolean changed; /**< Save on exit if @c changed, remove if not @c exist. */
141 gboolean old; /**< Converted from old format. */
142 } GeanyBuildCommand;
144 /* project command array pointers */
145 extern GeanyBuildCommand *non_ft_proj;
146 extern GeanyBuildCommand *exec_proj;
147 extern gchar *regex_proj; /* project non-fileregex string */
149 typedef struct BuildMenuItems
151 GtkWidget *menu;
152 GtkWidget **menu_item[GEANY_GBG_COUNT + 1]; /* +1 for fixed items */
153 } BuildMenuItems;
155 /* a structure defining the destinations for a set of groups of commands & regex */
156 typedef struct BuildDestination
158 GeanyBuildCommand **dst[GEANY_GBG_COUNT];
159 gchar **fileregexstr;
160 gchar **nonfileregexstr;
161 } BuildDestination;
163 /* opaque pointers returned from build functions and passed back to them */
164 typedef struct TableFields *TableData;
166 void build_init(void);
168 void build_finalize(void);
170 /* menu configuration dialog functions */
171 GtkWidget *build_commands_table(GeanyDocument *doc, GeanyBuildSource dst, TableData *data, GeanyFiletype *ft);
173 gboolean build_read_commands(BuildDestination *dst, TableData data, gint response);
175 void build_free_fields(TableData data);
177 void build_set_non_ft_wd_to_proj(TableData table_data);
179 /* build response decode assistance function */
180 gboolean build_parse_make_dir(const gchar *string, gchar **prefix);
182 /* build menu functions */
184 void build_menu_update(GeanyDocument *doc);
186 void build_toolbutton_build_clicked(GtkAction *action, gpointer user_data);
188 void build_remove_menu_item(GeanyBuildSource src, GeanyBuildGroup grp, gint cmd);
190 GeanyBuildCommand *build_get_menu_item(GeanyBuildSource src, GeanyBuildGroup grp, gint cmd);
192 GeanyBuildCommand *build_get_current_menu_item(GeanyBuildGroup grp, gint cmd, gint *src);
194 BuildMenuItems *build_get_menu_items(gint filetype_idx);
196 /* load and store menu configuration */
197 void build_load_menu(GKeyFile *config, GeanyBuildSource dst, gpointer ptr);
199 void build_save_menu(GKeyFile *config, gpointer ptr, GeanyBuildSource src);
201 void build_set_group_count(GeanyBuildGroup grp, gint count);
203 gint build_get_group_count(GeanyBuildGroup grp);
205 gchar **build_get_regex(GeanyBuildGroup grp, GeanyFiletype *ft, gint *from);
207 #endif