Commit Graph

569 Commits

Author SHA1 Message Date
Nikolay Sivov 20f4a9ff7b riched20: Handle invalid HFONT values passed to WM_SETFONT.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2015-10-05 22:27:12 +09:00
Jactry Zeng d62dd46516 riched20: Implement EM_SETFONTSIZE. 2015-08-27 21:43:46 +09:00
Alex Henrie af19e64017 riched20: Fix link notification conditions and add tests. 2015-06-18 17:11:05 +09:00
Huw Davies 17f273360a riched20: Append a final \par when writing the whole buffer. 2015-06-09 14:47:30 +09:00
Nikolay Sivov 0b94369bb7 riched20: Reduce code duplication in WM_SETTEXT/WM_CREATE handler. 2015-06-02 20:53:44 +09:00
Nikolay Sivov 251e168590 riched20: Implement SetText() for selection range. 2015-05-27 14:31:40 +09:00
Nikolay Sivov 81fc69d7e6 riched20: Added IDispatch support. 2015-05-25 21:43:17 +09:00
Alexandre Julliard 50009c4a95 riched20: Update rectangle on WM_WINDOWPOSCHANGED instead of WM_SIZE.
Some applications don't forward WM_SIZE to the window proc.
2015-04-28 19:57:37 +09:00
Christoph von Wittich ca2b70b285 riched20: Handle SCF_WORD. 2015-04-01 22:34:20 +09:00
Christoph von Wittich c0c36fba70 riched20: EM_SETSEL should not return 0. 2015-03-31 14:46:06 +09:00
Francois Gouget cd0200113c riched20: Remove unneeded NONAMELESSXXX directives. 2015-03-19 14:05:48 +09:00
Michael Stefaniuc f40b4291d4 riched20: Remove no-op addition with 0 (PVS-Studio). 2015-02-25 21:27:42 +09:00
Michael Stefaniuc 54d3816eb8 riched20: IDC_IBEAM is already an int resource (PVS-Studio). 2015-02-18 16:09:00 +09:00
Guillaume Charifi 27ac8d265e riched20: Do not destroy IRichEditOle if still referenced. 2014-11-17 17:27:43 +09:00
Michael Stefaniuc 7f295effbd riched20: SUCCEEDED() is already a BOOL (PVS-Studio). 2014-10-31 10:49:34 +09:00
Jactry Zeng a9491ec5d9 riched20: Add IID_IRichEditOle and IID_ITextDocument support for ITextServices::QueryInterface. 2014-10-30 12:02:52 +09:00
Jactry Zeng 234310e752 riched20: Add COM aggregation support for IRichEditOle. 2014-10-30 12:02:17 +09:00
Jactry Zeng ffb706ceb0 riched20: Fix a leak. 2014-10-30 12:00:57 +09:00
Jactry Zeng 1f6073c861 riched20: Implement ITextSelection::GetText. 2014-07-21 18:45:38 +02:00
Jactry Zeng 455eca6d22 riched20: Return nonzero value instead of zero when EM_SETREADONLY succeeds. 2014-07-04 19:30:25 +02:00
Jactry Zeng 10e6a665fd riched20: Initialize ed->reOle in ME_MakeEditor(). 2014-07-03 18:17:59 +02:00
Jactry Zeng 6ea4da4038 riched20: Don't create too many IRichEditOle interface for a RichEdit. 2014-07-01 12:53:47 +02:00
Alex Henrie 6b947701a7 riched20: Consider adjacent runs when computing EN_LINK range. 2014-06-17 10:36:53 +02:00
Huw Davies b89c7c8fc2 riched20: Don't skip the final carriage return in SFF_SELECTION mode. 2014-06-11 13:06:23 +02:00
Nikolay Sivov 601738dfb5 riched20: GetClientSite() is implemented for IRichEditOle so uncomment related code (Coverity). 2014-04-15 21:03:54 +02:00
Huw Davies fa50baf31f riched20: Keep track of fractions of WHEEL_DELTA when scrolling. 2014-03-31 15:29:02 +02:00
Huw Davies 2f07df59f9 riched20: Add a helper to return the default line height and use that in EM_LINESCROLL. 2014-03-31 15:29:00 +02:00
Hans Leidekker db094db851 riched20: Don't return DLGC_HASSETSEL from WM_GETDLGCODE if the control style includes ES_SAVESEL. 2014-03-28 17:57:19 +01:00
Frédéric Delanoy 5f88ba5b61 riched20: Use BOOL type where appropriate. 2014-03-19 11:33:22 +01:00
Jactry Zeng 88214a5874 riched20: Add UTF8 support for EM_SETTEXTEX. 2014-01-27 16:59:15 +01:00
Jactry Zeng eb8f47518e riched20: Use codepage in ME_ToUnicode. 2014-01-27 16:59:08 +01:00
Jactry Zeng 51936be04d riched20: Use CP_UNICODE instead of 1200. 2014-01-06 20:52:40 +01:00
Huw Davies 160f65f24a riched20: Move the various selection setting methods to a common function. 2013-12-06 13:14:58 +01:00
Frédéric Delanoy e81412a4db riched20: Use BOOL type where appropriate. 2013-11-20 11:26:07 +01:00
Piotr Caban d31048f0ae riched20: Fix loop condition while processing control content in WM_CREATE. 2013-10-08 15:39:01 +02:00
Frédéric Delanoy f03d251ef2 riched20: Use BOOL type where appropriate. 2013-10-08 09:09:22 +02:00
Piotr Caban e660bf676c riched20: Set control content in WM_CREATE message. 2013-10-07 19:52:44 +02:00
Andrew Eikum 360afb93b5 riched20: Continue interpreting data as UTF-8 after the first chunk boundary. 2013-10-02 11:01:33 +02:00
Jactry Zeng 1cbdb2aff7 riched20: Add a length return parameter to ME_ToUnicode. 2013-09-10 12:27:37 +02:00
Alexandre Julliard 85f8828560 riched20: Don't bother to unregister classes at process exit. 2013-05-14 11:33:19 +02:00
Huw Davies 5ddfc36cc0 riched20: Add a visual vs logical order flag to the character to position mapping routines. 2013-04-17 14:26:09 +02:00
Huw Davies c409fc13fd riched20: Set the bidi base embedding level. 2013-03-25 14:09:38 +01:00
Andrew Eikum 3f02c24163 riched20: EM_FINDTEXT implementation should match richedit character type. 2013-03-25 14:07:19 +01:00
Huw Davies 7a59014fa2 riched20: Send WM_CHAR notifications. 2013-02-28 21:02:06 +01:00
Huw Davies 86f077b163 riched20: Add an explicit run length member and use it rather than accessing the string length. 2013-01-31 16:32:12 +01:00
Huw Davies 27578f8bb6 riched20: Add a helper to retrieve the run text. 2013-01-30 17:19:31 +01:00
Huw Davies dee40e90ce riched20: Move undo handling to a different set of structs as the display item structs are not a good fit. 2013-01-29 17:50:17 +01:00
Marcus Meissner 3a2de10a9c riched20: Fixed pointer to value out of scope (Coverity). 2012-08-20 10:57:08 +02:00
Qian Hong cb8c500ee6 riched20: Added support for UTF8 BOM stream. 2012-08-17 13:58:11 +02:00
Nikolay Sivov e3f0d40840 riched20: Use proper interface methods macros. 2012-08-13 11:48:23 +02:00
Dan Kegel a59e766ea7 riched20: Accept middle click as paste (like edit control does). 2012-06-19 11:09:49 +02:00
Dylan Smith 2ebfd01b51 richedit: Remove some unused structure fields. 2012-05-14 12:04:24 +02:00
Dylan Smith 18fa3287f6 richedit: Remove always FALSE parameter from ME_PaintContent. 2012-05-08 09:42:16 +02:00
Jason Edmeades efbde389c7 richedit: v1.0 richedit uses CR and LF for enter. 2012-01-23 16:07:41 +01:00
Dylan Smith f61d417a34 richedit: Return number of chars inserted for EM_STREAMIN with SF_RTF. 2011-09-26 12:16:59 +02:00
Dylan Smith e060272de7 richedit: Return number of bytes read for EM_STREAMIN with SF_TEXT. 2011-09-26 12:16:56 +02:00
Amine Khaldi 4b7795a943 riched20: Add a missing break. 2011-02-23 19:23:38 +01:00
Dylan Smith d43cddcc83 richedit: Clear non-default style when changing to plain text mode.
Although the text must be empty for the mode to change to plain text
mode, there still may be a non-default style for the temporary insert
style and style for the end of text run.
2011-01-12 11:32:19 +01:00
Dylan Smith ad056fe7d7 richedit: Check for bits instead of equality in EM_SETCHARFORMAT.
There are unsupported flags documented on MSDN which would cause problems
for the equality checks used in EM_SETCHARFORMAT.  Also, to handle a
combined set of flags they must be checked for in the right order.
2010-07-30 11:36:01 +02:00
Dylan Smith 16d7890426 richedit: Don't change text mode with undo or redo stack. 2010-07-30 11:36:01 +02:00
Dylan Smith 75eef41881 richedit: Return correct values when EM_SETTEXTMODE fails.
The checks for the text length and invalid parameters needed to be swapped,
and the code could be easily simplified.
2010-07-30 11:36:01 +02:00
Dylan Smith dfa80b35b0 richedit: Invalidate without calling UpdateWindow in many cases. 2010-07-29 10:28:00 +02:00
Dylan Smith 1964e603fd richedit: Remove redundant commit and repaint in ME_StreamInText.
ME_StreamInText is only used in one function, ME_StreamIn, which always
calls ME_CommitUndo and ME_UpdateRepaint after calling this function.
2010-07-29 10:27:38 +02:00
Dylan Smith 328a3f1d8c richedit: EN_UPDATE notification is sent on WM_PAINT. 2010-07-29 10:27:30 +02:00
Austin Lund 61e5fec020 riched20: Process messages which arrive before WM_NCCREATE. 2010-07-08 17:33:25 +02:00
Dylan Smith 6072a69d38 richedit: Keep default char format on WM_SETFONT in plain text mode. 2010-06-07 15:27:52 +02:00
Dylan Smith 3f1d3e0ea1 richedit: Simplify redundant code in WM_IME_COMPOSITION. 2010-05-24 11:30:23 +02:00
Dylan Smith e809bc887d richedit: Commit undo items after modifications in WM_IME_COMPOSITION.
ME_InsertTextFromCursor could previously follow the ME_CommitUndo call
leaving uncommitted changes which would cause improper grouping of commits,
or an assertion failure.
2010-05-24 11:30:12 +02:00
Dylan Smith fb7d6b783e richedit: Missing HeapFree in WM_IME_COMPOSITION. (Smatch).
ME_InsertTextFromCursor copies the string passed into it rather than making
taking ownership of it.
2010-05-24 11:30:06 +02:00
Dylan Smith d312d4e33c richedit: Revert commit that caused a regression. (Bug 22758).
Revert commit 049cf5aca0
richedit: Avoid notifying parent window in improper state.

