]> git.lyx.org Git - lyx.git/blob - src/minibuffer.h
07d26fa0eecc2d766d6ec9e70948a91135fa36d7
[lyx.git] / src / minibuffer.h
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
21         ///
22         bool shows_no_match;
23         ///
24         void setTimer(int a) {
25                 fl_set_timer(timer, a);
26         }
27         ///
28         void Set(string const & = string(),
29                  string const & = string(),
30                  string const & = string(),
31                  int delay_secs= 6);
32         /// 
33         string GetText() const { return text; }
34         ///
35         void Init();
36         ///
37         void ExecCommand();
38         /** allows to store and reset the contents one time. Usefull
39           for status messages like "load font" (Matthias)
40           */
41         void Store();
42         ///
43         void Reset();
44         ///
45         void Activate();
46         ///
47         void Deactivate();
48         ///
49         static void ExecutingCB(FL_OBJECT *ob, long);
50         ///
51         static void TimerCB(FL_OBJECT *ob, long);
52         ///
53         static int  peek_event(FL_OBJECT *, int, FL_Coord, FL_Coord,
54                                int, void *);
55 private:
56         ///
57         LyXView *owner;
58         ///
59         string text;
60         ///
61         string text_stored;
62         ///
63         FL_OBJECT *add(int, FL_Coord, FL_Coord, FL_Coord, FL_Coord);
64         ///
65         FL_OBJECT *timer;
66         ///
67         FL_OBJECT *the_buffer;
68         ///
69         string cur_cmd;
70         ///
71         enum{ MAX_HISTORY = 10 };
72         ///
73         string history[MAX_HISTORY];
74         ///
75         int history_idx, history_cnt;
76         ///
77         void addHistory(string const &cmd) { 
78                 if (history_cnt == 0 || (history_cnt>0 && cmd!= history[(history_cnt-1) % MAX_HISTORY])) {
79                     history[history_cnt % MAX_HISTORY] = cmd;
80                     ++history_cnt;
81                 }
82                 history_idx = history_cnt;
83         }
84         ///
85         string getHistory() { return history[history_idx % MAX_HISTORY]; }
86 };
87 #endif