Page 1 of 2
Plain Text Bullets on Copy
Posted: Thu Sep 14, 2023 11:46 pm
by standay
Hi Sergey,
Is there any way to copy bullets from an rve doc and get them to paste into plain text with some sort of markers still there? Or is there some way to get the marker text (bullet or number) from list items?
Thanks Sergey
Stan
Re: Plain Text Bullets on Copy
Posted: Sun Sep 17, 2023 11:00 am
by Sergey Tkachenko
1. Currently, this behavior is hard-coded. TRichView copies the result of GetSelTextW method to the Clipboard, this method internally calls SaveTextToStreamW with the parameter TextOnly = True. With this option, content of most non-text items is not stored, including list markers.
Now I think that excluding the list markers is not a good idea, so it will be changed in the next update.
Quick fix: in RVMarker.pas, change TRVMarkerItemInfo.GetBoolValue to:
Code: Select all
function TRVMarkerItemInfo.GetBoolValue(Prop: TRVItemBoolProperty): Boolean;
begin
case Prop of
rvbpDrawingChangesFont, rvbpDocXOnlyBeforeAfter, rvbpAlwaysInText:
Result := True;
else
Result := inherited GetBoolValue(Prop);
end;
end;
2. Getting visible text from marker is possible, but not documented.
(rv.GetItem(ItemNo) as TRVListMarkerInfo).DisplayString
Re: Plain Text Bullets on Copy
Posted: Sun Sep 17, 2023 3:54 pm
by standay
Hi Sergey,
I tried both options and both worked. Using option 2 I was able to process selected text indents as well in my own code.
Would it eventually be possible to add processing the indents when copying text (to use as plain text) in general? I'm not sure about the overall implications of this but thought I'd mention it.
Thanks for this information. It helps, especially with numbered lists.
Stan
Re: Plain Text Bullets on Copy
Posted: Fri Oct 06, 2023 8:39 pm
by jgkoehn
Unfortunately since "bullets" are included but not selected this causes many problems and produces unexpected results
For example
If one searches for <slf> in the following.
It now includes the bullet with the <slf> even though the bullet is not inside of <slf> and should not have been selected.
Re: Plain Text Bullets on Copy
Posted: Fri Oct 06, 2023 8:43 pm
by jgkoehn
Please restore original functionality and allow users to add bullets if they so desire by something such as.
GetSelTextW(TextOnly: Boolean = True);
Since bullets are not technically text.
Re: Plain Text Bullets on Copy
Posted: Fri Oct 06, 2023 8:52 pm
by jgkoehn
Or if the above is not possible/preferrable please help me find a workable solution that I can use and not have bullets included unless they are specifically selected.
I understand if I was searching for <slf> in <slf> bullet text </slf> but when it is bullet <slf> and still gets the bullet it does not seem right. Perhaps I am misunderstanding something
In this scenario I only selected the word "test" the line is bullet space test so there should be a division
But I got this when debugging.
- Capture.JPG (8.74 KiB) Viewed 359274 times
Re: Plain Text Bullets on Copy
Posted: Fri Oct 06, 2023 9:19 pm
by jgkoehn
I went in and added:
IncludeListItemsAsText This may not be the best but works for now.
Code: Select all
if SelectionOnly AND IncludeListItemsAsText then
begin
MarkerItemNo := GetFirstParaSectionItem(StartItemNo);
if (GetItemStyle(MarkerItemNo) = rvsListMarker) then
begin
s := GetNonTextStr(MarkerItemNo, 0, 1, CustomSave);
RVFWriteW(Stream, GetStr(GetItem(MarkerItemNo), s, CustomSave));
end;
end;
Re: Plain Text Bullets on Copy
Posted: Fri Oct 06, 2023 9:31 pm
by jgkoehn
To help solve this would it be possible to make it so List Items could be selectable?
That way if they were not selected they would not be included.
Re: Plain Text Bullets on Copy
Posted: Fri Oct 06, 2023 9:45 pm
by standay
Sergey,
I'm OK using
Code: Select all
(rv.GetItem(ItemNo) as TRVListMarkerInfo).DisplayString
So whatever you work out won't cause any problems for me.
Stan
Re: Plain Text Bullets on Copy
Posted: Sat Oct 07, 2023 11:58 pm
by jgkoehn
I could see the benefit of having it included in the text but also only if it is actually selected. Right now it seems to be starting at the list item even if the select starts later in the line.
Re: Plain Text Bullets on Copy
Posted: Sun Oct 08, 2023 10:46 am
by standay
jgkoehn wrote: ↑Sat Oct 07, 2023 11:58 pm
I could see the benefit of having it included in the text but also only if it is actually selected. Right now it seems to be starting at the list item even if the select starts later in the line.
I looked at Word and Libreoffice. Both allow selecting bullets separately from text. That makes it easy to change bullet color independently from the text. Both allow an alt+left mouse button to select text separately from bullets. If you do that in Libreoffice and copy it, you still get the bullets. In Word you get just the text. If you select bulleted text as a whole, in Libreoffice you get the bullets but no indents included, in Word you get bullets and indents. So that's how those 2 handle bullets.
In the case of the rve component, something like this might work:
Code: Select all
GetSelTextW( IncludeMarkers: boolean = false; IncludeIndents: boolean = false );
So, you'd have these easily available:
Code: Select all
rve.GetSelTextW; //as it is now, text only, no markers, no indents in copied text
rve.GetSelTextW( true ); //markers included, no indents in copied text
rve.GetSelTextW( false, true ); //no markers, indents included in copied text
rve.GetSelTextW( true, true ); /both markers and indents included in copied text
Being able to select markers in the rve would be a great help as well when trying to set the marker color and font.
Stan
Re: Plain Text Bullets on Copy
Posted: Sun Oct 08, 2023 3:24 pm
by jgkoehn
I think that would be a good solution.
I agree if somehow the list marker could be select so as to change its color that would be beneficial. While also allowing to keep the text seperate.
Re: Plain Text Bullets on Copy
Posted: Sun Oct 08, 2023 8:01 pm
by Sergey Tkachenko
Probably it will be implemented in future, but this feature requires a lot of work.
First, this is a very special selection. List markers cannot be included in normal selection, they can be selected only separately from other content.
Next, all markers of the same level must be selected at the same time.
Next, this feature makes sense only if operations changing certain font properties of selected list markers will be implemented.
Re: Plain Text Bullets on Copy
Posted: Sun Oct 08, 2023 8:07 pm
by jgkoehn
That makes sense.
How can it temporarily be fixed since this at present with now including the listmarkers breaks a lot of code? "I can implement my work around" but it doesn't really solve it if it just gets overwritten. Plus the listmarker is not really part of the selected text but outside of it.
Re: Plain Text Bullets on Copy
Posted: Wed Oct 11, 2023 4:13 pm
by jgkoehn
Since this will take work to implement how can one take list markers back out of GetSelText without modifying TRichView code?