]> git.lyx.org Git - lyx.git/commitdiff
John's minibuffer, checkInsetHit, lyxfunc-timeout patches + fix crash
authorJürgen Vigna <jug@sad.it>
Mon, 3 Dec 2001 13:17:04 +0000 (13:17 +0000)
committerJürgen Vigna <jug@sad.it>
Mon, 3 Dec 2001 13:17:04 +0000 (13:17 +0000)
on changing ERT insets Status (inlined, open, collapsed).

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3138 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView_pimpl.C
src/ChangeLog
src/insets/ChangeLog
src/insets/insettext.C
src/lyxfunc.C
src/lyxlength.C
src/minibuffer.C
src/text.C

index 1fb1f9c5a66751d22e1455a97ba69923ae205bf7..f69d95cdb37aaaba4a9787c145891ef5167894fb 100644 (file)
@@ -874,58 +874,45 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y,
        text->setCursorFromCoordinates(bv_, cursor, x, y_tmp);
        text->setCursor(bv_, cursor, cursor.par(),cursor.pos(),true);
 
-
+       lyx::pos_type pos;
        if (cursor.pos() < cursor.par()->size()
            && cursor.par()->isInset(cursor.pos())
-           && isEditableInset(cursor.par()->getInset(cursor.pos()))) {
-
-               // Check whether the inset really was hit
-               Inset * tmpinset = cursor.par()->getInset(cursor.pos());
-               LyXFont font = text->getFont(buffer_,
-                                                 cursor.par(), cursor.pos());
-               int const width = tmpinset->width(bv_, font);
-               int const inset_x = font.isVisibleRightToLeft()
-                       ? cursor.x() - width : cursor.x();
-               int const start_x = inset_x + tmpinset->scroll();
-               int const end_x = inset_x + width;
-
-               if (x > start_x && x < end_x
-                   && y_tmp > cursor.y() - tmpinset->ascent(bv_, font)
-                   && y_tmp < cursor.y() + tmpinset->descent(bv_, font)) {
-                       text->setCursor(bv_, cursor.par(),cursor.pos(), true);
-                       x = x - start_x;
-                       // The origin of an inset is on the baseline
-                       y = y_tmp - (text->cursor.y()); 
-                       return tmpinset;
-               }
+           && isEditableInset(cursor.par()->getInset(cursor.pos())))
+       {
+               pos = cursor.pos();
+       } else if ((cursor.pos() - 1 >= 0)
+               && cursor.par()->isInset(cursor.pos() - 1)
+               && isEditableInset(cursor.par()->getInset(cursor.pos() - 1)))
+       {
+               pos = cursor.pos() - 1;
+               // if the inset takes a full row, then the cursor.y()
+               // at the end of the inset will be wrong. So step the cursor
+               // back one
+               text->setCursor(bv_, cursor, cursor.par(), cursor.pos() - 1, true);
+       } else {
+               return 0;
        }
 
-       if ((cursor.pos() - 1 >= 0) &&
-           cursor.par()->isInset(cursor.pos() - 1) &&
-           isEditableInset(cursor.par()->getInset(cursor.pos() - 1))) {
-               Inset * tmpinset = cursor.par()->getInset(cursor.pos()-1);
-               LyXFont font = text->getFont(buffer_, cursor.par(),
-                                                 cursor.pos() - 1);
-               int const width = tmpinset->width(bv_, font);
-               int const inset_x = font.isVisibleRightToLeft()
-                       ? cursor.x() : cursor.x() - width;
-               int const start_x = inset_x + tmpinset->scroll();
-               int const end_x = inset_x + width;
-
-               if (x > start_x && x < end_x
-                   && y_tmp > cursor.y() - tmpinset->ascent(bv_, font)
-                   && y_tmp < cursor.y() + tmpinset->descent(bv_, font)) {
-#if 0
-                       if (move_cursor && (tmpinset != bv_->theLockingInset()))
-#endif
-                               text->setCursor(bv_, cursor.par(),
-                                               cursor.pos() - 1, true);
-                       x = x - start_x;
-                       // The origin of an inset is on the baseline
-                       y = y_tmp - (text->cursor.y()); 
-                       return tmpinset;
-               }
+       // Check whether the inset really was hit
+       Inset * inset = cursor.par()->getInset(pos);
+       LyXFont const & font = text->getFont(buffer_, cursor.par(), pos);
+       int const width = inset->width(bv_, font);
+       int const inset_x = font.isVisibleRightToLeft()
+               ? cursor.x() - width : cursor.x();
+       int const start_x = inset_x + inset->scroll();
+       int const end_x = inset_x + width;
+       int const start_y = cursor.y() - inset->ascent(bv_, font);
+       int const end_y = cursor.y() + inset->descent(bv_, font);
+       if (x > start_x && x < end_x && y_tmp > start_y && y < end_y) {
+               text->setCursor(bv_, cursor.par(), pos, true);
+               x = x - start_x;
+               // The origin of an inset is on the baseline
+               y = y_tmp - (text->cursor.y()); 
+               return inset;
        }
+
        return 0;
 }
 
