]> git.lyx.org Git - lyx.git/blob - src/kbsequence.h
Various fixes, removed "default" language, inserted new lyxrc tag
[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 "LString.h"
17
18 #define KB_PREALLOC  16
19
20 class kb_keymap;
21
22 /// Holds a key sequence and the current and standard keymaps
23 class kb_sequence {
24 public:
25         ///
26         kb_sequence() {
27                 stdmap = curmap = 0;
28                 sequence = staticseq;
29                 modifiers = staticmod;
30                 length = 0; 
31                 size = KB_PREALLOC;
32         }
33         
34         ///
35         ~kb_sequence() {
36                 if (sequence != staticseq) {
37                         delete sequence;
38                         delete modifiers;
39                 }
40         }
41         
42         /** Add a key to the key sequence and look it up in the curmap
43             if the latter is defined. */
44         int addkey(unsigned int key, unsigned int mod, unsigned int nmod = 0);
45
46         ///
47         int print(string & buf, bool when_defined = false) const;
48         
49         ///
50         int printOptions(string & buf) const;
51         
52         /// Make length negative to mark the sequence as deleted
53         void delseq();
54         
55         ///
56         char getiso() const;
57         
58         ///
59         unsigned int getsym() const;
60         
61         ///
62         void reset();
63         
64         ///
65         int parse(string const & s);
66         
67         /// Keymap to use if a new sequence is starting
68         kb_keymap * stdmap;
69         
70         /// Keymap to use for the next key
71         kb_keymap * curmap;
72         
73         /** Array holding the current key sequence.
74             If sequence[length-1] < 0xff it can be used as ISO8859 char */
75         unsigned int * sequence;
76         
77         ///
78         unsigned int * modifiers;
79         
80         /// Current length of key sequence
81         int length;
82         
83 private:
84         /// Static array preallocated for sequence
85         unsigned int staticseq[KB_PREALLOC];
86         
87         ///
88         unsigned int staticmod[KB_PREALLOC];
89         
90         /// Physically allocated storage size
91         int size;
92 };
93
94 #endif