#include "gettext.h"
#include "LyXAction.h"
#include "BufferView.h"
+#include "frontends/Timeout.h"
+#include <cctype>
using SigC::slot;
using std::vector;
+using std::back_inserter;
+using std::find;
extern LyXAction lyxaction;
: stored_(false), owner_(o), state_(spaces)
{
add(FL_NORMAL_INPUT, x, y, h, w);
- timer.setTimeout(6000);
- timer.timeout.connect(slot(this, &MiniBuffer::init));
- stored_timer.setTimeout(1500);
- stored_timer.timeout.connect(slot(this, &MiniBuffer::stored_slot));
+
+ timer = new Timeout(6000);
+ timer->timeout.connect(slot(this, &MiniBuffer::init));
+
+ stored_timer = new Timeout(1500);
+ stored_timer->timeout.connect(slot(this, &MiniBuffer::stored_slot));
deactivate();
}
{
dropdown_ = new DropDown(owner_, the_buffer);
dropdown_->result.connect(slot(this, &MiniBuffer::set_complete_input));
+ dropdown_->keypress.connect(slot(this, &MiniBuffer::append_char));
}
MiniBuffer::~MiniBuffer()
{
+ delete timer;
+ delete stored_timer;
delete dropdown_;
}
{
stored_input = str;
stored_ = true;
- stored_timer.start();
+ stored_timer->start();
}
char const * tmp = fl_get_input(ob);
string input = tmp ? tmp : "";
if (stored_) {
- stored_timer.stop();
+ stored_timer->stop();
input = stored_input;
set_input(input);
stored_ = false;
vector<string> comp;
lyx::copy_if(completion_.begin(),
completion_.end(),
- std::back_inserter(comp), prefix(input));
+ back_inserter(comp), prefix(input));
if (comp.empty()) {
// No matches
vector<string> vtmp;
lyx::copy_if(comp.begin(),
comp.end(),
- std::back_inserter(vtmp),
+ back_inserter(vtmp),
prefix(test));
if (vtmp.size() != comp.size()) {
test.erase(test.length() - 1);
fl_get_wingeometry(fl_get_real_object_window(the_buffer),
&x, &y, &w, &h);
- // asynchronous completion
- dropdown_->select(comp, x, y + h, w);
+ // asynchronous completion
+ int const air = the_buffer->x;
+ x += air;
+ y += h - (the_buffer->h + air);
+ w = the_buffer->w;
+ dropdown_->select(comp, x, y, w);
}
return 1;
}
// of argumetns LFUN's should have first. (Lgb)
// First check for match
vector<string>::const_iterator cit =
- std::find(completion_.begin(),
+ find(completion_.begin(),
completion_.end(),
input);
if (cit == completion_.end()) {
void MiniBuffer::message(string const & str)
{
- timer.restart();
+ timer->restart();
string const ntext = strip(str);
if (!the_buffer->focus) {
set_input(ntext);
return;
timeout.emit();
- timer.stop();
+ timer->stop();
}
}
+void MiniBuffer::append_char(char c)
+{
+ if (!c || !isprint(c))
+ return;
+
+ char const * tmp = fl_get_input(the_buffer);
+ string str = tmp ? tmp : "";
+
+ str += c;
+
+ fl_set_input(the_buffer, str.c_str());
+}
+
+
void MiniBuffer::set_input(string const & str)
{
fl_set_input(the_buffer, str.c_str());