]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView_pimpl.C
next step...
[lyx.git] / src / BufferView_pimpl.C
index 5e41617770f06cf5fc0c9b67c87b8d5a27bb10f5..082bfb463eb7b460700ddec9e0e4cbe4e9b72330 100644 (file)
@@ -366,10 +366,7 @@ int BufferView::Pimpl::resizeCurrentBuffer()
 
        /// clear the "Formatting Document" message 
        owner_->message("");
-       /// get rid of the splash screen if it's not gone already
-       owner_->getDialogs()->destroySplash();
+
        return 0;
 }
 
@@ -567,7 +564,7 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state)
 
 // Single-click on work area
 void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
-                                           unsigned int button)
+                                            unsigned int button)
 {
        if (!buffer_ || !screen_.get()) return;
 
@@ -592,9 +589,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
                   otherwise give the event to the inset */
                if (inset_hit == bv_->theLockingInset()) {
                        bv_->theLockingInset()->
-                               insetButtonPress(bv_,
-                                                xpos, ypos,
-                                                button);
+                               insetButtonPress(bv_,xpos, ypos,button);
                        return;
                } else {
                        bv_->unlockInset(bv_->theLockingInset());
@@ -701,7 +696,7 @@ void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, unsigned int button)
 void BufferView::Pimpl::tripleClick(int /*x*/, int /*y*/, unsigned int button)
 {
        // select a line
-       if (buffer_)
+       if (!buffer_)
                return;
 
        LyXText * text = bv_->getLyXText();
@@ -808,6 +803,9 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
                return;
        }
 
+#ifdef WITH_WARNINGS
+#warning variable c is set but never used. What is it good for?? (JMarc)
+#endif
        // check whether we want to open a float
        if (bv_->text) {
                bool hit = false;
@@ -889,7 +887,7 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y,
            (cursor.par()->getInset(cursor.pos() - 1)->editable())) {
                Inset * tmpinset = cursor.par()->getInset(cursor.pos()-1);
                LyXFont font = text->getFont(buffer_, cursor.par(),
-                                                 cursor.pos()-1);
+                                                 cursor.pos() - 1);
                int const width = tmpinset->width(bv_, font);
                int const inset_x = font.isVisibleRightToLeft()
                        ? cursor.x() : cursor.x() - width;
@@ -981,6 +979,9 @@ void BufferView::Pimpl::update()
                        bv_->text->status(bv_, st);
                        screen_->update(bv_->text, bv_);
                }
+               // do this here instead of in the screen::update because of
+               // the above loop!
+               bv_->text->status(bv_, LyXText::UNCHANGED);
                if (fitc)
                        fitCursor();
        }
@@ -1036,7 +1037,7 @@ void BufferView::Pimpl::update(LyXText * text, BufferView::UpdateCodes f)
 
        if (text->inset_owner) {
                text->inset_owner->setUpdateStatus(bv_, InsetText::NONE);
-           updateInset(text->inset_owner, true);
+           updateInset(text->inset_owner, false);
        } else {
            update();
        }
@@ -1212,12 +1213,7 @@ void BufferView::Pimpl::setState()
                return;
 
        LyXText * text = bv_->getLyXText();
-       if (text->real_current_font.isRightToLeft()
-#ifndef NO_LATEX
-           &&
-           text->real_current_font.latex() != LyXFont::ON
-#endif
-               ) {
+       if (text->real_current_font.isRightToLeft()) {
                if (owner_->getIntl()->keymap == Intl::PRIMARY)
                        owner_->getIntl()->KeyMapSec();
        } else {
@@ -1599,14 +1595,6 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                owner_->getDialogs()->setUserFreeFont();
                break;
 
-#ifndef NO_LATEX
-       case LFUN_TEX:
-               Tex(bv_);
-               setState();
-               owner_->showState();
-               break;
-#endif
-               
        case LFUN_FILE_INSERT:
        {
                MenuInsertLyXFile(argument);
@@ -2363,7 +2351,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                        // just comment out the line below...
                        showCursor();
                } else {
-                       bv_->cut();
+                       bv_->cut(false);
                }
                moveCursorUpdate(false);
                owner_->showState();
@@ -2394,6 +2382,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                                                 cursor.par()->params().pagebreakBottom(),
                                                 VSpace(VSpace::NONE), 
                                                 cursor.par()->params().spaceBottom(),
+                                                cursor.par()->params().spacing(), 
                                                 cursor.par()->params().align(), 
                                                 cursor.par()->params().labelWidthString(), 0);
                                        lt->cursorLeft(bv_);
@@ -2419,7 +2408,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                                       | BufferView::CHANGE);
                        }
                } else {
-                       bv_->cut();
+                       bv_->cut(false);
                }
        }
        break;
@@ -2506,7 +2495,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                                showCursor();
                        }
                } else {
-                       bv_->cut();
+                       bv_->cut(false);
                }
                owner_->showState();
                setState();
@@ -2531,6 +2520,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                                         cursor.par()->params().pagebreakTop(), 
                                         cursor.par()->params().pagebreakBottom(),
                                         VSpace(VSpace::NONE), cursor.par()->params().spaceBottom(),
+                                        cursor.par()->params().spacing(), 
                                         cursor.par()->params().align(), 
                                         cursor.par()->params().labelWidthString(), 0);
                                update(lt,
@@ -2546,7 +2536,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                                       | BufferView::CHANGE);
                        }
                } else
