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