]> git.lyx.org Git - lyx.git/blob - src/LyXAction.h
2c1bda9e2b685d402c450ecf47c69e0709913f96
[lyx.git] / src / LyXAction.h
1 // -*- C++ -*-
2 #ifndef _LYXACTION_H_
3 #define _LYXACTION_H_
4
5 #ifdef __GNUG__
6 #pragma interface
7 #endif
8
9 #include "commandtags.h"
10
11 class LString;
12
13 /// Command name - action   
14 struct kb_func_table {
15         ///
16         char const *name;
17         ///
18         kb_action action;
19 };
20
21
22 /** This class encapsulates LyX action and user command operations.
23  */
24 class LyXAction {
25 public:
26         ///
27         LyXAction();
28         ///
29         ~LyXAction();
30     
31         /** Returns an action tag from a string. Returns kb_action.
32           Include arguments in func_name ONLY if you
33           want to create new pseudo actions. */
34         int LookupFunc(char const *func_name); 
35
36         /** Returns an action tag which name is the most similar to a string.
37             Don't include arguments, they would be ignored. */
38         int getApproxFunc(char const *func);
39
40         /** Returns an action name the most similar to a string.
41             Don't include arguments, they would be ignored. */
42         const char *getApproxFuncName(char const *func);
43
44         /// Returns a pseudo-action given an action and its argument.
45         int getPseudoAction(kb_action action, char const *arg);
46
47         /// Retrieves the real action and its argument.
48         int retrieveActionArg(int i, char const **arg);
49     
50         /// Search for an existent pseudoaction, return -1 if it doesn't exist.
51         int searchActionArg(kb_action action, char const *arg);
52
53         /// Check if a value is a pseudo-action. 
54         bool isPseudoAction(int);
55     
56         /// Not sure if this function should be here 
57         int bindKey(char const* seq, int action);
58         
59         /// Return the name associated with command
60         char const *getActionName(int action) const;
61
62         /// Return one line help text associated with command
63         char const *helpText(kb_action action) const;
64
65          /// True if the command is Read Only (not allowed for RO buffers)
66         bool isFuncRO(kb_action action) const;
67
68 private:
69      
70         ///  Standard commands
71         static kb_func_table const * lyx_func_table;
72         /// Number of commands
73         int funcCount;
74         ///  Pseudoactions
75         static kb_func_table *lyx_func_args;
76         ///  Pseudoaction index
77         static int psd_idx; 
78         /// Last action index found
79         int last_action_idx;
80 };
81      
82
83 /* --------------------   Inlines  ------------------ */
84     
85      
86 inline
87 bool LyXAction::isPseudoAction(int a) 
88
89         return (a >= (int)LFUN_LASTACTION); 
90 }
91      
92
93 #endif