// -*- C++ -*-
-#ifndef _MINIBUFFER_H
-#define _MINIBUFFER_H
+#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)
- : owner(o)
- {
- text = _("Welcome to LyX!");
- shows_no_match = true;
- history_idx = history_cnt = 0;
- add(FL_NORMAL_INPUT, x, y, h, w);
- }
+ MiniBuffer(LyXView * o,
+ FL_Coord x, FL_Coord y, FL_Coord h, FL_Coord w);
+
+ /// destructor
+ ~MiniBuffer();
+
+ /// create drop down
+ void dd_init();
+
+ ///
+ 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(LString const& = LString(),
- LString const& = LString(),
- LString const& = LString(),
- int delay_secs=6);
- ///
- LString 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 inserted 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();
+ boost::signal1<void, string const &> stringReady;
///
- void Activate();
+ //boost::signal0<void> escape;
///
- void Deactivate();
+ boost::signal0<void> timeout;
private:
///
- LyXView *owner;
+ void activate();
+ ///
+ void deactivate();
+ ///
+ 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;
///
- LString text;
+ FL_OBJECT * add(int, FL_Coord, FL_Coord, FL_Coord, FL_Coord);
///
- LString text_stored;
+ Timeout * timer;
///
- FL_OBJECT *add(int, FL_Coord, FL_Coord, FL_Coord, FL_Coord);
+ Timeout * stored_timer;
+ /// the dropdown menu
+ DropDown * dropdown_;
///
- static void ExecutingCB(FL_OBJECT *ob, long);
+ FL_OBJECT * the_buffer;
///
- static void TimerCB(FL_OBJECT *ob, long);
+ std::vector<string> completion_;
///
- static int peek_event(FL_OBJECT *, int, FL_Coord, FL_Coord,
- int, void *);
- ///
- FL_OBJECT *timer;
+ std::vector<string> * history_;
///
- FL_OBJECT *the_buffer;
+ std::vector<string>::iterator hist_iter;
///
- LString cur_cmd;
- ///
- enum{ MAX_HISTORY = 10 };
- ///
- LString history[MAX_HISTORY];
- ///
- int history_idx, history_cnt;
- ///
- void addHistory(LString 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;
- }
- ///
- LString getHistory() { return history[history_idx % MAX_HISTORY]; }
+ State state_;
};
#endif