The commit was meant to fix a problem caused by ME_SendSelChange being
called in ME_SendSelChange, but moving the calls to ME_CommitUndo caused
a regression. So this patch reverts the previous commit, and my
following patch will instead fix the bug by moving the call to
ME_SendSelChange out of ME_CommitUndo.
2010-05-19 11:17:55 +02:00
Michael Stefaniuc cf13e8a390 riched20: Avoid using long. 2010-05-17 12:42:33 +02:00
Dylan Smith 049cf5aca0 richedit: Avoid notifying parent window in improper state.
ME_CommitUndo and ME_CommitCoalescingUndo call ME_SendSelChange, which
may notify the parent window that the selection has changed, therefore
should generally be called after wrapping the text. Otherwise, the parent
window may send a message to the editor and cause an assertion failure.
2010-05-17 12:42:31 +02:00
Gerald Pfeifer 6dd4b071cc riched20: Remove variable pCell which is not really used from ME_StreamIn. 2010-05-10 10:11:34 +02:00
Michael Stefaniuc d3bc43b5ed Grammar fixes "is doesn't" => "doesn't". 2010-01-11 11:33:59 -06:00
Michael Stefaniuc 3b45ababfb riched20: Remove some explicit LPARAM/WPARAM casts. 2009-12-28 12:27:13 +01:00
Huw Davies 8808fccd57 riched20: Initialise window size.
Found by Valgrind.
2009-12-16 12:42:40 +01:00
Huw Davies d4383b4498 riched20: Initialise the style flags.
Found by Valgrind.
2009-12-15 16:09:12 +01:00
Huw Davies d88c47fccb riched20: Fix a memory leak.
Found by Valgrind.
2009-12-14 12:04:05 +01:00
Eric Pouech 38df8cfb04 richedit: When inserting an OLE object from an RTF stream, don't force update as the stream is not fully read. 2009-11-09 20:02:03 +01:00
Sergey Khodych 12a417de8a riched20: Implement handling of WM_KEYDOWN VK_TAB in the dialog mode. 2009-10-13 12:38:58 +02:00
Sergey Khodych a50ca4ace0 riched20: Implement handling of WM_KEYDOWN VK_ESCAPE in the dialog mode. 2009-10-13 12:38:54 +02:00
Sergey Khodych 8fb119ba8b riched20: Implement handling of WM_KEYDOWN VK_RETURN in the dialog mode. 2009-10-13 12:38:49 +02:00
Sergey Khodych 851c33ddd9 riched20: Enable the dialog mode after receiving WM_GETDLGCODE message. 2009-10-13 12:38:44 +02:00
Dylan Smith 3fe20bdc7e richedit: Handle to parent window is cached.
The parent window for the richedit control on creation is the one that
receives notify messages, even after the parent has been changed using
SetParent.
2009-09-30 17:41:06 +02:00
Dylan Smith 0342ab0df1 richedit: Use ITextHost interface in ME_LinkNotify.
Using the ITextHost interface allows this notification to be received
for windowless richedit controls.  Windowed richedit conrols have an
ITextHost implementation that will fill in hwndFrom and idFrom, but
these should probably be initialized to 0 for windowless richedit
controls.
2009-09-28 12:54:16 +02:00
Dylan Smith 99b37b2376 richedit: Silence fixme for WM_STYLECHANGING & WM_STYLECHANGED. 2009-09-24 15:15:09 +02:00
Dylan Smith 989bdd1579 richedit: Use ME_MoveCursorChars in ME_FindText to find relative offset.
When a previous character needed to be found, it is simpler to move
existing cursor rather than retravese the linked list to find the offset
again.
2009-08-13 15:35:37 +02:00
Dylan Smith bd4704280d richedit: Replace offsets arg with ME_Cursor for ME_InternalDeleteText.
Offsets are still used within the function, but this patch reduces the
use of it at the entry to the function.
2009-08-13 15:35:17 +02:00
Dylan Smith 02228ee176 richedit: Use ME_Cursor instead of offsets for ME_CharFromPos. 2009-08-13 15:35:01 +02:00
Dylan Smith a69ef26599 richedit: Use ME_Cursor instead of offsets for copying text. 2009-08-13 15:34:54 +02:00
Dylan Smith 60a72583f4 richedit: Use ME_Cursor instead of offsets for ME_UpdateLinkAttribute. 2009-08-13 15:34:47 +02:00
Dylan Smith c92bb271b7 richedit: Use ME_Cursor instead of offsets for ME_GetTextRange. 2009-08-12 17:35:55 +02:00
Dylan Smith 2da0d8e933 richedit: Use ME_Cursor instead of offsets for ME_SetCharFormat.
The test that succeeded from this change was as a result of allowing the
end of the character format change be specified using NULL as the rest
of the text.  Before, the end paragraph run at the end of the text was
not being set for this case, when all the text was supposed to have its
character format changed.
2009-08-12 17:35:50 +02:00
Dylan Smith ade37203a5 richedit: Use ME_Cursor instead of offsets for ME_GetCharFormat.
Prevent extra conversions from character offset to ME_Cursor.
2009-08-12 17:35:42 +02:00
Dylan Smith 2bc726930f richedit: Add helpers for setting cursor to start/end of text. 2009-08-12 17:35:30 +02:00
Dylan Smith 32dcd3bbe1 richedit: Created functions to move between runs and track paragraphs.
Plenty of places in the code find following or preceding runs, then
afterwards find the paragraph from the run.  This is inefficient because
the same linked list is used for both runs and paragraphs, so changes in
paragraphs can be detected while returning the next or previous run.
2009-08-12 17:35:24 +02:00
Dylan Smith 0362b1b087 richedit: Improve efficiency of ME_IsCandidateAnURL.
The code was previously getting the same text in the loop from the
editor, and it was converting each of the prefixes to compare against
for each URL candidate.
2009-08-12 17:34:44 +02:00
Dylan Smith 82e102107c richedit: ME_GetTextW must use source and destination lengths.
Before a single length was used for the number of characters to retrieve
from the text, and to keep track of the size of the buffer.  These are
not equivalent, since there is a possible end of line conversion.
2009-08-12 17:32:16 +02:00
Dylan Smith 46b84aed4a richedit: Added function to get selection cursors in order.
Previously the only convenient way to get the start and end of the
selection was through offsets, which eventually need to get converted
back into items in the linked list storing the text.  The new function
will help with eliminating these inefficiencies.
2009-08-12 17:29:30 +02:00
Dylan Smith be0fb1ef5d richedit: Make the ME_GetCursorOfs function more flexible.
This function will make it easier to work with ME_Cursor objects, which
should be used in a lot of places instead of character offsets (which
often require seeking through the linked lists to perform operations
with).
2009-08-12 17:29:20 +02:00
Dylan Smith 114a64ce5d richedit: Added missing style releases.
Style objects are referenced counted in richedit controls, so I tried to
make sure styles were released properly.  This can be checked using with
the all_refs global reference count to see if everything is cleaned up.
2009-08-10 17:10:34 +02:00
Dylan Smith 71cb069246 richedit: Use richedit class string macros from public headers. 2009-08-10 17:10:14 +02:00
Dylan Smith 05c730fd4c richedit: Prevent using uninitialized nAvailWidth in initialization. 2009-08-03 16:00:34 +02:00
Dylan Smith c4b023b1b6 richedit: Prevent buffer overflows in WM_GETTEXT.
The application AutoGK was getting the length of the text with
WM_GETTEXTLENGTH to allocate an appropriate buffer size, but then
claimed the buffer was twice the size when sending WM_GETTEXTEX.  This
caused the memcpy call to overflow the actual buffer since the count
is based on the size of the buffer alone, regardless of the amount of
text retrieved.
2009-08-03 16:00:16 +02:00
Dylan Smith 3d89e29155 richedit: Handle NULL buffer or 0 buffer length in ME_GetTextEx.
ME_GetTextEx directly handles EM_GETTEXTEX, and previously a NULL buffer
would be dereferenced, and a 0 buffer length would cause nCount an
underflow in the nCount value which would allow a buffer overflow to
occur.
2009-08-03 15:59:57 +02:00
Dylan Smith 0deb3d04ed richedit: Scrollinfo stored as 16-bit values externally.
The application Blitzin2 was sending WM_VSCROLL messages to the
richedit control directly, when normally this message is supposed to
be a notification sent after the scrollinfo is set.  Native richedit
controls always use the 16-bit value passed to this message to set the
scroll position for SB_THUMBPOSITION, rather than trying to find a
32-bit value through GetScrollInfo like I had previously done.
2009-07-22 11:08:33 +02:00
Dylan Smith c6cf567706 richedit: Properly restore style after end of rtf group.
Rich text files have groupings of text, where styles are pushed onto
the stack when encountering a start of the group, then popped at the
end of the group.  This was being handled improperly before, because a
single styleChanged flag was being stored to keep track of whether the
style needed to be restored at the end of a group. This fails to work
properly since the single flag isn't keeping track of all the levels
of the stack, so some styles are not restored properly.
2009-07-20 12:18:43 +02:00
Dylan Smith dde41d5c13 richedit: Handle missing colours in rtf colour table.
When a colour table entry is empty, then the default colour is used.
For an incomplete colour table entry 0 is used for the missing colours.

