winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
April 2008
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
4 participants
1278 discussions
Start a n
N
ew thread
Lei Zhang : winmm: Do not unload drivers when the process is terminating.
by Alexandre Julliard
29 Apr '08
29 Apr '08
Module: wine Branch: master Commit: d20f982433b6c1fe735699f3172e67d2e0a6884b URL:
http://source.winehq.org/git/wine.git/?a=commit;h=d20f982433b6c1fe735699f31…
Author: Lei Zhang <thestig(a)google.com> Date: Mon Apr 28 12:28:19 2008 -0700 winmm: Do not unload drivers when the process is terminating. --- dlls/winmm/winmm.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dlls/winmm/winmm.c b/dlls/winmm/winmm.c index a6fec99..8342c44 100644 --- a/dlls/winmm/winmm.c +++ b/dlls/winmm/winmm.c @@ -193,8 +193,14 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad) /* close all opened MCI drivers */ MCI_SendCommand(MCI_ALL_DEVICE_ID, MCI_CLOSE, MCI_WAIT, 0L, TRUE); MMDRV_Exit(); - /* now unload all remaining drivers... */ - DRIVER_UnloadAll(); + /* There's no guarantee the drivers haven't already been unloaded on + * process shutdown. + */ + if (!fImpLoad) + { + /* now unload all remaining drivers... */ + DRIVER_UnloadAll(); + } WINMM_DeleteIData(); break;
1
0
0
0
Alex Villacís Lasso : richedit: Paragraph may have multiple rows, which should possibly update nHeight.
by Alexandre Julliard
29 Apr '08
29 Apr '08
Module: wine Branch: master Commit: d2a8461585f2b2ba53be7a38dcee3964c0abb966 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=d2a8461585f2b2ba53be7a38d…
Author: Alex Villacís Lasso <a_villacis(a)palosanto.com> Date: Sun Apr 27 22:25:47 2008 -0500 richedit: Paragraph may have multiple rows, which should possibly update nHeight. Otherwise, a paragraph with multiple rows might fail to make the scrollbar appear when displaying text. --- dlls/riched20/wrap.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/dlls/riched20/wrap.c b/dlls/riched20/wrap.c index 43d3d79..4767074 100644 --- a/dlls/riched20/wrap.c +++ b/dlls/riched20/wrap.c @@ -508,6 +508,14 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) { ME_DestroyContext(&c, editor->hWnd); + /* Each paragraph may contain multiple rows, which should be scrollable, even + if the containing paragraph has nYPos == 0 */ + item = editor->pBuffer->pFirst; + while ((item = ME_FindItemFwd(item, diStartRow)) != NULL) { + assert(item->type == diStartRow); + editor->nHeight = max(editor->nHeight, item->member.row.nYPos); + } + if (bModified || editor->nTotalLength < editor->nLastTotalLength) ME_InvalidateMarkedParagraphs(editor); return bModified;
1
0
0
0
Alex Villacís Lasso : richedit: Fix modify step setting in EM_SETCHARFORMAT.
by Alexandre Julliard
29 Apr '08
29 Apr '08
Module: wine Branch: master Commit: 3cad256d54eb7071a3693102ee683bdbbd087227 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=3cad256d54eb7071a3693102e…
Author: Alex Villacís Lasso <a_villacis(a)palosanto.com> Date: Sun Apr 27 13:17:28 2008 -0500 richedit: Fix modify step setting in EM_SETCHARFORMAT. EM_SETCHARFORMAT with wParam==0 sets default char format and does NOT set modify step flag. EM_SETCHARFORMAT with wParam==SCF_SELECTION only sets modify step flag when selection is nonempty. EM_GETMODIFY returns -1, not 1, when modify flag is set. Tests for the above behavior. --- dlls/riched20/editor.c | 8 +++-- dlls/riched20/tests/editor.c | 58 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 660942f..84c8d36 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -2206,7 +2206,7 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, return lColor; } case EM_GETMODIFY: - return editor->nModifyStep == 0 ? 0 : 1; + return editor->nModifyStep == 0 ? 0 : -1; case EM_SETMODIFY: { if (wParam) @@ -2249,8 +2249,10 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, } else if (wParam == SCF_ALL) { if (editor->mode & TM_PLAINTEXT) ME_SetDefaultCharFormat(editor, p); - else + else { ME_SetCharFormat(editor, 0, ME_GetTextLength(editor), p); + editor->nModifyStep = 1; + } } else if (editor->mode & TM_PLAINTEXT) { return 0; } else { @@ -2258,8 +2260,8 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, ME_GetSelection(editor, &from, &to); bRepaint = (from != to); ME_SetSelectionCharFormat(editor, p); + if (from != to) editor->nModifyStep = 1; } - editor->nModifyStep = 1; ME_CommitUndo(editor); if (bRepaint) ME_RewrapRepaint(editor); diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index b365965..05db7f8 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -438,6 +438,57 @@ static void test_EM_SETCHARFORMAT(void) (LPARAM) &cf2); ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc); + cf2.cbSize = sizeof(CHARFORMAT2); + SendMessage(hwndRichEdit, EM_GETCHARFORMAT, (WPARAM) SCF_DEFAULT, + (LPARAM) &cf2); + + /* Test state of modify flag before and after valid EM_SETCHARFORMAT */ + cf2.cbSize = sizeof(CHARFORMAT2); + SendMessage(hwndRichEdit, EM_GETCHARFORMAT, (WPARAM) SCF_DEFAULT, + (LPARAM) &cf2); + cf2.dwMask = CFM_ITALIC | cf2.dwMask; + cf2.dwEffects = CFE_ITALIC ^ cf2.dwEffects; + + /* wParam==0 is default char format, does not set modify */ + SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)NULL); + rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0); + ok(rc == 0, "Text marked as modified, expected not modified!\n"); + rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, 0, (LPARAM) &cf2); + ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc); + rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0); + ok(rc == 0, "Text marked as modified, expected not modified!\n"); + + /* wParam==SCF_SELECTION sets modify if nonempty selection */ + SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)NULL); + rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0); + ok(rc == 0, "Text marked as modified, expected not modified!\n"); + rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf2); + ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc); + rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0); + ok(rc == 0, "Text marked as modified, expected not modified!\n"); + + SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"wine"); + rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0); + ok(rc == 0, "Text marked as modified, expected not modified!\n"); + rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf2); + ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc); + rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0); + ok(rc == 0, "Text marked as modified, expected not modified!\n"); + SendMessage(hwndRichEdit, EM_SETSEL, 0, 2); + rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf2); + ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc); + rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0); + ok(rc == -1, "Text not marked as modified, expected modified! (%d)\n", rc); + + /* wParam==SCF_ALL sets modify regardless of whether text is present */ + SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)NULL); + rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0); + ok(rc == 0, "Text marked as modified, expected not modified!\n"); + rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, (WPARAM) SCF_ALL, (LPARAM) &cf2); + ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc); + rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0); + ok(rc == -1, "Text not marked as modified, expected modified! (%d)\n", rc); + DestroyWindow(hwndRichEdit); } @@ -472,10 +523,17 @@ static void test_EM_SETTEXTMODE(void) cf2.dwMask = CFM_ITALIC | cf2.dwMask; cf2.dwEffects = CFE_ITALIC ^ cf2.dwEffects; + rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0); + ok(rc == 0, "Text marked as modified, expected not modified!\n"); + /*EM_SETCHARFORMAT is not yet fully implemented for all WPARAMs in wine; however, SCF_ALL has been implemented*/ rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, (WPARAM) SCF_ALL, (LPARAM) &cf2); ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc); + + rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0); + ok(rc == -1, "Text not marked as modified, expected modified! (%d)\n", rc); + SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) "wine"); /*Select the string "wine"*/
1
0
0
0
Alex Villacís Lasso : richedit: Flip the big switch and encode actual CR and LF into end-of-paragraph runs .
by Alexandre Julliard
29 Apr '08
29 Apr '08
Module: wine Branch: master Commit: 4047df0f564786437cdf9a0712fbee603f5f3d2f URL:
http://source.winehq.org/git/wine.git/?a=commit;h=4047df0f564786437cdf9a071…
Author: Alex Villacís Lasso <a_villacis(a)palosanto.com> Date: Sat Apr 26 22:49:35 2008 -0500 richedit: Flip the big switch and encode actual CR and LF into end-of-paragraph runs. Document remaining uses of bEmulateVersion10 and other checks for CRLF in editor.c. Make RTF reader emit a \r or a \r\n according to emulation, not a \n, which breaks streaming tests. Remove todo_wine from a bunch of riched32 tests that now succeed. --- dlls/riched20/caret.c | 43 ++++++++++++++++++++++++++--------------- dlls/riched20/editor.c | 26 +++++++++++++++++++++++- dlls/riched20/reader.c | 3 +- dlls/riched32/tests/editor.c | 34 ++++++++++++++++---------------- 4 files changed, 70 insertions(+), 36 deletions(-) diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c index a8e51db..bf53aff 100644 --- a/dlls/riched20/caret.c +++ b/dlls/riched20/caret.c @@ -524,6 +524,8 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor, if (pos-str < len) { /* handle EOLs */ ME_DisplayItem *tp, *end_run; ME_Style *tmp_style; + int numCR, numLF; + if (pos!=str) ME_InternalInsertTextFromCursor(editor, nCursor, str, pos-str, style, 0); p = &editor->pCursors[nCursor]; @@ -534,38 +536,47 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor, tmp_style = ME_GetInsertStyle(editor, nCursor); /* ME_SplitParagraph increases style refcount */ - /* TODO: move here and fix logic for pos updating according to emulation, - so that number of CR and LF encoded are a result of such logic, instead - of hardcoded as below. - */ - if (editor->bEmulateVersion10) - tp = ME_SplitParagraph(editor, p->pRun, p->pRun->member.run.style, 1, 1); - else - tp = ME_SplitParagraph(editor, p->pRun, p->pRun->member.run.style, 1, 0); - p->pRun = ME_FindItemFwd(tp, diRun); - end_run = ME_FindItemBack(tp, diRun); - ME_ReleaseStyle(end_run->member.run.style); - end_run->member.run.style = tmp_style; - p->nOffset = 0; + /* Encode and fill number of CR and LF according to emulation mode */ if (editor->bEmulateVersion10) { const WCHAR * tpos; + /* We have to find out how many consecutive \r are there, and if there + is a \n terminating the run of \r's. */ + numCR = 0; numLF = 0; tpos = pos; while (tpos-str < len && *tpos == '\r') { tpos++; + numCR++; } if (tpos-str >= len) { - if (tpos != pos) pos++; - } else if (*tpos == '\n') + /* Reached end of text without finding anything but '\r' */ + if (tpos != pos) { + pos++; + } + numCR = 1; numLF = 0; + } else if (*tpos == '\n') { + /* The entire run of \r's plus the one \n is one single line break */ pos = tpos + 1; - else + numLF = 1; + } else { + /* Found some other content past the run of \r's */ pos++; + numCR = 1; numLF = 0; + } } else { if(pos-str < len && *pos =='\r') pos++; if(pos-str < len && *pos =='\n') pos++; + numCR = 1; numLF = 0; } + tp = ME_SplitParagraph(editor, p->pRun, p->pRun->member.run.style, numCR, numLF); + p->pRun = ME_FindItemFwd(tp, diRun); + end_run = ME_FindItemBack(tp, diRun); + ME_ReleaseStyle(end_run->member.run.style); + end_run->member.run.style = tmp_style; + p->nOffset = 0; + if(pos-str <= len) { len -= pos - str; str = pos; diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index d0d6195..4b4db9f 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -1101,7 +1101,10 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre if (parser.lpRichEditOle) IRichEditOle_Release(parser.lpRichEditOle); - /* Remove last line break, as mandated by tests */ + /* Remove last line break, as mandated by tests. This is not affected by + CR/LF counters, since RTF streaming presents only \para tokens, which + are converted according to the standard rules: \r for 2.0, \r\n for 1.0 + */ if (stripLastCR) { int newfrom, newto; ME_GetSelection(editor, &newfrom, &newto); @@ -1213,6 +1216,21 @@ ME_FindItemAtOffset(ME_TextEditor *editor, ME_DIType nItemType, int nOffset, int } while (item && (item->member.run.nCharOfs + runLength <= nOffset)); if (item) { nOffset -= item->member.run.nCharOfs; + + /* Special case: nOffset may not point exactly at the division between the + \r and the \n in 1.0 emulation. If such a case happens, it is sent + into the next run, if one exists + */ + if ( item->member.run.nFlags & MERF_ENDPARA + && nOffset == item->member.run.nCR + && item->member.run.nLF > 0) { + ME_DisplayItem *nextItem; + nextItem = ME_FindItemFwd(item, diRun); + if (nextItem) { + nOffset = 0; + item = nextItem; + } + } if (nItemOffset) *nItemOffset = nOffset; } @@ -2487,6 +2505,7 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, { GETTEXTLENGTHEX how; + /* CR/LF conversion required in 2.0 mode, verbatim in 1.0 mode */ how.flags = GTL_CLOSE | (editor->bEmulateVersion10 ? 0 : GTL_USECRLF) | GTL_NUMCHARS; how.codepage = unicode ? 1200 : CP_ACP; return ME_GetTextLengthEx(editor, &how); @@ -2552,7 +2571,10 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, else { /* potentially each char may be a CR, why calculate the exact value with O(N) when - we can just take a bigger buffer? :) */ + we can just take a bigger buffer? :) + The above assumption still holds with CR/LF counters, since CR->CRLF expansion + occurs only in richedit 2.0 mode, in which line breaks have only one CR + */ int crlfmul = (ex->flags & GT_USECRLF) ? 2 : 1; LPWSTR buffer; DWORD buflen = ex->cb; diff --git a/dlls/riched20/reader.c b/dlls/riched20/reader.c index 1ecca08..5ee9fa2 100644 --- a/dlls/riched20/reader.c +++ b/dlls/riched20/reader.c @@ -2605,7 +2605,8 @@ static void SpecialChar (RTF_Info *info) case rtfSect: case rtfRow: case rtfPar: - RTFPutUnicodeChar (info, '\n'); + RTFPutUnicodeChar (info, '\r'); + if (info->editor->bEmulateVersion10) RTFPutUnicodeChar (info, '\n'); break; case rtfNoBrkSpace: RTFPutUnicodeChar (info, 0x00A0); diff --git a/dlls/riched32/tests/editor.c b/dlls/riched32/tests/editor.c index 21972ab..70d1558 100644 --- a/dlls/riched32/tests/editor.c +++ b/dlls/riched32/tests/editor.c @@ -110,21 +110,21 @@ static void test_WM_SETTEXT() } TEST_SETTEXT(TestItem1, TestItem1, 1, 0, 0) - TEST_SETTEXT(TestItem2, TestItem2, 1, 1, 1) - TEST_SETTEXT(TestItem3, TestItem3, 2, 1, 1) - TEST_SETTEXT(TestItem4, TestItem4, 3, 1, 0) - TEST_SETTEXT(TestItem5, TestItem5, 2, 1, 0) - TEST_SETTEXT(TestItem6, TestItem6, 3, 1, 0) - TEST_SETTEXT(TestItem7, TestItem7, 4, 1, 0) + TEST_SETTEXT(TestItem2, TestItem2, 1, 0, 1) + TEST_SETTEXT(TestItem3, TestItem3, 2, 0, 1) + TEST_SETTEXT(TestItem4, TestItem4, 3, 0, 0) + TEST_SETTEXT(TestItem5, TestItem5, 2, 0, 0) + TEST_SETTEXT(TestItem6, TestItem6, 3, 0, 0) + TEST_SETTEXT(TestItem7, TestItem7, 4, 0, 0) TEST_SETTEXT(TestItem8, TestItem8, 2, 0, 0) TEST_SETTEXT(TestItem9, TestItem9, 3, 0, 0) TEST_SETTEXT(TestItem10, TestItem10, 3, 0, 0) TEST_SETTEXT(TestItem11, TestItem11, 1, 0, 0) TEST_SETTEXT(TestItem12, TestItem12, 2, 0, 0) TEST_SETTEXT(TestItem13, TestItem13, 3, 0, 0) - TEST_SETTEXT(TestItem14, TestItem14, 2, 1, 0) - TEST_SETTEXT(TestItem15, TestItem15, 3, 1, 1) - TEST_SETTEXT(TestItem16, TestItem16, 4, 1, 0) + TEST_SETTEXT(TestItem14, TestItem14, 2, 0, 0) + TEST_SETTEXT(TestItem15, TestItem15, 3, 0, 1) + TEST_SETTEXT(TestItem16, TestItem16, 4, 0, 0) #undef TEST_SETTEXT DestroyWindow(hwndRichEdit); @@ -332,11 +332,11 @@ static void test_EM_STREAMOUT(void) SendMessage(hwndRichEdit, EM_STREAMOUT, (WPARAM)(SF_TEXT), (LPARAM)&es); r = strlen(buf); - todo_wine { /* Currently fails because of solitary \r mangling */ + ok(r == 13, "streamed text length is %d, expecting 13\n", r); ok(strcmp(buf, TestItem2) == 0, "streamed text different, got %s\n", buf); - } + SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) TestItem3); p = buf; es.dwCookie = (DWORD_PTR)&p; @@ -360,8 +360,8 @@ static const struct getline_s { int wine_todo; } gl[] = { {0, 10, "foo bar\r\n", 0}, - {1, 10, "\n", 1}, - {2, 10, "bar\n", 1}, + {1, 10, "\n", 0}, + {2, 10, "bar\n", 0}, {3, 10, "\r\n", 0}, /* Buffer smaller than line length */ @@ -493,9 +493,9 @@ static void test_EM_GETTEXTRANGE(void) result = SendMessage(hwndRichEdit, EM_GETTEXTRANGE, 0, (LPARAM)&textRange); ok(result == 7, "EM_GETTEXTRANGE returned %ld, expected %d\n", result, strlen(expect2)); - todo_wine { + ok(!strcmp(expect2, buffer), "EM_GETTEXTRANGE filled %s\n", buffer); - } + DestroyWindow(hwndRichEdit); } @@ -524,9 +524,9 @@ static void test_EM_GETSELTEXT(void) result = SendMessage(hwndRichEdit, EM_GETSELTEXT, 0, (LPARAM)buffer); ok(result == 7, "EM_GETTEXTRANGE returned %ld, expected %d\n", result, strlen(expect2)); - todo_wine { + ok(!strcmp(expect2, buffer), "EM_GETTEXTRANGE filled %s\n", buffer); - } + DestroyWindow(hwndRichEdit); }
1
0
0
0
Alex Villacís Lasso : richedit: Implement rule that in 1.0 emulation, a single CR that terminates the text is NOT a line break.
by Alexandre Julliard
29 Apr '08
29 Apr '08
Module: wine Branch: master Commit: cac55008c9640014bcbd9ccdbbe1872e3f390719 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=cac55008c9640014bcbd9ccdb…
Author: Alex Villacís Lasso <a_villacis(a)palosanto.com> Date: Sun Apr 27 09:24:15 2008 -0500 richedit: Implement rule that in 1.0 emulation, a single CR that terminates the text is NOT a line break. Fix riched32 test that now succeed. --- dlls/riched20/editor.c | 18 ++++++++++++++++++ dlls/riched32/tests/editor.c | 6 +++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 4b4db9f..3121293 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -2702,12 +2702,30 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, ME_DisplayItem *item = editor->pBuffer->pFirst->next; int nRows = 0; + ME_DisplayItem *prev_para = NULL, *last_para = NULL; + while (item != editor->pBuffer->pLast) { assert(item->type == diParagraph); + prev_para = ME_FindItemBack(item, diRun); + if (prev_para) { + assert(prev_para->member.run.nFlags & MERF_ENDPARA); + } nRows += item->member.para.nRows; item = item->member.para.next_para; } + last_para = ME_FindItemBack(item, diRun); + assert(last_para); + assert(last_para->member.run.nFlags & MERF_ENDPARA); + if (editor->bEmulateVersion10 && prev_para && last_para->member.run.nCharOfs == 0 + && prev_para->member.run.nCR == 1 && prev_para->member.run.nLF == 0) + { + /* In 1.0 emulation, the last solitary \r at the very end of the text + (if one exists) is NOT a line break. + FIXME: this is an ugly hack. This should have a more regular model. */ + nRows--; + } + TRACE("EM_GETLINECOUNT: nRows==%d\n", nRows); return max(1, nRows); } diff --git a/dlls/riched32/tests/editor.c b/dlls/riched32/tests/editor.c index 70d1558..abecaee 100644 --- a/dlls/riched32/tests/editor.c +++ b/dlls/riched32/tests/editor.c @@ -110,8 +110,8 @@ static void test_WM_SETTEXT() } TEST_SETTEXT(TestItem1, TestItem1, 1, 0, 0) - TEST_SETTEXT(TestItem2, TestItem2, 1, 0, 1) - TEST_SETTEXT(TestItem3, TestItem3, 2, 0, 1) + TEST_SETTEXT(TestItem2, TestItem2, 1, 0, 0) + TEST_SETTEXT(TestItem3, TestItem3, 2, 0, 0) TEST_SETTEXT(TestItem4, TestItem4, 3, 0, 0) TEST_SETTEXT(TestItem5, TestItem5, 2, 0, 0) TEST_SETTEXT(TestItem6, TestItem6, 3, 0, 0) @@ -123,7 +123,7 @@ static void test_WM_SETTEXT() TEST_SETTEXT(TestItem12, TestItem12, 2, 0, 0) TEST_SETTEXT(TestItem13, TestItem13, 3, 0, 0) TEST_SETTEXT(TestItem14, TestItem14, 2, 0, 0) - TEST_SETTEXT(TestItem15, TestItem15, 3, 0, 1) + TEST_SETTEXT(TestItem15, TestItem15, 3, 0, 0) TEST_SETTEXT(TestItem16, TestItem16, 4, 0, 0) #undef TEST_SETTEXT
1
0
0
0
Alex Villacís Lasso : richedit: Only notify selection change when selection has actually changed from previous notification .
by Alexandre Julliard
29 Apr '08
29 Apr '08
Module: wine Branch: master Commit: 1fa39b50c0bafeb72e85c257391e6cd5fb70182d URL:
http://source.winehq.org/git/wine.git/?a=commit;h=1fa39b50c0bafeb72e85c2573…
Author: Alex Villacís Lasso <a_villacis(a)palosanto.com> Date: Sun Apr 27 13:08:55 2008 -0500 richedit: Only notify selection change when selection has actually changed from previous notification. Otherwise, redundant and early notifications are sent to apps that do not expect them. Fixes crash #1 with Perfect! TextEdit. --- dlls/riched20/caret.c | 10 +++++++++- dlls/riched20/editor.c | 2 ++ dlls/riched20/editstr.h | 3 +++ 3 files changed, 14 insertions(+), 1 deletions(-) diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c index bf53aff..b2172ac 100644 --- a/dlls/riched20/caret.c +++ b/dlls/riched20/caret.c @@ -1330,7 +1330,15 @@ void ME_SendSelChange(ME_TextEditor *editor) sc.seltyp |= SEL_TEXT; if (sc.chrg.cpMin < sc.chrg.cpMax+1) /* wth were RICHEDIT authors thinking ? */ sc.seltyp |= SEL_MULTICHAR; - SendMessageW(GetParent(editor->hWnd), WM_NOTIFY, sc.nmhdr.idFrom, (LPARAM)&sc); + TRACE("cpMin=%d cpMax=%d seltyp=%d (%s %s)\n", + sc.chrg.cpMin, sc.chrg.cpMax, sc.seltyp, + (sc.seltyp & SEL_TEXT) ? "SEL_TEXT" : "", + (sc.seltyp & SEL_MULTICHAR) ? "SEL_MULTICHAR" : ""); + if (sc.chrg.cpMin != editor->notified_cr.cpMin || sc.chrg.cpMax != editor->notified_cr.cpMax) + { + editor->notified_cr = sc.chrg; + SendMessageW(GetParent(editor->hWnd), WM_NOTIFY, sc.nmhdr.idFrom, (LPARAM)&sc); + } } BOOL diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 3121293..660942f 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -1665,6 +1665,8 @@ ME_TextEditor *ME_MakeEditor(HWND hWnd) { else ed->cPasswordMask = 0; + ed->notified_cr.cpMin = ed->notified_cr.cpMax = 0; + return ed; } diff --git a/dlls/riched20/editstr.h b/dlls/riched20/editstr.h index aedaefa..1e2c770 100644 --- a/dlls/riched20/editstr.h +++ b/dlls/riched20/editstr.h @@ -331,6 +331,9 @@ typedef struct tagME_TextEditor /*for IME */ int imeStartIndex; DWORD selofs, linesel, sely; + + /* Track previous notified selection */ + CHARRANGE notified_cr; } ME_TextEditor; typedef struct tagME_Context
1
0
0
0
Alex Villacís Lasso : richedit: WM_SETTEXT - Clear modify step flag before any notifications can be sent.
by Alexandre Julliard
29 Apr '08
29 Apr '08
Module: wine Branch: master Commit: c52bc5881600e6830e2849ca59632755cdaa0bf2 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=c52bc5881600e6830e2849ca5…
Author: Alex Villacís Lasso <a_villacis(a)palosanto.com> Date: Sun Apr 27 14:21:02 2008 -0500 richedit: WM_SETTEXT - Clear modify step flag before any notifications can be sent. Otherwise the app-defined WM_NOTIFY callback might see the modify flag set, even though WM_SETTEXT is supposed to clear it. --- dlls/riched20/editor.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 84c8d36..b153fc1 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -2436,10 +2436,10 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, } else TRACE("WM_SETTEXT - NULL\n"); + editor->nModifyStep = 0; ME_CommitUndo(editor); ME_EmptyUndoStack(editor); ME_SetSelection(editor, 0, 0); - editor->nModifyStep = 0; ME_UpdateRepaint(editor); return 1; }
1
0
0
0
Alex Villacís Lasso : richedit: Private movement of cursors in text insertion should not cause WM_NOTIFY to be sent .
by Alexandre Julliard
29 Apr '08
29 Apr '08
Module: wine Branch: master Commit: 829940458f11bc74f4fefca5cb200ad9abd17951 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=829940458f11bc74f4fefca5c…
Author: Alex Villacís Lasso <a_villacis(a)palosanto.com> Date: Sun Apr 27 15:47:26 2008 -0500 richedit: Private movement of cursors in text insertion should not cause WM_NOTIFY to be sent. As text is inserted, the cursor is moved to the end, and then back to offset 0. A reordering of operations prevents a WM_NOTIFY from being sent on cursor being moved to the end, and another by being moved back to the beginning. If the cursor was not at offset 0, then exactly one WM_NOTIFY must be sent, for the movement from previous position to the beginning. With tests to prove this change and the previous one (modify flag should be off on WM_SETTEXT-caused WM_NOTIFY). --- dlls/riched20/editor.c | 2 +- dlls/riched20/tests/editor.c | 79 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 79 insertions(+), 2 deletions(-) diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index b153fc1..392a60a 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -2436,10 +2436,10 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, } else TRACE("WM_SETTEXT - NULL\n"); + ME_SetSelection(editor, 0, 0); editor->nModifyStep = 0; ME_CommitUndo(editor); ME_EmptyUndoStack(editor); - ME_SetSelection(editor, 0, 0); ME_UpdateRepaint(editor); return 1; } diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index 05db7f8..891c713 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -3125,6 +3125,83 @@ static void test_eventMask(void) } +static int received_WM_NOTIFY = 0; +static int modify_at_WM_NOTIFY = 0; +static HWND hwndRichedit_WM_NOTIFY; + +static LRESULT WINAPI WM_NOTIFY_ParentMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + if(message == WM_NOTIFY) + { + received_WM_NOTIFY = 1; + modify_at_WM_NOTIFY = SendMessage(hwndRichedit_WM_NOTIFY, EM_GETMODIFY, 0, 0); + } + return DefWindowProcA(hwnd, message, wParam, lParam); +} + +static void test_WM_NOTIFY(void) +{ + HWND parent; + WNDCLASSA cls; + CHARFORMAT2 cf2; + + /* register class to capture WM_NOTIFY */ + cls.style = 0; + cls.lpfnWndProc = WM_NOTIFY_ParentMsgCheckProcA; + cls.cbClsExtra = 0; + cls.cbWndExtra = 0; + cls.hInstance = GetModuleHandleA(0); + cls.hIcon = 0; + cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW); + cls.hbrBackground = GetStockObject(WHITE_BRUSH); + cls.lpszMenuName = NULL; + cls.lpszClassName = "WM_NOTIFY_ParentClass"; + if(!RegisterClassA(&cls)) assert(0); + + parent = CreateWindow(cls.lpszClassName, NULL, WS_POPUP|WS_VISIBLE, + 0, 0, 200, 60, NULL, NULL, NULL, NULL); + ok (parent != 0, "Failed to create parent window\n"); + + hwndRichedit_WM_NOTIFY = new_richedit(parent); + ok(hwndRichedit_WM_NOTIFY != 0, "Failed to create edit window\n"); + + SendMessage(hwndRichedit_WM_NOTIFY, EM_SETEVENTMASK, 0, ENM_SELCHANGE); + + /* Notifications for selection change should only be sent when selection + actually changes. EM_SETCHARFORMAT is one message that calls + ME_CommitUndo, which should check whether message should be sent */ + received_WM_NOTIFY = 0; + cf2.cbSize = sizeof(CHARFORMAT2); + SendMessage(hwndRichedit_WM_NOTIFY, EM_GETCHARFORMAT, (WPARAM) SCF_DEFAULT, + (LPARAM) &cf2); + cf2.dwMask = CFM_ITALIC | cf2.dwMask; + cf2.dwEffects = CFE_ITALIC ^ cf2.dwEffects; + SendMessage(hwndRichedit_WM_NOTIFY, EM_SETCHARFORMAT, 0, (LPARAM) &cf2); + ok(received_WM_NOTIFY == 0, "Unexpected WM_NOTIFY was sent!\n"); + + /* WM_SETTEXT should NOT cause a WM_NOTIFY to be sent when selection is + already at 0. */ + received_WM_NOTIFY = 0; + modify_at_WM_NOTIFY = 0; + SendMessage(hwndRichedit_WM_NOTIFY, WM_SETTEXT, 0, (LPARAM)"sometext"); + ok(received_WM_NOTIFY == 0, "Unexpected WM_NOTIFY was sent!\n"); + ok(modify_at_WM_NOTIFY == 0, "WM_NOTIFY callback saw text flagged as modified!\n"); + + received_WM_NOTIFY = 0; + modify_at_WM_NOTIFY = 0; + SendMessage(hwndRichedit_WM_NOTIFY, EM_SETSEL, 4, 4); + ok(received_WM_NOTIFY == 1, "Expected WM_NOTIFY was NOT sent!\n"); + + received_WM_NOTIFY = 0; + modify_at_WM_NOTIFY = 0; + SendMessage(hwndRichedit_WM_NOTIFY, WM_SETTEXT, 0, (LPARAM)"sometext"); + ok(received_WM_NOTIFY == 1, "Expected WM_NOTIFY was NOT sent!\n"); + ok(modify_at_WM_NOTIFY == 0, "WM_NOTIFY callback saw text flagged as modified!\n"); + + DestroyWindow(hwndRichedit_WM_NOTIFY); + DestroyWindow(parent); +} + START_TEST( editor ) { MSG msg; @@ -3134,7 +3211,6 @@ START_TEST( editor ) * RICHED20.DLL, so the linker doesn't actually link to it. */ hmoduleRichEdit = LoadLibrary("RICHED20.DLL"); ok(hmoduleRichEdit != NULL, "error: %d\n", (int) GetLastError()); - test_WM_CHAR(); test_EM_FINDTEXT(); test_EM_GETLINE(); @@ -3168,6 +3244,7 @@ START_TEST( editor ) test_EM_GETTEXTLENGTHEX(); test_EM_REPLACESEL(1); test_EM_REPLACESEL(0); + test_WM_NOTIFY(); test_eventMask(); /* Set the environment variable WINETEST_RICHED20 to keep windows
1
0
0
0
Alex Villacís Lasso : richedit: Modify ME_GetTextW() to honor CR and LF encodings.
by Alexandre Julliard
29 Apr '08
29 Apr '08
Module: wine Branch: master Commit: e8aa9dee561979ac8fd0b3770f535120f201b136 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=e8aa9dee561979ac8fd0b3770…
Author: Alex Villacís Lasso <a_villacis(a)palosanto.com> Date: Sat Apr 26 20:37:50 2008 -0500 richedit: Modify ME_GetTextW() to honor CR and LF encodings. ME_GetTextLengthEx should ignore GTL_USECRLF in 1.0 emulation mode. --- dlls/riched20/caret.c | 4 +++- dlls/riched20/editor.c | 31 +++++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c index 56cd2b1..a8e51db 100644 --- a/dlls/riched20/caret.c +++ b/dlls/riched20/caret.c @@ -57,7 +57,9 @@ int ME_GetTextLengthEx(ME_TextEditor *editor, const GETTEXTLENGTHEX *how) length = ME_GetTextLength(editor); - if ((GetWindowLongW(editor->hWnd, GWL_STYLE) & ES_MULTILINE) && (how->flags & GTL_USECRLF)) + if ((GetWindowLongW(editor->hWnd, GWL_STYLE) & ES_MULTILINE) + && (how->flags & GTL_USECRLF) + && !editor->bEmulateVersion10) /* Ignore GTL_USECRLF flag in 1.0 emulation */ length += editor->nParagraphs - 1; if (how->flags & GTL_NUMBYTES) diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 01502bf..4ba23a5 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -3376,6 +3376,9 @@ int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int nStart, int nChars, in return 0; } + /* bCRLF flag is only honored in 2.0 and up. 1.0 must always return text verbatim */ + if (editor->bEmulateVersion10) bCRLF = 0; + if (nStart) { int nLen = ME_StrLen(item->member.run.strText) - nStart; @@ -3394,6 +3397,8 @@ int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int nStart, int nChars, in while(nChars && item) { int nLen = ME_StrLen(item->member.run.strText); + if (item->member.run.nFlags & MERF_ENDPARA) + nLen = item->member.run.nCR + item->member.run.nLF; if (nLen > nChars) nLen = nChars; @@ -3406,16 +3411,30 @@ int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int nStart, int nChars, in nLen = 0; nChars = 0; } else { - *buffer = '\r'; if (bCRLF) { - *(++buffer) = '\n'; + /* richedit 2.0 case - actual line-break is \r but should report \r\n */ + assert(nLen == 1); + *buffer++ = '\r'; + *buffer = '\n'; /* Later updated by nLen==1 at the end of the loop */ nWritten++; } - assert(nLen == 1); - /* our end paragraph consists of 2 characters now */ - if (editor->bEmulateVersion10) - nChars--; + else + { + int i, j; + + /* richedit 2.0 verbatim has only \r. richedit 1.0 should honor encodings */ + i = 0; + while (nChars - i > 0 && i < item->member.run.nCR) + { + buffer[i] = '\r'; i++; + } + j = 0; + while (nChars - i - j > 0 && j < item->member.run.nLF) + { + buffer[i+j] = '\n'; j++; + } + } } } else
1
0
0
0
Alex Villacís Lasso : richedit: Remove indication for bCRLF, now that ME_GetTextW() knows how to honor CR and LF counters.
by Alexandre Julliard
29 Apr '08
29 Apr '08
Module: wine Branch: master Commit: 3a271386ec96a9c8468c01ac8251bdbc0d3c6a40 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=3a271386ec96a9c8468c01ac8…
Author: Alex Villacís Lasso <a_villacis(a)palosanto.com> Date: Sat Apr 26 21:16:41 2008 -0500 richedit: Remove indication for bCRLF, now that ME_GetTextW() knows how to honor CR and LF counters. EM_GETTEXTRANGE and EM_GETSELTEXT are affected by this, so include tests to ensure no behavior was broken. --- dlls/riched20/editor.c | 4 +- dlls/riched20/tests/editor.c | 63 ++++++++++++++++++++++++++++++++++++++ dlls/riched32/tests/editor.c | 69 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 134 insertions(+), 2 deletions(-) diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 4ba23a5..d0d6195 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -2594,12 +2594,12 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, rng->chrg.cpMin, rng->chrg.cpMax, unicode, editor->bEmulateVersion10, ME_GetTextLength(editor)); if (unicode) - return ME_GetTextW(editor, rng->lpstrText, rng->chrg.cpMin, rng->chrg.cpMax-rng->chrg.cpMin, editor->bEmulateVersion10); + return ME_GetTextW(editor, rng->lpstrText, rng->chrg.cpMin, rng->chrg.cpMax-rng->chrg.cpMin, 0); else { int nLen = rng->chrg.cpMax-rng->chrg.cpMin; WCHAR *p = ALLOC_N_OBJ(WCHAR, nLen+1); - int nChars = ME_GetTextW(editor, p, rng->chrg.cpMin, nLen, editor->bEmulateVersion10); + int nChars = ME_GetTextW(editor, p, rng->chrg.cpMin, nLen, 0); /* FIXME this is a potential security hole (buffer overrun) if you know more about wchar->mbyte conversion please explain */ diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index 28b4ce5..b365965 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -753,6 +753,67 @@ static void test_WM_GETTEXT(void) DestroyWindow(hwndRichEdit); } +static void test_EM_GETTEXTRANGE(void) +{ + HWND hwndRichEdit = new_richedit(NULL); + const char * text1 = "foo bar\r\nfoo bar"; + const char * text2 = "foo bar\rfoo bar"; + const char * expect = "bar\rfoo"; + char buffer[1024] = {0}; + LRESULT result; + TEXTRANGEA textRange; + + SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text1); + + textRange.lpstrText = buffer; + textRange.chrg.cpMin = 4; + textRange.chrg.cpMax = 11; + result = SendMessage(hwndRichEdit, EM_GETTEXTRANGE, 0, (LPARAM)&textRange); + ok(result == 7, "EM_GETTEXTRANGE returned %ld, expected %d\n", + result, strlen(expect)); + ok(!strcmp(expect, buffer), "EM_GETTEXTRANGE filled %s\n", buffer); + + SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text2); + + textRange.lpstrText = buffer; + textRange.chrg.cpMin = 4; + textRange.chrg.cpMax = 11; + result = SendMessage(hwndRichEdit, EM_GETTEXTRANGE, 0, (LPARAM)&textRange); + ok(result == 7, "EM_GETTEXTRANGE returned %ld, expected %d\n", + result, strlen(expect)); + ok(!strcmp(expect, buffer), "EM_GETTEXTRANGE filled %s\n", buffer); + + DestroyWindow(hwndRichEdit); +} + +static void test_EM_GETSELTEXT(void) +{ + HWND hwndRichEdit = new_richedit(NULL); + const char * text1 = "foo bar\r\nfoo bar"; + const char * text2 = "foo bar\rfoo bar"; + const char * expect = "bar\rfoo"; + char buffer[1024] = {0}; + LRESULT result; + + SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text1); + + SendMessage(hwndRichEdit, EM_SETSEL, 4, 11); + result = SendMessage(hwndRichEdit, EM_GETSELTEXT, 0, (LPARAM)buffer); + ok(result == 7, "EM_GETTEXTRANGE returned %ld, expected %d\n", + result, strlen(expect)); + ok(!strcmp(expect, buffer), "EM_GETTEXTRANGE filled %s\n", buffer); + + SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text2); + + SendMessage(hwndRichEdit, EM_SETSEL, 4, 11); + result = SendMessage(hwndRichEdit, EM_GETSELTEXT, 0, (LPARAM)buffer); + ok(result == 7, "EM_GETTEXTRANGE returned %ld, expected %d\n", + result, strlen(expect)); + ok(!strcmp(expect, buffer), "EM_GETTEXTRANGE filled %s\n", buffer); + + DestroyWindow(hwndRichEdit); +} + /* FIXME: need to test unimplemented options and robustly test wparam */ static void test_EM_SETOPTIONS(void) { @@ -3028,6 +3089,8 @@ START_TEST( editor ) test_TM_PLAINTEXT(); test_EM_SETOPTIONS(); test_WM_GETTEXT(); + test_EM_GETTEXTRANGE(); + test_EM_GETSELTEXT(); test_EM_AUTOURLDETECT(); test_EM_SETUNDOLIMIT(); test_ES_PASSWORD(); diff --git a/dlls/riched32/tests/editor.c b/dlls/riched32/tests/editor.c index 6fe027b..21972ab 100644 --- a/dlls/riched32/tests/editor.c +++ b/dlls/riched32/tests/editor.c @@ -464,6 +464,73 @@ static void test_EM_LINELENGTH(void) DestroyWindow(hwndRichEdit); } +static void test_EM_GETTEXTRANGE(void) +{ + HWND hwndRichEdit = new_richedit(NULL); + const char * text1 = "foo bar\r\nfoo bar"; + const char * text2 = "foo bar\rfoo bar"; + const char * expect1 = "bar\r\nfoo"; + const char * expect2 = "bar\rfoo"; + char buffer[1024] = {0}; + LRESULT result; + TEXTRANGEA textRange; + + SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text1); + + textRange.lpstrText = buffer; + textRange.chrg.cpMin = 4; + textRange.chrg.cpMax = 12; + result = SendMessage(hwndRichEdit, EM_GETTEXTRANGE, 0, (LPARAM)&textRange); + ok(result == 8, "EM_GETTEXTRANGE returned %ld, expected %d\n", + result, strlen(expect1)); + ok(!strcmp(expect1, buffer), "EM_GETTEXTRANGE filled %s\n", buffer); + + SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text2); + + textRange.lpstrText = buffer; + textRange.chrg.cpMin = 4; + textRange.chrg.cpMax = 11; + result = SendMessage(hwndRichEdit, EM_GETTEXTRANGE, 0, (LPARAM)&textRange); + ok(result == 7, "EM_GETTEXTRANGE returned %ld, expected %d\n", + result, strlen(expect2)); + todo_wine { + ok(!strcmp(expect2, buffer), "EM_GETTEXTRANGE filled %s\n", buffer); + } + + DestroyWindow(hwndRichEdit); +} + +static void test_EM_GETSELTEXT(void) +{ + HWND hwndRichEdit = new_richedit(NULL); + const char * text1 = "foo bar\r\nfoo bar"; + const char * text2 = "foo bar\rfoo bar"; + const char * expect1 = "bar\r\nfoo"; + const char * expect2 = "bar\rfoo"; + char buffer[1024] = {0}; + LRESULT result; + + SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text1); + + SendMessage(hwndRichEdit, EM_SETSEL, 4, 12); + result = SendMessage(hwndRichEdit, EM_GETSELTEXT, 0, (LPARAM)buffer); + ok(result == 8, "EM_GETTEXTRANGE returned %ld, expected %d\n", + result, strlen(expect1)); + ok(!strcmp(expect1, buffer), "EM_GETTEXTRANGE filled %s\n", buffer); + + SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text2); + + SendMessage(hwndRichEdit, EM_SETSEL, 4, 11); + result = SendMessage(hwndRichEdit, EM_GETSELTEXT, 0, (LPARAM)buffer); + ok(result == 7, "EM_GETTEXTRANGE returned %ld, expected %d\n", + result, strlen(expect2)); + todo_wine { + ok(!strcmp(expect2, buffer), "EM_GETTEXTRANGE filled %s\n", buffer); + } + + DestroyWindow(hwndRichEdit); +} + START_TEST( editor ) { MSG msg; @@ -475,6 +542,8 @@ START_TEST( editor ) ok(hmoduleRichEdit != NULL, "error: %d\n", (int) GetLastError()); test_WM_SETTEXT(); + test_EM_GETTEXTRANGE(); + test_EM_GETSELTEXT(); test_WM_GETTEXTLENGTH(); test_EM_STREAMIN(); test_EM_STREAMOUT();
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
9
...
128
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
Results per page:
10
25
50
100
200