]> git.lyx.org Git - lyx.git/blobdiff - src/minibuffer.C
fix typo that put too many include paths for most people
[lyx.git] / src / minibuffer.C
index f660a6e69792f7e2af420f302eb7c64f8df11c2d..92a307dfc73d5040f4d3a1ddfc9496d567efbf61 100644 (file)
@@ -3,10 +3,10 @@
  *                 The MiniBuffer Class
  *                 read minibuffer.h for more
  *                 information.
- * 
+ *
  *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-2001 The LyX Team.  
- * 
+ *           Copyright 1995-2001 The LyX Team.
+ *
  * ###########################################################################
  */
 
@@ -18,9 +18,9 @@
 #pragma implementation
 #endif
 
-// FIXME: temporary 
+// FIXME: temporary
 #include "frontends/xforms/DropDown.h"
+
 #include "minibuffer.h"
 
 #include "support/lyxalgo.h"
@@ -31,6 +31,7 @@
 #include "gettext.h"
 #include "LyXAction.h"
 #include "BufferView.h"
+#include "frontends/Timeout.h"
 
 #include <cctype>
 
@@ -46,7 +47,7 @@ namespace {
 
 struct prefix {
        string p;
-       prefix(string const & s) 
+       prefix(string const & s)
                : p(s) {}
        bool operator()(string const & s) const {
                return prefixIs(s, p);
@@ -61,15 +62,17 @@ MiniBuffer::MiniBuffer(LyXView * o, FL_Coord x, FL_Coord y,
        : 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();
 }
 
-// thanks for nothing, xforms (recursive creation not allowed) 
+
+// thanks for nothing, xforms (recursive creation not allowed)
 void MiniBuffer::dd_init()
 {
        dropdown_ = new DropDown(owner_, the_buffer);
@@ -80,11 +83,13 @@ void MiniBuffer::dd_init()
 
 MiniBuffer::~MiniBuffer()
 {
+       delete timer;
+       delete stored_timer;
        delete dropdown_;
 }
 
-void MiniBuffer::stored_slot() 
+
+void MiniBuffer::stored_slot()
 {
        if (stored_) {
                stored_ = false;
@@ -93,11 +98,11 @@ void MiniBuffer::stored_slot()
 }
 
 
-void MiniBuffer::stored_set(string const & str) 
+void MiniBuffer::stored_set(string const & str)
 {
        stored_input = str;
        stored_ = true;
-       stored_timer.start();
+       stored_timer->start();
 }
 
 
@@ -112,12 +117,12 @@ int MiniBuffer::peek_event(FL_OBJECT * ob, int event, int key)
                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;
                }
-               
+
                switch (key) {
                case XK_Down:
                        if (hist_iter != history_->end()) {
@@ -130,7 +135,7 @@ int MiniBuffer::peek_event(FL_OBJECT * ob, int event, int key)
                        } else {
                                set_input((*hist_iter));
                        }
-                       return 1; 
+                       return 1;
                case XK_Up:
                        if (hist_iter == history_->begin()) {
                                // no further history
@@ -140,12 +145,12 @@ int MiniBuffer::peek_event(FL_OBJECT * ob, int event, int key)
                                --hist_iter;
                                set_input((*hist_iter));
                        }
-                       return 1; 
+                       return 1;
                case 9:
                case XK_Tab:
                {
                        // Completion handling.
-                       
+
                        vector<string> comp;
                        lyx::copy_if(completion_.begin(),
                                     completion_.end(),
@@ -182,11 +187,11 @@ int MiniBuffer::peek_event(FL_OBJECT * ob, int event, int key)
                                        test += tmp[test.length()];
                                }
                                set_input(test);
-                               
+
                                int x,y,w,h;
                                fl_get_wingeometry(fl_get_real_object_window(the_buffer),
                                        &x, &y, &w, &h);
+
                                // asynchronous completion
                                int const air = the_buffer->x;
                                x += air;
@@ -194,7 +199,7 @@ int MiniBuffer::peek_event(FL_OBJECT * ob, int event, int key)
                                w = the_buffer->w;
                                dropdown_->select(comp, x, y, w);
                        }
-                       return 1; 
+                       return 1;
                }
                case 27:
                case XK_Escape:
@@ -203,7 +208,7 @@ int MiniBuffer::peek_event(FL_OBJECT * ob, int event, int key)
                        init();
                        deactivate();
                        //escape.emit();
-                       return 1; 
+                       return 1;
                case 13:
                case XK_Return:
                {
@@ -250,9 +255,9 @@ int MiniBuffer::peek_event(FL_OBJECT * ob, int event, int key)
                                return 1;
                        }
                        }
-                       
+
                }
-               
+
                default:
                        return 0;
                }
@@ -261,22 +266,22 @@ int MiniBuffer::peek_event(FL_OBJECT * ob, int event, int key)
                //lyxerr << "Unhandled minibuffer event!" << endl;
                break;
        }
