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