]> git.lyx.org Git - lyx.git/blobdiff - src/minibuffer.C
Change the latex font names in order to match the names of type1inst.
[lyx.git] / src / minibuffer.C
index 7583a803eb74f571964c36ff84fab08e1208e82b..152cd3eb8e31ff9d81e34529e5600699f2f87310 100644 (file)
@@ -32,6 +32,7 @@
 #include "LyXAction.h"
 #include "BufferView.h"
 
+#include <cctype>
 
 using SigC::slot;
 using std::vector;
@@ -71,6 +72,7 @@ void MiniBuffer::dd_init()
 {
        dropdown_ = new DropDown(owner_, the_buffer);
        dropdown_->result.connect(slot(this, &MiniBuffer::set_complete_input));
+       dropdown_->keypress.connect(slot(this, &MiniBuffer::append_char));
 }
 
 
@@ -100,6 +102,9 @@ void MiniBuffer::stored_set(string const & str)
 int MiniBuffer::peek_event(FL_OBJECT * ob, int event, int key)
 {
        switch (event) {
+       case FL_UNFOCUS:
+               deactivate();
+               break;
        case FL_KEYBOARD:
        {
                char const * tmp = fl_get_input(ob);
@@ -180,8 +185,12 @@ int MiniBuffer::peek_event(FL_OBJECT * ob, int event, int key)
                                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; 
                }
@@ -215,7 +224,9 @@ int MiniBuffer::peek_event(FL_OBJECT * ob, int event, int key)
                                // Return the inputted string
                                deactivate();
                                owner_->view()->focus(true);
-                               history_->push_back(input);
+                               if (!input.empty()) {
+                                       history_->push_back(input);
+                               }
                                stringReady.emit(input);
 # if 0
                        }
@@ -381,8 +392,25 @@ void MiniBuffer::redraw()
 
 void MiniBuffer::set_complete_input(string const & str)
 {
-       if (!str.empty())
-               set_input(str);
+       if (!str.empty()) {
+               // add a space so the user can type
+               // an argument immediately
+               set_input(str + " ");
+       }
+}
+
+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());
 }