diff --git a/src/ChangeLog b/src/ChangeLog index 14879c5c86..98757c3ef2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2001-09-27 Adrien Rebollo + + * paragraph_pimpl.C (simpleTeXSpecialChars): handle latin9 too. + +2001-09-26 Jean-Marc Lasgouttes + + * text2.C (fixCursorAfterDelete): new method. Fixes the parameters + of a cursor (row, etc.) after a character has been deleted + (deleteEmptyParagraphMechanism): call the method above on _all_ + cursors held by the LyXText when a double space has been + detected/deleted. 2001-09-27 Angus Leeming * BufferView_pimpl.C (buffer): call WorkArea::show to pop-up the diff --git a/src/lyxfunc.C b/src/lyxfunc.C index d168f41aa5..d1df3e1b24 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -241,7 +241,7 @@ void LyXFunc::processKeySym(KeySym keysym, unsigned int state) return; } - // Can we be sure that this will work for all X-Windows + // Can we be sure that this will work for all X Window // implementations? (Lgb) // This code snippet makes lyx ignore some keys. Perhaps // all of them should be explictly mentioned? diff --git a/src/lyxtext.h b/src/lyxtext.h index 5ed0732a65..3be37e1cff 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -241,7 +241,7 @@ public: */ mutable LyXCursor cursor; // actual cursor position - /** The structrue that keeps track of the selections set. */ + /** The structure that keeps track of the selections set. */ struct Selection { Selection() : set_(false), mark_(false) @@ -269,12 +269,12 @@ public: }; mutable Selection selection; - /// needed for the toggling - LyXCursor last_sel_cursor; // cursor position on last selection made - /// - LyXCursor toggle_cursor; // the following two are needed for toggling - /// the selection in screen.C - LyXCursor toggle_end_cursor; + /// needed for the toggling (cursor position on last selection made) + mutable LyXCursor last_sel_cursor; + /// needed for toggling the selection in screen.C + mutable LyXCursor toggle_cursor; + /// needed for toggling the selection in screen.C + mutable LyXCursor toggle_end_cursor; /// need the selection cursor: void setSelection(BufferView *); @@ -544,6 +544,12 @@ private: float & fill_label_hfill, bool bidi = true) const; + // fix the cursor `cur' after a characters has been deleted at `where' + // position. Called by deleteEmptyParagraphMechanism + void fixCursorAfterDelete(BufferView * bview, + LyXCursor & cur, + LyXCursor const & where) const; + /// void deleteEmptyParagraphMechanism(BufferView *, LyXCursor const & old_cursor) const; diff --git a/src/paragraph_pimpl.C b/src/paragraph_pimpl.C index 6bcc718fa4..de5185747e 100644 --- a/src/paragraph_pimpl.C +++ b/src/paragraph_pimpl.C @@ -323,10 +323,13 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf, case '°': case '±': case '²': case '³': case '×': case '÷': case '¹': case 'ª': case 'º': case '¬': case 'µ': - if (bparams.inputenc == "latin1" || + if ((bparams.inputenc == "latin1" || + bparams.inputenc == "latin9") || (bparams.inputenc == "auto" && - font.language()->encoding()->LatexName() - == "latin1")) { + (font.language()->encoding()->LatexName() + == "latin1" || + font.language()->encoding()->LatexName() + == "latin9"))) { os << "\\ensuremath{" << c << '}'; diff --git a/src/text2.C b/src/text2.C index caaa887447..fbd32326a5 100644 --- a/src/text2.C +++ b/src/text2.C @@ -2195,7 +2195,7 @@ void LyXText::setCursorIntern(BufferView * bview, Paragraph * par, if (it != inset_owner) { lyxerr << "InsetText is " << it << endl; lyxerr << "inset_owner is " << inset_owner << endl; -#warning I belive this code is wrong. (Lgb) +#warning I believe this code is wrong. (Lgb) #warning Jürgen, have a look at this. (Lgb) #warning Hmmm, I guess you are right but we #warning should verify when this is needed @@ -2349,6 +2349,26 @@ void LyXText::cursorDownParagraph(BufferView * bview) const } } +// fix the cursor `cur' after a characters has been deleted at `where' +// position. Called by deleteEmptyParagraphMechanism +void LyXText::fixCursorAfterDelete(BufferView * bview, + LyXCursor & cur, + LyXCursor const & where) const +{ + // if cursor is not in the paragraph where the delete occured, + // do nothing + if (cur.par() != where.par()) + return; + + // if cursor position is after the place where the delete occured, + // update it + if (cur.pos() > where.pos()) + cur.pos(cur.pos()-1); + + // recompute row et al. for this cursor + setCursor(bview, cur, cur.par(), cur.pos(), cur.boundary()); +} + void LyXText::deleteEmptyParagraphMechanism(BufferView * bview, LyXCursor const & old_cursor) const @@ -2396,14 +2416,25 @@ void LyXText::deleteEmptyParagraphMechanism(BufferView * bview, && old_cursor.par()->isLineSeparator(old_cursor.pos() - 1)) { old_cursor.par()->erase(old_cursor.pos() - 1); redoParagraphs(bview, old_cursor, old_cursor.par()->next()); - // correct cursor - if (old_cursor.par() == cursor.par() && - cursor.pos() > old_cursor.pos()) { - setCursorIntern(bview, cursor.par(), - cursor.pos() - 1); - } else - setCursorIntern(bview, cursor.par(), - cursor.pos()); + +#ifdef WITH_WARNINGS +#warning This will not work anymore when we have multiple views of the same buffer +// In this case, we will have to correct also the cursors held by +// other bufferviews. It will probably be easier to do that in a more +// automated way in LyXCursor code. (JMarc 26/09/2001) +#endif + // correct all cursors held by the LyXText + fixCursorAfterDelete(bview, cursor, old_cursor); + fixCursorAfterDelete(bview, selection.cursor, + old_cursor); + fixCursorAfterDelete(bview, selection.start, + old_cursor); + fixCursorAfterDelete(bview, selection.end, old_cursor); + fixCursorAfterDelete(bview, last_sel_cursor, + old_cursor); + fixCursorAfterDelete(bview, toggle_cursor, old_cursor); + fixCursorAfterDelete(bview, toggle_end_cursor, + old_cursor); return; } }