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) {
32 { 'label' => L("Code to execute:"),
40 if (! regex(t, '/;\s*$/'))
46 mp.alert(L("Error: ") ~ ERROR);
51 mp.alert(L("Exit value:\n") ~ t);
55 mp.actions['eval_doc'] = sub (d) {
56 local t = join(mp.get_active_area(d), "\n");
62 mp.alert(L("Error: ") ~ ERROR);
64 /* try to move the cursor to the line
65 where the error was */
66 local l = regex(ERROR, [ '/, line /', '/[0-9]+/' ]);
76 mp.actions['exec_action'] = sub(d) {
77 local l = mp.actions->keys()->sort();
79 l = map(l, sub (e) { e ~ ' - ' ~ L(mp.actdesc[e] || ''); });
82 { 'label' => L("Select action to execute:"),
88 local a = regex(l[r[0]], '/^[^ ]+/');
90 mp.active()->mp.actions[a]();
94 mp.actions['encoding'] = sub (d) {
96 { 'label' => L("Encoding (utf-8, iso8859-1, etc.; empty, current locale)") ~ ':',
98 'history' => 'encoding' }
102 if (encoding(t[0]) == -1)
103 mp.alert(L("Invalid encoding ") ~ t[0]);
106 mp.actions['zoom_in'] = sub (d) {
108 mp.config.font_size++;
112 mp.actions['zoom_out'] = sub (d) {
114 if (mp.config.font_size > 4) {
115 mp.config.font_size--;
120 mp.actions['about'] = sub (d) {
122 "\nMinimum Profit %s - Programmer Text Editor\n\n"\
123 "Components: MPDM %s, MPSL %s\n\n"\
124 "Copyright (C) 1991-2011 Angel Ortega <angel@triptico.com>\n"\
126 "This program is free software; you can redistribute it and/or\n"\
127 "modify it under the terms of the GNU General Public License\n"\
128 "as published by the Free Software Foundation; either version 2\n"\
129 "of the License, or (at your option) any later version.\n"\
131 "This program is distributed in the hope that it will be useful,\n"\
132 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"\
133 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"\
134 "See the GNU General Public License for more details.\n"\
136 "You should have received a copy of the GNU General Public License\n"\
137 "along with this program; if not, write to the Free Software Foundation,\n"\
138 "Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n"\
140 "Home page: http://www.triptico.com/software/mp.html\n"\
141 "Mailing list: mp-subscribe@lists.triptico.com\n");
144 msg = sprintf(msg, mp.VERSION, mpdm.version, MPSL.VERSION);
146 d = mp.open("<about>");
148 if (size(d.txt.lines) == 1) {
155 /** default key bindings **/
157 mp.keycodes['escape'] = 'eval';
158 mp.keycodes['f12'] = 'zoom_in';
159 mp.keycodes['ctrl-kp-plus' ] = 'zoom_in';
160 mp.keycodes['f11'] = 'zoom_out';
161 mp.keycodes['ctrl-kp-minus' ] = 'zoom_out';
163 /** action descriptions **/
165 mp.actdesc['eval'] = LL("Execute MPSL code...");
166 mp.actdesc['eval_doc'] = LL("Execute document as MPSL");
167 mp.actdesc['exec_action'] = LL("Execute action on document...");
168 mp.actdesc['encoding'] = LL("Set charset encoding...");
169 mp.actdesc['zoom_in'] = LL("Bigger font");
170 mp.actdesc['zoom_out'] = LL("Smaller font");
171 mp.actdesc['about'] = LL("About...");
176 /* overwrite of the MPSL dump() function, dumping over a text document */
178 local d = mp.open("<dump>");
181 mp.insert(d, dumper(v));