Plain Text Bullets on Copy

General TRichView support forum. Please post your questions here
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Plain Text Bullets on Copy

Post 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
Sergey Tkachenko
Site Admin
Posts: 17554
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Plain Text Bullets on Copy

Post 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
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Re: Plain Text Bullets on Copy

Post 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
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: Plain Text Bullets on Copy

Post 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.
  • <slf>text</slf>
It now includes the bullet with the <slf> even though the bullet is not inside of <slf> and should not have been selected.
Last edited by jgkoehn on Fri Oct 06, 2023 8:45 pm, edited 1 time in total.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: Plain Text Bullets on Copy

Post 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.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: Plain Text Bullets on Copy

Post 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
Capture.JPG (8.74 KiB) Viewed 359037 times
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: Plain Text Bullets on Copy

Post 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;
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: Plain Text Bullets on Copy

Post 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.
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Re: Plain Text Bullets on Copy

Post 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
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: Plain Text Bullets on Copy

Post 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.
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Re: Plain Text Bullets on Copy

Post 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
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: Plain Text Bullets on Copy

Post 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.
Sergey Tkachenko
Site Admin
Posts: 17554
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Plain Text Bullets on Copy

Post 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.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: Plain Text Bullets on Copy

Post 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.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: Plain Text Bullets on Copy

Post by jgkoehn »

Since this will take work to implement how can one take list markers back out of GetSelText without modifying TRichView code?
Post Reply