-                       bv_->cut();
+                       bv_->cut(false);
        }
        break;
 
@@ -2601,6 +2591,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                                         cursor.par()->params().pagebreakTop(), 
                                         cursor.par()->params().pagebreakBottom(),
                                         VSpace(VSpace::DEFSKIP), cursor.par()->params().spaceBottom(),
+                                        cursor.par()->params().spacing(), 
                                         cursor.par()->params().align(), 
                                         cursor.par()->params().labelWidthString(), 1);
                                //update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
@@ -2745,7 +2736,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                if (floatList.typeExist(argument)) {
                        insertAndEditInset(new InsetFloat(argument));
                } else {
-                       lyxerr << "Non-existant float type: "
+                       lyxerr << "Non-existent float type: "
                               << argument << endl;
                }
                break;
@@ -2761,7 +2752,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                        else
                                delete new_inset;
                } else {
-                       lyxerr << "Non-existant float type: "
+                       lyxerr << "Non-existent float type: "
                               << argument << endl;
                }
                
@@ -2860,18 +2851,6 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        }
        break;
 
-       case LFUN_GETLATEX:
-       {
-#ifndef NO_LATEX
-               LyXFont & font = bv_->getLyXText()->current_font;
-                if (font.latex() == LyXFont::ON)
-                       owner_->getLyXFunc()->setMessage("L");
-                else
-#endif
-                       owner_->getLyXFunc()->setMessage("0");
-       }
-       break;
-
        // --- accented characters ---------------------------
                
        case LFUN_UMLAUT:
@@ -2933,6 +2912,10 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                mathDispatchMathMode(bv_, argument);
                break;
                
+       case LFUN_GREEK:                 // Insert a single greek letter
+               mathDispatchGreek(bv_, argument);
+               break;
+               
        case LFUN_CITATION_INSERT:
        {
                InsetCommandParams p;
@@ -2952,9 +2935,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                // The argument can be up to two tokens separated 
                // by a space. The first one is the bibstyle.
                string const db       = token(argument, ' ', 0);
-               string bibstyle = token(argument, ' ', 1);
-               if (bibstyle.empty())
-                       bibstyle = "plain";
+               string const bibstyle = token(argument, ' ', 1);
 
                InsetCommandParams p( "BibTeX", db, bibstyle );
                InsetBibtex * inset = new InsetBibtex(p);
@@ -3003,11 +2984,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                InsetCommandParams p("index");
                if (argument.empty()) {
                        string const idxstring(bv_->getLyXText()->getStringToIndex(bv_));
-                       if (!idxstring.empty()) {
-                               p.setContents(idxstring);
-                       } else {
-                               break;
-                       }
+                       p.setContents(idxstring);
                } else {
                        p.setContents(argument);
                }
@@ -3096,13 +3073,14 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                string arg = argument;
 
                if (arg.empty()) {
-                       arg = bv_->getLyXText()->selectionAsString(buffer_);
+                       arg = bv_->getLyXText()->selectionAsString(buffer_,
+                                                                  false);
  
                        // FIXME
                        if (arg.size() > 100 || arg.empty()) {
                                // Get word or selection
                                bv_->getLyXText()->selectWordWhenUnderCursor(bv_, LyXText::WHOLE_WORD);
-                               arg = bv_->getLyXText()->selectionAsString(buffer_);
+                               arg = bv_->getLyXText()->selectionAsString(buffer_, false);
                                // FIXME: where is getLyXText()->unselect(bv_) ?
                        }
                }
@@ -3125,7 +3103,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                
                if (lyxrc.auto_region_delete) {
                        if (lt->selection.set()) {
-                               lt->cutSelection(bv_, false);
+                               lt->cutSelection(bv_, false, false);
                                bv_->update(lt,
                                            BufferView::SELECT
                                            | BufferView::FITCUR
@@ -3264,6 +3242,8 @@ void BufferView::Pimpl::specialChar(InsetSpecialChar::Kind kind)
                InsetSpecialChar * new_inset = 
                        new InsetSpecialChar(kind);
                insertInset(new_inset);
+               // Ok, what happens here if we are unable to insert
+               // the inset? Leak it?
        }
 }
 
@@ -3279,7 +3259,13 @@ void BufferView::Pimpl::smartQuote()
                c = ' ';
 
        hideCursor();
-       if (!insertInset(new InsetQuotes(c, bv_->buffer()->params)))
+
+       LyXLayout const & style = textclasslist.Style(
+               bv_->buffer()->params.textclass,
+               lt->cursor.par()->getLayout());
+       
+       if (style.pass_thru ||
+               (!insertInset(new InsetQuotes(c, bv_->buffer()->params))))
                Dispatch(LFUN_SELFINSERT, "\"");
 }
 
@@ -3353,13 +3339,11 @@ bool BufferView::Pimpl::insertInset(Inset * inset, string const & lout)
                bv_->text->setParagraph(bv_, 0, 0,
                                   0, 0,
                                   VSpace(VSpace::NONE), VSpace(VSpace::NONE),
+                                  Spacing(),
                                   LYX_ALIGN_LAYOUT, 
                                   string(),
                                   0);
                update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
-#ifndef NO_LATEX
-               bv_->text->current_font.setLatex(LyXFont::OFF);
-#endif
        }
        
        bv_->text->insertInset(bv_, inset);