4 A Programmer's Text Editor
6 Miscellaneous editor actions.
8 Copyright (C) 1991-2009 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('/;\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['about'] = sub (d) {
104 "\nMinimum Profit %s - Programmer Text Editor\n\n"\
105 "Components: MPDM %s, MPSL %s\n\n"\
106 "Copyright (C) 1991-2009 Angel Ortega <angel@triptico.com>\n"\
108 "This program is free software; you can redistribute it and/or\n"\
109 "modify it under the terms of the GNU General Public License\n"\
110 "as published by the Free Software Foundation; either version 2\n"\
111 "of the License, or (at your option) any later version.\n"\
113 "This program is distributed in the hope that it will be useful,\n"\
114 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"\
115 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"\
116 "See the GNU General Public License for more details.\n"\
118 "You should have received a copy of the GNU General Public License\n"\
119 "along with this program; if not, write to the Free Software Foundation,\n"\
120 "Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n"\
122 "Home page: http://www.triptico.com/software/mp.html\n"\
123 "Mailing list: mp-subscribe@lists.triptico.com\n");
126 msg = sprintf(msg, mp.VERSION, mpdm.version, MPSL.VERSION);
128 d = mp.open("<about>");
130 if (size(d.txt.lines) == 1) {
137 /** default key bindings **/
139 mp.keycodes['escape'] = 'eval';
140 mp.keycodes['f12'] = 'zoom_in';
141 mp.keycodes['ctrl-kp-plus' ] = 'zoom_in';
142 mp.keycodes['f11'] = 'zoom_out';
143 mp.keycodes['ctrl-kp-minus' ] = 'zoom_out';
145 /** action descriptions **/
147 mp.actdesc['eval'] = LL("Execute MPSL code...");
148 mp.actdesc['eval_doc'] = LL("Execute document as MPSL");
149 mp.actdesc['encoding'] = LL("Set charset encoding...");
150 mp.actdesc['zoom_in'] = LL("Bigger font");
151 mp.actdesc['zoom_out'] = LL("Smaller font");
152 mp.actdesc['about'] = LL("About...");
157 /* overwrite of the MPSL dump() function, dumping over a text document */
159 local d = mp.open("<dump>");
162 mp.insert(d, dumper(v));