-       
+
        return 0;
 }
 
 
 extern "C" {
-       
+
        static
-       int C_MiniBuffer_peek_event(FL_OBJECT * ob, int event, 
+       int C_MiniBuffer_peek_event(FL_OBJECT * ob, int event,
                                    FL_Coord, FL_Coord,
                                    int key, void * /*xev*/)
        {
                MiniBuffer * mini = static_cast<MiniBuffer*>(ob->u_vdata);
                return mini->peek_event(ob, event, key);
        }
-       
+
 }
 
 
@@ -294,28 +299,28 @@ FL_OBJECT * MiniBuffer::add(int type, FL_Coord x, FL_Coord y,
                           FL_Coord w, FL_Coord h)
 {
        FL_OBJECT * obj;
-       
+
        the_buffer = obj = fl_add_input(type, x, y, w, h, text.c_str());
-        fl_set_object_boxtype(obj, FL_DOWN_BOX);
-        fl_set_object_resize(obj, FL_RESIZE_ALL);
-        fl_set_object_gravity(obj, SouthWestGravity, SouthEastGravity);
-        fl_set_object_color(obj, FL_MCOL, FL_MCOL);
-        fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-       
+       fl_set_object_boxtype(obj, FL_DOWN_BOX);
+       fl_set_object_resize(obj, FL_RESIZE_ALL);
+       fl_set_object_gravity(obj, SouthWestGravity, SouthEastGravity);
+       fl_set_object_color(obj, FL_MCOL, FL_MCOL);
+       fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+
        // To intercept Up, Down, Table for history
-        fl_set_object_prehandler(obj, C_MiniBuffer_peek_event);
-        obj->u_vdata = this;
-        obj->wantkey = FL_KEY_TAB;
+       fl_set_object_prehandler(obj, C_MiniBuffer_peek_event);
+       obj->u_vdata = this;
+       obj->wantkey = FL_KEY_TAB;
 
        set_input(text);
-       
+
        return obj;
 }
 
 
-void MiniBuffer::message(string const & str) 
+void MiniBuffer::message(string const & str)
 {
-       timer.restart();
+       timer->restart();
        string const ntext = strip(str);
        if (!the_buffer->focus) {
                set_input(ntext);
@@ -324,7 +329,7 @@ void MiniBuffer::message(string const & str)
 }
 
 
-void MiniBuffer::messagePush(string const & str) 
+void MiniBuffer::messagePush(string const & str)
 {
        text_stored = text;
        message(str);
@@ -366,7 +371,7 @@ void MiniBuffer::init()
                return;
 
        timeout.emit();
-       timer.stop();
+       timer->stop();
 }
 
 
@@ -385,7 +390,7 @@ void MiniBuffer::deactivate()
 }
 
 
-void MiniBuffer::redraw() 
+void MiniBuffer::redraw()
 {
        fl_redraw_object(the_buffer);
        XFlush(fl_display);
@@ -401,7 +406,7 @@ void MiniBuffer::set_complete_input(string const & str)
        }
 }
 
+
 void MiniBuffer::append_char(char c)
 {
        if (!c || !isprint(c))
@@ -415,7 +420,7 @@ void MiniBuffer::append_char(char c)
        fl_set_input(the_buffer, str.c_str());
 }
 
+
 void MiniBuffer::set_input(string const & str)
 {
        fl_set_input(the_buffer, str.c_str());