#ifndef MINIBUFFER_H
#define MINIBUFFER_H
-#include FORMS_H_LOCATION
#include "LString.h"
-#include "gettext.h"
+
+#include <boost/signals/signal0.hpp>
+#include <boost/signals/signal1.hpp>
+#include <boost/signals/trackable.hpp>
+
+#include <vector>
+
+#include FORMS_H_LOCATION
#ifdef __GNUG__
#pragma interface
#endif
class LyXView;
+class DropDown;
+class Timeout;
///
-class MiniBuffer {
+class MiniBuffer : public boost::signals::trackable {
public:
+ enum State {
+ spaces,
+ nospaces
+ };
+
///
MiniBuffer(LyXView * o,
FL_Coord x, FL_Coord y, FL_Coord h, FL_Coord w);
+ /// destructor
+ ~MiniBuffer();
+
+ /// create drop down
+ void dd_init();
+
///
- bool shows_no_match;
+ void addSet(string const &,
+ string const & = string());
+
///
- void setTimer(int a) {
- fl_set_timer(timer, a);
- }
+ void message(string const & str);
///
- void Set(string const & = string(),
- string const & = string(),
- string const & = string(),
- int delay_secs= 6);
- ///
- string const GetText() const { return text; }
+ void messagePush(string const & str);
///
- void Init();
+ 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 inserted the signal stringReady is
+ emitted.
+ */
+ void getString(State space,
+ std::vector<string> const & completion,
+ std::vector<string> & history);
///
- void PrepareForCommand();
- /** allows to store and reset the contents one time. Usefull
- for status messages like "load font" (Matthias)
- */
- void Store();
+ void redraw();
///
- void Reset();
+ int peek_event(FL_OBJECT *, int, int);
///
- void Activate();
+ boost::signal1<void, string const &> stringReady;
///
- void Deactivate();
+ //boost::signal0<void> escape;
///
- static void ExecutingCB(FL_OBJECT *ob, long);
+ boost::signal0<void> timeout;
+private:
///
- static void TimerCB(FL_OBJECT *ob, long);
+ void activate();
///
- static int peek_event(FL_OBJECT *, int, FL_Coord, FL_Coord,
- int, void *);
-private:
+ void deactivate();
///
- LyXView * owner;
+ void prepare();
+ ///
+ void stored_slot();
+ ///
+ void stored_set(string const &);
+ /// set the minibuffer content if str non-empty
+ void set_complete_input(string const &);
+ /// append c to the current contents
+ void append_char(char c);
+ /// set the minibuffer content
+ void set_input(string const &);
+ ///
+ void init();
+ ///
+ 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;
+ ///
+ Timeout * timer;
+ ///
+ Timeout * stored_timer;
+ /// the dropdown menu
+ DropDown * dropdown_;
///
FL_OBJECT * the_buffer;
///
- string cur_cmd;
- ///
- enum{ MAX_HISTORY = 10 };
- ///
- mutable string history[MAX_HISTORY];
- ///
- mutable int history_idx;
- ///
- mutable int history_cnt;
- ///
- void addHistory(string const & cmd) const {
- 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 const getHistory() const { return history[history_idx % MAX_HISTORY]; }
+ std::vector<string> completion_;
+ ///
+ std::vector<string> * history_;
+ ///
+ std::vector<string>::iterator hist_iter;
+ ///
+ State state_;
};
#endif