RICHEDIT: PageUp implementation
Krzysztof Foltman
wdev at foltman.com
Sun Mar 20 05:57:38 CST 2005
ChangeLog:
* added support for PageUp key
Krzysztof
-------------- next part --------------
Index: caret.c
===================================================================
RCS file: /home/wine/wine/dlls/riched20/caret.c,v
retrieving revision 1.7
diff -u -r1.7 caret.c
--- caret.c 19 Mar 2005 17:06:17 -0000 1.7
+++ caret.c 20 Mar 2005 11:57:11 -0000
@@ -697,6 +697,63 @@
assert(pCursor->pRun->type == diRun);
}
+void ME_ArrowPageUp(ME_TextEditor *editor, ME_Cursor *pCursor)
+{
+ ME_DisplayItem *pRun = pCursor->pRun;
+ ME_DisplayItem *pLast, *p;
+ int x, y, ys, yd, yp, yprev;
+ ME_Cursor tmp_curs = *pCursor;
+
+ x = ME_GetXForArrow(editor, pCursor);
+ if (!pCursor->nOffset && editor->bCaretAtEnd)
+ pRun = ME_FindItemBack(pRun, diRun);
+
+ p = ME_FindItemBack(pRun, diStartRowOrParagraph);
+ assert(p->type == diStartRow);
+ yp = ME_FindItemBack(p, diParagraph)->member.para.nYPos;
+ yprev = ys = y = yp + p->member.row.nYPos;
+ yd = y - editor->sizeWindow.cy;
+ pLast = p;
+
+ do {
+ p = ME_FindItemBack(p, diStartRowOrParagraph);
+ if (!p)
+ break;
+ if (p->type == diParagraph) { /* crossing paragraphs */
+ if (p->member.para.prev_para == NULL)
+ break;
+ yp = p->member.para.prev_para->member.para.nYPos;
+ continue;
+ }
+ y = yp + p->member.row.nYPos;
+ if (y < yd)
+ break;
+ pLast = p;
+ yprev = y;
+ } while(1);
+
+ pCursor->pRun = ME_FindRunInRow(editor, pLast, x, &pCursor->nOffset, &editor->bCaretAtEnd);
+ ME_UpdateSelection(editor, &tmp_curs);
+ if (yprev < editor->sizeWindow.cy)
+ {
+ ME_EnsureVisible(editor, ME_FindItemFwd(editor->pBuffer->pFirst, diRun));
+ ME_Repaint(editor);
+ }
+ else {
+/* ME_Repaint(editor); */
+ UpdateWindow(editor->hWnd);
+ ME_Scroll(editor, 0, ys-yprev);
+ UpdateWindow(editor->hWnd);
+ }
+ assert(pCursor->pRun);
+ assert(pCursor->pRun->type == diRun);
+}
+
+/* FIXME: in the original RICHEDIT, PageDown always scrolls by the same amount
+ of pixels, even if it makes the scroll bar position exceed its normal maximum.
+ In such a situation, clicking the scrollbar restores its position back to the
+ normal range (ie. sets it to (doclength-screenheight)). */
+
void ME_ArrowPageDown(ME_TextEditor *editor, ME_Cursor *pCursor)
{
ME_DisplayItem *pRun = pCursor->pRun;
@@ -865,7 +922,6 @@
{
editor->pCursors[1] = *pTempCursor;
return TRUE;
-/* ME_EnsureVisible(editor, editor->pCursors[0].pRun); */
}
}
@@ -941,6 +997,11 @@
ME_RepaintSelection(editor, &tmp_curs);
ME_SendSelChange(editor);
return TRUE;
+ case VK_PRIOR:
+ ME_ArrowPageUp(editor, p);
+ ME_ClearTempStyle(editor);
+ ME_SendSelChange(editor);
+ return TRUE;
case VK_NEXT:
ME_ArrowPageDown(editor, p);
ME_ClearTempStyle(editor);
More information about the wine-patches
mailing list