Add UI elements to control single-line regex settings
[geany-mirror.git] / src / build.h
blob276eef0d52dbd27ea55d22e2be75a080b631fb65
1 /*
2 * build.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.
22 /** @file build.h Interface to the Build menu functionality. */
24 #ifndef GEANY_BUILD_H
25 #define GEANY_BUILD_H 1
27 #include "document.h"
28 #include "filetypes.h"
30 #include "gtkcompat.h"
32 G_BEGIN_DECLS
34 /* Order is important (see GBO_TO_GBG, GBO_TO_CMD below) */
35 /* * Geany Known Build Commands.
36 * These commands are named after their default use.
37 * Only these commands can currently have keybindings.
38 **/
39 typedef enum
41 GEANY_GBO_COMPILE, /* *< default compile file */
42 GEANY_GBO_BUILD, /* *< default build file */
43 GEANY_GBO_MAKE_ALL, /* *< default make */
44 GEANY_GBO_CUSTOM, /* *< default make user specified target */
45 GEANY_GBO_MAKE_OBJECT, /* *< default make object, make %e.o */
46 GEANY_GBO_EXEC, /* *< default execute ./%e */
47 GEANY_GBO_COUNT /* *< count of how many */
48 } GeanyBuildType;
50 /** Groups of Build menu items. */
51 typedef enum
53 GEANY_GBG_FT, /* *< filetype items */
54 GEANY_GBG_NON_FT, /* *< non filetype items.*/
55 GEANY_GBG_EXEC, /* *< execute items */
56 GEANY_GBG_COUNT /* *< count of groups. */
57 } GeanyBuildGroup;
59 /* include the fixed widgets in an array indexed by groups */
60 #define GBG_FIXED GEANY_GBG_COUNT
62 /* * Convert @c GeanyBuildType to @c GeanyBuildGroup.
64 * This macro converts @c GeanyBuildType enum values (the "known" commands)
65 * to the group they are part of.
67 * @param gbo the @c GeanyBuildType value.
69 * @return the @c GeanyBuildGroup group that @a gbo is in.
71 * Note this is a macro so that it can be used in static initialisers.
72 **/
73 #define GBO_TO_GBG(gbo) ((gbo)>GEANY_GBO_EXEC?GEANY_GBG_COUNT:((gbo)>=GEANY_GBO_EXEC?GEANY_GBG_EXEC: \
74 ((gbo) >= GEANY_GBO_MAKE_ALL ? GEANY_GBG_NON_FT : GEANY_GBG_FT)))
76 /* * Convert @c GeanyBuildType to command index.
78 * This macro converts @c GeanyBuildType enum values (the "known" commands)
79 * to the index within the group.
81 * @param gbo the @c GeanyBuildType value.
83 * @return the index of the @a gbo command in its group.
85 * Note this is a macro so that it can be used in static initialisers.
86 **/
87 #define GBO_TO_CMD(gbo) ((gbo)>=GEANY_GBO_COUNT?(gbo)-GEANY_GBO_COUNT:((gbo)>=GEANY_GBO_EXEC?(gbo)-GEANY_GBO_EXEC: \
88 ((gbo) >= GEANY_GBO_MAKE_ALL ? (gbo)-GEANY_GBO_MAKE_ALL : (gbo))))
90 enum GeanyBuildFixedMenuItems
92 GBF_NEXT_ERROR,
93 GBF_PREV_ERROR,
94 GBF_COMMANDS,
95 GBF_SEP_1,
96 GBF_SEP_2,
97 GBF_SEP_3,
98 GBF_SEP_4,
99 GBF_COUNT
102 /** Build menu item sources in increasing priority */
103 typedef enum
105 GEANY_BCS_DEF, /* *< Default values. */
106 GEANY_BCS_FT, /* *< System filetype values. */
107 GEANY_BCS_HOME_FT, /* *< Filetypes in ~/.config/geany/filedefs */
108 GEANY_BCS_PREF, /* *< Preferences file ~/.config/geany/geany.conf */
109 GEANY_BCS_PROJ_FT, /* *< Project file filetype command */
110 GEANY_BCS_PROJ, /* *< Project file if open. */
111 GEANY_BCS_COUNT /* *< Count of sources. */
112 } GeanyBuildSource;
114 typedef struct GeanyBuildInfo
116 GeanyBuildGroup grp;
117 guint cmd;
118 GPid pid; /* process id of the spawned process */
119 gchar *dir;
120 guint file_type_id;
121 gchar *custom_target;
122 gint message_count;
123 } GeanyBuildInfo;
125 extern GeanyBuildInfo build_info;
127 /** The entries of a command for a menu item */
128 typedef enum GeanyBuildCmdEntries
130 GEANY_BC_LABEL, /* *< The menu item label, _ marks mnemonic */
131 GEANY_BC_COMMAND, /* *< The command to run. */
132 GEANY_BC_WORKING_DIR, /* *< The directory to run in */
133 GEANY_BC_CMDENTRIES_COUNT /* *< Count of entries */
134 } GeanyBuildCmdEntries;
136 /* * The command for a menu item. */
137 typedef struct GeanyBuildCommand
139 /* * Pointers to g_string values of the command entries.
140 * Must be freed if the pointer is changed. */
141 gchar *label; /* *< Menu item label */
142 gchar *command; /* *< Command to run */
143 gchar *working_dir; /* *< working directory */
144 gboolean exists; /* *< If the entries have valid values. */
145 gboolean changed; /* *< Save on exit if @c changed, remove if not @c exist. */
146 gboolean old; /* *< Converted from old format. */
147 } GeanyBuildCommand;
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 BuildTableFields *BuildTableData;
167 void build_init(void);
169 void build_finalize(void);
171 /* menu configuration dialog functions */
172 GtkWidget *build_commands_table(GeanyDocument *doc, GeanyBuildSource dst, BuildTableData *data, GeanyFiletype *ft);
174 void build_read_project(GeanyFiletype *ft, BuildTableData build_properties);
176 void build_free_fields(BuildTableData data);
178 /* build response decode assistance function */
179 gboolean build_parse_make_dir(const gchar *string, gchar **prefix);
181 /* build menu functions */
183 void build_menu_update(GeanyDocument *doc);
185 void build_toolbutton_build_clicked(GtkAction *action, gpointer user_data);
187 void build_remove_menu_item(const GeanyBuildSource src, const GeanyBuildGroup grp, const gint cmd);
189 GeanyBuildCommand *build_get_menu_item(const GeanyBuildSource src, const GeanyBuildGroup grp, const guint cmd);
191 const gchar *build_get_current_menu_item(const GeanyBuildGroup grp, const guint cmd,
192 const GeanyBuildCmdEntries field);
194 void build_set_menu_item(const GeanyBuildSource src, const GeanyBuildGroup grp,
195 const guint cmd, const GeanyBuildCmdEntries field, const gchar *value);
197 void build_activate_menu_item(const GeanyBuildGroup grp, const guint cmd);
199 BuildMenuItems *build_get_menu_items(gint filetype_idx);
201 /* load and store menu configuration */
202 void build_load_menu(GKeyFile *config, GeanyBuildSource dst, gpointer ptr);
204 void build_save_menu(GKeyFile *config, gpointer ptr, GeanyBuildSource src);
206 void build_set_group_count(GeanyBuildGroup grp, gint count);
208 guint build_get_group_count(const GeanyBuildGroup grp);
210 gchar **build_get_regex(GeanyBuildGroup grp, GeanyFiletype *ft, guint *from);
212 G_END_DECLS
214 #endif /* GEANY_BUILD_H */