From: Jürgen Vigna Date: Mon, 3 Dec 2001 13:17:04 +0000 (+0000) Subject: John's minibuffer, checkInsetHit, lyxfunc-timeout patches + fix crash X-Git-Tag: 1.6.10~20240 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=63ab8b351789ec3e77feba3918548627dbaa1347;p=features.git John's minibuffer, checkInsetHit, lyxfunc-timeout patches + fix crash 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 --- diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 1fb1f9c5a6..f69d95cdb3 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -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; } diff --git a/src/ChangeLog b/src/ChangeLog index 51cad52209..03bc2152e6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,8 +1,20 @@ +2001-12-03 Juergen Vigna + + * text.C (rowLast): simplified code + +2001-12-03 John Levon + + * lyxfunc.C: fix show options on timeout + 2001-12-03 Lars Gullik Bjønnes * screen.C (topCursorVisible): scroll half a page when the cursor reached top of bottom of screen +2001-12-02 John Levon + + * minibuffer.C: deactivate on loss of focus + 2001-12-02 Lars Gullik Bjønnes * vspace.[Ch] (operator!=): add operator. @@ -12,6 +24,10 @@ * BufferView_pimpl.C: refuse to open an inset when there's a selection. +2001-11-30 John Levon + + * BufferView_pimpl.C: allow to click on RHS of full row insets + 2001-11-30 Juergen Vigna * tabular.C (LyXTabular): add a same_id to set the same id's in the @@ -107,7 +123,7 @@ * paragraph_pimpl.h: * paragraph_pimpl.C: tidy, and fix font-change in "LaTeX" bug a bit - + 2001-11-26 John Levon * text.C: diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 3fcf5d7107..00c3101df9 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2001-12-03 Juergen Vigna + + * insettext.C (updateInsetInInset): use lt variable to forbid + changes of LyXText in an update call. + 2001-12-01 John Levon * insettabular.C: capture some more functions to prevent diff --git a/src/insets/insettext.C b/src/insets/insettext.C index c05b94713f..8b70df3e27 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -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(); } diff --git a/src/lyxfunc.C b/src/lyxfunc.C index e420b2c8fc..ae28ce37f7 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -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(); } diff --git a/src/lyxlength.C b/src/lyxlength.C index 8f782873bc..35bfb87ad5 100644 --- a/src/lyxlength.C +++ b/src/lyxlength.C @@ -18,6 +18,8 @@ #include "Lsstream.h" +#include + namespace { // this is now here and in lyxgluelength.C diff --git a/src/minibuffer.C b/src/minibuffer.C index 7583a803eb..0ea7b7e25c 100644 --- a/src/minibuffer.C +++ b/src/minibuffer.C @@ -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); diff --git a/src/text.C b/src/text.C index 8e5d3ea8d4..d4ccf901e0 100644 --- a/src/text.C +++ b/src/text.C @@ -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;