]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insettext.C
fix typo that put too many include paths for most people
[lyx.git] / src / insets / insettext.C
index 4eb85c6df570933dadbdd2ef3758cf37a775a26b..3ceb4f48812088d2d5af000f6cfb8fbe54e070fe 100644 (file)
@@ -187,7 +187,7 @@ void InsetText::init(InsetText const * ins, bool same_id)
        insetDescent = 0;
        insetWidth = 0;
        old_max_width = 0;
-       no_selection = false;
+       no_selection = true;
        need_update = FULL;
        drawTextXOffset = 0;
        drawTextYOffset = 0;
@@ -618,16 +618,17 @@ void InsetText::updateLocal(BufferView * bv, int what, bool mark_dirty) const
        }
        lt->fullRebreak(bv);
        setUpdateStatus(bv, what);
-       bool flag = (((need_update != CURSOR) && (need_update != NONE)) ||
-                    (lt->status() != LyXText::UNCHANGED) || lt->selection.set());
+       bool flag = mark_dirty ||
+               (((need_update != CURSOR) && (need_update != NONE)) ||
+                (lt->status() != LyXText::UNCHANGED) || lt->selection.set());
        if (!lt->selection.set())
                lt->selection.cursor = lt->cursor;
        if (clear)
                lt = 0;
+       if (locked && (need_update & CURSOR) && bv->fitCursor())
+               need_update |= FULL;
        if (flag)
                bv->updateInset(const_cast<InsetText *>(this), mark_dirty);
-       else
-               bv->fitCursor();
 
        if (need_update == CURSOR)
                need_update = NONE;
@@ -681,7 +682,6 @@ void InsetText::edit(BufferView * bv, int x, int y, unsigned int button)
                font.setLanguage(bv->getParentLanguage(this));
                setFont(bv, font, false);
        }
-//     showInsetCursor(bv);
        if (clear)
                lt = 0;
 
@@ -689,6 +689,7 @@ void InsetText::edit(BufferView * bv, int x, int y, unsigned int button)
        if (drawFrame_ == LOCKED)
                code = CURSOR|DRAW_FRAME;
        updateLocal(bv, code, false);
+       showInsetCursor(bv);
 
        // Tell the paragraph dialog that we've entered an insettext.
        bv->owner()->getDialogs()->updateParagraph();
@@ -733,13 +734,13 @@ void InsetText::edit(BufferView * bv, bool front)
                font.setLanguage(bv->getParentLanguage(this));
                setFont(bv, font, false);
        }
-//     showInsetCursor(bv);
        if (clear)
                lt = 0;
        int code = CURSOR;
        if (drawFrame_ == LOCKED)
                code = CURSOR|DRAW_FRAME;
        updateLocal(bv, code, false);
+       showInsetCursor(bv);
 }
 
 
@@ -750,7 +751,7 @@ void InsetText::insetUnlock(BufferView * bv)
                the_locking_inset = 0;
        }
        hideInsetCursor(bv);
-       no_selection = false;
+       no_selection = true;
        locked = false;
        int code;
        if (drawFrame_ == LOCKED)
@@ -935,7 +936,6 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
                                                            x - inset_x,
                                                            y - inset_y,
                                                            button);
-                       no_selection = false;
                        return;
                } else if (inset) {
                        // otherwise unlock the_locking_inset and lock the new inset
@@ -948,13 +948,15 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
 //                     inset->edit(bv, x - inset_x, y - inset_y, button);
                        if (the_locking_inset)
                                updateLocal(bv, CURSOR, false);
-                       no_selection = false;
                        return;
                }
                // otherwise only unlock the_locking_inset
                the_locking_inset->insetUnlock(bv);
                the_locking_inset = 0;
        }
