]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView_pimpl.C
mathed31.diff
[lyx.git] / src / BufferView_pimpl.C
index 5162dc61108cb938c3b33576d9325e4724b235a3..dff6e8a53eac36c82d505cf1e572ceac95f45583 100644 (file)
@@ -21,6 +21,7 @@
 #include "TextCache.h"
 #include "bufferlist.h"
 #include "insets/insetbib.h"
+#include "insets/insettext.h"
 #include "lyx_gui_misc.h"
 #include "lyxrc.h"
 #include "intl.h"
@@ -43,7 +44,6 @@ bool selection_possible = false;
 extern BufferList bufferlist;
 extern char ascii_type;
 
-extern "C" void TimerCB(FL_OBJECT *, long); 
 extern void sigchldhandler(pid_t pid, int * status);
 extern int bibitemMaxWidth(BufferView *, LyXFont const &);
 
@@ -76,11 +76,7 @@ BufferView::Pimpl::Pimpl(BufferView * b, LyXView * o,
        : bv_(b), owner_(o), cursor_timeout(400)
 {
        buffer_ = 0;
-#if 0
-       workarea_ = new WorkArea(bv_, xpos, ypos, width, height);
-#else
        workarea_ = new WorkArea(xpos, ypos, width, height);
-#endif
        // Setup the signals
        workarea_->scrollCB.connect(slot(this, &BufferView::Pimpl::scrollCB));
        workarea_->workAreaExpose
@@ -199,7 +195,7 @@ void BufferView::Pimpl::buffer(Buffer * b)
 void BufferView::Pimpl::resize(int xpos, int ypos, int width, int height)
 {
        workarea_->resize(xpos, ypos, width, height);
-       update(SELECT);
+       update(bv_->text, SELECT);
        redraw();
 }
 
@@ -246,6 +242,8 @@ int BufferView::Pimpl::resizeCurrentBuffer()
        LyXParagraph * par = 0;
        LyXParagraph * selstartpar = 0;
        LyXParagraph * selendpar = 0;
+       UpdatableInset * the_locking_inset;
+       
        int pos = 0;
        int selstartpos = 0;
        int selendpos = 0;
@@ -265,6 +263,7 @@ int BufferView::Pimpl::resizeCurrentBuffer()
                selendpos = bv_->text->sel_end_cursor.pos();
                selection = bv_->text->selection;
                mark_set = bv_->text->mark_set;
+               the_locking_inset = bv_->text->the_locking_inset;
                delete bv_->text;
                bv_->text = new LyXText(bv_);
        } else {
@@ -295,13 +294,15 @@ int BufferView::Pimpl::resizeCurrentBuffer()
                        bv_->text->SetCursor(bv_, selstartpar, selstartpos);
                        bv_->text->sel_cursor = bv_->text->cursor;
                        bv_->text->SetCursor(bv_, selendpar, selendpos);
-                       bv_->text->SetSelection();
+                       bv_->text->SetSelection(bv_);
                        bv_->text->SetCursor(bv_, par, pos);
                } else {
                        bv_->text->SetCursor(bv_, par, pos);
                        bv_->text->sel_cursor = bv_->text->cursor;
                        bv_->text->selection = false;
                }
+               // remake the inset locking
+               bv_->text->the_locking_inset = the_locking_inset;
        }
        bv_->text->first = screen_->TopCursorVisible(bv_->text);
        buffer_->resizeInsets(bv_);
@@ -312,9 +313,8 @@ int BufferView::Pimpl::resizeCurrentBuffer()
        bv_->setState();
        AllowInput(bv_);
 
-       // Now if the title form still exist kill it
-       TimerCB(0, 0);
-
+       owner_->getDialogs()->hideSplash();
        return 0;
 }
 
@@ -521,9 +521,9 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state)
        bv_->text->SetCursorFromCoordinates(bv_, x, y + bv_->text->first);
       
        if (!bv_->text->selection)
-               update(BufferView::UPDATE); // Maybe an empty line was deleted
+               update(bv_->text, BufferView::UPDATE); // Maybe an empty line was deleted
       
-       bv_->text->SetSelection();
+       bv_->text->SetSelection(bv_);
        screen_->ToggleToggle(bv_->text, bv_);
        fitCursor(bv_->text);
        screen_->ShowCursor(bv_->text, bv_);
