]> git.lyx.org Git - lyx.git/blob - src/kbmap.h
remove mention of lyxrc from the splash
[lyx.git] / src / kbmap.h
1 // -*- C++ -*-
2 /**
3  * \file kbmap.h
4  * Copyright 1995-2002 the LyX Team
5  * Read the file COPYING
6  *
7  * \author Lars Gullik Bjønnes <larsbj@lyx.org>
8  * \author John Levon <moz@compsoc.man.ac.uk>
9  */
10
11 #ifndef KBMAP_H
12 #define KBMAP_H
13
14 #include "LString.h"
15 #include "frontends/key_state.h"
16 #include "frontends/LyXKeySym.h"
17
18 #include <list>
19
20 class kb_sequence;
21
22 /// Defines key maps and actions for key sequences
23 class kb_keymap {
24 public:
25         /**
26          * Bind a key sequence to an action.
27          * @return 0 on success, or position in string seq where error
28          * occurs.
29          * See kb_sequence::parse for the syntax of the seq string
30          */
31         string::size_type bind(string const & seq, int action);
32
33         /// print all available keysyms
34         string const print() const;
35
36         /**
37          * Look up a key press in the keymap.
38          * @param key the keysym
39          * @param mod the modifiers
40          * @param seq the current key sequence so far
41          * @return the action / LFUN_PREFIX / LFUN_UNKNOWN_ACTION
42          */
43         int lookup(LyXKeySymPtr key,
44                    key_modifier::state mod, kb_sequence * seq) const;
45
46         /// Given an action, find all keybindings.
47         string const findbinding(int action,
48                                  string const & prefix = string()) const;
49
50         /**
51          * Returns a string of the given keysym, with modifiers.
52          * @param key the key as a keysym
53          * @param mod the modifiers
54          */
55         static string const printKeysym(LyXKeySymPtr key,
56                                         key_modifier::state mod);
57
58         typedef std::pair<key_modifier::state, key_modifier::state> modifier_pair;
59
60 private:
61         ///
62         struct kb_key {
63                 /// Keysym
64                 LyXKeySymPtr code;
65
66                 /// Modifier masks
67                 modifier_pair mod;
68
69                 /// Keymap for prefix keys
70                 boost::shared_ptr<kb_keymap> table;
71
72                 /// Action for !prefix keys
73                 int action;
74         };
75
76         /**
77          * Define an action for a key sequence.
78          * @param r internal recursion level
79          */
80         void defkey(kb_sequence * seq, int action, unsigned int r = 0);
81
82         ///  Returns a string of the given key
83         string const printKey(kb_key const & key) const;
84
85         /// is the table empty ?
86         bool empty() const {
87                 return table.empty();
88         }
89         ///
90         typedef std::list<kb_key> Table;
91         ///
92         Table table;
93 };
94
95 #endif // KBMAP_H