]> git.lyx.org Git - lyx.git/blob - src/minibuffer.h
Dekels tabular/textinset patches
[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 #include "Timeout.h"
9
10 #ifdef __GNUG__
11 #pragma interface
12 #endif
13
14 class LyXView;
15
16 #ifdef SIGC_CXX_NAMESPACES
17 using SigC::Object;
18 #endif
19
20 ///
21 class MiniBuffer : public Object{
22 public:
23         ///
24         MiniBuffer(LyXView * o,
25                    FL_Coord x, FL_Coord y, FL_Coord h, FL_Coord w);
26
27         ///
28         bool shows_no_match;
29
30         ///
31         void setTimer(unsigned int a) {
32                 timer.setTimeout(a * 1000);
33         }
34
35         ///
36         void Set(string const & = string(),
37                  string const & = string(),
38                  string const & = string(),
39                  unsigned int delay_secs = 6);
40         /// 
41         string const GetText() const { return text; }
42         ///
43         void Init();
44         ///
45         void PrepareForCommand();
46         /** allows to store and reset the contents one time. Usefull
47           for status messages like "load font" (Matthias)
48           */
49         void Store();
50         ///
51         void Reset();
52         ///
53         void Activate();
54         ///
55         void Deactivate();
56         ///
57         static void ExecutingCB(FL_OBJECT * ob, long);
58         ///
59         static int  peek_event(FL_OBJECT *, int, FL_Coord, FL_Coord,
60                                int, void *);
61 private:
62         ///
63         LyXView * owner;
64         ///
65         string text;
66         ///
67         string text_stored;
68         ///
69         FL_OBJECT * add(int, FL_Coord, FL_Coord, FL_Coord, FL_Coord);
70         ///
71         Timeout timer;
72         ///
73         FL_OBJECT * the_buffer;
74         ///
75         string cur_cmd;
76         ///
77         enum{ MAX_HISTORY = 10 };
78         ///
79         mutable string history[MAX_HISTORY];
80         ///
81         mutable int history_idx;
82         ///
83         mutable int history_cnt;
84         ///
85         void addHistory(string const & cmd) const { 
86                 if (history_cnt == 0
87                     || (history_cnt > 0
88                         && cmd != history[(history_cnt - 1) % MAX_HISTORY])) {
89                     history[history_cnt % MAX_HISTORY] = cmd;
90                     ++history_cnt;
91                 }
92                 history_idx = history_cnt;
93         }
94         ///
95         string const getHistory() const {
96                 return history[history_idx % MAX_HISTORY];
97         }
98 };
99 #endif