4 A Programmer's Text Editor
6 Miscellaneous editor actions.
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['eval'] = sub (d) {
34 label: L("Code to execute:"),
44 if (! regex(t, '/;\s*$/'))
50 mp.alert(L("Error: ") ~ ERROR);
55 mp.alert(L("Exit value:\n") ~ t);
59 mp.actions['eval_doc'] = sub (d) {
60 local t = join(mp.get_active_area(d), "\n");
66 mp.alert(L("Error: ") ~ ERROR);
68 /* try to move the cursor to the line
69 where the error was */
70 local l = regex(ERROR, [ '/, line /', '/[0-9]+/' ]);
80 mp.actions['exec_action'] = sub(d) {
81 local l = mp.actions->keys()->sort();
83 l = map(l, sub (e) { e ~ ' - ' ~ L(mp.actdesc[e] || ''); });
88 label: L("Select action to execute:"),
96 local a = regex(l[r[0]], '/^[^ ]+/');
98 mp.active()->mp.actions[a]();
102 mp.actions['encoding'] = sub (d) {
106 label: L("Encoding (utf-8, iso8859-1, etc.; empty, current locale)") ~ ':',
114 if (encoding(t[0]) == -1)
115 mp.alert(L("Invalid encoding ") ~ t[0]);
118 mp.actions['zoom_in'] = sub (d) {
120 mp.config.font_size++;
124 mp.actions['zoom_out'] = sub (d) {
126 if (mp.config.font_size > 4) {
127 mp.config.font_size--;
132 mp.actions['about'] = sub (d) {
134 "Minimum Profit %s (%s) - Programmer Text Editor\n\n"\
135 "Components: MPDM %s, MPSL %s\n\n"\
136 "Copyright (C) 1991-2011 Angel Ortega <angel@triptico.com> and others\n"\
138 "This program is free software; you can redistribute it and/or\n"\
139 "modify it under the terms of the GNU General Public License\n"\
140 "as published by the Free Software Foundation; either version 2\n"\
141 "of the License, or (at your option) any later version.\n"\
143 "This program is distributed in the hope that it will be useful,\n"\
144 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"\
145 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"\
146 "See the GNU General Public License for more details.\n"\
148 "You should have received a copy of the GNU General Public License\n"\
149 "along with this program; if not, write to the Free Software Foundation,\n"\
150 "Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n"\
152 "Home page: http://triptico.com/software/mp.html\n"\
153 "Mailing list: mp-subscribe@lists.triptico.com\n");
156 msg = sprintf(msg, mp.VERSION, (mp.drv.id || 'unknown'), mpdm.version, MPSL.VERSION);
158 d = mp.open("<about>");
160 if (size(d.txt.lines) == 1) {
167 /** default key bindings **/
169 mp.keycodes['escape'] = 'eval';
170 mp.keycodes['f12'] = 'zoom_in';
171 mp.keycodes['ctrl-kp-plus' ] = 'zoom_in';
172 mp.keycodes['f11'] = 'zoom_out';
173 mp.keycodes['ctrl-kp-minus' ] = 'zoom_out';
175 /** action descriptions **/
177 mp.actdesc['eval'] = LL("Execute MPSL code...");
178 mp.actdesc['eval_doc'] = LL("Execute document as MPSL");
179 mp.actdesc['exec_action'] = LL("Execute action on document...");
180 mp.actdesc['encoding'] = LL("Set charset encoding...");
181 mp.actdesc['zoom_in'] = LL("Bigger font");
182 mp.actdesc['zoom_out'] = LL("Smaller font");
183 mp.actdesc['about'] = LL("About...");
188 /* overwrite of the MPSL dump() function, dumping over a text document */
190 local d = mp.open("<dump>");
193 mp.insert(d, dumper(v));