4 A Programmer's Text Editor
6 A simple IDE-like build system.
8 Copyright (C) 1991-2011 Angel Ortega <angel@triptico.com>
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License
12 as published by the Free Software Foundation; either version 2
13 of the License, or (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 http://www.triptico.com
28 /** editor actions **/
30 mp.actions['build'] = sub(doc) {
34 if ((t = mp.build_get_targets()) == NULL) {
35 mp.alert(L("No Makefile targets found."));
39 /* more than one target? ask user to pick one */
42 { 'label' => L("Makefile target") ~ ':',
56 mp.long_op(mp.build_execute, target);
60 mp.actions['insert_next_item'] = sub(doc) {
63 foreach (l, doc.txt.lines) {
64 local r = regex(l, ['/^ \* /', '/[0-9]+/', '/: /']);
71 mp.insert(doc, ' * ' ~ (n + 1) ~ ': ');
74 /** Default key bindings **/
76 mp.keycodes['f2'] = "build";
78 /** action descriptions **/
80 mp.actdesc['build'] = LL("Build project...");
81 mp.actdesc['insert_next_item'] = LL("Insert next item");
86 sub mp.build_get_targets
90 if ((f = open('Makefile', 'r')) != NULL) {
98 if (t = regex(l, '/^[A-Za-z0-9_\.-]+:/'))
99 push(r, sregex(t, '/:/', ''));
109 sub mp.build_execute(target)
111 local log = mp.open('<make output>');
116 /* pipe through make */
118 if ((p = popen('make ' ~ target, 'r')) != NULL) {
129 log.syntax = mp.syntax.make_output;
133 /* set the last search regex to match file:line strings,
134 so that calling seek-next and seek-prev moves there */
135 mp.last_search = '/^[a-z\.\_0-9\/-]+:[0-9]+:/m';