fix selection bug + latin9 tweaks

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2808 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2001-09-27 09:52:06 +00:00
parent 91777cb3a1
commit 7cf094f99e
5 changed files with 71 additions and 20 deletions

View File

@ -1,3 +1,14 @@
2001-09-27 Adrien Rebollo <adrien.rebollo@gmx.fr>
* paragraph_pimpl.C (simpleTeXSpecialChars): handle latin9 too.
2001-09-26 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* 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 <a.leeming@ic.ac.uk>
* BufferView_pimpl.C (buffer): call WorkArea::show to pop-up the

View File

@ -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?

View File

@ -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;

View File

@ -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
<< '}';

View File

@ -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;
}
}