r5162 | eht16 | 2010-08-15 13:53:09 +0100 (Sun, 15 Aug 2010) | 1 line
[geany-mirror.git] / src / build.h
blobfd459e45cfb66c6c9272b983d65a1097db27c446
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 /* Order is important (see GBO_TO_GBG, GBO_TO_CMD below) */
30 /** Geany Known Build Commands.
31 * These commands are named after their default use.
32 * Only these commands can currently have keybindings.
33 **/
34 typedef enum
36 GEANY_GBO_COMPILE, /**< default compile file */
37 GEANY_GBO_BUILD, /**< default build file */
38 GEANY_GBO_MAKE_ALL, /**< default make */
39 GEANY_GBO_CUSTOM, /**< default make user specified target */
40 GEANY_GBO_MAKE_OBJECT, /**< default make object, make %e.o */
41 GEANY_GBO_EXEC, /**< default execute ./%e */
42 GEANY_GBO_COUNT /**< count of how many */
43 } GeanyBuildType;
45 /** Groups of Build menu items. */
46 typedef enum
48 GEANY_GBG_FT, /**< filetype items */
49 GEANY_GBG_NON_FT, /**< non filetype items.*/
50 GEANY_GBG_EXEC, /**< execute items */
51 GEANY_GBG_COUNT /**< count of groups. */
52 } GeanyBuildGroup;
54 /* include the fixed widgets in an array indexed by groups */
55 #define GBG_FIXED GEANY_GBG_COUNT
57 /** Convert @c GeanyBuildType to @c GeanyBuildGroup.
59 * This macro converts @c GeanyBuildType enum values (the "known" commands)
60 * to the group they are part of.
62 * @param gbo the @c GeanyBuildType value.
64 * @return the @c GeanyBuildGroup group that @a gbo is in.
66 * Note this is a macro so that it can be used in static initialisers.
67 **/
68 #define GBO_TO_GBG(gbo) ((gbo)>GEANY_GBO_EXEC?GEANY_GBG_COUNT:((gbo)>=GEANY_GBO_EXEC?GEANY_GBG_EXEC: \
69 ((gbo) >= GEANY_GBO_MAKE_ALL ? GEANY_GBG_NON_FT : GEANY_GBG_FT)))
71 /** Convert @c GeanyBuildType to command index.
73 * This macro converts @c GeanyBuildType enum values (the "known" commands)
74 * to the index within the group.
76 * @param gbo the @c GeanyBuildType value.
78 * @return the index of the @a gbo command in its group.
80 * Note this is a macro so that it can be used in static initialisers.
81 **/
82 #define GBO_TO_CMD(gbo) ((gbo)>=GEANY_GBO_COUNT?(gbo)-GEANY_GBO_COUNT:((gbo)>=GEANY_GBO_EXEC?(gbo)-GEANY_GBO_EXEC: \
83 ((gbo) >= GEANY_GBO_MAKE_ALL ? (gbo)-GEANY_GBO_MAKE_ALL : (gbo))))
85 enum GeanyBuildFixedMenuItems
87 GBF_NEXT_ERROR,
88 GBF_PREV_ERROR,
89 GBF_COMMANDS,
90 GBF_SEP_1,
91 GBF_SEP_2,
92 GBF_SEP_3,
93 GBF_SEP_4,
94 GBF_COUNT
97 /** Build menu item sources in increasing priority */
98 typedef enum
100 GEANY_BCS_DEF, /**< Default values. */
101 GEANY_BCS_FT, /**< System filetype values. */
102 GEANY_BCS_HOME_FT, /**< Filetypes in ~/.config/geany/filedefs */
103 GEANY_BCS_PREF, /**< Preferences file ~/.config/geany/geany.conf */
104 GEANY_BCS_PROJ_FT, /**< Project file filetype command */
105 GEANY_BCS_PROJ, /**< Project file if open. */
106 GEANY_BCS_COUNT /**< Count of sources. */
107 } GeanyBuildSource;
109 typedef struct GeanyBuildInfo
111 GeanyBuildGroup grp;
112 gint cmd;
113 GPid pid; /* process id of the spawned process */
114 gchar *dir;
115 guint file_type_id;
116 gchar *custom_target;
117 gint message_count;
118 } GeanyBuildInfo;
120 extern GeanyBuildInfo build_info;
122 /** The entries of a command for a menu item */
123 typedef enum GeanyBuildCmdEntries
125 GEANY_BC_LABEL, /**< The menu item label, _ marks mnemonic */
126 GEANY_BC_COMMAND, /**< The command to run. */
127 GEANY_BC_WORKING_DIR, /**< The directory to run in */
128 GEANY_BC_CMDENTRIES_COUNT /**< Count of entries */
129 } GeanyBuildCmdEntries;
131 /** The command for a menu item. */
132 typedef struct GeanyBuildCommand
134 /** Pointers to g_string values of the command entries.
135 * Must be freed if the pointer is changed. */
136 gchar *entries[GEANY_BC_CMDENTRIES_COUNT];
137 gboolean exists; /**< If the entries have valid values. */
138 gboolean changed; /**< Save on exit if @c changed, remove if not @c exist. */
139 gboolean old; /**< Converted from old format. */
140 } GeanyBuildCommand;
142 typedef struct BuildMenuItems
144 GtkWidget *menu;
145 GtkWidget **menu_item[GEANY_GBG_COUNT + 1]; /* +1 for fixed items */
146 } BuildMenuItems;
148 /* a structure defining the destinations for a set of groups of commands & regex */
149 typedef struct BuildDestination
151 GeanyBuildCommand **dst[GEANY_GBG_COUNT];
152 gchar **fileregexstr;
153 gchar **nonfileregexstr;
154 } BuildDestination;
156 /* opaque pointers returned from build functions and passed back to them */
157 typedef struct BuildTableFields *BuildTableData;
159 void build_init(void);
161 void build_finalize(void);
163 /* menu configuration dialog functions */
164 GtkWidget *build_commands_table(GeanyDocument *doc, GeanyBuildSource dst, BuildTableData *data, GeanyFiletype *ft);
166 void build_read_project(GeanyFiletype *ft, BuildTableData build_properties);
168 void build_free_fields(BuildTableData data);
170 void build_set_non_ft_wd_to_proj(BuildTableData table_data);
172 /* build response decode assistance function */
173 gboolean build_parse_make_dir(const gchar *string, gchar **prefix);
175 /* build menu functions */
177 void build_menu_update(GeanyDocument *doc);
179 void build_toolbutton_build_clicked(GtkAction *action, gpointer user_data);
181 void build_remove_menu_item(GeanyBuildSource src, GeanyBuildGroup grp, gint cmd);
183 GeanyBuildCommand *build_get_menu_item(GeanyBuildSource src, GeanyBuildGroup grp, gint cmd);
185 GeanyBuildCommand *build_get_current_menu_item(GeanyBuildGroup grp, gint cmd, gint *src);
187 BuildMenuItems *build_get_menu_items(gint filetype_idx);
189 /* load and store menu configuration */
190 void build_load_menu(GKeyFile *config, GeanyBuildSource dst, gpointer ptr);
192 void build_save_menu(GKeyFile *config, gpointer ptr, GeanyBuildSource src);
194 void build_set_group_count(GeanyBuildGroup grp, gint count);
196 gint build_get_group_count(GeanyBuildGroup grp);
198 gchar **build_get_regex(GeanyBuildGroup grp, GeanyFiletype *ft, gint *from);
200 #endif