Fixes #4850 - Show URL of Link in Tooltip (+ StatusBar in UICatalog)#4850
Fixes #4850 - Show URL of Link in Tooltip (+ StatusBar in UICatalog)#4850tig merged 35 commits intogui-cs:v2_developfrom
Conversation
|
Very cool idea. You get extra credit if instead of changing the text drawn on hover you use a Popover to show a "tool tip". I've long wanted this capabilitiy. You'd modify If you are not interested, no biggie... we'll get to it eventually. |
I like this idea too. Should I keep the same PR / branch? |
Sure. Just edit titles. |
|
@tig My terminal already shows native tooltips via OSC 8 hyperlinks.
|
|
As far as I know only WT does that. |
Add
|
Refactored the UICatalog About dialog to use a new ShowAboutDialog method with a Dialog, tagline, ASCII art, and a clickable Link to the project URL. Removed GetAboutBoxMessage and made AboutUrl a public constant. Updated Link to trigger Command.Activate on mouse click and moved URL opening logic to OnActivated. OpenUrl now checks for the "DisableRealDriverIO" environment variable. Simplified UseToolTip property and improved tooltip management. Clarified hotkey handling in Link. Removed obsolete About box test from TextFormatterDrawTests.cs.
Replace MessageBox.Query with a custom Dialog containing 3 subviews: - Tagline label - GradientArtView: Terminal.Gui logo in box-drawing chars with diagonal color gradient - Link view with clickable GitHub URL and tooltip Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@ccoulioufr please see my updates. a) Activating instead of Accepting Thoughts? |
|
@tig I was thinking about a more global handling of tooltips. |
|
Here it is: 🧠 Design & Implementation RationaleThis PR introduces a tooltip system designed to be simple, flexible, and low-overhead, while remaining consistent with existing UI patterns. 🔹 Shared
|
|
I think I like it all except View.UseToolTip. this is not true:
This property adds at least 8 bytes to View. I've been working hard to reduce View footprint. It's a huge class. If we can avoid adding more properties to it we should. Instead how about defining ITooltip that has an EnableToolTip bool. Any View subclass that wants to support tooltips can implement this interface. Will that work? We'll want to provide a defult implementation (ToolTipImpl) so View authors can just inherit from that. Or, it coudl be done like how IOrientation works with OrientationHelper. |
|
@tig I will rework it, taking these points into account. |
🔄 Refactor: Tooltip System SimplificationThis PR significantly refactors the tooltip system to improve simplicity, flexibility, and maintainability. 🔹 Avoid ToolTipImpl and IToolTipable
Why:
🔹 Introduced Extension-Based APITooltip support is now provided via extension methods on View: view.SetToolTip("Hello");
view.SetToolTip(() => dynamicText);
view.SetToolTip(() => new Label { Text = "Custom" });
view.RemoveToolTip();Benefits:
🔹 Unified ToolTipProviderA single ToolTipProvider class is used to define tooltip content:
This replaces multiple competing properties and removes ambiguity. view.SetToolTip(new ToolTipProvider(() => Url));🔹 Centralized State in TooltipManager
This avoids storing tooltip-related state inside View. 🔹 Safe Cleanup via DisposingTooltip registrations are now automatically cleaned up: target.Disposing += OnDisposing;
🔹 API Summaryview.SetToolTip("Text");
view.SetToolTip(() => dynamicText);
view.SetToolTip(() => new CustomView());
view.RemoveToolTip();✅ ResultThis refactor delivers:
|
There was a problem hiding this comment.
Pull request overview
Updates Terminal.Gui’s Link UX to be more browser-like by surfacing the destination URL on hover (UICatalog StatusBar) and introducing a new tooltip infrastructure used to show link URLs by default.
Changes:
- Update
Linkto open viaCommand.Activateand set a default tooltip that returnsUrl. - Add new tooltip infrastructure (
ToolTipHost,ToolTipProvider,TooltipManager, and view extensions) and wire it intoLink. - Update UICatalog (Links scenario + About dialog) and adjust/remove related tests.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| Tests/UnitTestsParallelizable/Views/LinkTests.cs | Updates expectations for Link.Url default behavior and OSC8 suppression. |
| Tests/UnitTestsParallelizable/Text/TextFormatterDrawTests.cs | Removes UICatalog about-box text rendering test and associated dependency. |
| Terminal.sln.DotSettings | Adds coord to the user dictionary. |
| Terminal.Gui/Views/Link.cs | Switches click behavior to Activate, adds default tooltip, adjusts URL opening guard, and updates acceptance/activation handling. |
| Terminal.Gui/App/Popovers/ToolTipProvider.cs | Adds a provider wrapper for tooltip content/view factories. |
| Terminal.Gui/App/Popovers/ToolTipManager.cs | Introduces a singleton tooltip manager handling hover registration and shared tooltip display. |
| Terminal.Gui/App/Popovers/ToolTipHost.cs | Adds a Popover-based host for tooltip content with positioning logic. |
| Terminal.Gui/App/Popovers/TooTipExtensions.cs | Adds View extension methods for setting/removing tooltips. |
| Examples/UICatalog/UICatalogRunnable.cs | Refactors About dialog to a custom dialog containing a Link and gradient logo view. |
| Examples/UICatalog/Scenarios/Links.cs | Updates StatusBar hover indicator to show _link.Url instead of _link.Text. |
Refactored ToolTipExtensions to use a local static extension class for cleaner instance method usage. Updated method signatures, improved XML documentation formatting, and streamlined TooltipManager event registration. Applied minor code style fixes and updated the Link class to use the new tooltip extension pattern.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@ccoulioufr Please see the code review comments and fix the issues. Also, and this is probably due to #4850 (comment), when I run the LInks Scenrio in UICatalgo and hover over the example link, then quit the scenario there are errors about non-disposed views. This must be fixed. Thanks. |
|
@tig Here is the first batch of fixes. |
|
@tig I don't manage to reproduce the failed test on my computer. Any advice? |
If you have resharper, run the tests until failure:
the problem is this: public static ToolTipManager Instance { get; } = new ();This breaks multiple apps running in parallel in the same process. |
ApplicationToolTip: Thread-Safe Tooltip ManagementSummaryRefactored tooltip management to support parallel test execution by eliminating the singleton pattern and integrating tooltip management at the ProblemThe previous SolutionRenamed ChangesArchitecture
Benefits✅ Thread-safe: Each Testing
Related
|
…ioufr/Terminal.Gui into fix/show-link-url-on-enter
- Code Cleanup of UI Catalog to fix nullability risks - Replace Label+URL with Link controls in AnimationScenario and FileDialogExamples; add tooltips for links. - Refactor Links scenario to use local variables, add API docs link, and show URL in status bar on hover. - Rename AboutUrl to ABOUT_URL and add tooltip in UICatalogRunnable. - Apply code style improvements: pattern matching, event handler syntax, and field cleanup.
Update Link text to show 'Terminal.Gui.Views.Link' Changed Link control text from "Docs" to "Terminal.Gui.Views.Link" for clearer destination indication; URL remains unchanged.
|
@ccoulioufr I did some code cleanup and updated other places where urls were used to use Link. I think this is ready to merge, although there is a bug in the output render with OSC8 where it's not getting cleared properly: I recommend we merge what we have here and then fix that bug in a separate issue. |
Moved and updated IDesignable.EnableForDesign to set Title, Url, and attach a tooltip on Initialized. The tooltip informs users that the Link opens the URL in the default browser.
|
Great news!
|
Remove default left-click activation from Link Removed MouseBindings.Add for LeftButtonClicked in Link, so clicking a Link no longer triggers Activate by default.
Fixed... |



Fixes
Rationale: This change makes the link hover behavior browser-like. When hovering over a hyperlink, users expect to see the destination URL in the status bar (similar to web browsers), not the display text. This provides better UX by allowing users to preview where the link will take them before clicking, matching the familiar behavior from modern browsers.
Testing