Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2016-11

Question about TRichMemo

14 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

silvioprog

Hello,

First, thanks for this great component
<https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/components/richmemo/>! :-)

So, what do you think about distributing it on Lazarus components directory and it cames installed by default in the IDE?

Anyway, I'm going to send some patches to improve this component ...

Thank you!

Silvio Clécio -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20161101/cc1223ae/attachment.html>

Reply by email

Dmitry Boyarintsev
to silvioprog

On Tue, Nov 1, 2016 at 10:50 PM, silvioprog via Lazarus <

wrote: Anyway, I'm going to send some patches to improve this component ...

Thank you! Looking forward!

Pure Delphi-compatibility patches are likely to be rejected. (unless they're implemented in the form of helpers)

Keeping in mind cross-platform compatibility is greatly appreciated (thus Windows only features are likely to be rejected as well... or could be added in a form of functions/helpers, rather than a part of TCustomRichMemo interface)

thanks,
Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20161101/f54fc46f/attachment-0001.html>

Reply by email

silvioprog
to Dmitry Boyarintsev

On Wed, Nov 2, 2016 at 12:38 AM, Dmitry Boyarintsev <

Show quoted text 20 lines
wrote: On Tue, Nov 1, 2016 at 10:50 PM, silvioprog via Lazarus < > wrote: > Anyway, I'm going to send some patches to improve this component ... > Thank you! Looking forward! Pure Delphi-compatibility patches are likely to be rejected. (unless they're implemented in the form of helpers) Keeping in mind cross-platform compatibility is greatly appreciated (thus Windows only features are likely to be rejected as well... or could be added in a form of functions/helpers, rather than a part of TCustomRichMemo interface) thanks, Dmitry

Done: http://bugs.freepascal.org/view.php?id=30852 .

ps. this component should be installed as default in Lazarus IDE. ;-)

Silvio Clécio -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20161102/8918b3b4/attachment.html>

Reply by email

Dmitry Boyarintsev
to silvioprog

On Wed, Nov 2, 2016 at 7:25 PM, silvioprog via Lazarus <

Show quoted text 5 lines

Yep, totally fine. Should accept it tonight. Thank you.

ps. this component should be installed as default in Lazarus IDE. ;-)

It's not my call.

Including a component into an IDE is a big administrative issue. The main question is - how - the component is included: as a part of LCL (default components set) or as 3d-party component.

If the component to become LCL-default component, then the whole work of maintaining it goes to respective widgetset maintainers. If the component to go as a 3d party component, then it needs some sort of versioning in place (and this is not the case for richmemo). So it would be clear which version (revision) of the component goes with the next Lazarus release.

thanks,
Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20161102/4816ddc8/attachment.html>

Reply by email

silvioprog
to Dmitry Boyarintsev

On Wed, Nov 2, 2016 at 9:09 PM, Dmitry Boyarintsev via Lazarus <

Show quoted text 10 lines
wrote: On Wed, Nov 2, 2016 at 7:25 PM, silvioprog via Lazarus < > wrote: > > Done: http://bugs.freepascal.org/view.php?id=30852 . > Yep, totally fine. Should accept it tonight. Thank you.

Perfect! :-)

I had some ideas, and I can send small patches showing them. For example, what do you think about adding the GetLink() method in the TCustomRichMemo class and the href:string attribute in the TLinkMouseInfo record? It can allow the programmer to do something like this:

procedure TForm1.RichMemo1LinkAction(Sender: TObject; ALinkAction:
TLinkAction;
  const info: TLinkMouseInfo; LinkStart, LinkLen: Integer);
var
  Link: string;
begin
  if RichMemo1.GetLink(LinkStart, LinkLen, Link) then
    OpenURL(Link);
end;

or:

var
  Link: string;
begin
  Link := RichMemo1.GetLink(LinkStart, LinkLen);
  if Link  '' then
    OpenURL(Link);
end;

or just (easiest way):

procedure TForm1.RichMemo1LinkAction(Sender: TObject; ALinkAction:
TLinkAction;
  const info: TLinkMouseInfo; LinkStart, LinkLen: Integer);
begin
    OpenURL(info.href);
...

I can implement it easily on GTK using
g_object_set_data()/g_object_get_data() doing small changes in the SetTextUIParams()/GetTextUIParams()/Gtk2_RichMemoMouseButton() functions, however, it depends on your decision, if so, I can send a patch asap (first version for GTK but future patch for win-VCL). :-)

