[SOLVED] Opening a url from the Lazarus editor lazarus / 9-Editor ---------------------------------------------------------------------- 440bx · 2025-11-19 15:39 Hello, A while back I suggested/requested that Lazarus recognize urls in comments and give the option of opening them in the browser. The original feature request is at: https://forum.lazarus.freepascal.org/index.php/topic,70145.msg546396.h tml#msg546396 I was wondering if that feature has been added to Lazarus ?  I know I could install the most current version to find out but, I already have 12 versions of Lazarus installed and I don't want to install another one just to find out the answer to this simple question. Thank you for your help. The attachment shows what the editor I use does with urls in comments.  Normally, the url is underlined, when right clicking on it, it is highlighted and the option to open it is first in the popup menu.   It's quite convenient.  It would be very nice to have something like that in Lazarus. ---------------------------------------------------------------------- LV · 2025-11-19 19:55 Quote from: 440bx on November 19, 2025, 04:39:08 pmA while back I suggested/requested that Lazarus recognize urls in comments and give the option of opening them in the browser. This is a very useful feature that I also use in other editors. To make it work in Lazarus, I developed a simple utility some time ago. Here’s how it works: highlight the URL in the code (refer to LazarusEditor.png), then press Ctrl+C, and the link will open in your default browser (see Opening URL.png). P.S. I published this utility somewhere; I'll look for it now and provide you with a link. ---------------------------------------------------------------------- dsiders · 2025-11-19 20:17 Quote from: 440bx on November 19, 2025, 04:39:08 pmA while back I suggested/requested that Lazarus recognize urls in comments and give the option of opening them in the browser. The original feature request is at: https://forum.lazarus.freepascal.org/index.php/topic,70145.msg546396.h tml#msg546396 I was wondering if that feature has been added to Lazarus ?  The trunk version does not currently have URL recognition in comments, nor an Open URL option on the context menu. I you really want to see the feature implemented, you should submit a feature request to the issue tracker at: https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues. Not the forum. ---------------------------------------------------------------------- 440bx · 2025-11-19 20:33 @LV, Thank you, I'm looking forward to giving your utility a spin. @dsiders, Thank you for the update on the feature's implementation.  I will create a "formal" feature request. Request link: https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41917 ---------------------------------------------------------------------- LV · 2025-11-19 20:35 Quote from: dsiders on November 19, 2025, 09:17:53 pmThe trunk version does not currently have URL recognition in comments, nor an Open URL option on the context menu. I you really want to see the feature implemented, you should submit a feature request to the issue tracker at: https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues. Not the forum. This is really the best solution, but while I wait for it, I'm using a workaround: https://forum.lazarus.freepascal.org/index.php/topic,72313 .msg566208.html#msg566208. ---------------------------------------------------------------------- n7800 · 2025-11-19 20:38 Quote from: 440bx on November 19, 2025, 04:39:08 pmA while back I suggested/requested that Lazarus recognize urls in comments and give the option of opening them in the browser. The original feature request is at: https://forum.lazarus.freepascal.org/index.php/topic,70145.msg546396.h tml#msg546396 Please don't create new threads unless necessary, and just stick to the original one. This will make it easier to read them in the future rather than clicking links. Quote from: 440bx on November 19, 2025, 04:39:08 pmI know I could install the most current version to find out but, I already have 12 versions of Lazarus installed and I don't want to install another one just to find out the answer to this simple question. 12 installations and not a single trunk? You definitely need at least one... I have the opposite: one stable installation (for my projects) and about 5 trunks for IDE development and simultaneous work on different Git branches )) ---------------------------------------------------------------------- 440bx · 2025-11-19 21:04 I have 6 trunk installations but they are older versions of trunk, I think all different versions of 3.99 (but, I could be wrong about that.) I really need to do some cleanup but, I've forgotten what was important (modified stuff) in each installation, so now it's going to be time consuming to figure out what each installation was for and what I should save from it. I created this thread because all I really wanted was to find out if the feature had already been implemented, which is a different thing than requesting the feature but, now that you mention it, I agree with you that I should have asked the question in the original thread.  Next time... ---------------------------------------------------------------------- LV · 2025-11-20 06:04 The utility integrates into the Lazarus IDE in one minute (see screenshot). Select this menu. Select any piece of code containing a URL and Ctrl+C. The link will open in your default browser. ---------------------------------------------------------------------- 440bx · 2025-11-20 07:48 @LV, is that screenshot from the ForgetAboutCookiesCrossPlatform.zip attachment you linked to in a previous post or some other thing I missed ? I ask because I don't have any problems with cookies and I don't want to install something that may create some in the attempt of fixing a problem that doesn't exist.  That said, I'd really like to be able to open a url from Lazarus, therefore if that does, I will install it. ---------------------------------------------------------------------- LV · 2025-11-20 18:24 @440bx, I've been away, busy with work. Quote from: 440bx on November 20, 2025, 08:48:11 amI ask because I don't have any problems with cookies and I don't want to install something that may create some in the attempt of fixing a problem that doesn't exist.  That said, I'd really like to be able to open a url from Lazarus, therefore if that does, I will install it. Okay. If you want to try it: 1. Download and compile the utility (in the attachment). 2. Open Lazarus IDE -> Tools -> Configure External Tools (screenshot 1). 3. The ClipBoardURLOpener menu item will appear (screenshot 2) -> click it and the utility will run. 4. Select any code fragment with a URL -> Ctrl+C -> your default browser will open the link. 5. That's it. ---------------------------------------------------------------------- 440bx · 2025-11-20 20:05 Thank you @LV. ---------------------------------------------------------------------- DomingoGP · 2025-11-21 18:38 I have made an Ide package than adds a menu item in the source  editor popup menu to open the url/file when the caret is over a link that starts by: file:// https:// http:// www. The link shoud be enclosed in quotes or double quotes if it has spaces If the caret is not over a link it does nothing. Also there is a command to add a shorcut key in the: Tools -> options-> keymappings  view menu category. I hope someone finds this useful. Regards Domingo. ---------------------------------------------------------------------- LV · 2025-11-21 19:00 Quote from: DomingoGP on November 21, 2025, 07:38:21 pmI have made an Ide package than adds a menu item in the source  editor popup menu to open the url/file when the caret is over a link that starts by: file:// https:// http:// www. The link shoud be enclosed in quotes or double quotes if it has spaces If the caret is not over a link it does nothing. Also there is a command to add a shorcut key in the: Tools -> options-> keymappings  view menu category. I hope someone finds this useful. Regards Domingo. 👍 ---------------------------------------------------------------------- 440bx · 2025-11-21 20:35 Quote from: DomingoGP on November 21, 2025, 07:38:21 pmI have made an Ide package than adds a menu item in the source  editor popup menu to open the url/file when the caret is over a link that starts by: file:// https:// http:// www. Thank you very much Domingo.  That is great. This makes it the third package from you that I've installed and use.  The "save when switching app" I use constantly, likely hundreds of times a day.  The bookmark one, not nearly as often but, it is extremely convenient to have the bookmark list and being able to sort it by file.  Really makes life easier.  Now, this url one is just what the doctor ordered to have single click access to an API's documentation page.  I use this in my editor all the time and now I can use it from Lazarus without having to switch.  Extremely convenient. Domingo, thank you again. @LV, I appreciate your contribution too, it's just that Domingo's implementation is exactly what I wanted. Now that I said "exactly", actually, it's almost exactly what I wanted.  Two minor characteristics are missing, they are: 1. it would be really great if the OpenLink(URL) menu item was the first menu item (make it first only when the caret is on a url.)  That would make it faster to select. 2. it would be nice if the url was highlighted in some ways when right clicking on it (feedback that it is "selected") Note: those are very minor things, just "nice to have".  The feature is great as it is.  I suspect that implementing either one of those might require changes in SynEdit. ---------------------------------------------------------------------- DomingoGP · 2025-11-21 22:55 Quote from: 440bx on November 21, 2025, 09:35:52 pmDomingo, thank you again. You are welcome, I'm glad you liked it.  Quote from: 440bx on November 21, 2025, 09:35:52 pm1. it would be really great if the OpenLink(URL) menu item was the first menu item (make it first only when the caret is on a url.)  That would make it faster to select. The attached new version implements this and enables/disables the menu item  if the caret is/is not over  a link. Note that it takes into acount the caret position, not the mouse position, so You shoult press the left button first to change the caret position. Quote from: 440bx on November 21, 2025, 09:35:52 pm2. it would be nice if the url was highlighted in some ways when right clicking on it (feedback that it is "selected") I'm Sorry, but  I don't know at the moment how implement this, I guess that it needs a custom synedit Highlighter but I have no experience on this field. ---------------------------------------------------------------------- 440bx · 2025-11-22 07:31 Domingo, again, thank you! It's a small detail but, it makes it quicker and easier to activate the link.  Good stuff ---------------------------------------------------------------------- LV · 2025-11-22 20:18 Quote from: 440bx on November 21, 2025, 09:35:52 pmNow that I said "exactly", actually, it's almost exactly what I wanted.  Two minor characteristics are missing, they are: 1. it would be really great if the OpenLink(URL) menu item was the first menu item (make it first only when the caret is on a url.)  That would make it faster to select. 2. it would be nice if the url was highlighted in some ways when right clicking on it (feedback that it is "selected") Note: those are very minor things, just "nice to have".  The feature is great as it is.  I suspect that implementing either one of those might require changes in SynEdit. @440bx, I experimented a bit after work. Here's the package (attached). No context menus required. 1. Press Alt   -> the URL will be underlined (see screenshot). 2. Then, click -> the link will open in the browser. That's it. ---------------------------------------------------------------------- n7800 · 2025-11-22 21:21 Interesting implementation! Just a quick overview without testing... 1. You can use the RegisterChangeEvent events to hook for adding/removing editors: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SourceEditorManagerIntf.RegisterChangeEvent(semEditorDestroy, @MyHandl erDestroy);SourceEditorManagerIntf.RegisterChangeEvent(semEditorCreate , @MyHandlerCreate);{$if declared(semEditorCloned)} // since Lazarus 4.0SourceEditorManagerIntf.RegisterChangeEvent(semEditorCloned, @MyHandlerCreate); // also Create event{$endif} 2. Perhaps its other handlers will also be useful? 3. In the event of an error opening the URL, it's better to simply display a message box instead of raising an exception, which could lead to the loss of unsaved data. 4. It seems this won't work if another plugin also overrides event handlers (( By the way: * AltHighlightManager.Free can be called without checking for nil, since it's a class method. * Instead of "TSynEdit(EditorsList)", it's better to use "EditorsList as TSynEdit", since is checks the type before use (although I see you check it before assignment). ---------------------------------------------------------------------- 440bx · 2025-11-22 21:34 @LV, Unfortunately, I am not getting what you described.  Maybe I'm doing something wrong or maybe it is because I don't use the docked IDE ? Anyway, when I press the Alt key, Lazarus' main window comes to the top.  I can see that the url gets underlined for a split second but once the main window has come to the top, the url is no longer highlighted and clicking on it has no effect. Attached to this post are screenshots of "before pressing alt" and "after pressing alt".  Notice that the main window is obscured before pressing Alt, after Alt is pressed then what appears is what is in the second screenshot but, the url is not underlined and clicking on it has no effect. ---------------------------------------------------------------------- LV · 2025-11-22 21:46 @440bx, 1. Press Alt -> the link will be highlighted. 2. Hold Alt and left-click. ---------------------------------------------------------------------- 440bx · 2025-11-22 22:31 Quote from: LV on November 22, 2025, 10:46:52 pm@440bx, 1. Press Alt -> the link will be highlighted. 2. Hold Alt and left-click. Works perfectly!  Short and simple.  Thank you @LV, this is great ---------------------------------------------------------------------- LV · 2025-11-22 22:34 You're welcome. Good night. ---------------------------------------------------------------------- 440bx · 2025-11-23 10:36 @LV, There is a problem with the package.  When it is installed, quitting Lazarus results in Lazarus using 100% of the CPU for about 10 seconds before it ends. This is noticeable if you're running something like Process Hacker or Process Explorer where it is shown one CPU is pegged at 100% for roughly 10 seconds.  It seems to eventually end without leaving anything "bad" but, it shouldn't take that long to end.  When the package is not installed, Lazarus ends in fractions of a second. ---------------------------------------------------------------------- LV · 2025-11-23 14:16 @440bx, I was unable to reproduce your issue on two computers running Windows 11 with Lazarus 3.4 and trunk. The CPU load was nearly 0%, and in all tested cases, the Lazarus IDE closed "instantly". ---------------------------------------------------------------------- 440bx · 2025-11-23 15:47 Quote from: LV on November 23, 2025, 03:16:00 pm@440bx, I was unable to reproduce your issue on two computers running Windows 11 with Lazarus 3.4 and trunk. Just FYI, I am running Lazarus v4.0rc3 (release candidate) on Win 7 SP1 64 bit. Quote from: LV on November 23, 2025, 03:16:00 pmThe CPU load was nearly 0%, and in all tested cases, the Lazarus IDE closed "instantly". That's what should happen but, doesn't happen on my installation when the package is installed. Attached is a screenshot of CPU consumption when quitting Lazarus when the package is installed.  It took over 10 seconds for Lazarus to end and, noticeably, for some reason Lazarus does a lot of disc I/O when the package is installed (34.78MB/s in the screenshot and stays roughly at that number until Lazarus finally ends.) The CPU usage is 55.22% because this is a VM installation with 2 cores.  One core at 100% is 50% total CPU utilization. ---------------------------------------------------------------------- LV · 2025-11-23 19:06 @440bx, Everything works well on Windows 11. To understand why this is happening on Windows 7, I need to borrow a friend's computer or purchase a copy of Windows 7. I will try that next week. ---------------------------------------------------------------------- 440bx · 2025-11-23 20:02 Quote from: LV on November 23, 2025, 08:06:22 pm@440bx, Everything works well on Windows 11. To understand why this is happening on Windows 7, I need to borrow a friend's computer or purchase a copy of Windows 7. I will try that next week. I don't want you to go through that much trouble. The problem might also be that I'm using a different version of Lazarus than you are. In the meantime, I'm using Domingo's package which works fine. With hesitation, I'm going to mention that there are a fair number of places that offer free Windows 7 product keys (many of them are genuine, honest to goodness product keys of computers that have long been put "to sleep".)  Original ISOs are available from a fair number of reputable sites.  IOW, you could install it in a Hyper-V VM at no cost. The one potential problem is that in your hunt for good product keys you'll run into some "less than reputable" sites that could be problematic if you're not _very_ careful. HTH. ---------------------------------------------------------------------- LV · 2025-11-25 17:58 I find the topic discussed in this post quite interesting. I have worked on the package and am currently using it in my projects with Lazarus on Windows 11. Anyone is welcome to test it, modify it as they wish, and use it for their own purposes. Ctrl+Click URL Highlighter for Lazarus IDE This package adds Ctrl+Click URL navigation to the Lazarus IDE, as well as URL highlighting when holding Ctrl. It works similarly to URL navigation in modern IDEs. Features -Detects URLs inside source code:   - http://…   - https://…   - ftp://…   - file://…   - www.… - Underlines the URL when hovering with the mouse while holding Ctrl - Changes the mouse cursor to a hand when hovering over a link - Opens the URL in the browser via Ctrl + LeftClick - Fully supports the first editor tab (handles Lazarus initialization order) How it Works The package attaches the following handlers to every TSynEdit inside the source editor: - OnMouseMove — detects mouse position - OnPaint — draws the underline under the URL - OnKeyDown/OnKeyUp — tracks Ctrl key state - OnMouseDown — handles Ctrl+Click - semEditorCreate and semEditorActivate — attaches handlers to newly created and already existing editors When the mouse is over a URL and Ctrl is pressed, the package highlights it; when Ctrl+Click is performed, it calls OpenURL or OpenDocument. Installation 1. Open Lazarus. 2. Go to Package → Open Package File (.lpk). 3. Select SynEditOpenURL.lpk. 4. Click Compile. 5. Click Use → Install and confirm Lazarus restart. After Lazarus restarts, the functionality is enabled automatically. Known Limitations - Underline appears only while holding Ctrl. - URL detection is limited to a specific set of characters. Project Structure SynEditOpenURL/  ├─ SynEditOpenURL.pas        — main module  ├─ SynEditOpenURL.lpk        — Lazarus package  └─ README.md                 — documentation License Free to use. You may include it in your own projects and modify it as needed. ---------------------------------------------------------------------- 440bx · 2025-11-25 18:26 @LV, I just tried the package and I'm pleased to report that the delay when closing Lazarus is now gone.  Well done. Thank you!