Refactor newinv2.md deep dive doc

Terminal.Gui v2 introduces a transformative redesign, simplifying the library's architecture and improving maintainability. Key changes include:

- Added TrueColor support with 24-bit RGB handling.
- Introduced `Adornment` framework for borders, padding, and margins.
- Enhanced Unicode and wide character support for internationalization.
- Added `LineCanvas` for drawing lines and shapes with box-drawing characters.
- Simplified API by consolidating redundant methods and aligning with modern .NET standards.
- Introduced `ConfigurationManager` for user-customizable themes and text styles.
- Improved scrolling with `Viewport` and integrated `ScrollBar`.
- Added new layout features like `Dim.Auto`, `Pos.AnchorEnd`, and `Pos.Align`.
- Overhauled keyboard and mouse APIs for better input handling.
- Introduced new views (e.g., `DatePicker`, `ColorPicker`, `GraphView`) and enhanced existing ones.
- Added Sixel image support for rendering graphics in compatible terminals.
- Ensured AOT compatibility for improved deployment and performance.

This update lays the foundation for building modern, user-friendly terminal applications.
This commit is contained in:
Tig
2025-10-26 09:56:55 -06:00
parent 7b4ad8cb59
commit 76b8f026e8

View File

@@ -18,32 +18,32 @@ This architectural shift has resulted in the removal of thousands of lines of re
## Modern Look & Feel - Technical Details
### TrueColor Support
- **Implementation**: v2 introduces 24-bit color support by extending the `Attribute` class to handle RGB values, with fallback to 16-color mode for older terminals. This is evident in the `ConsoleDriver` implementations, which now map colors to the appropriate terminal escape sequences.
- **Impact**: Developers can now use a full spectrum of colors without manual palette management, as seen in v1. The `Color` struct in v2 supports direct RGB input, and drivers handle the translation to terminal capabilities.
- **Usage**: See the `ColorPicker` view for an example of how TrueColor is leveraged to provide a rich color selection UI.
- **Implementation**: v2 introduces 24-bit color support by extending the @Terminal.Gui.Drawing.Attribute class to handle RGB values, with fallback to 16-color mode for older terminals. This is evident in the @Terminal.Gui.Drivers.IConsoleDriver implementations, which now map colors to the appropriate terminal escape sequences.
- **Impact**: Developers can now use a full spectrum of colors without manual palette management, as seen in v1. The @Terminal.Gui.Drawing.Color struct in v2 supports direct RGB input, and drivers handle the translation to terminal capabilities via [IConsoleDriver.SupportsTrueColor](~/api/Terminal.Gui.Drivers.IConsoleDriver.yml#Terminal_Gui_Drivers_IConsoleDriver_SupportsTrueColor).
- **Usage**: See the [ColorPicker](~/api/Terminal.Gui.Views.ColorPicker.yml) view for an example of how TrueColor is leveraged to provide a rich color selection UI.
### Enhanced Borders and Padding (Adornments)
- **Implementation**: v2 introduces a new `Adornment` class hierarchy, with `Margin`, `Border`, and `Padding` as distinct view-like entities that wrap content. This is a significant departure from v1, where borders were often hardcoded or required custom drawing.
- **Code Change**: In v1, `View` had rudimentary border support via properties like `BorderStyle`. In v2, `View` has a `Border` property of type `Border`, which is itself a configurable entity with properties like `Thickness` and `Effect3D`.
- **Implementation**: v2 introduces a new @Terminal.Gui.ViewBase.Adornment class hierarchy, with @Terminal.Gui.ViewBase.Margin, @Terminal.Gui.ViewBase.Border, and @Terminal.Gui.ViewBase.Padding as distinct view-like entities that wrap content. This is a significant departure from v1, where borders were often hardcoded or required custom drawing.
- **Code Change**: In v1, @Terminal.Gui.ViewBase.View had rudimentary border support via properties like `BorderStyle`. In v2, @Terminal.Gui.ViewBase.View has a @Terminal.Gui.ViewBase.View.Border property of type @Terminal.Gui.ViewBase.Border, which is itself a configurable entity with properties like @Terminal.Gui.Drawing.Thickness, [Border.LineStyle](~/api/Terminal.Gui.ViewBase.Border.yml#Terminal_Gui_ViewBase_Border_LineStyle), and [Border.Settings](~/api/Terminal.Gui.ViewBase.Border.yml#Terminal_Gui_ViewBase_Border_Settings).
- **Impact**: This allows for consistent border rendering across all views and simplifies custom view development by providing a reusable adornment framework.
### User Configurable Color Themes
- **Implementation**: v2 adds a `ConfigurationManager` that supports loading and saving color schemes from configuration files. Themes are applied via `ColorScheme` objects, which can be customized per view or globally.
- **Impact**: Unlike v1, where color schemes were static or required manual override, v2 enables end-users to personalize the UI without code changes, enhancing accessibility and user preference support.
### User Configurable Color Themes and Text Styles
- **Implementation**: v2 adds a @Terminal.Gui.Configuration.ConfigurationManager that supports loading and saving color schemes from configuration files. Themes are applied via @Terminal.Gui.Drawing.Scheme objects, which can be customized per view or globally. Each @Terminal.Gui.Drawing.Attribute in a @Terminal.Gui.Drawing.Scheme now includes a [TextStyle](~/api/Terminal.Gui.Drawing.TextStyle.yml) property supporting Bold, Italic, Underline, Strikethrough, Blink, Reverse, and Faint text styles.
- **Impact**: Unlike v1, where color schemes were static or required manual override, v2 enables end-users to personalize not just colors but also text styling (bold, italic, underline, etc.) without code changes, significantly enhancing accessibility and user preference support.
### Enhanced Unicode/Wide Character Support
- **Implementation**: v2 improves Unicode handling by correctly managing wide characters in text rendering and input processing. The `TextFormatter` class now accounts for Unicode width in layout calculations.
- **Implementation**: v2 improves Unicode handling by correctly managing wide characters in text rendering and input processing. The [TextFormatter](~/api/Terminal.Gui.Text.TextFormatter.yml) class now accounts for Unicode width in layout calculations.
- **Impact**: This fixes v1 issues where wide characters (e.g., CJK scripts) could break layout or input handling, making Terminal.Gui v2 suitable for international applications.
### LineCanvas
- **Implementation**: A new `LineCanvas` class provides a drawing API for creating lines and shapes using box-drawing characters. It includes logic for auto-joining lines at intersections, selecting appropriate glyphs dynamically.
- **Code Example**: In v2, `LineCanvas` is used internally by views like `Border` to draw clean, connected lines, a feature absent in v1.
- **Implementation**: A new [LineCanvas](~/api/Terminal.Gui.Drawing.LineCanvas.yml) class provides a drawing API for creating lines and shapes using box-drawing characters. It includes logic for auto-joining lines at intersections, selecting appropriate glyphs dynamically.
- **Code Example**: In v2, [LineCanvas](~/api/Terminal.Gui.Drawing.LineCanvas.yml) is used internally by views like @Terminal.Gui.ViewBase.Border and @Terminal.Gui.Views.Line to draw clean, connected lines, a feature absent in v1.
- **Impact**: Developers can create complex diagrams or UI elements with minimal effort, improving the visual fidelity of terminal applications.
## Simplified API - Under the Hood
### API Consistency and Reduction
- **Change**: v2 revisits every public API, consolidating redundant methods and properties. For example, v1 had multiple focus-related methods scattered across `View` and `Application`; v2 centralizes these in `ApplicationNavigation`.
- **Change**: v2 revisits every public API, consolidating redundant methods and properties. For example, v1 had multiple focus-related methods scattered across @Terminal.Gui.ViewBase.View and @Terminal.Gui.App.Application; v2 centralizes these in [ApplicationNavigation](~/api/Terminal.Gui.App.ApplicationNavigation.yml).
- **Impact**: This reduces the learning curve for new developers and minimizes the risk of using deprecated or inconsistent APIs.
- **Example**: The v1 `View.MostFocused` property is replaced by `Application.Navigation.GetFocused()`, reducing traversal overhead and clarifying intent.
@@ -63,112 +63,127 @@ This architectural shift has resulted in the removal of thousands of lines of re
- **Impact**: Developers can predict when resources are released, reducing bugs related to dangling references or uninitialized states.
### Adornments Framework
- **Technical Detail**: Adornments are implemented as nested views that surround the content area, each with its own drawing and layout logic. For instance, `Border` can draw 3D effects or custom glyphs.
- **Code Change**: In v2, `View` has properties like `Margin`, `Border`, and `Padding`, each configurable independently, unlike v1's limited border support.
- **Technical Detail**: Adornments are implemented as nested views that surround the content area, each with its own drawing and layout logic. @Terminal.Gui.ViewBase.Border supports multiple @Terminal.Gui.Drawing.LineStyle options (Single, Double, Heavy, Rounded, Dashed, Dotted) with automatic line intersection handling via [LineCanvas](~/api/Terminal.Gui.Drawing.LineCanvas.yml).
- **Code Change**: In v2, @Terminal.Gui.ViewBase.View has properties @Terminal.Gui.ViewBase.View.Margin, @Terminal.Gui.ViewBase.View.Border, and @Terminal.Gui.ViewBase.View.Padding, each configurable independently, unlike v1's limited border support.
- **Impact**: This modular approach allows for reusable UI elements and simplifies creating visually consistent applications.
### Built-in Scrolling/Virtual Content Area
- **v1 Issue**: Scrolling required using `ScrollView` or manual offset management, which was error-prone.
- **v2 Solution**: Every `View` in v2 has a `Viewport` rectangle representing the visible portion of a potentially larger content area defined by `GetContentSize()`. Changing `Viewport.Location` scrolls the content.
- **Code Example**: In v2, `TextView` uses this to handle large text buffers without additional wrapper views.
- **v2 Solution**: Every @Terminal.Gui.ViewBase.View in v2 has a @Terminal.Gui.ViewBase.View.Viewport rectangle representing the visible portion of a potentially larger content area defined by [View.GetContentSize](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_GetContentSize). Changing `Viewport.Location` scrolls the content.
- **Code Example**: In v2, [TextView](~/api/Terminal.Gui.Views.TextView.yml) uses this to handle large text buffers without additional wrapper views.
- **Impact**: Simplifies implementing scrollable content and reduces the need for specialized container views.
### Improved ScrollBar
- **Change**: v2 replaces `ScrollBarView` with `ScrollBar`, a cleaner implementation integrated with the built-in scrolling system. `VerticalScrollBar` and `HorizontalScrollBar` properties on `View` enable scroll bars with minimal code.
- **Change**: v2 replaces `ScrollBarView` with [ScrollBar](~/api/Terminal.Gui.Views.ScrollBar.yml), a cleaner implementation integrated with the built-in scrolling system. @Terminal.Gui.ViewBase.View.VerticalScrollBar and @Terminal.Gui.ViewBase.View.HorizontalScrollBar properties enable scroll bars with minimal code.
- **Impact**: Developers can add scroll bars to any view without managing separate view hierarchies, a significant usability improvement over v1.
### DimAuto, PosAnchorEnd, and PosAlign
- **DimAuto**: Automatically sizes views based on content or subviews, reducing manual layout calculations.
- **PosAnchorEnd**: Allows anchoring to the right or bottom of a superview, enabling flexible layouts not easily achievable in v1.
- **PosAlign**: Provides alignment options (left, center, right) for multiple views, streamlining UI design.
- **[Dim.Auto](~/api/Terminal.Gui.Dim.yml#Terminal_Gui_Dim_Auto_Terminal_Gui_DimAutoStyle_Terminal_Gui_Dim_Terminal_Gui_Dim_)**: Automatically sizes views based on content or subviews, reducing manual layout calculations.
- **[Pos.AnchorEnd](~/api/Terminal.Gui.Pos.yml#Terminal_Gui_Pos_AnchorEnd_System_Int32_)**: Allows anchoring to the right or bottom of a superview, enabling flexible layouts not easily achievable in v1.
- **[Pos.Align](~/api/Terminal.Gui.Pos.yml)**: Provides alignment options (left, center, right) for multiple views, streamlining UI design.
- **Impact**: These features reduce boilerplate layout code and support responsive designs in terminal constraints.
### View Arrangement
- **Technical Detail**: The `Arrangement` property on `View` supports flags like `Movable`, `Resizable`, and `Overlapped`, enabling dynamic UI interactions via keyboard and mouse.
- **Code Example**: `Window` in v2 uses `Arrangement` to allow dragging and resizing, a feature requiring custom logic in v1.
- **Technical Detail**: The @Terminal.Gui.ViewBase.View.Arrangement property supports flags like @Terminal.Gui.ViewBase.ViewArrangement.Movable, @Terminal.Gui.ViewBase.ViewArrangement.Resizable, and @Terminal.Gui.ViewBase.ViewArrangement.Overlapped, enabling dynamic UI interactions via keyboard and mouse.
- **Code Example**: [Window](~/api/Terminal.Gui.Views.Window.yml) in v2 uses @Terminal.Gui.ViewBase.View.Arrangement to allow dragging and resizing, a feature requiring custom logic in v1.
- **Impact**: Developers can create desktop-like experiences in the terminal with minimal effort.
### Keyboard Navigation Overhaul
- **v1 Issue**: Navigation was inconsistent, with coupled concepts like `CanFocus` and `TabStop` leading to unpredictable focus behavior.
- **v2 Solution**: v2 decouples these concepts, introduces `TabBehavior` enum for clearer intent (`TabStop`, `TabGroup`, `NoStop`), and centralizes navigation logic in `ApplicationNavigation`.
- **v1 Issue**: Navigation was inconsistent, with coupled concepts like @Terminal.Gui.ViewBase.View.CanFocus and `TabStop` leading to unpredictable focus behavior.
- **v2 Solution**: v2 decouples these concepts, introduces @Terminal.Gui.Input.TabBehavior enum for clearer intent (`TabStop`, `TabGroup`, `NoStop`), and centralizes navigation logic in [ApplicationNavigation](~/api/Terminal.Gui.App.ApplicationNavigation.yml).
- **Impact**: Ensures accessibility by guaranteeing keyboard access to all focusable elements, with unit tests enforcing navigation keys on built-in views.
### Sizable/Movable Views
- **Implementation**: Any view can be made resizable or movable by setting `Arrangement` flags, with built-in mouse and keyboard handlers for interaction.
- **Impact**: Enhances user experience by allowing runtime UI customization, a feature limited to specific views like `Window` in v1.
- **Implementation**: Any view can be made resizable or movable by setting @Terminal.Gui.ViewBase.View.Arrangement flags, with built-in mouse and keyboard handlers for interaction.
- **Impact**: Enhances user experience by allowing runtime UI customization, a feature limited to specific views like [Window](~/api/Terminal.Gui.Views.Window.yml) in v1.
## New and Improved Built-in Views - Detailed Analysis
### New Views
- **DatePicker**: Provides a calendar-based date selection UI, leveraging v2's improved drawing and navigation systems.
- **Slider**: A new control for range selection, using `LineCanvas` for smooth rendering and supporting TrueColor for visual feedback.
- **Shortcut**: An opinionated view for command display with key bindings, simplifying status bar or toolbar creation.
- **Bar**: A foundational view for horizontal or vertical layouts of `Shortcut` or other items, used in `StatusBar`, `MenuBar`, and `PopoverMenu`.
- **FileDialog**: Modernized with a `TreeView` for navigation, icons using Unicode glyphs, and search functionality, far surpassing v1's basic dialog.
- **ColorPicker**: Leverages TrueColor for a comprehensive color selection experience, supporting multiple color models (HSV, RGB, HSL).
v2 introduces many new View subclasses that were not present in v1:
- **Bar**: A foundational view for horizontal or vertical layouts of `Shortcut` or other items, used in `StatusBar`, `MenuBarv2`, and `PopoverMenu`.
- **CharMap**: A scrollable, searchable Unicode character map with support for the Unicode Character Database (UCD) API, enabling users to browse and select from all Unicode codepoints with detailed character information.
- **ColorPicker**: Leverages TrueColor for a comprehensive color selection experience, supporting multiple color models (HSV, RGB, HSL, Grayscale) with interactive color bars.
- **DatePicker**: Provides a calendar-based date selection UI with month/year navigation, leveraging v2's improved drawing and navigation systems.
- **FlagSelector**: Enables selection of non-mutually-exclusive flags with checkbox-based UI, supporting both dictionary-based and enum-based flag definitions.
- **GraphView**: Displays graphs (bar charts, scatter plots, line graphs) with flexible axes, labels, scaling, scrolling, and annotations - bringing data visualization to the terminal.
- **Line**: Draws single horizontal or vertical lines using the `LineCanvas` system with automatic intersection handling and multiple line styles (Single, Double, Heavy, Rounded, Dashed, Dotted).
- **Menuv2 System** (MenuBarv2, PopoverMenu): A completely redesigned menu system built on the `Bar` infrastructure, providing a more flexible and visually appealing menu experience.
- **NumericUpDown<T>**: Type-safe numeric input with increment/decrement buttons, supporting `int`, `long`, `float`, `double`, and `decimal` types.
- **OptionSelector**: Displays a list of mutually-exclusive options with checkbox-style UI (radio button equivalent), supporting both horizontal and vertical orientations.
- **Shortcut**: An opinionated view for displaying commands with key bindings, simplifying status bar and toolbar creation with consistent visual presentation.
- **Slider**: A sophisticated control for range selection with multiple styles (horizontal/vertical bars, indicators), multiple options per slider, configurable legends, and event-driven value changes.
- **SpinnerView**: Displays animated spinner glyphs to indicate progress or activity, with multiple built-in styles (Line, Dots, Bounce, etc.) and support for auto-spin or manual animation control.
### Improved Views
- **ScrollView**: Deprecated in favor of built-in scrolling on `View`, reducing complexity and view hierarchy depth.
- **TableView**: Now supports generic collections, checkboxes, and tree structures, moving beyond v1's `DataTable` limitation, with improved rendering performance.
- **StatusBar**: Rebuilt on `Bar`, providing a more flexible and visually appealing status display.
Many existing views from v1 have been significantly enhanced in v2:
- **FileDialog** (OpenDialog, SaveDialog): Completely modernized with `TreeView` for hierarchical file navigation, Unicode glyphs for icons, search functionality, and history tracking - far surpassing v1's basic file dialogs.
- **ScrollBar**: Replaces v1's `ScrollBarView` with a cleaner implementation featuring automatic show/hide, proportional sizing with `ScrollSlider`, and seamless integration with View's built-in scrolling system.
- **StatusBar**: Rebuilt on the `Bar` infrastructure, providing more flexible item management, automatic sizing, and better visual presentation.
- **TableView**: Massively enhanced with support for generic collections (via `IEnumerableTableSource`), checkboxes with `CheckBoxTableSourceWrapper`, tree structures via `TreeTableSource`, custom cell rendering, and significantly improved performance.
- **ScrollView**: Deprecated in favor of View's built-in scrolling capabilities, eliminating the need for wrapper views and simplifying scrollable content implementation.
## Beauty - Visual Enhancements
### Borders
- **Implementation**: Uses the `Border` adornment to render 3D effects or custom styles, configurable per view.
- **Impact**: Adds visual depth to UI elements, making applications feel more polished compared to v1's flat borders.
- **Implementation**: Uses the @Terminal.Gui.ViewBase.Border adornment with @Terminal.Gui.Drawing.LineStyle options and [LineCanvas](~/api/Terminal.Gui.Drawing.LineCanvas.yml) for automatic line intersection handling.
- **Impact**: Adds visual polish to UI elements, making applications feel more refined compared to v1's basic borders.
### Gradient
- **Implementation**: A new `Gradient` API allows rendering color transitions across view elements, using TrueColor for smooth effects.
- **Implementation**: [Gradient](~/api/Terminal.Gui.Drawing.Gradient.yml) and [GradientFill](~/api/Terminal.Gui.Drawing.GradientFill.yml) APIs allow rendering color transitions across view elements, using TrueColor for smooth effects.
- **Impact**: Enables modern-looking UI elements like gradient borders or backgrounds, not possible in v1 without custom drawing.
## Configuration Manager - Persistence and Customization
- **Technical Detail**: `ConfigurationManager` in v2 uses JSON or other formats to persist settings like themes, key bindings, and view properties to disk.
- **Code Change**: Unlike v1, where settings were ephemeral or hardcoded, v2 provides a centralized system for loading/saving configurations.
- **Technical Detail**: @Terminal.Gui.Configuration.ConfigurationManager in v2 uses JSON to persist settings like themes, key bindings, and view properties to disk via @Terminal.Gui.Configuration.SettingsScope and [ConfigLocations](~/api/Terminal.Gui.Configuration.ConfigLocations.yml).
- **Code Change**: Unlike v1, where settings were ephemeral or hardcoded, v2 provides a centralized system for loading/saving configurations using the [ConfigurationManagerAttribute](~/api/Terminal.Gui.Configuration.ConfigurationManagerAttribute.yml).
- **Impact**: Allows for user-specific customizations and library-wide settings without recompilation, enhancing flexibility.
## Logging & Metrics - Debugging and Performance
- **Implementation**: v2 introduces a multi-level logging system for internal operations (e.g., rendering, input handling) and metrics for performance tracking (e.g., frame rate, redraw times).
- **Impact**: Developers can diagnose issues like slow redraws or terminal compatibility problems, a capability absent in v1, reducing guesswork in debugging.
- **Implementation**: v2 introduces a multi-level logging system via [Logging](~/api/Terminal.Gui.App.Logging.yml) for internal operations (e.g., rendering, input handling) using Microsoft.Extensions.Logging.ILogger, and metrics for performance tracking via [Logging.Meter](~/api/Terminal.Gui.App.Logging.yml#Terminal_Gui_App_Logging_Meter) (e.g., frame rate, redraw times, iteration timing).
- **Impact**: Developers can diagnose issues like slow redraws or terminal compatibility problems using standard .NET logging frameworks (Serilog, NLog, etc.) and metrics tools (dotnet-counters), a capability absent in v1, reducing guesswork in debugging.
## Sixel Image Support - Graphics in Terminal
- **Technical Detail**: v2 supports the Sixel protocol for rendering images and animations directly in compatible terminals (e.g., Windows Terminal, xterm).
- **Code Change**: New rendering logic in console drivers detects terminal support and handles Sixel data transmission.
- **Technical Detail**: v2 supports the Sixel protocol for rendering images and animations directly in compatible terminals (e.g., Windows Terminal, xterm) via [SixelEncoder](~/api/Terminal.Gui.Drawing.SixelEncoder.yml).
- **Code Change**: New rendering logic in console drivers detects terminal support via [SixelSupportDetector](~/api/Terminal.Gui.Drawing.SixelSupportDetector.yml) and handles Sixel data transmission through [SixelToRender](~/api/Terminal.Gui.Drawing.SixelToRender.yml).
- **Impact**: Brings graphical capabilities to terminal applications, far beyond v1's text-only rendering, opening up new use cases like image previews.
## Updated Keyboard API - Comprehensive Input Handling
### Key Class
- **Change**: Replaces v1's `KeyEvent` struct with a `Key` class, providing a high-level abstraction over raw key codes with properties for modifiers and key type.
- **Change**: Replaces v1's `KeyEvent` struct with a [Key](~/api/Terminal.Gui.Input.Key.yml) class, providing a high-level abstraction over raw key codes with properties for modifiers and key type.
- **Impact**: Simplifies keyboard handling by abstracting platform differences, making code more portable and readable.
### Key Bindings
- **Implementation**: v2 introduces a binding system mapping keys to `Command` enums via `View.KeyBindings`, with scopes (`Application`, `Focused`, `HotKey`) for priority.
- **Impact**: Replaces v1's ad-hoc key handling with a structured approach, allowing views to declare supported commands and customize responses easily.
- **Example**: `TextField` in v2 binds `Key.Tab` to text insertion rather than focus change, customizable by developers.
- **Implementation**: v2 introduces a binding system mapping keys to @Terminal.Gui.Input.Command enums via @Terminal.Gui.ViewBase.View.KeyBindings, with scopes (`Application`, `Focused`, `HotKey`) for priority.
- **Impact**: Replaces v1's ad-hoc key handling with a structured approach, allowing views to declare supported commands via @Terminal.Gui.ViewBase.View.AddCommand and customize responses easily.
- **Example**: [TextField](~/api/Terminal.Gui.Views.TextField.yml) in v2 binds `Key.Tab` to text insertion rather than focus change, customizable by developers.
### Default Close Key
- **Change**: Changed from `Ctrl+Q` in v1 to `Esc` in v2 for closing apps or `Toplevel` views.
- **Change**: Changed from `Ctrl+Q` in v1 to `Esc` in v2 for closing apps or @Terminal.Gui.Views.Toplevel views, accessible via [Application.QuitKey](~/api/Terminal.Gui.App.Application.yml#Terminal_Gui_App_Application_QuitKey).
- **Impact**: Aligns with common user expectations, improving UX consistency across terminal applications.
## Updated Mouse API - Enhanced Interaction
### MouseEvent Class
- **Change**: Replaces `MouseEventEventArgs` with `MouseEvent`, providing a cleaner structure for mouse data (position, flags).
### MouseEventArgs Class
- **Change**: Replaces v1's `MouseEventEventArgs` with [MouseEventArgs](~/api/Terminal.Gui.Input.MouseEventArgs.yml), providing a cleaner structure for mouse data (position, flags via @Terminal.Gui.Input.MouseFlags).
- **Impact**: Simplifies event handling with a more intuitive API, reducing errors in mouse interaction logic.
### Granular Mouse Handling
- **Implementation**: v2 offers specific events for clicks, double-clicks, and movement, with flags for button states.
- **Implementation**: v2 offers specific events for clicks (@Terminal.Gui.ViewBase.View.MouseClick), double-clicks, and movement, with [MouseFlags](~/api/Terminal.Gui.Input.MouseFlags.yml) for button states.
- **Impact**: Developers can handle complex mouse interactions (e.g., drag-and-drop) more easily than in v1.
### Highlight Event and Continuous Button Presses
- **Highlight**: Views can visually respond to mouse hover or click via the `Highlight` event.
- **Continuous Presses**: Setting `WantContinuousButtonPresses = true` repeats `Command.Accept` during button hold, useful for sliders or buttons.
- **Highlight**: Views can visually respond to mouse hover or click via the @Terminal.Gui.ViewBase.View.Highlight event and [View.HighlightStyle](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_HighlightStyle) property.
- **Continuous Presses**: Setting @Terminal.Gui.ViewBase.View.WantContinuousButtonPresses = true repeats @Terminal.Gui.Input.Command.Accept during button hold, useful for sliders or buttons.
- **Impact**: Enhances interactive feedback, making terminal UIs feel more responsive.
## AOT Support - Deployment and Performance
- **Implementation**: v2 ensures compatibility with Ahead-of-Time compilation and single-file applications by avoiding reflection patterns problematic for AOT.
- **Impact**: Simplifies deployment for environments requiring AOT (e.g., .NET Native), a feature not explicitly supported in v1, reducing runtime overhead.
- **Implementation**: v2 ensures compatibility with Ahead-of-Time compilation and single-file applications by avoiding reflection patterns problematic for AOT, using source generators and [SourceGenerationContext](~/api/Terminal.Gui.Configuration.SourceGenerationContext.yml) for JSON serialization.
- **Impact**: Simplifies deployment for environments requiring Native AOT (see `Examples/NativeAot`), a feature not explicitly supported in v1, reducing runtime overhead and enabling faster startup times.
## Conclusion