mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-08 10:11:21 +00:00
fix selection when cursor is in between two spaces
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_1_6@2888 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
5aa6c20376
commit
2458541066
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
||||
2001-10-15 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* src/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-10-01 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* lib/languages: change default encoding for estonian to latin1
|
||||
|
||||
2001-10-01 Garst R. Reese <reese@isn.net>
|
||||
|
||||
* lib/tex/hollywood.cls:
|
||||
|
@ -17,7 +17,7 @@ dutch dutch "Dutch" false iso8859-1 nl ""
|
||||
english english "English" false iso8859-1 en ""
|
||||
esperanto esperanto "Esperanto" false iso8859-3 eo ""
|
||||
#and what country code should esperanto have?? (Garst)
|
||||
estonian estonian "Estonian" false iso8859-4 et_EE ""
|
||||
estonian estonian "Estonian" false iso8859-1 et_EE ""
|
||||
finnish finnish "Finnish" false iso8859-1 fi ""
|
||||
frenchb frenchb "French" false iso8859-1 fr ""
|
||||
french french "French (GUTenberg)" false iso8859-1 fr ""
|
||||
|
@ -220,15 +220,15 @@ public:
|
||||
///
|
||||
mutable LyXCursor sel_cursor;
|
||||
///
|
||||
LyXCursor sel_start_cursor;
|
||||
mutable LyXCursor sel_start_cursor;
|
||||
///
|
||||
mutable LyXCursor sel_end_cursor;
|
||||
/// needed for the toggling
|
||||
LyXCursor last_sel_cursor;
|
||||
mutable LyXCursor last_sel_cursor;
|
||||
///
|
||||
LyXCursor toggle_cursor;
|
||||
mutable LyXCursor toggle_cursor;
|
||||
///
|
||||
LyXCursor toggle_end_cursor;
|
||||
mutable LyXCursor toggle_end_cursor;
|
||||
|
||||
/// need the selection cursor:
|
||||
void SetSelection();
|
||||
@ -566,6 +566,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;
|
||||
|
49
src/text2.C
49
src/text2.C
@ -2332,6 +2332,26 @@ void LyXText::CopySelection(BufferView * bview)
|
||||
bview->buffer()->params.textclass);
|
||||
}
|
||||
|
||||
// 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::PasteSelection(BufferView * bview)
|
||||
{
|
||||
@ -3072,21 +3092,32 @@ void LyXText::DeleteEmptyParagraphMechanism(BufferView * bview,
|
||||
// If the pos around the old_cursor were spaces, delete one of them.
|
||||
if (old_cursor.par() != cursor.par() || old_cursor.pos() != cursor.pos()) {
|
||||
// Only if the cursor has really moved
|
||||
|
||||
|
||||
if (old_cursor.pos() > 0
|
||||
&& old_cursor.pos() < old_cursor.par()->Last()
|
||||
&& old_cursor.par()->IsLineSeparator(old_cursor.pos())
|
||||
&& 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, sel_cursor, old_cursor);
|
||||
fixCursorAfterDelete(bview, sel_start_cursor,
|
||||
old_cursor);
|
||||
fixCursorAfterDelete(bview, sel_end_cursor,
|
||||
old_cursor);
|
||||
fixCursorAfterDelete(bview, last_sel_cursor,
|
||||
old_cursor);
|
||||
fixCursorAfterDelete(bview, toggle_cursor, old_cursor);
|
||||
fixCursorAfterDelete(bview, toggle_end_cursor,
|
||||
old_cursor);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user