Forum > Editor
Lazarus editor feature request/suggestion
440bx:
Hello,
Sometimes it is convenient to refer to a url in a comment, presumably because there is additional relevant information about the code.
For instance, the GetComboBoxInfo definition could be followed by a comment such as:
{ https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getcomboboxinfo }
It would be very nice if it were possible to click anywhere on that url and have Lazarus open the default browser or a new tab in the browser if it is already running with that page (just as the browser that is displaying this post does if the url is clicked on.)
This would be particularly useful when the code is relying on obscure, i.e., not well known, information that is fully elaborated in some url.
Comments welcome.
hukka:
The basic functionality is basically just a simple API call on most platforms, but the implementation requires certain decisions:
- What constitutes a valid enough URL for this case? Does it have to be fully qualified, or should it also accept www.foobar.com, just foobar.com? And what protocols? Should we also accept FTP? Gopher? Anything with :// ?
- UI considerations: should opening an URL be its own mouse action in the IDE Options->Editor->Mouse dialog? Like Notepad++ requires a ctrl-click IIRC, and I certainly don't want Lazarus opening URLs when I just want to select the text for copying.
- URL highlighting is an obvious thing that should to be implemented then too. You'd probably also want hovered URLs to be highlighted differently as that's the norm in UIs. That'd be two more settings in the highlighters.
I'm not at all against such a feature but I can understand how seemingly simple things like this end up not getting implemented due to the work required. I would personally be happy with just having URL highlighting. (EDIT: on second thought just having the URL highlighting would be confusing to users if the URLs aren't clickable.)
Just my two euro cents.
Tony Stone:
I am going to try to implement it this weekend! On first thought I wouldn't think I like needing to use a key+click combination. I feel like it should highlight like a normal URL and underline and change the mouse cursor to a hand but only when in a comment. Because I can see where I want to have a URL as a string value and there I think I would prefer needing a key+mouse click combination. But even a Ctrl+Click could be acceptable on a URL in a string value because you wouldn't expect for it to make you jump to anything in the source editor anyway. I don't know... I really like this idea!
But man... the simplest ideas always end up with a ton of cases I never consider. Either way this is my project this weekend, if I do a decent job i'll post a patch here.
First I need to get the latest trunk to build properly, my last bright idea seems to be the source of a failed build now. It is probably time for me to stop using FPCUpDeluxe as my crutch anyway. lol
--- Quote from: 440bx on February 07, 2025, 11:55:10 pm ---This would be particularly useful when the code is relying on obscure, i.e., not well known, information that is fully elaborated in some url.
Comments welcome.
--- End quote ---
440bx:
Thank you for the comments.
I envisioned something really simple. I would be perfectly satisfied if values were limited to those starting with "http://" and "https://", that makes it a bit simpler to determine the address may be _usable_, which means it isn't necessarily valid.
As far as it being valid, I'd personally put the burden entirely on the programmer, none at all on the editor, IOW, aside from establishing the text starts with "http://" or "https://" in order to change the cursor to the one the system normally uses to indicate a url, nothing else. IOW, the editor would not concern itself with validity at all, i.e, no fancy url parsing.
There is one thing that, on second thought, might be appropriate if this feature is implemented and that is, it should be an "opt-in" feature because it is conceivable for it to be used maliciously. Because of this, I believe it should be inactive by default and activated only by the programmer when he/she is willing to accept full responsibility for whatever actions a link may cause.
TRon:
fwiw: most editors that I use and also the terminal 'lights up by underlining sometimes changing the colour of" the url when hovering over it with the mouse to indicate that an action can be performed and a right mouse click when active a popup-menu that has an action listed as "open url" as (first) item. Some use/allow also to use the ctrl-mouse-click (as fast action).
Navigation
[0] Message Index
[#] Next page