#ifndef MINIBUFFER_H
#define MINIBUFFER_H
+#include <sigc++/signal_system.h>
+#include <vector>
+
#include FORMS_H_LOCATION
#include "LString.h"
-#include "gettext.h"
+#include "frontends/Timeout.h"
#ifdef __GNUG__
#pragma interface
class LyXView;
///
-class MiniBuffer {
+class MiniBuffer : public SigC::Object {
public:
+ enum State {
+ spaces,
+ nospaces
+ };
+
+ ///
+ MiniBuffer(LyXView * o,
+ FL_Coord x, FL_Coord y, FL_Coord h, FL_Coord w);
+
///
- MiniBuffer(LyXView *o, FL_Coord x, FL_Coord y, FL_Coord h, FL_Coord w)
- : owner(o)
- {
- text = _("Welcome to LyX!");
- shows_no_match = true;
- history_idx = history_cnt = 0;
- add(FL_NORMAL_INPUT, x, y, h, w);
- }
+ void addSet(string const &,
+ string const & = string());
+
///
- bool shows_no_match;
+ void message(string const & str);
///
- void setTimer(int a) {
- fl_set_timer(timer, a);
- }
+ void messagePush(string const & str);
///
- void Set(string const & = string(),
- string const & = string(),
- string const & = string(),
- int delay_secs= 6);
- ///
- string GetText() const { return text; }
+ void messagePop();
+
+ /** Makes the minibuffer wait for a string to be inserted.
+ Waits for a string to be inserted into the minibuffer, when
+ the string has been insterted the signal stringReady is
+ emitted.
+ */
+ void getString(State space,
+ std::vector<string> const & completion,
+ std::vector<string> & history);
///
- void Init();
+ void redraw();
///
- void ExecCommand();
- /** allows to store and reset the contents one time. Usefull
- for status messages like "load font" (Matthias)
- */
- void Store();
+ int peek_event(FL_OBJECT *, int, int);
///
- void Reset();
+ SigC::Signal1<void, string const &> stringReady;
///
- void Activate();
+ //SigC::Signal0<void> escape;
///
- void Deactivate();
+ SigC::Signal0<void> timeout;
+private:
///
- static void ExecutingCB(FL_OBJECT *ob, long);
+ void activate();
///
- static void TimerCB(FL_OBJECT *ob, long);
+ void deactivate();
///
- static int peek_event(FL_OBJECT *, int, FL_Coord, FL_Coord,
- int, void *);
-private:
+ void prepare();
+ ///
+ void stored_slot();
+ ///
+ void stored_set(string const &);
+ ///
+ void set_input(string const &);
+ ///
+ void init();
///
- LyXView *owner;
+ string stored_input;
+ ///
+ bool stored_;
+ ///
+ LyXView * owner_;
///
string text;
///
string text_stored;
///
- FL_OBJECT *add(int, FL_Coord, FL_Coord, FL_Coord, FL_Coord);
- ///
- FL_OBJECT *timer;
- ///
- FL_OBJECT *the_buffer;
- ///
- string cur_cmd;
- ///
- enum{ MAX_HISTORY = 10 };
- ///
- string history[MAX_HISTORY];
- ///
- int history_idx, history_cnt;
- ///
- void addHistory(string const &cmd) {
- if (history_cnt == 0 || (history_cnt>0 && cmd!= history[(history_cnt-1) % MAX_HISTORY])) {
- history[history_cnt % MAX_HISTORY] = cmd;
- history_cnt++;
- }
- history_idx = history_cnt;
- }
- ///
- string getHistory() { return history[history_idx % MAX_HISTORY]; }
+ FL_OBJECT * add(int, FL_Coord, FL_Coord, FL_Coord, FL_Coord);
+ ///
+ Timeout timer;
+ ///
+ Timeout stored_timer;
+ ///
+ FL_OBJECT * the_buffer;
+ ///
+ std::vector<string> completion_;
+ ///
+ std::vector<string> * history_;
+ ///
+ std::vector<string>::iterator hist_iter;
+ ///
+ State state_;
};
#endif