+       if (!inset)
+               no_selection = false;
+
        if (bv->theLockingInset()) {
                if (isHighlyEditableInset(inset)) {
                        UpdatableInset * uinset = static_cast<UpdatableInset*>(inset);
@@ -969,7 +971,6 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
                        uinset->edit(bv, x - inset_x, y - inset_y, 0);
                        if (the_locking_inset)
                                updateLocal(bv, CURSOR, false);
-                       no_selection = false;
                        return;
                }
        }
@@ -984,6 +985,7 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
                        lt = getLyXText(bv);
                        clear = true;
                }
+               int old_first_y = lt->first_y;
 
                lt->setCursorFromCoordinates(bv, x - drawTextXOffset,
                                             y + insetAscent);
@@ -1003,6 +1005,9 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
                        updateLocal(bv, CURSOR, false);
                }
                bv->owner()->setLayout(cpar(bv)->layout());
+               // we moved the view we cannot do mouse selection in this case!
+               if (getLyXText(bv)->first_y != old_first_y)
+                       no_selection = true;
                old_par = cpar(bv);
                // Insert primary selection with middle mouse
                // if there is a local selection in the current buffer,
@@ -1018,12 +1023,12 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
                getLyXText(bv)->clearSelection();
        }
        showInsetCursor(bv);
-       no_selection = false;
 }
 
 
 bool InsetText::insetButtonRelease(BufferView * bv, int x, int y, int button)
 {
+       no_selection = true;
        if (the_locking_inset) {
                return the_locking_inset->insetButtonRelease(bv,
                                                             x - inset_x, y - inset_y,
@@ -1053,13 +1058,15 @@ bool InsetText::insetButtonRelease(BufferView * bv, int x, int y, int button)
 
 void InsetText::insetMotionNotify(BufferView * bv, int x, int y, int state)
 {
-       if (no_selection || ((mouse_x == x) && (mouse_y == y)))
-               return;
        if (the_locking_inset) {
                the_locking_inset->insetMotionNotify(bv, x - inset_x,
                                                     y - inset_y,state);
                return;
        }
+
+       if (no_selection || ((mouse_x == x) && (mouse_y == y)))
+               return;
+
        bool clear = false;
        if (!lt) {
                lt = getLyXText(bv);
@@ -1143,6 +1150,7 @@ InsetText::localDispatch(BufferView * bv,
 #ifdef WITH_WARNINGS
 #warning I changed this to always return Dispatched maybe it is wrong (20011001 Jug)
 #endif
+                       updateLocal(bv, CURSOR, false);
                        return result;
                }
        }
@@ -1318,7 +1326,7 @@ InsetText::localDispatch(BufferView * bv,
                        break;
                }
                lt->breakParagraph(bv, 0);
-               updwhat = FULL;
+               updwhat = CURSOR | FULL;
                updflag = true;
                break;
        case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
@@ -1327,7 +1335,7 @@ InsetText::localDispatch(BufferView * bv,
                        break;
                }
                lt->breakParagraph(bv, 1);
-               updwhat = FULL;
+               updwhat = CURSOR | FULL;
                updflag = true;
                break;
 
@@ -1339,7 +1347,7 @@ InsetText::localDispatch(BufferView * bv,
                setUndo(bv, Undo::INSERT,
                        lt->cursor.par(), lt->cursor.par()->next());
                lt->insertChar(bv, Paragraph::META_NEWLINE);
-               updwhat = CURSOR_PAR;
+               updwhat = CURSOR | CURSOR_PAR;
                updflag = true;
        }
        break;
@@ -1450,6 +1458,9 @@ InsetText::localDispatch(BufferView * bv,
 
        if (result >= FINISHED)
                bv->unlockInset(this);
+
+       if (result == DISPATCHED_NOUPDATE && (need_update & FULL))
+               result = DISPATCHED;
        return result;
 }
 
@@ -1767,7 +1778,8 @@ void InsetText::fitInsetCursor(BufferView * bv) const
        int const asc = lyxfont::maxAscent(font);
        int const desc = lyxfont::maxDescent(font);
 
-       bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc);
+       if (bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc))
+               need_update |= FULL;
 }