Commit Graph

569 Commits

Author SHA1 Message Date
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
Dylan Smith 573102ee88 richedit: Fixed implementation of WM_GETDLGCODE message.
This fixes inconsistencies shown in the tests I added for the
WM_GETDLGCODE.  The tests covered different cases handled by the
current implementation in order to show that the native implementation
is simpler for all these cases.
2009-01-08 13:35:05 +01:00
Dylan Smith 28645c64d5 richedit: Avoid rewrapping all text for isolated format changes.
When the character or paragraph format is changed the paragraph that
is changed is already marked to be rewrapped, so ME_MarkAllForWrapping
shouldn't be called.  Since ME_RewrapRepaint uses this function, it
shouldn't be called in these circumstances, since rewrapping all the
text can cause noticable delays when working with a lot of text.
2009-01-06 12:52:09 +01:00
Dylan Smith f361910514 richedit: Use 32-bit rather than 16-bit trackbar value for scrolling. 2009-01-06 12:44:24 +01:00
Dylan Smith fc13c70b78 richedit: Mask window id on WM_COMMAND notifications. 2009-01-04 14:59:54 +01:00
Dylan Smith 7a54306008 richedit: Fix unicode truncation on EM_GETLINE message. 2009-01-03 14:55:30 +01:00
Dylan Smith c9977df853 richedit: Prevented a dereference of a freed pointer.
On WM_DESTROY the editor was getting freed, then it was used to obtain
a handle to the editor.  This patch moves it just before the editor is
freed within ME_DestroyEditor.
2008-12-27 20:22:53 +01:00
Maarten Lankhorst ac85a76b2d riched20: Fix cast for dwCookie. 2008-12-23 18:51:05 +01:00
Dylan Smith 5dc1271ba6 richedit: Move message handling to function callable without window.
In order to make the message handling available to windowless richedit
controls, the message handling must be in a function that can be
called from the ITextServices_TxSendMessage method.  This method will
never have a handle to a window to pass to RichEditWndProc_common in
order to get the editor with GetWindowLongPtrW, but passing the editor
will work (even if hWnd is NULL).
2008-12-20 11:43:44 +01:00
Dylan Smith dc03b6b2f2 richedit: Removed redundant editor height variables and calculations.
During wrapping there were three different heights that were being
stored, with only one of them being done correctly.  The other ones
failed to incorporate the height of the paragraph or row, so ended up
being incorrect.
2008-12-20 11:43:09 +01:00
Dylan Smith 297716e01c richedit: Made sure text is offset by formatting rectangle.
The formatting rectangle is set with EM_SETRECT, and retrieved with
EM_GETRECT, so it corresponds to rcFormat in the code.  This defines the
area that the richedit control should draw the text so that it is
offset by the top-left corner of the formatting rectangle, and clipped
so that it doesn't draw past the bottom or right hand side.  Thus this
is important for implementing windowless richedit controls to not
interfere with the rest of the window.
2008-12-18 14:19:40 +01:00
Dylan Smith c87ca3d9e8 richedit: Move implementation of WM_CHAR to its own function. 2008-12-16 14:10:25 +01:00
Dylan Smith e5f5dc60a7 richedit: Removed some unnecessary SendMessage calls to itself. 2008-12-16 14:10:19 +01:00
Dylan Smith c7c2ff1fbc richedit: Move implementation of EM_GETTEXTEX to its own function. 2008-12-16 14:09:47 +01:00
Dylan Smith 4f41972b15 richedit: Move implementation of EM_GETTEXTRANGE to its own function.
The RichEditWndProc_common function is big enough already by handling
all the window messages, so moving code to handle a message to its own
function makes the code more readable.
2008-12-16 14:09:40 +01:00
Dylan Smith 7e94a230e1 richedit: Removed unused hwndEdit variable for the RTF parser.
There is no reason for the rich text format parser to need a handle to
the window, and even if there were it has a handle to the editor which
contains a handle to the window.  It is better to remove this
considering we need to cut down on the use of window handles to
implement windowless richedit controls.
2008-12-15 13:20:01 +01:00
Dylan Smith 8ab0570d02 richedit: Removed an unnecessary call to GetScrollInfo.
The vertical scrollbar state is stored internally within the control,
so should be used when possible.  This will become more necessary when
windowless richedit controls are implemented, and there will no hWnd
to pass to GetScrollInfo.
2008-12-15 13:16:20 +01:00
Dylan Smith 0c8e4b6d02 richedit: Compare editor rather than hWnd in ME_CalculateClickCount.
Comparing the editor as apposed to the handle to the window will work
just as well right now, but will also work when there is no window
handle to make a comparison with, which will be the case with
windowless richedit controls.
2008-12-15 13:16:08 +01:00
Dylan Smith 6901e0cec7 richedit: Use ME_EnsureVisible to implement EM_SCROLLCARET.
The code for the ME_EnsureVisible function does exactly what
EM_SCROLLCARET does, yet this code is duplicated in order to handle
this message.  It is simpler to just use the existing function to
implement the message, and avoid internally sending the EM_SCROLLCARET
when this function is available.
2008-12-15 13:15:56 +01:00
Dylan Smith 1e8df4351d richedit: Removed unused ME_AutoURLDetect function. 2008-11-17 13:57:56 +01:00
Dylan Smith ea9f343c33 richedit: Update strings and comments regarding IME Status messages. 2008-11-17 13:12:35 +01:00
Andrew Talbot affc6e029c riched20: Sign-compare warnings fix. 2008-11-06 11:09:41 +01:00
Michael Stefaniuc 90024d03b2 riched20: Remove superflous casts. 2008-11-04 11:26:12 +01:00
Dylan Smith 09802e2c76 richedit: Handle negative position given to EM_POSFROMCHAR. 2008-10-29 11:52:18 +01:00
Dylan Smith 4c28a5bcfb richedit: Fixed initial word wrap setting when emulating 1.0. 2008-10-27 12:01:37 +01:00
Dylan Smith 46d79b0363 richedit: Fixed EM_POSFROMCHAR for pos of text length.
For some reason EM_POSFROMCHAR was returning 0 when the position was
equal to the end of the text, or beyond the end of the text. Instead
it should use the position at the end of the text for both these
cases.  The x value was also seen to be offset by 1 according to the
tests.
2008-10-22 13:54:54 +02:00
Dylan Smith 5bcb15dd7f richedit: Handle ctrl-key shortcuts on WM_KEYDOWN. 2008-10-22 13:54:53 +02:00
Dylan Smith c70f6a3933 richedit: Use the DefWindowProc to implement WM_SETREDRAW. 2008-10-20 11:37:27 +02:00
Dylan Smith 197f3f4c23 richedit: Added EM_SETMARGINS to the list of unsupported messages. 2008-10-13 11:41:55 +02:00
Dylan Smith 1d21d24a51 richedit: Show arrow cursor over scrollbar. 2008-10-06 13:54:49 +02:00
Dylan Smith 4785c2fa2d richedit: ES_AUTOHSCROLL window style disables word wrapping. 2008-10-06 13:52:25 +02:00
Dylan Smith bdf181b4d3 richedit: Use RTF reader for text starting with {\urtf. 2008-10-06 13:49:12 +02:00
Dylan Smith 2aa69c6c9e richedit: Prevent buffer overrun for tab stops buffer. 2008-09-12 12:35:29 +02:00
Dylan Smith fab258022e richedit: Fixed bugs in handling unterminated nested tables in RTF. 2008-09-12 11:55:43 +02:00
Dylan Smith 0d8e9e622f richedit: Make sure the nested tables' RTF properties are not skipped. 2008-09-12 11:55:30 +02:00
Dylan Smith d7ff24378a richedit: Enter inserts newline before table at start of document. 2008-09-12 11:55:22 +02:00
Dylan Smith 0843768919 richedit: Enter at the end of a table row appends a new row. 2008-09-12 11:55:14 +02:00
Dylan Smith 88a3a8a9c0 richedit: Don't put cursor in the table row start paragraph. 2008-09-12 11:55:08 +02:00
Dylan Smith 9a7d475db8 richedit: Avoid acting on control words in skipped RTF groups.
Previously the control words in skipped groups were being processed by
the read hook on the RTF parser.  By moving this code into the class
callbacks for the parser, the skipped groups actually remain skipped.
2008-09-11 12:38:20 +02:00
Dylan Smith f11fe1c7a9 richedit: Prevent typing text at end of table row. 2008-08-29 13:42:47 +02:00
Dylan Smith 36be721027 richedit: Prevent streaming in rich text at end of table row. 2008-08-29 13:41:41 +02:00
Dylan Smith 238fd58a09 richedit: Pressing tab with selection back to start of table. 2008-08-29 13:41:18 +02:00
Dylan Smith ddc107bd26 richedit: Added support for changing cell border colours. 2008-08-18 17:15:57 +02:00
Dylan Smith 421c5b0e02 richedit: Borders are now drawn for tables and nested tables. 2008-08-18 17:15:57 +02:00
Dylan Smith a47d4a4c3a richedit: Adjust table spacing with horizontal gap and left edge. 2008-08-18 17:15:57 +02:00
Dylan Smith fe1a24ff88 richedit: Substitute space for \tab and \par control words for simple tables.
For simple tables cells are represented with tabs, and a table row is
ended at the end of the paragraph, so native richedit controls
substitute spaces for \tab and \par rich text format control words.
2008-08-18 17:15:57 +02:00
Dylan Smith a382e35600 richedit: EM_[SG]ETPARAFORMAT returned the wrong value.
The values returned by EM_SETPARAFORMAT and EM_GETPARAFORMAT previously
indicated an error, and the included tests shows that Windows behaves as
documented.
2008-08-18 17:15:57 +02:00
Dylan Smith 59195ed2ec richedit: Added in support for streaming in and out nested tables. 2008-08-18 14:34:35 +02:00
Dylan Smith 300db3765f richedit: Each cell can contain multiple paragraphs in msftedit. 2008-08-18 14:34:11 +02:00
Dylan Smith d29f671d1a richedit: Protect deletion of cell boundaries when not deleting row. 2008-08-18 14:34:10 +02:00
Dylan Smith bf5ccefc4c richedit: Handle tab key properly within table cells.
Within table cells the tab key moves to the next cell in the table, or creates
a new table row when at the end of the table.
2008-08-18 14:34:10 +02:00
Dylan Smith e568e15142 richedit: Removed assumption about the order of rtf indent control words.
Previously the calculations of dxStartIdent and dxOffset depended on
their order.
2008-08-18 14:34:10 +02:00
Dylan Smith 6a65f3b38e richedit: Fixed rtf reader bug that caused large start indents.
The problem was that the paragraph format was being retrieved,
slightly modified and then used to set the paragraph format, without
limiting the mask to what was being set.  The PFM_OFFSETINDENT mask flag
being valid meant that dxStartIndent specifies a relative offset, thus
dxStartIndent was doubled.
2008-08-18 14:34:10 +02:00
Dylan Smith 11c8039699 richedit: Use tabstops to store cell positions. 2008-08-05 14:09:37 +02:00
Dylan Smith edb6304379 richedit: Added OleInitialize for clipboard operations. 2008-07-31 13:01:27 +02:00
Hongbo Ni 3cb685c861 riched32: Implement WM_UNICHAR support. 2008-07-29 14:09:23 +02:00
Dustin Brody 3a805d289e riched20: EM_SETTEXTTEX obeys ST_SELECTION with RTF inputs. 2008-07-29 12:50:35 +02:00
Alex Villacís Lasso acfb6ea210 richedit: Do not read actual scrollbar state for scrollbar update, use internal state instead. 2008-07-23 13:05:27 +02:00
Dylan Smith 7de6c2674a richedit: Added more conditional cursor changes.
Previously the cursor was either an IBEAM, or a reversed arrow when over
the selectionbar.
2008-07-10 12:16:58 +02:00
Dylan Smith d293b3fc98 richedit: Prevented cursor flicker while moving over selection bar.
When the cursor is moved over the selection bar, without holding any
mouse buttons down, the cursor would be repeatably set between the
normal cursor, set by DefWindowProc for the WM_SETCURSOR message, and
the reversed cursor, set by ME_MouseMove.
2008-07-10 12:16:39 +02:00
Dylan Smith 8172d69e8f richedit: Set the default paragraph format consistently.
I created a function to set the default paragraph format to ensure
consistency when this is done.  This initial paragraph format is also
now more consistent with native richedit controls.  The dwMask value
always appears to have the same value when retrieved from the native
richedit controls, so all the mask values are now initialized when the
PARAFORMAT2 structure is created.
2008-07-09 11:31:22 +02:00
Dylan Smith aba425eb70 richedit: PFE_TABLE flag is now used instead of private bTable value.
The PARAFORMAT structure has a bit in wEffects to indicate whether the
paragraph is a table or not, so this should be used instead of a private
bTable value, since this structure can be retrieved with EM_GETPARAFORMAT.
2008-07-09 11:31:21 +02:00
Dylan Smith eb4ed9cadf richedit: Removed unused variable bCaretShown in ME_TextEditor. 2008-07-08 21:08:53 +02:00
Michael Stefaniuc 0164bffd9a riched20: Fix typo. 2008-07-08 20:37:30 +02:00
Dylan Smith 762e5818d1 richedit: Hide cursor when text is selected.
The cursor should only be shown when there is no selection, since this
is how it is done in Windows.  This patch avoids showing the cursor when
there is a selection, and destroys the cursor when a selection is made.
2008-07-08 10:44:45 +02:00
Dylan Smith 69cf4e9ac4 richedit: Implemented triple click selection. 2008-07-08 10:44:32 +02:00
Dylan Smith abefc28fe7 richedit: Fixed drag and shift selection for words and lines.
Previously word drag and shift selection was not implemented.  Line
drag selection was working, but shift selection wasn't.
2008-07-08 10:43:55 +02:00
Dylan Smith 5b2bdc06d0 richedit: Fixed double click issues by sharing code with single click. 2008-07-07 14:16:07 +02:00
Dylan Smith 2eec4f03ed richedit: Fixed the selection bar width. 2008-07-07 11:10:49 +02:00
Dylan Smith db95d69f99 richedit: Made sure the caret position is stored when moving up/down.
The caret's x position is stored in ME_TextEditor.nUDArrowX so that when
the caret is moved up or down, it will stay along the same horizontal
position, or at the end of a line.  Unfortunately, the value stored in
nUDArrowX was being unconditionally discarded in ME_ArrowKey, preventing
it from serving its purpose.
2008-07-07 11:10:33 +02:00
Dylan Smith 632015dc62 richedit: Set error codes and stop parsing for some rtf syntax errors.
Checks were added for hexadecimal values that did not have valid
characters, and for EOF received before the final closing brace of the
rich text stream.  The error values were tested on richedit versions 1,
2, 3 & 4.1, and they were all the same for these cases.
2008-06-27 11:08:33 +02:00
Dylan Smith d1f1346f54 richedit: Implemented undo coalescing to group typing events.
Consecutively typed characters are grouped together to be undone
together.  The grouping of typed characters can be stopped by certain
events that are mentioned in MSDN's remarks on the EM_STOPGROUPTYPING
message, which is also implemented by this patch.
2008-06-26 21:18:50 +02:00
Dylan Smith 6d76d43718 richedit: Fixed a bug preventing NULL pointers from being in text.
Opening a text file with a NULL terminated character in it was causing
an assertion error after a run was being split due to word wrap.
Windows allows NULL terminated characters to be in the text.
2008-06-26 21:16:56 +02:00
Dylan Smith 67024f0f34 richedit: Prevented an assertion error on startup when run on Windows.
The call to GetClientRect returns 0 values for the returned RECT when
called in WM_NCCREATE in on Windows, which ended up causing an assertion
error when Wine's riched20.dll replaces the native version. Moving the
call to WM_CREATE fixes this problem (probably because NCCALCSIZE is
called in between).
2008-06-26 21:15:54 +02:00
Dylan Smith 6c2026a348 richedit: Show caret after pasting or streaming in text.
There was a missing call to ShowCaret after the caret was created.
2008-06-26 21:15:11 +02:00
Alex Villacís Lasso acec891ac2 richedit: EM_POSFROMCHAR should take into account scrollbar position. With tests. 2008-06-24 11:44:37 +02:00
Alex Villacís Lasso 3cc6e2365a richedit: When returning position through wParam pointer, EM_POSFROMCHAR must return 0 as LRESULT.
Add tests for EM_POSFROMCHAR for 1.0 and 2.0.
2008-06-24 11:43:42 +02:00
Michael Stefaniuc bc0acd1ac2 riched20: Remove redundant NULL check before heap_free (Smatch). 2008-06-21 11:17:08 +02:00
Alex Villacís Lasso d2900a53e1 richedit: Add tests for URL autodetection for EM_REPLACESEL, make them pass under Wine. 2008-06-19 12:10:00 +02:00
Alex Villacís Lasso 892a0b5f1e richedit: Add tests for URL autodetection for EM_SETTEXTEX, make them pass under Wine. 2008-06-19 12:09:46 +02:00
Alex Villacís Lasso f213af3795 richedit: Fix for the semantics of the flags for some effects reported by EM_GETCHARFORMAT.
Remove workaround put in place by a previous patch, due to buggy flag reporting.
Tests to verify fixed behavior.
2008-06-19 12:08:30 +02:00
Alex Villacís Lasso 4a5d100097 richedit: Add more tests for URL autodetection on WM_CHAR, make them pass under Wine. 2008-06-19 12:07:36 +02:00
Alex Villacís Lasso 38d7ba6eff richedit: WM_SETTEXT must immediately autodetect URLs, without waiting for a WM_CHAR. 2008-06-19 11:59:04 +02:00
Alex Villacís Lasso 60c42bd3db richedit: Fix misreporting of match offset for EM_FINDTEXT and EM_FINDTEXTEX. 2008-06-19 11:55:27 +02:00
Dylan Smith 76029ee9ec richedit: The wrong bits were cleared from wBorders in PARAFORMAT2. 2008-05-05 21:18:19 +02:00
Alex Villacís Lasso 2a4fc97c4c richedit: Add tests for EM_FINDTEXT in 1.0 emulation, make them pass under Wine. 2008-05-01 10:57:34 +02:00
Alex Villacís Lasso 2ab63774f1 richedit: On failure to parse incoming text as RTF, EM_STREAMIN must set dwError to -16. 2008-04-30 10:22:42 +02:00
Alex Villacís Lasso 829940458f 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).
2008-04-29 14:57:03 +02:00
Alex Villacís Lasso c52bc58816 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.
2008-04-29 14:56:46 +02:00
Alex Villacís Lasso 3cad256d54 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.
2008-04-29 14:56:23 +02:00
Alex Villacís Lasso 1fa39b50c0 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.
2008-04-29 14:56:11 +02:00
Alex Villacís Lasso cac55008c9 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.
2008-04-29 14:55:26 +02:00
Alex Villacís Lasso 4047df0f56 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.
2008-04-29 14:55:15 +02:00
Alex Villacís Lasso 3a271386ec 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.
2008-04-29 14:54:59 +02:00
Alex Villacís Lasso e8aa9dee56 richedit: Modify ME_GetTextW() to honor CR and LF encodings.
ME_GetTextLengthEx should ignore GTL_USECRLF in 1.0 emulation mode.
2008-04-29 14:54:46 +02:00
Alex Villacís Lasso d95cbeef67 richedit: EM_LINELENGTH: honor CR and LF counters.
Add fixup to ME_FindItemAtOffset(), fixes crash by null-pointer access.
Add tests for EM_LINELENGTH.
2008-04-29 14:54:29 +02:00
Alex Villacís Lasso 3968a67eb9 richedit: EM_GETLINE: honor CR and LF counters.
Add richedit 1.0 tests for EM_GETLINE.
2008-04-29 14:54:21 +02:00
Alex Villacís Lasso 8d37388fe7 richedit: Fixups to move over to reliance on CR and LF counters.
Text streamout now honors CR and LF counters.
Tests to pin down required EM_STREAMOUT behavior.
2008-04-29 14:54:05 +02:00
Eric Pouech 046cfcfd22 richedit: Ensure wrapping is done all the time after inserting an RTF stream. 2008-04-25 11:44:00 +02:00
Alex Villacís Lasso 4f95cf7072 riched20: Reject RTF that is recognized as invalid. 2008-04-24 22:12:13 +02:00
Alex Villacís Lasso d10256f309 riched20: Implement ignoring of last \par for EM_STREAMIN - 1.0 emulation. 2008-04-24 22:12:09 +02:00