1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
1999-11-15 12:01:38 +00:00
|
|
|
#ifndef LYXACTION_H
|
|
|
|
#define LYXACTION_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "commandtags.h"
|
|
|
|
|
|
|
|
class LString;
|
|
|
|
|
|
|
|
/// Command name - action
|
|
|
|
struct kb_func_table {
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
char const * name;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
kb_action action;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** This class encapsulates LyX action and user command operations.
|
|
|
|
*/
|
|
|
|
class LyXAction {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
LyXAction();
|
|
|
|
///
|
|
|
|
~LyXAction();
|
|
|
|
|
|
|
|
/** Returns an action tag from a string. Returns kb_action.
|
|
|
|
Include arguments in func_name ONLY if you
|
|
|
|
want to create new pseudo actions. */
|
1999-11-15 12:01:38 +00:00
|
|
|
int LookupFunc(char const * func_name);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/** Returns an action tag which name is the most similar to a string.
|
|
|
|
Don't include arguments, they would be ignored. */
|
1999-11-15 12:01:38 +00:00
|
|
|
int getApproxFunc(char const * func);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/** Returns an action name the most similar to a string.
|
|
|
|
Don't include arguments, they would be ignored. */
|
1999-11-15 12:01:38 +00:00
|
|
|
char const * getApproxFuncName(char const * func);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// Returns a pseudo-action given an action and its argument.
|
1999-11-15 12:01:38 +00:00
|
|
|
int getPseudoAction(kb_action action, char const * arg);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// Retrieves the real action and its argument.
|
1999-11-15 12:01:38 +00:00
|
|
|
int retrieveActionArg(int i, char const ** arg);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// Search for an existent pseudoaction, return -1 if it doesn't exist.
|
1999-11-15 12:01:38 +00:00
|
|
|
int searchActionArg(kb_action action, char const * arg);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// Check if a value is a pseudo-action.
|
|
|
|
bool isPseudoAction(int);
|
|
|
|
|
|
|
|
/// Not sure if this function should be here
|
1999-11-15 12:01:38 +00:00
|
|
|
int bindKey(char const * seq, int action);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// Return the name associated with command
|
1999-11-15 12:01:38 +00:00
|
|
|
char const * getActionName(int action) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// Return one line help text associated with command
|
1999-11-15 12:01:38 +00:00
|
|
|
char const * helpText(kb_action action) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// True if the command is Read Only (not allowed for RO buffers)
|
|
|
|
bool isFuncRO(kb_action action) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
/// Standard commands
|
|
|
|
static kb_func_table const * lyx_func_table;
|
|
|
|
/// Number of commands
|
|
|
|
int funcCount;
|
|
|
|
/// Pseudoactions
|
1999-11-15 12:01:38 +00:00
|
|
|
static kb_func_table * lyx_func_args;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Pseudoaction index
|
|
|
|
static int psd_idx;
|
|
|
|
/// Last action index found
|
|
|
|
int last_action_idx;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* -------------------- Inlines ------------------ */
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
bool LyXAction::isPseudoAction(int a)
|
|
|
|
{
|
1999-11-15 12:01:38 +00:00
|
|
|
return (a >= int(LFUN_LASTACTION));
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|