Show quoted text 18 lines
ps. this component should be installed as default in Lazarus IDE. ;-) > It's not my call. Including a component into an IDE is a big administrative issue. The main question is - how - the component is included: as a part of LCL (default components set) or as 3d-party component. If the component to become LCL-default component, then the whole work of maintaining it goes to respective widgetset maintainers. If the component to go as a 3d party component, then it needs some sort of versioning in place (and this is not the case for richmemo). So it would be clear which version (revision) of the component goes with the next Lazarus release. thanks, Dmitry.

Indeed. Anyway, I hope to see this (awesome) component installed by default in Lazarus IDE some day. :-)

Silvio Clécio -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20161102/62851013/attachment.html>

Reply by email

Torsten Bonde Christiansen
to silvioprog: First, thanks for this great component <https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tre…
silvioprog wrote 12 lines
Hello, First, thanks forthis great component <https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/components/richmemo/>! :-) So, what do you think about distributing it on Lazarus components directory and it cames installed by default in the IDE? Anyway, I'm going to send some patches to improve this component ...

If it all possible, can the part that generates the RichTextFormat be moved from the component into a seperate unit. This will make it possible to include RTF generators into eg. console programs.

Kind regards,
Torsten.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20161103/28262e9d/attachment.html>

Reply by email

Dmitry Boyarintsev
to silvioprog: On Wed, Nov 2, 2016 at 9:09 PM, Dmitry Boyarintsev via Lazarus < Perfect! :-) I had some…

On Wed, Nov 2, 2016 at 10:25 PM, silvioprog via Lazarus <

Show quoted text 6 lines
wrote: I had some ideas, and I can send small patches showing them. For example, what do you think about adding the GetLink() method in the TCustomRichMemo class and the href:string attribute in the TLinkMouseInfo record?

You might want to refer to SetLink method.
There's ALinkRef parameter, that serves this particular purpose. Naturally, LinkRef should end up in TLinkMouseInfo .

But I'd like to note, that "Links", are yet "under construction" area. For a few reasons:
* old win32 rich edit (for WindoesXP, doesn't have an api to read "href" data. However, a raw access to RTF could be used to extract it... as well as to store it)
* setting up a link >>might<< (not critical at themoment) require one more piece of information: Hint text (the text that's shown in the tooltip window)

However, if you implement Gtk side and add linkref or href to TLinkMouseInfo, the patch will be accepted.

thanks,
Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20161103/6f78f484/attachment.html>

Reply by email

Dmitry Boyarintsev
to Torsten Bonde Christiansen: If it all possible, can the part that generates the RichTextFormat be moved from the…

On Thu, Nov 3, 2016 at 5:18 AM, Torsten Bonde Christiansen via Lazarus <

Show quoted text 7 lines
wrote: If it all possible, can the part that generates the RichTextFormat be moved from the component into a seperate unit. This will make it possible to include RTF generators into eg. console programs.

Yes, it is possible

thanks,
Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20161103/70223049/attachment.html>

Reply by email

Dmitry Boyarintsev
to Dmitry Boyarintsev: On Wed, Nov 2, 2016 at 10:25 PM, silvioprog via Lazarus < You might want to refer to…

On Thu, Nov 3, 2016 at 2:52 PM, Dmitry Boyarintsev <

Show quoted text 7 lines
wrote: But I'd like to note, that "Links", are yet "under construction" area. For a few reasons: one more thing:

* custom RTF reader/writer must also be updated to recognize the link and use the proper API to generate one.

thanks,
Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20161103/2d236bb7/attachment.html>

Reply by email

silvioprog
to Dmitry Boyarintsev: On Wed, Nov 2, 2016 at 10:25 PM, silvioprog via Lazarus < You might want to refer to…

On Thu, Nov 3, 2016 at 3:52 PM, Dmitry Boyarintsev via Lazarus <

Show quoted text 13 lines
wrote: On Wed, Nov 2, 2016 at 10:25 PM, silvioprog via Lazarus < > wrote: > I had some ideas, and I can send small patches showing them. For example, > what do you think about adding the GetLink() method in the TCustomRichMemo > class and the href:string attribute in the TLinkMouseInfo record? > You might want to refer to SetLink method.

So so, SetLink applies/removes a link, GetLink have a diferente purpose, it just returns the link's URL. (even in friendly name hyperlinks <https://blogs.msdn.microsoft.com/murrays/2009/09/24/richedit-friendly-name-hyperlinks/>) :-)

There's ALinkRef parameter, that serves this particular purpose.

Naturally, LinkRef should end up in TLinkMouseInfo .

Perfect.

But I'd like to note, that "Links", are yet "under construction" area. For

Show quoted text 14 lines
a few reasons: * old win32 rich edit (for WindoesXP, doesn't have an api to read "href" data. However, a raw access to RTF could be used to extract it... as well as to store it) * setting up a link >>might<< (not critical at themoment) require one more piece of information: Hint text (the text that's shown in the tooltip window) However, if you implement Gtk side and add linkref or href to TLinkMouseInfo, the patch will be accepted. thanks, Dmitry

Done: http://bugs.freepascal.org/view.php?id=30857 .

I have a question regarding SetTextUIStyle for WinVCL, its current implementation is:

class procedure TRichEditManager.SetTextUIStyle(RichEditWnd: Handle; const
ui: TTextUIParam);
var
  w   : WPARAM;
  fmt : TCHARFORMAT2;
{  st  : TSetTextEx;
  linkrtf : String;
  txt     : WideString;
  txtrtf  : String;}
begin
  if RichEditWnd = 0 then Exit;
  w := SCF_SELECTION;
  FillChar(fmt, sizeof(fmt), 0);
  fmt.cbSize := sizeof(fmt);
  fmt.dwMask := CFM_LINK;
(*    txt := GetTextW(RichEditWnd, true);
    st.codepage:=CP_ACP;
    st.flags:=ST_SELECTION;
    txtrtf:=txt;
    writeln('txtrtf = ', txtrtf);
    linkrtf:=Format('{\rtf1{\field{\*\fldinst{ HYPERLINK
"%s"}}{\fldrslt{%s}}}}',
      [ui.linkref, txtrtf]);
    SendMessage(RichEditWnd, EM_SETTEXTEX, WPARAM(@st),
LParam(@linkrtf[1])); *)
  if uiLink in ui.features then fmt.dwEffects := fmt.dwEffects or CFE_LINK;
  SendMessage(RichEditWnd, EM_SETCHARFORMAT, w, PtrInt(@fmt));
