]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView_pimpl.C
Changed InsetText * in InsetCollapsable to be a InsetText.
[lyx.git] / src / BufferView_pimpl.C
index 6e79fd18113ed19960d358450d3cb4b25ecdca74..4890ac972e91bbf4aa2a8a6715b722d3bd5d5023 100644 (file)
 #include "insets/insetcaption.h"
 #include "mathed/formulamacro.h"
 extern LyXTextClass::size_type current_layout;
-extern void math_insert_symbol(BufferView *, string const &);
-extern bool math_insert_greek(BufferView *, char);
 extern int greek_kb_flag;
 
-#ifdef SIGC_CXX_NAMESPACES
-using SigC::slot;
-#endif
-
 using std::vector;
 using std::find_if;
 using std::pair;
 using std::endl;
 using std::make_pair;
 using std::min;
+using SigC::slot;
 
 /* the selection possible is needed, that only motion events are 
  * used, where the bottom press event was on the drawing area too */
@@ -79,19 +74,21 @@ bool selection_possible = false;
 extern BufferList bufferlist;
 extern char ascii_type;
 
+extern bool math_insert_greek(BufferView *, char);
 extern void sigchldhandler(pid_t pid, int * status);
 extern int bibitemMaxWidth(BufferView *, LyXFont const &);
 
 const unsigned int saved_positions_num = 20;
 
-static inline
+namespace {
+
+inline
 void waitForX()
 {
        XSync(fl_get_display(), 0);
 }
 
 
-static
 void SetXtermCursor(Window win)
 {
        static Cursor cursor;
@@ -105,6 +102,8 @@ void SetXtermCursor(Window win)
        XFlush(fl_get_display());
 }
 
+} // anon namespace
+
 
 BufferView::Pimpl::Pimpl(BufferView * b, LyXView * o,
             int xpos, int ypos, int width, int height)
@@ -349,7 +348,8 @@ int BufferView::Pimpl::resizeCurrentBuffer()
        bv_->setState();
        AllowInput(bv_);
 
-       owner_->getDialogs()->hideSplash();
+       /// get rid of the splash screen if it's not gone already
+       owner_->getDialogs()->destroySplash();
  
        return 0;
 }
@@ -766,7 +766,8 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
        
        selection_possible = false;
        
-       if (button >= 2) return;
+       if (button == 2)
+               return;
 
        bv_->setState();
        owner_->showState();
@@ -920,6 +921,8 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y,
   
        LyXCursor cursor;
        text->SetCursorFromCoordinates(bv_, cursor, x, y_tmp);
+       text->SetCursor(bv_, cursor, cursor.par(),cursor.pos(),true);
+
 
 #ifndef NEW_INSETS
        if (cursor.pos() < cursor.par()->Last()
@@ -942,7 +945,8 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y,
 
                if (x > start_x && x < end_x
                    && y_tmp > cursor.y() - tmpinset->ascent(bv_, font)
-                   && y_tmp < cursor.y() + tmpinset->descent(bv_, font)) {
+                   && y_tmp < cursor.y() + tmpinset->descent(bv_, font))
+               {
                        text->SetCursor(bv_, cursor.par(),cursor.pos(),true);
                        x = x - start_x;
                        // The origin of an inset is on the baseline
@@ -1268,10 +1272,10 @@ void BufferView::Pimpl::setState()
        LyXText * text = bv_->getLyXText();
        if (text->real_current_font.isRightToLeft() &&
            text->real_current_font.latex() != LyXFont::ON) {
-               if (owner_->getIntl()->primarykeymap)
+               if (owner_->getIntl()->keymap == Intl::PRIMARY)
                        owner_->getIntl()->KeyMapSec();
        } else {
-               if (!owner_->getIntl()->primarykeymap)
+               if (owner_->getIntl()->keymap == Intl::SECONDARY)
                        owner_->getIntl()->KeyMapPrim();
        }
 }
@@ -2749,7 +2753,12 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
               
        case LFUN_INSERT_MATH:
        {
-               math_insert_symbol(bv_, argument);
+               if (!available())
+                       break;
+               InsetFormula * f = new InsetFormula(true);
+               bv_->open_new_inset(f);
+               f->LocalDispatch(bv_, LFUN_INSERT_MATH, argument);
        }
        break;
        
@@ -2922,18 +2931,22 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                if (!bv_->insertInset(inset, "Standard", true))
                        delete inset;
        }
+                
        break;
 
        case LFUN_CHILD_INSERT:
        {
-               InsetCommandParams p;
-               p.setFromString(argument);
+               InsetInclude::Params p;
+               p.cparams.setFromString(argument);
+               p.masterFilename_ = buffer_->fileName();
 
-               InsetInclude * inset = new InsetInclude(p, *buffer_);
+               InsetInclude * inset = new InsetInclude(p);
                if (!bv_->insertInset(inset))
                        delete inset;
-               else
+               else {
                        bv_->updateInset(inset, true);
+                       bv_->owner()->getDialogs()->showInclude(inset);
+               }
        }
        break; 
 
@@ -3018,8 +3031,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                        for (string::size_type i = 0;
                             i < argument.length(); ++i) {
                                if (greek_kb_flag) {
-                                       if (!math_insert_greek(bv_,
-                                                              argument[i]))
+                                       if (!math_insert_greek(bv_, argument[i]))
                                                owner_->getIntl()->getTrans().TranslateAndInsert(argument[i], TEXT(bv_));
                                } else
                                        owner_->getIntl()->getTrans().TranslateAndInsert(argument[i], TEXT(bv_));
@@ -3037,7 +3049,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                } else {
                        // if we don't have an argument there was something
                        // strange going on so we just tell this to someone!
-                       owner_->getLyXFunc()->setErrorMessage(N_("No argument givven"));
+                       owner_->getLyXFunc()->setErrorMessage(N_("No argument given"));
                }
                break;
        }