]> git.lyx.org Git - lyx.git/blob - src/kbmap.h
use the new sstream return non-pods as const, use string instead of char * in a lot...
[lyx.git] / src / kbmap.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 KBMAP_H
10 #define KBMAP_H
11
12 #ifdef __GNUG__
13 #pragma interface
14 #endif
15
16 #include <list>
17
18 #include "LString.h"
19
20 class kb_sequence;
21
22 /// Defines key maps and actions for key sequences
23 class kb_keymap {
24 public:
25         ///
26         ~kb_keymap();
27         
28         /** Bind a key-sequence to an action.
29             Returns 0 on success. Otherwise, position in string where
30             error occured. */
31         int bind(string const & seq, int action);
32
33         ///
34         void print(string & buf) const;
35         
36         /// Look up a key in the keymap
37         int lookup(unsigned int key,
38                    unsigned int mod, kb_sequence * seq) const;
39
40         /// Given an action, find all keybindings.
41         string const findbinding(int action) const;
42 private:
43         ///
44         struct kb_key {
45                 /// Keysym
46                 unsigned int code;
47                 
48                 /// Modifier masks
49                 unsigned int mod;
50                 
51                 /// Keymap for prefix keys
52                 kb_keymap * table;
53                 
54                 /// Action for !prefix keys
55                 int action;
56         };
57
58
59         /// Define a new key sequence
60         int defkey(kb_sequence * seq, int action, int idx = 0);
61         ///
62         static string const keyname(kb_key const & k);
63         
64         ///
65         static
66         void printKey(kb_key const & key, string & buf);
67         ///
68         bool empty() const {
69                 return table.empty();
70         }
71         ///
72         typedef std::list<kb_key> Table;
73         ///
74         Table table;
75 };
76
77 #endif