From 5067e0fc2a6de0893c3408bde0665e708376965b Mon Sep 17 00:00:00 2001 From: Phil Krylov Date: Wed, 6 Jul 2005 11:12:10 +0000 Subject: [PATCH] Fixed EM_LINEINDEX handler and added EM_LINEFROMCHAR handler. --- dlls/riched20/editor.c | 35 ++++++++++------------------------- dlls/riched20/editor.h | 1 + dlls/riched20/row.c | 27 +++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 3fb2a9aa8b3..7f29b1b810a 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -76,7 +76,7 @@ - EM_SETZOOM 3.0 - EM_HIDESELECTION - EM_LIMITTEXT - - EM_LINEFROMCHAR + + EM_LINEFROMCHAR + EM_LINEINDEX - EM_LINELENGTH + EM_LINESCROLL @@ -914,7 +914,6 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP UNSUPPORTED_MSG(EM_GETZOOM) UNSUPPORTED_MSG(EM_HIDESELECTION) UNSUPPORTED_MSG(EM_LIMITTEXT) /* also known as EM_SETLIMITTEXT */ - UNSUPPORTED_MSG(EM_LINEFROMCHAR) UNSUPPORTED_MSG(EM_LINELENGTH) UNSUPPORTED_MSG(EM_PASTESPECIAL) /* UNSUPPORTED_MSG(EM_POSFROMCHARS) missing in Wine headers */ @@ -1308,37 +1307,23 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP } return max(1, nRows); } + case EM_LINEFROMCHAR: + { + if (wParam == -1) + return ME_RowNumberFromCharOfs(editor, ME_GetCursorOfs(editor, 1)); + else + return ME_RowNumberFromCharOfs(editor, wParam); + } case EM_EXLINEFROMCHAR: { - ME_DisplayItem *item = editor->pBuffer->pFirst->next; - int nOffset; - int nRow = 0; - - while (item && item->member.para.next_para->member.para.nCharOfs <= lParam) - { - nRow += item->member.para.nRows; - item = ME_FindItemFwd(item, diParagraph); - } - if (item) - { - nOffset = lParam - item->member.para.nCharOfs; - item = ME_FindItemFwd(item, diRun); - while ((item = ME_FindItemFwd(item, diStartRowOrParagraph))) - { - item = ME_FindItemFwd(item, diRun); - if (item->member.run.nCharOfs > nOffset) - break; - nRow++; - } - } - return nRow; + return ME_RowNumberFromCharOfs(editor, lParam); } case EM_LINEINDEX: { ME_DisplayItem *item, *para; if (wParam == -1) - item = ME_FindItemBack(editor->pCursors[1].pRun, diStartRow); + item = ME_FindItemBack(editor->pCursors[0].pRun, diStartRow); else item = ME_FindRowWithNumber(editor, wParam); if (!item) diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h index 8ea138c58de..c4c352c7910 100644 --- a/dlls/riched20/editor.h +++ b/dlls/riched20/editor.h @@ -101,6 +101,7 @@ ME_DisplayItem *ME_RowStart(ME_DisplayItem *item); ME_DisplayItem *ME_RowEnd(ME_DisplayItem *item); void ME_RenumberParagraphs(ME_DisplayItem *item); /* TODO */ ME_DisplayItem *ME_FindRowWithNumber(ME_TextEditor *editor, int nRow); +int ME_RowNumberFromCharOfs(ME_TextEditor *editor, int nOfs); /* run.c */ ME_DisplayItem *ME_MakeRun(ME_Style *s, ME_String *strData, int nFlags); diff --git a/dlls/riched20/row.c b/dlls/riched20/row.c index 061199a0c20..b803ed21302 100644 --- a/dlls/riched20/row.c +++ b/dlls/riched20/row.c @@ -101,3 +101,30 @@ ME_FindRowWithNumber(ME_TextEditor *editor, int nRow) item = ME_FindItemFwd(item, diStartRow); return item; } + + +int +ME_RowNumberFromCharOfs(ME_TextEditor *editor, int nOfs) +{ + ME_DisplayItem *item = editor->pBuffer->pFirst->next; + int nRow = 0; + + while (item && item->member.para.next_para->member.para.nCharOfs <= nOfs) + { + nRow += item->member.para.nRows; + item = ME_FindItemFwd(item, diParagraph); + } + if (item) + { + nOfs -= item->member.para.nCharOfs; + item = ME_FindItemFwd(item, diRun); + while ((item = ME_FindItemFwd(item, diStartRowOrParagraph)) != NULL) + { + item = ME_FindItemFwd(item, diRun); + if (item->member.run.nCharOfs > nOfs) + break; + nRow++; + } + } + return nRow; +}