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 / minibuffer.h < prev    next >
C/C++ Source or Header  |  1998-04-23  |  2KB  |  94 lines

  1. // -*- C++ -*-
  2. #ifndef _MINIBUFFER_H
  3. #define _MINIBUFFER_H
  4.  
  5. #include FORMS_H_LOCATION
  6. #include "LString.h"
  7. #include "gettext.h"
  8.  
  9. #ifdef __GNUG__
  10. #pragma interface
  11. #endif
  12.  
  13. class LyXView;
  14.  
  15. ///
  16. class MiniBuffer {
  17. public:
  18.     ///
  19.     MiniBuffer(LyXView *o, FL_Coord x, FL_Coord y, FL_Coord h, FL_Coord w)
  20.         : owner(o)
  21.     {
  22.         text = _("Welcome to LyX!");
  23.         shows_no_match = true;
  24.             history_idx = history_cnt = 0;
  25.             add(FL_NORMAL_INPUT, x, y, h, w);
  26.     }
  27.     ///
  28.     bool shows_no_match;
  29.     ///
  30.     void setTimer(int a) {
  31.         fl_set_timer(timer, a);
  32.     }
  33.     ///
  34.     void Set(LString const& = LString(),
  35.          LString const& = LString(),
  36.          LString const& = LString(),
  37.          int delay_secs=6);
  38.     /// 
  39.     LString GetText() const { return text; }
  40.     ///
  41.     void Init();
  42.     ///
  43.     void ExecCommand();
  44.     /** allows to store and reset the contents one time. Usefull
  45.       for status messages like "load font" (Matthias)
  46.       */
  47.     void Store();
  48.     ///
  49.     void Reset();
  50.     ///
  51.     void Activate();
  52.     ///
  53.     void Deactivate();
  54. private:
  55.     ///
  56.     LyXView *owner;
  57.     ///
  58.     LString text;
  59.     ///
  60.     LString text_stored;
  61.     ///
  62.     FL_OBJECT *add(int, FL_Coord, FL_Coord, FL_Coord, FL_Coord);
  63.     ///
  64.     static void ExecutingCB(FL_OBJECT *ob, long);
  65.     ///
  66.     static void TimerCB(FL_OBJECT *ob, long);
  67.     ///
  68.         static int  peek_event(FL_OBJECT *, int, FL_Coord, FL_Coord,
  69.                    int, void *);
  70.         ///
  71.     FL_OBJECT *timer;
  72.     ///
  73.     FL_OBJECT *the_buffer;
  74.     ///
  75.     LString cur_cmd;
  76.         ///
  77.         enum{ MAX_HISTORY = 10 };
  78.         ///
  79.         LString history[MAX_HISTORY];
  80.         ///
  81.         int history_idx, history_cnt;
  82.         ///
  83.         void addHistory(LString const &cmd) { 
  84.             if (history_cnt==0 || (history_cnt>0 && cmd!=history[history_cnt-1 % MAX_HISTORY])) {
  85.             history[history_cnt % MAX_HISTORY] = cmd;
  86.             history_cnt++;
  87.         }
  88.             history_idx = history_cnt;
  89.     }
  90.         ///
  91.         LString getHistory() { return history[history_idx % MAX_HISTORY]; }
  92. };
  93. #endif
  94.