4 A Programmer's Text Editor
6 Key sequences support (mainly for ANSI strings).
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
35 sub mp.pending_key() { shift(mp.keyseq.pending); }
37 sub mp.process_keyseq(key)
41 if (mp.keyseq.ptr == NULL)
42 mp.keyseq.ptr = mp.keyseq.store;
44 /* store the key in the temporal queue */
45 push(mp.keyseq.tmp, key);
47 /* get the key in the current pointer */
48 k = mp.keyseq.ptr[key];
51 /* no hash for key? string not found;
52 return back all the stored keys
54 mp.keyseq.pending = mp.keyseq.tmp;
56 key = mp.pending_key();
61 /* is the value itself a hash? keep searching */
66 /* value is scalar; it's the keycode, so
67 return it and restart over */
69 mp.keyseq.pending = [];
78 sub mp.add_keyseq(seq, keycode)
80 local p = mp.keyseq.store;
84 /* split by character and store as a chain of hashes
85 with the keycode as the final, scalar value */