@@ -638,34 +638,48 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
 void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, unsigned int button) 
 {
        // select a word
-       if (buffer_ && !bv_->theLockingInset()) {
-               if (screen_ && button == 1) {
-                       screen_->HideCursor();
-                       screen_->ToggleSelection(bv_->text, bv_);
-                       bv_->text->SelectWord(bv_);
-                       screen_->ToggleSelection(bv_->text, bv_, false);
-                       /* This will fit the cursor on the screen
-                        * if necessary */
-                       update(BufferView::SELECT|BufferView::FITCUR);
-               }
-       }   
+       if (!buffer_)
+           return;
+
+       LyXText * text = bv_->getLyXText();
+
+       if (text->bv_owner && bv_->theLockingInset())
+           return;
+
+       if (screen_ && button == 1) {
+           screen_->HideCursor();
+           screen_->ToggleSelection(text, bv_);
+           text->SelectWord(bv_);
+           screen_->ToggleSelection(text, bv_, false);
+           /* This will fit the cursor on the screen
+            * if necessary */
+           update(text, BufferView::SELECT|BufferView::FITCUR);
+       }
 }
 
 
 void BufferView::Pimpl::tripleClick(int /*x*/, int /*y*/, unsigned int button)
 {
        // select a line
-       if (buffer_ && screen_ && !bv_->theLockingInset() && (button == 1)) {
+       if (buffer_)
+               return;
+
+       LyXText * text = bv_->getLyXText();
+
+       if (text->bv_owner && bv_->theLockingInset())
+           return;
+
+       if (screen_ && (button == 1)) {
                screen_->HideCursor();
-               screen_->ToggleSelection(bv_->text, bv_);
-               bv_->text->CursorHome(bv_);
-               bv_->text->sel_cursor = bv_->text->cursor;
-               bv_->text->CursorEnd(bv_);
-               bv_->text->SetSelection();
-               screen_->ToggleSelection(bv_->text, bv_, false);
+               screen_->ToggleSelection(text, bv_);
+               text->CursorHome(bv_);
+               text->sel_cursor = text->cursor;
+               text->CursorEnd(bv_);
+               text->SetSelection(bv_);
+               screen_->ToggleSelection(text, bv_, false);
                /* This will fit the cursor on the screen
                 * if necessary */
-               update(BufferView::SELECT|BufferView::FITCUR);
+               update(text, BufferView::SELECT|BufferView::FITCUR);
        }
 }
 
@@ -1006,20 +1020,24 @@ void BufferView::Pimpl::update()
 // update(1)  -> update(1 + 2 + 4) -> update(7) -> update(SELECT|FITCUR|CHANGE)
 // update(3)  -> update(1)         -> update(1) -> update(SELECT)
 
-void BufferView::Pimpl::update(BufferView::UpdateCodes f)
+void BufferView::Pimpl::update(LyXText * text, BufferView::UpdateCodes f)
 {
        owner_->updateLayoutChoice();
 
-       if (!bv_->text->selection && (f & SELECT)) {
-               bv_->text->sel_cursor = bv_->text->cursor;
+       if (!text->selection && (f & SELECT)) {
+               text->sel_cursor = text->cursor;
        }
 
-       bv_->text->FullRebreak(bv_);
+       text->FullRebreak(bv_);
 
-       update();
+       if (text->inset_owner) {
+           text->inset_owner->SetUpdateStatus(bv_, InsetText::CURSOR_PAR);
+           bv_->updateInset(text->inset_owner, true);
+       } else
+           update();
 
        if ((f & FITCUR)) {
-               fitCursor(bv_->text);
+               fitCursor(text);
        }
 
        if ((f & CHANGE)) {
@@ -1125,10 +1143,10 @@ bool BufferView::Pimpl::available() const
 }
 
 
-void BufferView::Pimpl::beforeChange()
+void BufferView::Pimpl::beforeChange(LyXText * text)
 {
        toggleSelection();
-       bv_->text->ClearSelection();
+       text->ClearSelection();
 }
 
 
@@ -1151,7 +1169,7 @@ void BufferView::Pimpl::restorePosition(unsigned int i)
 
        string fname = saved_positions[i].filename;
 
-       beforeChange();
+       beforeChange(bv_->text);
 
        if (fname != buffer_->fileName()) {
                Buffer * b = bufferlist.exists(fname) ?
@@ -1166,7 +1184,7 @@ void BufferView::Pimpl::restorePosition(unsigned int i)
 
        bv_->text->SetCursor(bv_, par,
                             min(par->Last(), saved_positions[i].par_pos));
-       update(BufferView::SELECT|BufferView::FITCUR);
+       update(bv_->text, BufferView::SELECT|BufferView::FITCUR);
        if (i > 0)
                owner_->getMiniBuffer()->Set(_("Moved to bookmark ") + tostr(i));
 }
@@ -1283,13 +1301,13 @@ void BufferView::Pimpl::toggleToggle()
 
 void BufferView::Pimpl::center() 
 {
-       beforeChange();
+       beforeChange(bv_->text);
        if (bv_->text->cursor.y() > static_cast<int>((workarea_->height() / 2))) {
                screen_->Draw(bv_->text, bv_, bv_->text->cursor.y() - workarea_->height() / 2);
        } else {
                screen_->Draw(bv_->text, bv_, 0);
        }
-       update(BufferView::SELECT|BufferView::FITCUR);
+       update(bv_->text, BufferView::SELECT|BufferView::FITCUR);
        redraw();
 }
 
@@ -1299,7 +1317,7 @@ void BufferView::Pimpl::pasteClipboard(bool asPara)
        if (!buffer_) return;
 
        screen_->HideCursor();
-       bv_->beforeChange();
+       beforeChange(bv_->text);
        
        string const clip(workarea_->getClipboard());
        
@@ -1310,7 +1328,7 @@ void BufferView::Pimpl::pasteClipboard(bool asPara)
        } else {
                bv_->text->InsertStringA(bv_, clip);
        }
-       update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
+       update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
 }