1 Subject: textDrag.c: BlockDragSelection(): use cursorToHint to reduce redrawing
3 We have a way to optimize redrawing any cursor movement when we change the
4 text buffer. This patch apply it to the BlockDragSelection() function.
6 Actually this fixes a drawing bug with the Colored Cursorline (SF#683567)
7 patch. The cursor line is drawn above the selection while scrolling with the
8 selection down and leaves un-erased cursor lines behind.
12 source/textDrag.c | 20 +++++++++++++++-----
13 1 file changed, 15 insertions(+), 5 deletions(-)
15 diff --quilt old/source/textDrag.c new/source/textDrag.c
16 --- old/source/textDrag.c
17 +++ new/source/textDrag.c
18 @@ -361,12 +361,25 @@ void BlockDragSelection(TextWidget tw, i
20 /* Make the changes in the real buffer */
21 repText = BufGetRange(tempBuf, modRangeStart - tempStart,
22 tempModRangeEnd - tempStart);
25 TextDBlankCursor(textD);
27 + /* set cursorToHint to new cursor position to optimize redrawing */
28 + if (rectangular || overlay) {
29 + insRectEnd = insRectStart + origSel->rectEnd - origSel->rectStart;
30 + textD->cursorToHint = BufCountForwardDispChars(buf,
31 + BufCountForwardNLines(buf, insStart, tw->text.dragNLines),
34 + textD->cursorToHint = insStart + origSel->end - origSel->start;
37 BufReplace(buf, modRangeStart, bufModRangeEnd, repText);
38 + textD->cursorToHint = NO_HINT;
41 /* Store the necessary information for undoing this step */
42 tw->text.dragInsertPos = insStart;
43 tw->text.dragRectStart = insRectStart;
44 @@ -375,22 +388,19 @@ void BlockDragSelection(TextWidget tw, i
45 tw->text.dragSourceDeletePos = sourceDeletePos;
46 tw->text.dragSourceInserted = sourceInserted;
47 tw->text.dragSourceDeleted = sourceDeleted;
48 tw->text.dragType = dragType;
50 - /* Reset the selection and cursor position */
51 + /* Reset the selection */
52 if (rectangular || overlay) {
53 insRectEnd = insRectStart + origSel->rectEnd - origSel->rectStart;
54 BufRectSelect(buf, insStart, insStart + insertInserted, insRectStart,
56 - TextDSetInsertPosition(textD, BufCountForwardDispChars(buf,
57 - BufCountForwardNLines(buf, insStart, tw->text.dragNLines),
60 BufSelect(buf, insStart, insStart + origSel->end - origSel->start);
61 - TextDSetInsertPosition(textD, insStart + origSel->end - origSel->start);
64 TextDUnblankCursor(textD);
65 XtCallCallbacks((Widget)tw, textNcursorMovementCallback, (XtPointer)NULL);
66 tw->text.emTabsBeforeCursor = 0;