]> git.lyx.org Git - lyx.git/blob - src/kbsequence.h
060f8ae3963b2e88da77f67f8112ae46ea0cf0f6
[lyx.git] / src / kbsequence.h
1 // -*- C++ -*-
2 /* ======================================================================= *\
3    File   : kbmap.h, kbmap.h,v 1.3 1996/12/10 04:35:57 larsbj Exp
4    Author : chb, 30.Oct.1995
5    Docu   : see kbmap.C
6    Purpose: class definitions for XKeyEvent keymap handling
7    \* ==================================================================== */
8
9 #ifndef KBSEQUENCE_H
10 #define KBSEQUENCE_H
11
12 #ifdef __GNUG__
13 #pragma interface
14 #endif
15
16 #include <vector>
17 #include "LString.h"
18
19 #if 0
20 #define KB_PREALLOC  16
21 #endif
22
23 class kb_keymap;
24
25 /// Holds a key sequence and the current and standard keymaps
26 class kb_sequence {
27 public:
28         ///
29         kb_sequence() {
30                 stdmap = curmap = 0;
31 #if 0
32                 sequence = staticseq;
33                 modifiers = staticmod;
34 #endif
35                 length = 0;
36 #if 0
37                 size = KB_PREALLOC;
38 #endif
39         }
40
41 #if 0
42         ///
43         ~kb_sequence() {
44                 if (sequence != staticseq) {
45                         delete sequence;
46                         delete modifiers;
47                 }
48         }
49 #endif
50         
51         /** Add a key to the key sequence and look it up in the curmap
52             if the latter is defined. */
53         int addkey(unsigned int key, unsigned int mod, unsigned int nmod = 0);
54
55         ///
56         int print(string & buf, bool when_defined = false) const;
57         
58         ///
59         int printOptions(string & buf) const;
60         
61         /// Make length negative to mark the sequence as deleted
62         void delseq();
63         
64         ///
65         char getiso() const;
66         
67         ///
68         unsigned int getsym() const;
69         
70         ///
71         void reset();
72         
73         ///
74         int parse(string const & s);
75         
76         /// Keymap to use if a new sequence is starting
77         kb_keymap * stdmap;
78         
79         /// Keymap to use for the next key
80         kb_keymap * curmap;
81         
82         /** Array holding the current key sequence.
83             If sequence[length-1] < 0xff it can be used as ISO8859 char */
84 #if 0
85         unsigned int * sequence;
86 #else
87         std::vector<unsigned int> sequence;
88 #endif
89         
90         ///
91 #if 0
92         unsigned int * modifiers;
93 #else
94         std::vector<unsigned int> modifiers;
95 #endif
96         
97         /// Current length of key sequence
98         int length;
99 #if 0
100 private:
101         /// Static array preallocated for sequence
102         unsigned int staticseq[KB_PREALLOC];
103         
104         ///
105         unsigned int staticmod[KB_PREALLOC];
106         
107         /// Physically allocated storage size
108         int size;
109 #endif
110 };
111
112 #endif