]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView_pimpl.C
the spellcheck cleanup
[lyx.git] / src / BufferView_pimpl.C
index b7eafa9d9663223a7f89083ecc79dc97c681f35f..93b49159fe9775986ec819ab1233c8076758e89a 100644 (file)
@@ -25,6 +25,7 @@
 #include "bufferparams.h"
 #include "cursor.h"
 #include "debug.h"
+#include "dispatchresult.h"
 #include "factory.h"
 #include "FloatList.h"
 #include "funcrequest.h"
@@ -41,8 +42,7 @@
 #include "paragraph.h"
 #include "paragraph_funcs.h"
 #include "ParagraphParameters.h"
-#include "TextCache.h"
-#include "undo_funcs.h"
+#include "undo.h"
 #include "vspace.h"
 
 #include "insets/insetfloatlist.h"
@@ -255,7 +255,7 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
        bv_->showErrorList(_("Parse"));
 
        if (tolastfiles)
-               lastfiles->newFile(b->fileName());
+               LyX::ref().lastfiles().newFile(b->fileName());
 
        return true;
 }
@@ -297,14 +297,7 @@ void BufferView::Pimpl::buffer(Buffer * b)
                            << b << ')' << endl;
        if (buffer_) {
                disconnectBuffer();
-               // Put the old text into the TextCache, but
-               // only if the buffer is still loaded.
-               // Also set the owner of the test to 0
-               //              bv_->text->owner(0);
-               textcache.add(buffer_, workarea().workWidth(), bv_->text);
-               if (lyxerr.debugging())
-                       textcache.show(lyxerr, "BufferView::buffer");
-
+               delete bv_->text;
                bv_->text = 0;
        }
 
@@ -339,13 +332,6 @@ void BufferView::Pimpl::buffer(Buffer * b)
        } else {
                lyxerr[Debug::INFO] << "  No Buffer!" << endl;
                owner_->getDialogs().hideBufferDependent();
-
-               // Also remove all remaining text's from the testcache.
-               // (there should not be any!) (if there is any it is a
-               // bug!)
-               if (lyxerr.debugging())
-                       textcache.show(lyxerr, "buffer delete all");
-               textcache.clear();
        }
 
        update();
@@ -432,31 +418,10 @@ void BufferView::Pimpl::resizeCurrentBuffer()
                bv_->text->fullRebreak();
                update();
        } else {
-               lyxerr << "text not available!" << endl;
-               // See if we have a text in TextCache that fits
-               // the new buffer_ with the correct width.
-               bv_->text = textcache.findFit(buffer_, workarea().workWidth());
-               if (bv_->text) {
-                       lyxerr << "text in cache!" << endl;
-                       if (lyxerr.debugging()) {
-                               lyxerr << "Found a LyXText that fits:" << endl;
-                               textcache.show(lyxerr, make_pair(buffer_, make_pair(workarea().workWidth(), bv_->text)));
-                       }
-                       // Set the owner of the newly found text
-                       //      bv_->text->owner(bv_);
-                       if (lyxerr.debugging())
-                               textcache.show(lyxerr, "resizeCurrentBuffer");
-               } else {
-                       lyxerr << "no text in cache!" << endl;
                        bv_->text = new LyXText(bv_, 0, false, bv_->buffer()->paragraphs());
                        bv_->text->init(bv_);
-               }
        }
 
-#warning does not help much
-       //bv_->text->redoParagraphs(bv_->text->ownerParagraphs().begin(),
-       //      bv_->text->ownerParagraphs().end());
-
        if (par != -1) {
                bv_->text->selection.set(true);
                // At this point just to avoid the Delete-Empty-Paragraph-
@@ -629,16 +594,6 @@ void BufferView::Pimpl::workAreaResize()
                if (widthChange) {
                        // The visible LyXView need a resize
                        resizeCurrentBuffer();
-
-                       // Remove all texts from the textcache
-                       // This is not _really_ what we want to do. What
-                       // we really want to do is to delete in textcache
-                       // that does not have a BufferView with matching
-                       // width, but as long as we have only one BufferView
-                       // deleting all gives the same result.
-                       if (lyxerr.debugging())
-                               textcache.show(lyxerr, "Expose delete all");
-                       textcache.clear();
                }
        }
 
@@ -1184,7 +1139,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
                        // Note that the localDispatch performs updateInset
                        // also.
                        FuncRequest fr(bv_, LFUN_INSET_MODIFY, ev.argument);
-                       inset->localDispatch(fr);
+                       inset->dispatch(fr);
                } else {
                        FuncRequest fr(bv_, LFUN_INSET_INSERT, ev.argument);
                        dispatch(fr);
@@ -1322,7 +1277,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
                break;
 
        default:
-               return bv_->getLyXText()->dispatch(FuncRequest(ev, bv_));
+               return bv_->getLyXText()->dispatch(FuncRequest(ev, bv_)).dispatched();
        } // end of switch
 
        return true;
@@ -1340,7 +1295,7 @@ bool BufferView::Pimpl::insertInset(InsetOld * inset, string const & lout)
        }
 
        // not quite sure if we want this...
-       recordUndo(bv_, Undo::ATOMIC);
+       bv_->text->recUndo(bv_->text->cursor.par());
        freezeUndo();
 
        beforeChange(bv_->text);
@@ -1367,8 +1322,7 @@ bool BufferView::Pimpl::insertInset(InsetOld * inset, string const & lout)
 
                bv_->text->setLayout(lay);
 
-               bv_->text->setParagraph(0, 0,
-                                  0, 0,
+               bv_->text->setParagraph(
                                   VSpace(VSpace::NONE), VSpace(VSpace::NONE),
                                   Spacing(),
                                   LYX_ALIGN_LAYOUT,