Commit Graph

194 Commits

Author SHA1 Message Date
Huw Davies 5e53012736 riched20: Don't assume the the runs in a row are in visual order. 2013-02-26 18:18:16 +01:00
Huw Davies c5c4d54905 riched20: Allow the cursor offset to be equal to the run length - this implies the cursor is at the end of the run, which isn't necessarily the start of the next. 2013-02-26 18:18:12 +01:00
Huw Davies a6369b8332 riched20: Rewrite ME_FindPixelPos to use ME_GetRunInRow. 2013-02-25 17:11:58 +01:00
Huw Davies 87163410e5 riched20: Only retrieve the next row. 2013-02-25 17:11:56 +01:00
Huw Davies 41dd421222 riched20: Return a BOOL that indicates whether the hit is exact. 2013-02-25 17:11:53 +01:00
Huw Davies 0730db2b99 riched20: Change ME_FindRunInRow to fill out a cursor structure. 2013-02-25 17:11:51 +01:00
Huw Davies acaad0a842 riched20: Add the ability to CharFromPoint to either pick the closest leading edge or the leading edge of the selected character. 2013-02-18 16:34:10 +01:00
Huw Davies 1c0aaf7dd2 riched20: Use ME_PointFromChar to calculate the caret position. 2013-02-15 17:52:13 +01:00
Huw Davies 5168d66be7 riched20: Move the text to the paragraph level. 2013-02-05 20:15:37 +01:00
Huw Davies 872a2ad031 riched20: Pass a character ptr and length to SplitParagraph. 2013-02-05 20:15:36 +01:00
Huw Davies 48b9ab37ac riched20: Pass the character ptr and string length directly to the break proc helper. 2013-02-05 10:51:26 +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 c17af77b5c riched20: Add a helper to debug the run text. 2013-01-30 17:19:28 +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
Huw Davies 7a27ffb28c riched20: Avoid an unnecessary string duplication. 2013-01-22 19:13:07 +01:00
Dan Kegel 4996043374 riched20: Don't need to redraw when changing selection from none to none. 2012-05-10 08:30:58 +02:00
Frédéric Delanoy 7ed4f20305 riched20: Remove dead assignment (Clang). 2011-07-06 11:29:18 +02:00
Dylan Smith 8b8e4f89b2 richedit: Use ME_Cursor as parameter to ME_SplitRunSimple.
The paragraph needed to be included in the parameters to avoid needing
traverse the linked list of display items to find the paragraph.
2010-07-30 11:36:02 +02:00
Gerald Pfeifer f772c799ae riched20: Remove variables yprev and ys which are not really used from ME_ArrowPageUp. 2010-05-17 12:42:31 +02:00
Gerald Pfeifer 2d462ad088 riched20: Remove variable ys which is not really used from ME_ArrowPageDown. 2010-05-10 10:11:29 +02:00
Gerald Pfeifer f29514fbec riched20: Remove variable di which is not really used from ME_InsertEndRowFromCursor. 2010-05-03 15:42:18 +02:00
Gerald Pfeifer 01777ac5ce riched20: Remove variable yprev which is not really used from ME_ArrowPageDown. 2010-05-03 15:37:31 +02:00
David Hedberg 534398a57e richedit: GTL_PRECISE to GETTEXTLENGTHEX implies GTL_NUMBYTES.
If GTL_PRECISE is passed without specifying either GTL_NUMCHARS or
GTL_NUMBYTES, behave as if GTL_NUMBYTES was passed.
2010-03-01 11:33:01 +01:00
Dylan Smith 9106860c85 richedit: Prevent crash on word selection at end of paragraph. 2010-02-18 12:18:17 +01: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
Francois Gouget 6e80d875d4 riched20: Make ME_SetCursorToEnd() static. 2009-08-26 13:09:27 +02:00
Dylan Smith a8e58307f9 richedit: Fixed check for nOffset at the end of the cursor's run.
For some reason the code previously mixed up a selection cursor with the
result cursor.  The problem seemed to have corrected itself before as a
result of conversion between offsets and cursors, but my recent changes
made this bug more severe.
2009-08-17 13:57:50 +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 27c28ab292 richedit: Modified ME_MoveCursorsChars to move multiple chars.
Previously the function was only used to move a single character in
either direction, so I made the function more general so that it could
be used in more places.
2009-08-13 15:34:39 +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 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 fc618ab041 richedit: Add closing actions for IRichEditOle_fnInsertObject.
Previously inserting the object didn't result in the text being wrapped,
which would cause an assertion error when this is checked for during
repainting the text.  It is also important to invalidate the affected
areas of text, update the scrollbar, and end the creation of undo
transactions for this insertion.
2009-08-10 17:10:24 +02:00
Dylan Smith e306b91392 richedit: Avoid comparing padding in cursor structures on memcmp. 2009-08-07 14:57:24 +02:00
Francois Gouget 3d6c53b972 riched20: Make ME_GetCursorCoordinates() static and remove ME_MustBeWrapped() as it is unused. 2009-05-26 14:10:32 +02: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 c8b4455565 richedit: Removed ME_StrRelPos, ME_StrRelPos2, & ME_PosToVPos functions.
These functions were just being used for addition, so it was simpler to
remove the functions and modify the places it was used.