index 51cad52209dbc31596d98c098a5c3547f3e007ea..03bc2152e6855e2d0d4aacc44b1a2afb43c7c46c 100644 (file)
@@ -1,8 +1,20 @@
+2001-12-03  Juergen Vigna  <jug@sad.it>
+
+       * text.C (rowLast): simplified code
+
+2001-12-03  John Levon  <moz@compsoc.man.ac.uk>
+
+       * lyxfunc.C: fix show options on timeout
 2001-12-03  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * screen.C (topCursorVisible): scroll half a page when the cursor
        reached top of bottom of screen
 
+2001-12-02  John Levon  <moz@compsoc.man.ac.uk>
+
+       * minibuffer.C: deactivate on loss of focus
 2001-12-02  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * vspace.[Ch] (operator!=): add operator. 
        * BufferView_pimpl.C: refuse to open an inset when
        there's a selection.
 
+2001-11-30  John Levon  <moz@compsoc.man.ac.uk>
+
+       * BufferView_pimpl.C: allow to click on RHS of full row insets
 2001-11-30  Juergen Vigna  <jug@sad.it>
 
        * tabular.C (LyXTabular): add a same_id to set the same id's in the
        * paragraph_pimpl.h:
        * paragraph_pimpl.C: tidy, and fix font-change in "LaTeX"
          bug a bit
+
 2001-11-26  John Levon  <moz@compsoc.man.ac.uk>
 
        * text.C: 
index 3fcf5d71071c45b1be8073f61545ce045162d46e..00c3101df973cc9dd2a27041aa03a6d7af1c9ecc 100644 (file)
@@ -1,3 +1,8 @@
+2001-12-03  Juergen Vigna  <jug@sad.it>
+
+       * insettext.C (updateInsetInInset): use lt variable to forbid
+       changes of LyXText in an update call.
+
 2001-12-01  John Levon  <moz@compsoc.man.ac.uk>
 
        * insettabular.C: capture some more functions to prevent
index c05b94713fe49bc58258c281f2e66036e48b896f..8b70df3e27e37cd234a289a9e603467b66f896a7 100644 (file)
@@ -842,8 +842,17 @@ bool InsetText::updateInsetInInset(BufferView * bv, Inset * inset)
                setUpdateStatus(bv, CURSOR_PAR);
                return the_locking_inset->updateInsetInInset(bv, inset);
        }
-       if (getLyXText(bv)->updateInset(bv, inset))
+       bool clear = false;
+       if (!lt) {
+               lt = getLyXText(bv);
+               clear = true;
+       }
+       if (lt->updateInset(bv, inset)) {
+               if (clear)
+                       lt = 0;
                updateLocal(bv, CURSOR_PAR, false);
+       } else if (clear)
+               lt = 0;
        if (cpar(bv) == inset_par && cpos(bv) == inset_pos) {
                inset_x = cx(bv) - top_x + drawTextXOffset;
                inset_y = cy(bv) + drawTextYOffset;
@@ -2202,12 +2211,18 @@ void InsetText::reinitLyXText() const
 
 void InsetText::removeNewlines()
 {
+       bool changed = false;
+       
        for (Paragraph * p = par; p; p = p->next()) {
                for (int i = 0; i < p->size(); ++i) {
-                       if (p->getChar(i) == Paragraph::META_NEWLINE)
+                       if (p->getChar(i) == Paragraph::META_NEWLINE) {
+                               changed = true;
                                p->erase(i);
+                       }
                }
        }
+       if (changed)
+               reinitLyXText();
 }
 
 
index e420b2c8fc95e7b07659b2650903ce6bb29ba23d..ae28ce37f75ed1a975be88320103661bd556645e 100644 (file)
@@ -2015,7 +2015,7 @@ void LyXFunc::initMiniBuffer()
 
        // Else, when a non-complete key sequence is pressed,
        // show the available options.
-       else if (keyseq.length() > 1) {
+       if (keyseq.length() > 0 && !keyseq.deleted()) {
                text = keyseq.printOptions();
        }
    
index 8f782873bc361eaafaad98e26ee6c65500aeb139..35bfb87ad5a2cfdd429d95db265f3c7c7f64299f 100644 (file)
@@ -18,6 +18,8 @@
 
 #include "Lsstream.h"
 
+#include <cmath>
+
 namespace {
 // this is now here and in lyxgluelength.C
 
index 7583a803eb74f571964c36ff84fab08e1208e82b..0ea7b7e25c4c8324220f913716478cdddf8a00a2 100644 (file)
@@ -100,6 +100,9 @@ void MiniBuffer::stored_set(string const & str)
 int MiniBuffer::peek_event(FL_OBJECT * ob, int event, int key)
 {
        switch (event) {
+       case FL_UNFOCUS:
+               deactivate();
+               break;
        case FL_KEYBOARD:
        {
                char const * tmp = fl_get_input(ob);
index 8e5d3ea8d41b499d9aa5ee4cda39c7b44b7810fd..d4ccf901e0d569690f16770c23d022b0cd5e3272 100644 (file)
@@ -233,9 +233,7 @@ int LyXText::singleWidth(BufferView * bview, Paragraph * par,
 // Returns the paragraph position of the last character in the specified row
 pos_type LyXText::rowLast(Row const * row) const
 {
-       if (row->next() == 0)
-               return row->par()->size() - 1;
-       else if (row->next()->par() != row->par()) 
+       if (!row->next() || row->next()->par() != row->par())
                return row->par()->size() - 1;
        else 
                return row->next()->pos() - 1;