Previously the -1 value used internally for missing colours was being
converted into white, where it should be using the default colour that
is normally black.

This bug could be seen by loading the following rich text into wordpad:
{\rtf{\colortbl;;}\cf1 text}
2009-07-17 15:40:35 +02:00
Dylan Smith eddccdd1f2 richedit: Initially disable scrollbars for ES_DISABLENOSCROLL.
Previously after initial window creation of a richedit control with the
ES_DISABLENOSCROLL window style flag the scrollbar would be shown but
not disabled.  This patch fixes this issue by explicitly disabling and
showing the scrollbar.
2009-07-17 12:37:03 +02:00
Dylan Smith 88c2b90aa6 richedit: Support ascii RTF in WM_SETTEXT even for unicode messages.
WM_SETTEXT seems to check for {\rtf or {\urtf to determine if it is an
ascii RTF string, even if it is a unicode message.  So I removed the
check to see if it is a unicode message, and added a check for {\urtf.
2009-07-13 10:48:01 +02:00
Francois Gouget 19020b9ef5 riched20: Make some functions static. 2009-05-26 14:25:12 +02:00
Dylan Smith caca486029 richedit: Add bounds checks for EM_GETTEXTRANGE with tests.
Wine was not doing bounds checks for EM_GETTEXTRANGE, which was causing
a crash in Bug 17822.  The added tests would cause a crash without the
added bounds checks in the richedit code.

The bounds checks I put in HandleMessage, since ME_GetTextRange is also
called for ME_GETSELTEXT which should not have bounds checks, since it
uses the selection range.

When the ME_GETTEXTRANGE message returns 0, no text is copied, not even
the NULL terminating charter.  This differs from EM_GETSELTEXT which
will copy the NULL terminating character when no text is selected.  This
behaviour is consistent with native richedit controls.
2009-03-23 13:26:28 +01:00
Dylan Smith fdb3749138 richedit: Respect manually added links when autourldetect is disabled.
EM_SETCHARFORMAT can be used to make text links.  Automatic URL
detection being enable would cause these links to be removed if the text
is not a URL, so this must be prevented.

Previously checks were made for AutoURLDetect_bEnable before calling
ME_UpdateSelectionLinkAttribute, or ME_UpdateLinkAttribute.  This is
more error prone than checking for this within the function, so one call
was missing this check.

ME_SetCursor also didn't respect this behaviour, since it wouldn't set
the cursor to the hand when hovering over a link without automatic URL
detection disabled.
2009-03-09 12:28:33 +01:00
Dylan Smith bcd8dc93a2 richedit: Avoid calling ITextHost_TxNotify with EN_MSGFILTER.
The documentation for TxNotify says that it is not called with the
EN_MSGFILTER notification, so I made sure ME_FilterEvent didn't call
this method.
2009-03-06 12:49:04 +01:00
Dylan Smith 88eb1b5b6c richedit: EM_SETOPTIONS modify format rect when selbar setting change.
Before the code was modifying the format rect to compensate for space
being added or removed for the selection bar, but this should only
happen when the ECO_SELECTIONBAR setting bit changes.
2009-02-26 12:11:18 +01:00
Dylan Smith 73e0c5ea8b richedit: Never wrap for single line controls.
I tested without the ES_MULTILINE style, and found that wrapping
doesn't occur where it normally would.
2009-02-24 16:57:28 +01:00
Dylan Smith 963407a9ef richedit: EM_SHOWSCROLLBAR hides scrollbars for less than page of text.
When all the text fits on the screen, the scrollbars are not shown from
EM_SHOWSCROLLBAR.  The message instead adds support for the specified
scrollbar when lParam is TRUE, so that the scrollbar will be shown when
sufficient text is in the document.
2009-02-24 16:57:28 +01:00
Dylan Smith f28988684e richedit: Return FALSE for EM_LINESCROLL with single line control. 2009-02-24 16:57:28 +01:00
Dylan Smith b9b9835f93 richedit: Added missing initialization of nAvailWidth for ME_TextEditor. 2009-02-24 16:57:27 +01:00
Dylan Smith ecb6c2169c richedit: Store paragraph in cursors.
This prevents some needless searching for the start of the paragraph
from a run stored in a cursor.  Usually a pointer to the paragraph is
already available when the cursor is set anyway.
2009-02-10 12:59:09 +01:00
Dylan Smith 5f15de0690 richedit: Removed ME_StrLen and ME_StrVLen field access functions.
These functions were probably previously needed because of some wierd
special handling of backspace characters, but currently there is no
reason why the nLen field can't be accessed directly.

Having to functions that just access the string length field just causes
slightly more effort for someone to look at the code, because they need
to enter the function to find out what it actually is doing.
2009-02-09 13:05:13 +01:00
Dylan Smith 1ceb903f9d richedit: Simplified ME_UpdateSelectionLinkAttribute. 2009-02-09 13:05:12 +01:00
Dylan Smith c2c2c1117e richedit: Wrap even when message says not to repaint.
Wrapping is needed to be done even when repainting isn't done since
later messages expect line breaks to reflect the current text.  Some
message can specify not to paint the sceen, but this should prevent
wrapping from being done.
2009-02-09 13:05:12 +01:00
Dylan Smith d20e057d8e richedit: Accept paragraph as parameter for ME_CharOfsFromRunOfs.
Rather than get the paragraph from the run, the function allows the
caller to provide the paragraph, since it is already available.  This
reduces unnecessary traversals of lists that take longer as more runs
and rows are in the paragraph.
2009-02-06 14:50:27 +01:00
Dylan Smith 12ca50db7a richedit: Get the paragraph with ME_RunOfsFromCharOfs.
The ME_RunOfsFromCharOfs function finds the paragraph before finding the
run and offset within the run, so the function may as well be able to
return this paragraph to the caller.  Many callers to the function
instead find the paragraph from the run, which ends up unnecessarily
traversing a linked list of runs within the paragraph.
2009-02-06 14:50:27 +01:00
Dylan Smith 95d82484e1 richedit: Fixed EM_FINDTEXT to pass todo tests.
There was a bug in ME_FindText which would cause the final caracter
offset to be incorrect when a paragraph was crossed while matching
characters.  The problem was the character offset of the wrong
paragraph was used in the calculation of the start offset of the
match.
2009-02-02 15:21:45 +01:00
Dylan Smith 8662c6fe7b richedit: Implement EM_GETTEXTMODE.
The text mode is already stored, and EM_SETTEXTMODE already exists.

There was however a bug in EM_MakeEditor that could cause TM_PLAINTEXT
and TM_RICHEDIT to be set at the same time.  This was corrected to ensure
EM_GETTEXTMODE returned the proper mode being used.
2009-02-02 15:21:44 +01:00
Dylan Smith 1a3551b630 richedit: Use width from EM_SETTARGETDEVICE for wrapping.
The width for EM_SETTARGETDEVICE is used by some applications to set the
wrapping width to a certain distance in twips.  This can be used even
though the target device is ignored.
2009-02-02 15:21:44 +01:00
Marcus Meissner 4662271afd riched20: Removed unneeded NULL check (Coverity). 2009-01-29 12:44:53 +01:00
Dylan Smith f42e151a6c richedit: Updated internal style flags on EM_SHOWSCROLLBAR.
The internal style flags are used to determine whether to show or hide
the scrollbar when ME_UpdateScrollBar is called.  EM_SHOWSCROLLBAR seems
to update this state in native richedit controls.
2009-01-28 12:11:59 +01:00
Dylan Smith 5d74f58382 richedit: Actually store end of line string for end paragraph runs.
Previously a count of the carraige returns and line feeds were stored
for end of paragraph runs, and a paragraph sign was stored as the actual
string.  This was causing many special cases where the length of the
run needed to be determined differently if the run was or wasn't an
end of paragraph run.

There wasn't any use for storing the paragraph sign unless some drawing
code gets commented out to allow the end paragraphs to be shown,
therefore I changed the code to store the actual string that gets
retrieved by WM_GETTEXT.
2009-01-28 12:11:36 +01:00
Dylan Smith 61308257f2 richedit: Removed redundant ME_FindItemAtOffset using ME_RunOfsFromCharOfs.
The two functions ME_FindItemAtOffset and ME_RunOfsFromCharOfs were almost
identically used, since ME_FindItemAtOffset was always used to find a run.
The only difference was how they returned the offset within the run for an
end of paragraph run.

For ME_FindItemAtOffset it would return the next run if it was in between \r
and \n. ME_RunOfsFromCharOfs would instead return an nOffset of 0 for end
paragraph runs.  This subtle difference introduced bugs, so I decided to
avoid having special case in this function when creating this patch, and
instead let the caller handle this case.
2009-01-27 11:21:33 +01:00
Dylan Smith 61f189cec8 richedit: Handle starting in EOL sequence in EM_GETTEXTRANGE.
EM_GETTEXTRANGE allows the start character offset and end characters
offset to be used to specify the range of text to retrieve.  If the
start offset is in the middle of an end of paragraph run (i.e. \r\n),
then it should only retrieve the characters after the specified
character offset.
2009-01-27 11:21:16 +01:00
Dylan Smith c94e78a572 richedit: Handle case for EM_LINELENGTH when offset is between \r\n.
I found that ME_FindItemAtOffset and ME_CursorFromCharOfs are used
almost identically, except for how they handle a character offset that
is between a carriage return and line feed.  In this case
ME_CursorFromCharOfs sets the cursor's run offset to 0, but
ME_FindItemAtOffset instead returns the next run which is what was
causing ME_LINELENGTH to incorrectly return the length of the next
line.
2009-01-27 11:20:59 +01:00
Nikolay Sivov e49cb3bfcb richedit: Update EM_GETOLEINTERFACE documentation status. 2009-01-22 15:28:22 +01:00
Dylan Smith 94146a72ad richedit: Removed some unused invalidation code.
The ME_InvalidateFromOfs and ME_QueueInvalidateFromCursor functions are
never called, and the nInvalidOfs variable had its value set but never
used.
2009-01-22 15:28:22 +01:00
Dylan Smith a6c7b6fdb2 richedit: Typing is ignored while mouse is captured.
I noticed a while ago that on Windows XP richedit controls ignored
characters typed while the mouse is captured (e.g. from holding the left
or middle button down).  Arrow keys, delete, and backspace, copying,
cutting, pasting, and everything else handled on WM_CHAR and WM_KEYDOWN
messages are also ignored.
2009-01-22 15:28:22 +01:00
Dylan Smith e7b68a20fd richedit: Implemented ITextServices_TxSendMessage. 2009-01-21 11:55:22 +01:00
Dylan Smith 902afbc65b richedit: Prevented using NULL hwnd for certain operations.
Certain operations will simply not be done for windowless richedit
controls, such as WM_PAINT which isn't done for windowless richedit
controls since ITextServices provides a TxDraw method.
2009-01-21 11:55:03 +01:00
Dylan Smith 05c788ac6f richedit: Used ITextHost methods to avoid using window handle directly.
The methods in ITextHost are mostly thin wrappers around functions that
take a handle to a window as their first parameter.  This patch just
uses the wrapper functions provided by ITextHost instead of using the
functions that require a handle to a window that the editor might now
have (for windowless richedit controls).
2009-01-21 11:54:43 +01:00
Dylan Smith 6c4dda009e richedit: Implemented ITextHost for windowed richedit controls. 2009-01-21 11:54:26 +01:00
Dylan Smith b4babc16bb richedit: EM_SETTEXTEX detects ascii richtext with Unicode codepage. 2009-01-19 12:46:41 +01:00
Dylan Smith 89f88a49a4 richedit: Store an internal copy of the window style flags. 2009-01-16 12:35:28 +01:00
Dylan Smith e6fedf879c richedit: Implemented the horizontal scrollbar. 2009-01-15 14:13:38 +01:00
Dylan Smith fcabbbf30f richedit: Zoom in and out with mouse wheel with control held. 2009-01-14 14:22:37 +01:00
Andrew Talbot 8ddf6c0a25 riched20: Declare some functions static. 2009-01-13 15:53:43 +01:00
Dylan Smith f885d40d67 richedit: Store mouse captured state rather than calling GetCapture.
Windowless richedit control will not be able to call GetCapture without
a handle to the host window (and there is no ITextHost_TxGetCapture
method), but there is a ITextHost_TxSetCapture method available for
setting and releasing the capture on the mouse.  This means that the
richedit control will need to keep track of whether it has captured the
mouse or not to implement windowless richedit controls.
2009-01-12 14:42:02 +01:00
Dylan Smith 8089d980d1 richedit: Set bEmulateVersion10 initially to avoid retroactive changes.
Previously the WM_NCCREATE was handled by the as if it was always for
later versions, then the window proc for version 1.0 would make
appropriate changes afterwards.  Instead both versions should call the
same function (e.g. ME_MakeEditor) and provide the value for
bEmulateVersion10 to make the code clearer.
2009-01-12 14:40:11 +01:00
Dylan Smith 603be645d2 richedit: Pressing enter adds newline on WM_KEYDOWN rather than WM_CHAR. 2009-01-12 14:39:42 +01:00
Dylan Smith 1f6b8c7fd9 richedit: Missing condition for inserting newline before table.
This case occurs when the cursor is at the start of the table, the
table is at the start of the text, and there is no selection.
2009-01-09 14:06:13 +01:00