The ME_StrRelPos2 and ME_PosToVPos were just simple wrappers around
ME_StrRelPos, and ME_PosToVPos wasn't being used.
2009-02-09 13:05:13 +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 d306b6b5e9 richedit: Removed some conditions that are always taken.
ME_GetCursorCoordinates had two conditions that were always taken.  The
first condition was if(pCursor->pRun->type == diRun) was following an
assertion making the exact same check.  The next one, if(row), should
always be taken, otherwise the richedit controls are in a corrupt state,
therefore an assertion is more appropriate.
2009-02-09 13:05:12 +01:00
Dylan Smith 71d797c55c richedit: Directly get start and end of text on Ctrl-Home or Ctrl-End.
Previously it found the start or end by traversing the linked lists of
run, rows, paragraphs, and cells from the current position of the
cursors.  Clearly it is better to get the start or end directly to make
it a constant time operation.
2009-02-09 13:05:12 +01:00
Dylan Smith 5a84e193c2 richedit: Removed incorrect FIXME comment.
The fixme comment is suggesting wrapping a paragraph within a function
that is for moving the selection cursor up or down a line when the up
or down keys are pressed.  The contents fo paragraph aren't being
changed, so there is no need to wrap the paragraph.
2009-02-06 14:50:27 +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 ea9e062b6c richedit: Removed unnecessary calls to ME_WrapMarkedParagraphs.
These calls to ME_WrapMarkedParagraphs never do anything, and don't make
sense to be called in these places. These places are for ME_MoveCaret,
and ME_ArrowHome, which both don't involve any text being modified, and
all (direct and indirect) calls to these functions are done after the
text has already been wrapped.
2009-02-06 14:50:27 +01:00
Dylan Smith a490e155dc richedit: Simplified the character length delete protection.
The value for nMaxChars can be found easier by using ME_GetTextLength.
2009-02-06 14:50:27 +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 0832737427 richedit: End of line sequence limited to 2 carriage returns.
riched32.dll does preserve the carriage returns and line feeds unlike
later versions of the richedit control, however the tests previously
missed the fact that a sequence of carriage returns followed by a line
feed (e.g. \r\r\r\n) can actually cause multiple paragraph breaks.
2009-01-27 11:20:37 +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 89f88a49a4 richedit: Store an internal copy of the window style flags. 2009-01-16 12:35:28 +01:00
Dylan Smith 77a94bed98 richedit: Fix implementation of handling Page Up/Down keys. 2009-01-16 12:34:54 +01:00
Dylan Smith e6fedf879c richedit: Implemented the horizontal scrollbar. 2009-01-15 14:13:38 +01:00
Andrew Talbot 8ddf6c0a25 riched20: Declare some functions static. 2009-01-13 15:53:43 +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 e5f5dc60a7 richedit: Removed some unnecessary SendMessage calls to itself. 2008-12-16 14:10:19 +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
Juan Lang fb30d61c97 riched20: Use helper function rather than goto to return found position. 2008-09-11 11:45:23 +02:00
Dylan Smith 300db3765f richedit: Each cell can contain multiple paragraphs in msftedit. 2008-08-18 14:34:11 +02:00
Dylan Smith bc61a637b9 richedit: Reversed deletion direction so tables are inserted forwards. 2008-08-18 14:34:10 +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 608c54ee69 richedit: Word/Line/Paragraph selection had selection anchor on wrong side.
After selection a word, line, or paragraph with multi click selection or using
the selection bar, then shift can be held and the arrows can be used to move
one of the ends of the selection.
2008-08-18 14:34:10 +02:00
Dylan Smith 4e56a3cda9 richedit: Joined paragraph format depends on number of characters deleted. 2008-08-05 14:09:37 +02:00
Dylan Smith 11c8039699 richedit: Use tabstops to store cell positions. 2008-08-05 14:09:37 +02:00
Dylan Smith 97d56caafe richedit: Fixed regression caused by destroying the caret.
The regression was caused by destroying the caret when it didn't need to
be shown in the richedit control, but this affected other controls.
2008-07-16 19:56:24 +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 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 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 7c352b9638 richedit: Implemented paragraph selection. 2008-07-08 10:44:12 +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 379835b634 richedit: Made sure word selection selects only one word. 2008-07-07 14:16:07 +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 66f948c010 richedit: Clicking below end of text now selects closest character.
Before the end of the text was selected when clicking below the end of
the text, rather than using the x position to find the appropriate
character on the last row that is closest to the pixel position.
2008-06-30 12:10:02 +02:00
Dylan Smith fad2b57cd7 richedit: Ensure caret is seen if moved past end of view over trailing spaces. 2008-06-27 11:09:37 +02:00
Dylan Smith 438d8e1c58 richedit: Caret size must match font size characters to be inserted.
When the caret is at the start of a run, it uses the font of the
previous run for inserting characters.  The caret size previously was
the wrong height for the characters being inserted when the caret was at
the start of a line, but not the start of a paragraph so this patch
fixes this bug.
2008-06-27 11:09:14 +02:00
Dylan Smith 461830a83d richedit: Removed redundant code for getting the insert style.
The function ME_GetInsertStyle already checks for the case where there
is a selection, so there is no need to duplicate this code for
ME_GetSelectionInsertStyle.
2008-06-27 11:08:19 +02:00
Dylan Smith 9b67a38f1a richedit: Make cursor visible when selecting via mouse above/below editor. 2008-06-26 21:18:28 +02:00
Dylan Smith eaf7becabd richedit: Null pointer check missing on optional parameter.
The function ME_FindRunInRow uses two parameters to return values by
reference, and treated these parameters as if they were optional except
for the start of the function which set *pbCaretAtEnd without checking
to see if was a NULL pointer.
2008-06-26 21:14:52 +02:00
Dylan Smith 6f9f01f28f richedit: bCaretAtEnd should not be reset from rewrapping text.
The bCaretAtEnd value in ME_TextEditor is used to identify that the
caret is at the end of a wrapped line instead of the start of the next
line in the paragraph since both these positions correspond to the
same position in the document. The bCaretAtEnd value was previously
being set back to FALSE whenever the window was resized.
2008-06-25 11:24:13 +02:00
Dylan Smith 308582b4f5 richedit: Allow cursor to move over trailing spaces in wrapped lines. 2008-06-25 11:23:39 +02:00
Alex Villacís Lasso c7873afbb2 richedit: Insertion style must NOT be cleared unless selection actually changed. 2008-06-19 12:10:13 +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 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 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 fd55773680 richedit: Remove reliance on bEmulateVersion10 for end-of-line handling in ME_InternalDeleteText. 2008-04-29 14:54:12 +02:00
Alex Villacís Lasso d47f66191e richedit: Add support for encoding number of CR and LF contained within a line break. 2008-04-29 14:53:46 +02:00
Alex Villacís Lasso 820de0bd59 riched32: Implement a portion of suggested interpretation of CRLF handling for richedit 1.0 emulation.
Fixes a few todos introduced by previous patch.
2008-04-21 20:27:52 +02:00
Eric Pouech 5d36c47e1f richedit: Fixed object leaks generated by context creation & destruction. 2008-03-17 14:37:58 +01:00
Eric Pouech a86d7bdcea richedit: Pass left margin around when computing the size of a run, so that a tab will get a correct size. 2008-03-17 14:36:06 +01:00
Eric Pouech a64c22c8b1 richedit: Store shift-enter (keyboard) and \line (rtf) as end of row (and emit \line while saving in RTF). 2008-03-17 14:34:44 +01:00
Eric Pouech 00de77517a riched20: Start handling OLE objects inside richedit. 2008-02-05 11:11:32 +01:00
Eric Pouech d48905cf21 richedit: Small optimisation in ME_GetSelectionInsertStyle. 2008-01-02 13:55:24 +01:00
Eric Pouech e9be142d78 richedit: Rewrote FindPixelPos so that it always return something.
Made the function static as well.
2008-01-02 13:55:14 +01:00
Maarten Lankhorst b81335501f riched20: Implement ECO/EM SELECTIONBAR. 2007-12-17 11:34:40 +01:00
Alex Villacís Lasso 3b636b58ba riched20: EM_GETTEXTLENGTHEX must not count last paragraph break if GTL_USECRLF. 2007-12-07 17:36:01 +01:00