]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView_pimpl.C
last Friday's text*.C -> text_func shuffle
[lyx.git] / src / BufferView_pimpl.C
index a2770b274f54b7582f6b68cead2be0715b01d7b8..e2892808d5d2cced7a3f62df0910de98dea93b9a 100644 (file)
@@ -3,6 +3,7 @@
  * Copyright 2002 the LyX Team
  * Read the file COPYING
  *
+ * \author Lars Gullik Bjønnes
  * \author various
  */
 
@@ -75,6 +76,7 @@ using std::make_pair;
 using std::min;
 
 using lyx::pos_type;
+using namespace lyx::support;
 using namespace bv_funcs;
 
 extern BufferList bufferlist;
@@ -167,14 +169,13 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
        }
        Buffer * b = bufferlist.newBuffer(s);
 
-       bv_->resetErrorList();
        //attach to the error signal in the buffer
-       b->parseError.connect(boost::bind(&BufferView::Pimpl::addError, 
+       b->parseError.connect(boost::bind(&BufferView::Pimpl::addError,
                                          this, _1));
 
-       bool loaded = true;
+       bool loaded = ::loadLyXFile(b, s);
 
-       if (! ::loadLyXFile(b, s)) {
+       if (! loaded) {
                bufferlist.release(b);
                string text = bformat(_("The document %1$s does "
                                        "not yet exist.\n\n"
@@ -183,13 +184,12 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
                int const ret = Alert::prompt(_("Create new document?"),
                         text, 0, 1, _("&Create"), _("Cancel"));
 
-               if (ret == 0) {
-                       bufferlist.close(buffer_, false);
-                       buffer(newFile(s, string(), true));
-               }
+               if (ret == 0)
+                       b = newFile(s, string(), true);
+               else
+                       return false;
 
-               loaded = false;
-       } 
+       }
 
        buffer(b);
 
@@ -260,7 +260,7 @@ void BufferView::Pimpl::buffer(Buffer * b)
                }
 
                // FIXME: needed when ?
-               bv_->text->top_y(screen().topCursorVisible(bv_->text->cursor, bv_->text->top_y()));
+               bv_->text->top_y(screen().topCursorVisible(bv_->text));
 
                // Buffer-dependent dialogs should be updated or
                // hidden. This should go here because some dialogs (eg ToC)
@@ -360,7 +360,7 @@ int BufferView::Pimpl::resizeCurrentBuffer()
                mark_set = bv_->text->selection.mark();
                the_locking_inset = bv_->theLockingInset();
                buffer_->resizeInsets(bv_);
-               // I don't think the delete and new are necessary here we 
+               // I don't think the delete and new are necessary here we
                // just could call only init! (Jug 20020419)
                delete bv_->text;
                bv_->text = new LyXText(bv_);
@@ -411,7 +411,7 @@ int BufferView::Pimpl::resizeCurrentBuffer()
                bv_->theLockingInset(the_locking_inset);
        }
 
-       bv_->text->top_y(screen().topCursorVisible(bv_->text->cursor, bv_->text->top_y()));
+       bv_->text->top_y(screen().topCursorVisible(bv_->text));
 
        switchKeyMap();
        owner_->busy(false);
@@ -619,7 +619,7 @@ void BufferView::Pimpl::update(LyXText * text, BufferView::UpdateCodes f)
                text->selection.cursor = text->cursor;
        }
 
-       text->fullRebreak();
+       text->partialRebreak();
 
        if (text->inset_owner) {
                text->inset_owner->setUpdateStatus(bv_, InsetText::NONE);
@@ -638,7 +638,7 @@ void BufferView::Pimpl::update(BufferView::UpdateCodes f)
                text->selection.cursor = text->cursor;
        }
 
-       text->fullRebreak();
+       text->partialRebreak();
 
        if (text->inset_owner) {
                text->inset_owner->setUpdateStatus(bv_, InsetText::NONE);
@@ -722,7 +722,7 @@ void BufferView::Pimpl::restorePosition(unsigned int i)
                        b = bufferlist.newBuffer(fname);
                        ::loadLyXFile(b, fname); // don't ask, just load it
                }
-               if (b != 0) 
+               if (b != 0)
                        buffer(b);
        }
 
@@ -1259,7 +1259,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
                        // FIXME
                        if (arg.size() > 100 || arg.empty()) {
                                // Get word or selection
-                               bv_->getLyXText()->selectWordWhenUnderCursor(LyXText::WHOLE_WORD);
+                               bv_->getLyXText()->selectWordWhenUnderCursor(lyx::WHOLE_WORD);
                                arg = bv_->getLyXText()->selectionAsString(buffer_, false);
                                // FIXME: where is getLyXText()->unselect(bv_) ?
                        }