]> git.lyx.org Git - lyx.git/blob - src/minibuffer.h
27b802c5b0b45a5fbe283cc386b68f9fe0d155b0
[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                 : 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(string const& = string(),
35                  string const& = string(),
36                  string const& = string(),
37                  int delay_secs=6);
38         /// 
39         string 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         string text;
59         ///
60         string 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         string cur_cmd;
76         ///
77         enum{ MAX_HISTORY = 10 };
78         ///
79         string history[MAX_HISTORY];
80         ///
81         int history_idx, history_cnt;
82         ///
83         void addHistory(string 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         string getHistory() { return history[history_idx % MAX_HISTORY]; }
92 };
93 #endif