end;

what about to change it to?

class procedure TRichEditManager.SetTextUIStyle(RichEditWnd: Handle; const
ui: TTextUIParam);
var
{  w   : WPARAM;
  fmt : TCHARFORMAT2;}
  st  : TSetTextEx;
  linkrtf : String;
  txt     : String;
begin
  if RichEditWnd = 0 then Exit;
(*  w := SCF_SELECTION;
  FillChar(fmt, sizeof(fmt), 0);
  fmt.cbSize := sizeof(fmt);
  fmt.dwMask := CFM_LINK;*)
  txt := GetTextUtf8(RichEditWnd, true);
  st.codepage:=CP_UTF8;
  st.flags:=ST_SELECTION;
  linkrtf:=Concat('{\rtf1{\field{\*\fldinst{ HYPERLINK
"',ui.linkref,'"}}{\fldrslt{ ',txt,' }}}}');
  SendMessage(RichEditWnd, EM_SETTEXTEX, WPARAM(@st), LParam(@linkrtf[1]));
(*  if uiLink in ui.features then fmt.dwEffects := fmt.dwEffects or
CFE_LINK;
  SendMessage(RichEditWnd, EM_SETCHARFORMAT, w, PtrInt(@fmt));*)
end;

I'm not sure about SetTextUIStyle purpose, if it just retrieve links, the implementation above is done, otherwise it needs a small change, if uiLink in ui.features it applies HYPERLINK, else it keeps EM_SETCHARFORMAT as is.

Anyway, it can be the next step implementing (friendly name) hyperlinks support as soon as 30857 was applied.

(I'm going to test some rtfs documents containing hyperlinks generated via RichMemo (current it does not keep hidden URLs), LibreOffice Writer and MS Word ... ).

Silvio Clécio -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20161103/4112c36b/attachment-0001.html>

Reply by email

Dmitry Boyarintsev
to silvioprog

On Thu, Nov 3, 2016 at 3:36 PM, silvioprog via Lazarus <

Show quoted text 9 lines
wrote: There's ALinkRef parameter, that serves this particular purpose. > Naturally, LinkRef should end up in TLinkMouseInfo . > Perfect.

Now, I take that back.
"ref" information might need to go to some other, rather than TLinkMouseInfo.
Instead, TLinkMouseInfo should contain information about the cursor (x,y, shift state, etc)
An extra parameter could be added that would contain LinkInformation

I have a question regarding SetTextUIStyle for WinVCL,

Why WinVCL? :)

