4 A Programmer's Text Editor
6 Miscellaneous editor actions.
8 Copyright (C) 1991-2007 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
30 mp.actions['eval'] = sub (d) {
32 { 'label' => L("Code to execute:"),
40 if (! regex('/;\s*$/', t))
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("\n", d.txt.lines);
62 mp.alert(L("Error: ") ~ ERROR);
64 /* try to move the cursor to the line
65 where the error was */
68 if ((l = regex( [ '/, line /', '/[0-9]+/' ], ERROR)) != NULL)
76 mp.actions['encoding'] = sub (d) {
78 { 'label' => L("Encoding (utf-8, iso8859-1, etc.; empty, current locale)") ~ ':',
80 'history' => 'encoding' }
84 if (encoding(t[0]) == -1)
85 mp.alert(L("Invalid encoding ") ~ t[0]);
88 mp.actions['zoom_in'] = sub (d) {
90 mp.config.font_size++;
94 mp.actions['zoom_out'] = sub (d) {
96 if (mp.config.font_size > 4) {
97 mp.config.font_size--;
102 mp.actions['word_count'] = sub (d) {
104 local a = mp.get_active_area(d);
108 w += size(mp.split_by_words(l));
111 mp.alert(sprintf(L("Lines: %d Words: %d"), size(a), w));
114 mp.actions['about'] = sub (d) {
116 "\nMinimum Profit %s - Programmer Text Editor\n\n"\
117 "Components: MPDM %s, MPSL %s\n\n"\
118 "Copyright (C) 1991-2007 Angel Ortega <angel@triptico.com>\n"\
120 "This program is free software; you can redistribute it and/or\n"\
121 "modify it under the terms of the GNU General Public License\n"\
122 "as published by the Free Software Foundation; either version 2\n"\
123 "of the License, or (at your option) any later version.\n"\
125 "This program is distributed in the hope that it will be useful,\n"\
126 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"\
127 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"\
128 "See the GNU General Public License for more details.\n"\
130 "You should have received a copy of the GNU General Public License\n"\
131 "along with this program; if not, write to the Free Software Foundation,\n"\
132 "Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n"\
134 "Home page: http://www.triptico.com/software/mp.html\n"\
135 "Mailing list: mp-subscribe@lists.triptico.com\n");
138 msg = sprintf(msg, mp.VERSION, mpdm.version, MPSL.VERSION);
140 d = mp.open("<about>");
142 if (size(d.txt.lines) == 1) {
149 /* default key bindings */
151 mp.keycodes['escape'] = 'eval';
152 mp.keycodes['f12'] = 'zoom_in';
153 mp.keycodes['ctrl-kp-plus' ] = 'zoom_in';
154 mp.keycodes['f11'] = 'zoom_out';
155 mp.keycodes['ctrl-kp-minus' ] = 'zoom_out';
157 /* action descriptions */
159 mp.actdesc['eval'] = LL("Execute MPSL code...");
160 mp.actdesc['eval_doc'] = LL("Execute document as MPSL");
161 mp.actdesc['encoding'] = LL("Set charset encoding...");
162 mp.actdesc['zoom_in'] = LL("Bigger font");
163 mp.actdesc['zoom_out'] = LL("Smaller font");
164 mp.actdesc['word_count'] = LL("Count words");
165 mp.actdesc['about'] = LL("About...");
170 /* overwrite of the MPSL dump() function, dumping over a text document */
172 local d = mp.open("<dump>");
175 mp.insert(d, dumper(v));