home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / lyx-0.13.2.tar.gz / lyx-0.13.2.tar / lyx-0.13.2 / src / LyXAction.h < prev    next >
C/C++ Source or Header  |  1998-04-23  |  2KB  |  93 lines

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