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