Show quoted text 9 lines
what about to change it to? txt := GetTextUtf8(RichEditWnd, true); st.codepage:=CP_UTF8; st.flags:=ST_SELECTION; linkrtf:=Concat('{\rtf1{\field{\*\fldinst{ HYPERLINK "',ui.linkref,'"}}{\fldrslt{ ',txt,' }}}}'); SendMessage(RichEditWnd, EM_SETTEXTEX, WPARAM(@st), LParam(@linkrtf[1]));

That's fine. You just need to make sure that parameters are RTF escaped. Also, newer versions of RichEdit do provide API for Link management without need of going into raw RTF.

But that's why TRichEditManager class is there (even through there's only one implementation available)

thanks,
Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20161103/1d97fb15/attachment.html>

Reply by email

silvioprog
to Dmitry Boyarintsev

On Thu, Nov 3, 2016 at 4:48 PM, Dmitry Boyarintsev via Lazarus <

Show quoted text 19 lines
wrote: On Thu, Nov 3, 2016 at 3:36 PM, silvioprog via Lazarus < > wrote: > There's ALinkRef parameter, that serves this particular purpose. >> > Naturally, LinkRef should end up in TLinkMouseInfo . >> > > Perfect. > Now, I take that back. "ref" information might need to go to some other, rather than TLinkMouseInfo. Instead, TLinkMouseInfo should contain information about the cursor (x,y, shift state, etc) An extra parameter could be added that would contain LinkInformation

Do you mean about declaring an additional parameter something like this?:

RichMemo1LinkAction(Sender: TObject; ALinkAction: TLinkAction; AMouseInfo:
TLinkMouseInfo; *ATextInfo: TLinkTextInfo*; ALinkStart, ALinkLen: Integer);

If so, it seems a great idea, and the issue #30857 needs some additional patches. :-)

I have a question regarding SetTextUIStyle for WinVCL,

> Why WinVCL? :)

Nothing special, just because some commented code there hehe... xD But what is the main purpose about SetTextUIStyle, it retrieves only links, or links and formatted texts? :-)

what about to change it to?

Show quoted text 12 lines
> > txt := GetTextUtf8(RichEditWnd, true); > st.codepage:=CP_UTF8; > st.flags:=ST_SELECTION; > linkrtf:=Concat('{\rtf1{\field{\*\fldinst{ HYPERLINK > "',ui.linkref,'"}}{\fldrslt{ ',txt,' }}}}'); > SendMessage(RichEditWnd, EM_SETTEXTEX, WPARAM(@st), > LParam(@linkrtf[1])); > That's fine. You just need to make sure that parameters are RTF escaped.

Indeed. We need to fix that.

Also, newer versions of RichEdit do provide API for Link management without

Show quoted text 5 lines
need of going into raw RTF. But that's why TRichEditManager class is there (even through there's only one implementation available)

Yes. But I have an idea, we should keep Get/SetTextUIStyle and Get/SetLink supporting only raw links (as implemented above) because it is supported in mostly of richedit versions, but in future versions we should add two new Get/SetURL methods, available only on supported richedit APIs and providing all URL features. (see MS post talking about a SetURL method <https://blogs.msdn.microsoft.com/murrays/2009/09/24/richedit-friendly-name-hyperlinks/> (ITextRange::SetURL),
so we can follow the same concept :-) )

Silvio Clécio -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20161103/57bf0b0d/attachment.html>

Reply by email

Dmitry Boyarintsev
to silvioprog: On Thu, Nov 3, 2016 at 4:48 PM, Dmitry Boyarintsev via Lazarus < Do you mean about…

On Thu, Nov 3, 2016 at 4:17 PM, silvioprog via Lazarus <

Show quoted text 8 lines
wrote: Nothing special, just because some commented code there hehe... xD But what is the main purpose about SetTextUIStyle, it retrieves only links, or links and formatted texts? :-) Currently, it sets/gets links only (formatted texts go with FontParams and

GetTextAttributes).

If more features are to be added, it might easier to extend TTextUIParam structure, rather than introducing more methods to WSclass.

Something similar that happened to TFontParams. The structure didn't have Background colors or script positions (for ascended/descended texts)

thanks,
Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20161103/721b19c5/attachment-0001.html>

Reply by email