Dylan Smith : richedit: Word/Line/ Paragraph selection had selection anchor on wrong side.
Alexandre Julliard
julliard at winehq.org
Mon Aug 18 10:46:09 CDT 2008
Module: wine
Branch: master
Commit: 608c54ee69ec4b8b7fb89df01e4bdcd136c8fd21
URL: http://source.winehq.org/git/wine.git/?a=commit;h=608c54ee69ec4b8b7fb89df01e4bdcd136c8fd21
Author: Dylan Smith <dylan.ah.smith at gmail.com>
Date: Tue Aug 5 12:10:43 2008 -0400
richedit: Word/Line/Paragraph selection had selection anchor on wrong side.
After selection a word, line, or paragraph with multi click selection or using
the selection bar, then shift can be held and the arrows can be used to move
one of the ends of the selection.
---
dlls/riched20/caret.c | 48 ++++++++++++++++++++++++------------------------
1 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c
index 89cd132..93fa77b 100644
--- a/dlls/riched20/caret.c
+++ b/dlls/riched20/caret.c
@@ -725,8 +725,8 @@ ME_MoveCursorWords(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs)
void
ME_SelectByType(ME_TextEditor *editor, ME_SelectionType selectionType)
{
- /* pCursor[0] will be the start of the selection
- * pCursor[1] is the other end of the selection range
+ /* pCursor[0] is the end of the selection
+ * pCursor[1] is the start of the selection (or the position selection anchor)
* pCursor[2] and [3] are the selection anchors that are backed up
* so they are kept when the selection changes for drag selection.
*/
@@ -737,9 +737,9 @@ ME_SelectByType(ME_TextEditor *editor, ME_SelectionType selectionType)
case stPosition:
break;
case stWord:
- ME_MoveCursorWords(editor, &editor->pCursors[1], +1);
- editor->pCursors[0] = editor->pCursors[1];
- ME_MoveCursorWords(editor, &editor->pCursors[0], -1);
+ ME_MoveCursorWords(editor, &editor->pCursors[0], +1);
+ editor->pCursors[1] = editor->pCursors[0];
+ ME_MoveCursorWords(editor, &editor->pCursors[1], -1);
break;
case stLine:
case stParagraph:
@@ -753,16 +753,16 @@ ME_SelectByType(ME_TextEditor *editor, ME_SelectionType selectionType)
backSearchType = diStartRow;
fwdSearchType = diStartRowOrParagraphOrEnd;
}
- pItem = ME_FindItemBack(editor->pCursors[0].pRun, backSearchType);
- editor->pCursors[0].pRun = ME_FindItemFwd(pItem, diRun);
- editor->pCursors[0].nOffset = 0;
-
pItem = ME_FindItemFwd(editor->pCursors[0].pRun, fwdSearchType);
assert(pItem);
if (pItem->type == diTextEnd)
- editor->pCursors[1].pRun = ME_FindItemBack(pItem, diRun);
+ editor->pCursors[0].pRun = ME_FindItemBack(pItem, diRun);
else
- editor->pCursors[1].pRun = ME_FindItemFwd(pItem, diRun);
+ editor->pCursors[0].pRun = ME_FindItemFwd(pItem, diRun);
+ editor->pCursors[0].nOffset = 0;
+
+ pItem = ME_FindItemBack(pItem, backSearchType);
+ editor->pCursors[1].pRun = ME_FindItemFwd(pItem, diRun);
editor->pCursors[1].nOffset = 0;
break;
}
@@ -941,8 +941,8 @@ static void ME_ExtendAnchorSelection(ME_TextEditor *editor)
if (editor->nSelectionType == stPosition || editor->nSelectionType == stDocument)
return;
curOfs = ME_GetCursorOfs(editor, 0);
- anchorStartOfs = ME_GetCursorOfs(editor, 2);
- anchorEndOfs = ME_GetCursorOfs(editor, 3);
+ anchorStartOfs = ME_GetCursorOfs(editor, 3);
+ anchorEndOfs = ME_GetCursorOfs(editor, 2);
tmp_cursor = editor->pCursors[0];
editor->pCursors[0] = editor->pCursors[2];
@@ -950,36 +950,36 @@ static void ME_ExtendAnchorSelection(ME_TextEditor *editor)
if (curOfs < anchorStartOfs)
{
/* Extend the left side of selection */
- editor->pCursors[0] = tmp_cursor;
+ editor->pCursors[1] = tmp_cursor;
if (editor->nSelectionType == stWord)
- ME_MoveCursorWords(editor, &editor->pCursors[0], -1);
+ ME_MoveCursorWords(editor, &editor->pCursors[1], -1);
else
{
ME_DisplayItem *pItem;
ME_DIType searchType = ((editor->nSelectionType == stLine) ?
diStartRowOrParagraph:diParagraph);
- pItem = ME_FindItemBack(editor->pCursors[0].pRun, searchType);
- editor->pCursors[0].pRun = ME_FindItemFwd(pItem, diRun);
- editor->pCursors[0].nOffset = 0;
+ pItem = ME_FindItemBack(editor->pCursors[1].pRun, searchType);
+ editor->pCursors[1].pRun = ME_FindItemFwd(pItem, diRun);
+ editor->pCursors[1].nOffset = 0;
}
}
else if (curOfs >= anchorEndOfs)
{
/* Extend the right side of selection */
- editor->pCursors[1] = tmp_cursor;
+ editor->pCursors[0] = tmp_cursor;
if (editor->nSelectionType == stWord)
- ME_MoveCursorWords(editor, &editor->pCursors[1], +1);
+ ME_MoveCursorWords(editor, &editor->pCursors[0], +1);
else
{
ME_DisplayItem *pItem;
ME_DIType searchType = ((editor->nSelectionType == stLine) ?
diStartRowOrParagraphOrEnd:diParagraphOrEnd);
- pItem = ME_FindItemFwd(editor->pCursors[1].pRun, searchType);
+ pItem = ME_FindItemFwd(editor->pCursors[0].pRun, searchType);
if (pItem->type == diTextEnd)
- editor->pCursors[1].pRun = ME_FindItemBack(pItem, diRun);
+ editor->pCursors[0].pRun = ME_FindItemBack(pItem, diRun);
else
- editor->pCursors[1].pRun = ME_FindItemFwd(pItem, diRun);
- editor->pCursors[1].nOffset = 0;
+ editor->pCursors[0].pRun = ME_FindItemFwd(pItem, diRun);
+ editor->pCursors[0].nOffset = 0;
}
}
}
More information about the wine-cvs
mailing list