]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/XMiniBuffer.C
Yet more dialog tweaking from Rob.
[lyx.git] / src / frontends / xforms / XMiniBuffer.C
index e9e1f4f4dc1688b733c563e3f800c84b56660365..71c4380eb35d4c785c4d6b79ea4113d40dc3a9a9 100644 (file)
@@ -1,11 +1,13 @@
 // -*- C++ -*-
 /**
  * \file XMiniBuffer.C
- * Copyright 1995-2002 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
  * \author Lars
  * \author Asger and Juergen
+ *
+ * Full author contact details are available in file CREDITS
  */
 
 #include <config.h>
@@ -39,41 +41,35 @@ using std::vector;
 XMiniBuffer::XMiniBuffer(XFormsView * v, ControlCommandBuffer & control,
        FL_Coord x, FL_Coord y, FL_Coord h, FL_Coord w)
        : controller_(control), view_(v),
-       info_suffix_shown_(false)
+       info_shown_(false)
 {
        input_obj_ = create_input_box(FL_NORMAL_INPUT, x, y, h, w);
-       suffix_timer_.reset(new Timeout(1500));
+       info_timer_.reset(new Timeout(1500));
        idle_timer_.reset(new Timeout(6000));
-       suffix_timer_->timeout.connect(boost::bind(&XMiniBuffer::suffix_timeout, this));
-       idle_timer_->timeout.connect(boost::bind(&XMiniBuffer::idle_timeout, this));
-       idle_timer_->start(); 
+       info_con = info_timer_->timeout.connect(boost::bind(&XMiniBuffer::info_timeout, this));
+       idle_con = idle_timer_->timeout.connect(boost::bind(&XMiniBuffer::idle_timeout, this));
+       idle_timer_->start();
        messageMode();
 }
 
 
+// This is here so that scoped ptr will not require a complete type.
+XMiniBuffer::~XMiniBuffer()
+{}
+
+
 // thanks for nothing, xforms (recursive creation not allowed)
 void XMiniBuffer::dd_init()
 {
        dropdown_.reset(new DropDown(the_buffer_));
-       dropdown_->result.connect(boost::bind(&XMiniBuffer::set_complete_input, this, _1));
-       dropdown_->keypress.connect(boost::bind(&XMiniBuffer::append_char, this, _1));
-}
-
-
-XMiniBuffer::~XMiniBuffer()
-{
+       result_con = dropdown_->result.connect(boost::bind(&XMiniBuffer::set_complete_input, this, _1));
+       keypress_con = dropdown_->keypress.connect(boost::bind(&XMiniBuffer::append_char, this, _1));
 }
 
 
 int XMiniBuffer::peek_event(FL_OBJECT * ob, int event,
                            int key, XEvent * /*xev*/)
 {
-#if 0
-       if (dropdown_->isVisible()) {
-               return dropdown_->peek(xev);
-       }
-#endif
-
        switch (event) {
        case FL_FOCUS:
                messageMode(false);
@@ -84,11 +80,11 @@ int XMiniBuffer::peek_event(FL_OBJECT * ob, int event,
        case FL_KEYBOARD:
        {
                string input;
-               if (info_suffix_shown_) {
-                       suffix_timer_->stop();
-                       suffix_timeout();
+               if (info_shown_) {
+                       info_timer_->stop();
+                       info_timeout();
                }
+
                char const * tmp = fl_get_input(ob);
                input = tmp ? tmp : "";
 
@@ -100,13 +96,13 @@ int XMiniBuffer::peek_event(FL_OBJECT * ob, int event,
                {
                        string const h(controller_.historyDown());
                        if (h.empty()) {
-                               show_info_suffix(_("[End of history]"), input);
+                               show_info(_("[End of history]"), input, false);
                        } else {
                                set_input(h);
                        }
                        return 1;
                }
+
                case XK_Up:
 #ifdef XK_KP_Up
                case XK_KP_Up:
@@ -114,30 +110,30 @@ int XMiniBuffer::peek_event(FL_OBJECT * ob, int event,
                {
                        string const h(controller_.historyUp());
                        if (h.empty()) {
-                               show_info_suffix(_("[Beginning of history]"), input);
+                               show_info(_("[Beginning of history]"), input, false);
                        } else {
                                set_input(h);
                        }
                        return 1;
                }
+
                case 9:
                case XK_Tab:
                {
                        string new_input;
                        vector<string> comp = controller_.completions(input, new_input);
-                        
+
                        if (comp.empty() && new_input == input) {
-                               show_info_suffix(_("[no match]"), input);
+                               show_info(_("[no match]"), input);
                                break;
                        }
 
                        if (comp.empty()) {
                                set_input(new_input);
-                               show_info_suffix(("[only completion]"), new_input + " ");
+                               show_info(("[only completion]"), new_input + " ");
                                break;
                        }
-                                
+
                        set_input(new_input);
 
                        int x,y,w,h;
@@ -162,27 +158,9 @@ int XMiniBuffer::peek_event(FL_OBJECT * ob, int event,
                case XK_KP_Enter:
 #endif
                {
-#if 0
-                       // This will go in again in a little while
-                       // we need to be able to declare what types
-                       // of argumetns LFUN's should have first. (Lgb)
-                       // First check for match
-                       vector<string>::const_iterator cit =
-                               find(completion_.begin(),
-                                    completion_.end(),
-                                    input);
-                       if (cit == completion_.end()) {
-                               // no such func/item
-                               string const tmp = input + _(" [no match]");
-                               show_info_suffix(tmp, input);
-                       } else {
-#endif
                        messageMode();
                        redraw();
                        controller_.dispatch(input);
-# if 0
-                       }
-#endif
                        return 1;
                }
                default:
@@ -239,29 +217,32 @@ void XMiniBuffer::freeze()
        fl_set_object_prehandler(input_obj_, 0);
 }
 
-void XMiniBuffer::show_info_suffix(string const & suffix, string const & input)
+
+void XMiniBuffer::show_info(string const & info, string const & input, bool append)
 {
        stored_input_ = input;
-       info_suffix_shown_ = true;
-       set_input(input + " " + suffix); 
-       suffix_timer_->start();
+       info_shown_ = true;
+       if (append)
+               set_input(input + " " + info);
+       else
+               set_input(info);
+       info_timer_->start();
 }
+
 
 void XMiniBuffer::idle_timeout()
 {
-       set_input(currentState(view_->view()));
+       set_input(currentState(view_->view().get()));
 }
 
-void XMiniBuffer::suffix_timeout()
+
+void XMiniBuffer::info_timeout()
 {
-       info_suffix_shown_ = false;
+       info_shown_ = false;
        set_input(stored_input_);
 }
 
+
 bool XMiniBuffer::isEditingMode() const
 {
        return the_buffer_->focus;
@@ -305,8 +286,8 @@ void XMiniBuffer::append_char(char c)
 
        fl_set_input(the_buffer_, str.c_str());
 }
+
+
 void XMiniBuffer::set_complete_input(string const & str)
 {
        if (!str.empty()) {
@@ -314,8 +295,8 @@ void XMiniBuffer::set_complete_input(string const & str)
                // an argument immediately
                set_input(str + " ");
        }
-} 
+}
+
 
 void XMiniBuffer::message(string const & str)
 {
@@ -323,7 +304,7 @@ void XMiniBuffer::message(string const & str)
                set_input(str);
 }
 
+
 void XMiniBuffer::set_input(string const & str)
 {
        fl_set_input(the_buffer_, str.c_str());