On Thu, Nov 3, 2016 at 3:52 PM, Dmitry Boyarintsev via Lazarus < lazarus@lists.lazarus-ide.org> wrote: > > > On Wed, Nov 2, 2016 at 10:25 PM, silvioprog via Lazarus < > lazarus@lists.lazarus-ide.org> 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 > 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
-- _______________________________________________ Lazarus mailing list Lazarus@lists.lazarus-ide.org http://lists.lazarus-ide.org/listinfo/lazarus