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:"),
43 mp.alert(L("Error: ") ~ ERROR);
48 mp.alert(L("Exit value:\n") ~ t);
52 mp.actions['eval_doc'] = sub (d) {
53 local t = join("\n", d.txt.lines);
61 mp.alert(L("Error: ") ~ ERROR);
63 /* try to move the cursor to the line
64 where the error was */
67 if((l = regex( [ '/, line /', '/[0-9]+/' ], ERROR)) != NULL)
75 mp.actions['encoding'] = sub (d) {
77 { 'label' => L("Encoding (utf-8, iso8859-1, etc.; empty, current locale)") ~ ':',
79 'history' => 'encoding' }
83 if(encoding(t[0]) == -1)
84 mp.alert(L("Invalid encoding ") ~ t[0]);
87 mp.actions['zoom_in'] = sub (d) {
89 mp.config.font_size++;
93 mp.actions['zoom_out'] = sub (d) {
95 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.find_file_by_name("<about>");
148 d = mp.new("<about>", split("\n", msg));
151 /* default key bindings */
153 mp.keycodes['escape'] = 'eval';
154 mp.keycodes['f12'] = 'zoom_in';
155 mp.keycodes['ctrl-kp-plus' ] = 'zoom_in';
156 mp.keycodes['f11'] = 'zoom_out';
157 mp.keycodes['ctrl-kp-minus' ] = 'zoom_out';
159 /* action descriptions */
161 mp.actdesc['eval'] = LL("Execute MPSL code...");
162 mp.actdesc['eval_doc'] = LL("Execute document as MPSL");
163 mp.actdesc['encoding'] = LL("Set charset encoding...");
164 mp.actdesc['zoom_in'] = LL("Bigger font");
165 mp.actdesc['zoom_out'] = LL("Smaller font");
166 mp.actdesc['word_count'] = LL("Count words");
167 mp.actdesc['about'] = LL("About...");
172 /* overwrite of the MPSL dump() function, dumping over a text document */
174 local d = mp.open("<dump>");
177 mp.insert(d, dumper(v));