Skip to content

Feature/pager#39

Merged
trackd merged 17 commits intomainfrom
feature/pager
Mar 16, 2026
Merged

Feature/pager#39
trackd merged 17 commits intomainfrom
feature/pager

Conversation

@trackd
Copy link
Owner

@trackd trackd commented Mar 16, 2026

autogen pr notes from copilot..

This pull request introduces several enhancements and refactors to the TextMate PowerShell module, focusing on modularization, improved usability, and updated build/test workflows. The most significant changes include switching to a new module entry point, adding a built-in pager cmdlet, updating dependencies, and refining build scripts for robustness and clarity.

Module enhancements:

  • Changed the module entry point from lib/PSTextMate.dll to TextMate.psm1, enabling dynamic assembly loading and improved reload handling. (Module/TextMate.psd1, Module/TextMate.psm1, [1] [2]
  • Added the Out-Page cmdlet for interactive paging of renderable and text output, with accompanying documentation and README updates. (Module/TextMate.psd1, docs/en-us/Out-Page.md, README.md, [1] [2] [3]
  • Updated module version to 0.2.0 and improved description to highlight built-in Spectre rendering and paging. (Module/TextMate.psd1, Module/TextMate.psd1L2-R16)

Dependency and compatibility updates:

  • Updated required version of PwshSpectreConsole to 2.6.3 for compatibility and removed direct dependency loading from build and harness scripts. (Module/TextMate.psd1, TextMate.build.ps1, harness.ps1, [1] [2] [3] [4]

Build and test workflow improvements:

  • Refactored build script to handle native file updates more robustly, added a new DotNetTest task for running .NET tests, and updated solution/project structure for better modularity. (TextMate.build.ps1, TextMate.slnx, [1] [2] [3]
  • Updated project paths and file references for clarity and maintainability. (TextMate.build.ps1, [1] [2]

Formatting and configuration:

  • Added new view for HighlightedText objects in PowerShell format definitions to improve display. (Module/TextMate.format.ps1xml, Module/TextMate.format.ps1xmlR44-R62)
  • Adjusted .editorconfig settings to suppress certain diagnostics for improved developer experience. (.editorconfig, [1] [2]

Documentation and usability:

  • Expanded README with new usage examples, clarified descriptions, and added documentation for the new pager feature. (README.md, [1] [2] [3]

These changes collectively modernize the module, improve user experience, and streamline development workflows.

* Introduced a new `Pager` class for displaying renderables in an interactive pager format.
* Removed the deprecated `PagerNormal` class to streamline the codebase.
* Enhanced terminal compatibility with support for alternate buffers and synchronized output.
* Added `OutPageCmdlet` to facilitate sending renderables or VT-formatted strings to the pager.
* Improved image rendering estimation and handling within the pager.
* Refactored VT conversion utilities for better performance and maintainability.
…oved rendering

* Added support for handling `HighlightedText` in `OutPageCmdlet`.
* Updated rendering logic to accommodate highlighted text and non-highlighted input.
* Modified `Pager` to disable panel wrapping during paging for stable layout.
* Refactored `Writer` to utilize a `RenderContext` for better performance and memory management.
* Improved `SpectreRenderBridge` to use a `StringBuilder` for optimized string handling.
…renderable objects

* Refactored `RenderToString` to separate local and foreign rendering logic.
* Added detailed error messages for unsupported types.
* Improved handling of foreign renderables using reflection for dynamic type resolution.
* Updated `OutPageCmdlet` to support interactive paging of renderable objects.
* Enhanced rendering logic to handle various input types, including `HighlightedText` and foreign Spectre renderables.
* Introduced a new `Out-Page` cmdlet with comprehensive documentation.
* Improved footer display in the pager for better user experience.
* Added support for dynamic width adjustments in rendering.
* Updated module version to `0.2.0` and included new required modules.
…ting

* Introduced `PagerDocument`, `PagerSearchSession`, and `PagerViewportEngine` to manage document entries, search hits, and viewport rendering.
* Added `PagerHighlighting` for structured highlighting of search results.
* Implemented tests for pager functionality, ensuring correct behavior for search queries and rendering.
* Enhanced `Out-Page` command with metadata and help documentation.
* Integrated Spectre.Console for rendering and testing capabilities.
* Improved search highlighting behavior across various renderable types.
* Added `Streams` utility to facilitate output forwarding to PSCmdlet streams.
* Introduced tests for custom renderables and their interaction with the pager.
* Created a showcase document for validating search highlight behavior.
* Refactored highlighting logic to ensure scoped background colors for matches.
* Introduced a help overlay that displays keybindings when '?' is pressed.
* Added functionality to clear active search with the 'c' key.
* Updated `ScrollTop` method to accept `contentRows` instead of `windowHeight`.
* Enhanced the rendering logic to support the new help overlay.
* Refactored `PagerDocumentEntry` to use lazy evaluation for `SearchText` and `LineStarts`, improving performance.
* Updated `PagerSearchSession` to maintain a dictionary of hits by renderable, optimizing hit retrieval.
* Improved `PagerViewportEngine` to avoid unnecessary height recalculations when layout parameters remain unchanged.
* Enhanced error handling in various rendering and image processing methods to ensure robustness.
* Removed unused interfaces and classes related to TextMate styling, streamlining the codebase.
* Added tests to verify the correctness of search functionality and rendering behavior under various scenarios.
* Updated `HeadingRenderer` to use neutral fallback colors for headings.
* Improved `HorizontalRuleRenderer` to add padding for better visual separation.
* Enhanced `HtmlBlockRenderer` to handle exceptions more gracefully.
* Refactored `ImageRenderer` to use `AsyncLocal` for error tracking and improved exception handling.
* Modified `ListRenderer` to support nested lists and improved inline content extraction.
* Updated `MarkdownRenderer` to streamline pipeline creation and improve compatibility with GitHub Flavored Markdown.
* Enhanced `ParagraphRenderer` for better handling of inline elements and trailing line breaks.
* Changed `QuoteRenderer` to use rounded borders for quotes.
* Refactored `TableRenderer` to improve cell text extraction and removed unused header style method.
* Updated `ImageCanvas` and `PixelImage` to implement `IRenderable` interface for better rendering consistency.
* Improved utility methods in `StringBuilderPool` and `InlineTextExtractor` for optimized string handling.
* Added tests for task lists, nested lists, and link rendering to ensure proper functionality.
* Simplified `AddLines` method to utilize `TextMateHelper.AddSplitLines`.
* Improved `PagerDocument` to handle hyperlink targets and segment extraction more effectively.
* Enhanced `PagerHighlighting` to maintain original styles for borders while applying highlights.
* Updated tests to reflect changes in renderable matching logic and added new tests for segment highlighting.
* Clarified the description of the builtin pager in README.md.
* Improved the explanation of Sixel images in markdown.
* Added detailed navigation instructions for the Out-Page cmdlet.
Copilot AI review requested due to automatic review settings March 16, 2026 23:09
* Ensures compatibility with the latest features and fixes.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes the TextMate PowerShell module by introducing a new module entry point with an AssemblyLoadContext-based loader, adding an interactive pager (Out-Page), and refactoring rendering/utilities (including a new in-repo sixel implementation) alongside updated build and test workflows.

Changes:

  • Switched the module entry point to TextMate.psm1 to support dynamic assembly loading/reload behavior via a custom ALC.
  • Added interactive paging (Out-Page) plus pager/search/highlight infrastructure and new interactive tests.
  • Refactored markdown rendering + sixel/image rendering and centralized utilities via global usings and new helper facades.

Reviewed changes

Copilot reviewed 88 out of 90 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/testhelper.psm1 Test helpers updated to use SpectreRenderBridge and added host buffer capture.
tests/pager-highlight-showcase.md New manual validation fixture for pager highlight behavior.
tests/PSTextMate.InteractiveTests/SpectreLiveTestingTests.cs New interactive tests for Spectre Live + pager quit behavior.
tests/PSTextMate.InteractiveTests/SpectreConsoleTestingTests.cs New tests for string rendering parity + ANSI stripping.
tests/PSTextMate.InteractiveTests/PagerCoreTests.cs New unit tests for pager search + segment highlighting behavior.
tests/PSTextMate.InteractiveTests/PSTextMate.InteractiveTests.csproj New test project for interactive/pager behavior.
tests/Out-Page.tests.ps1 New Pester smoke test for Out-Page metadata/help.
tests/Format-Markdown.tests.ps1 Expanded markdown rendering expectations; uses updated helper.
src/Utilities/TokenStyleProcessor.cs Removed legacy utility (refactor/move).
src/Utilities/ThemeExtensions.cs Removed legacy theme conversion helpers.
src/Utilities/StringExtensions.cs Removed older extension set (replaced with slimmer version under src/PSTextMate).
src/Utilities/StringBuilderExtensions.cs Removed legacy StringBuilder helpers.
src/Utilities/SpectreTextMateStyler.cs Removed legacy styler implementation.
src/Utilities/MarkdownPatterns.cs Removed old location (reintroduced under src/PSTextMate/Utilities).
src/Utilities/ITextMateStyler.cs Removed legacy interface.
src/Utilities/Helpers.cs Removed old helper location (reintroduced under src/PSTextMate/Utilities).
src/Rendering/ImageRenderer.cs Removed old image renderer (replaced under src/PSTextMate/Rendering).
src/Rendering/HorizontalRuleRenderer.cs Removed old renderer (replaced under src/PSTextMate/Rendering).
src/PSTextMate/Utilities/using.cs Added global usings + aliases to reduce per-file imports.
src/PSTextMate/Utilities/Writer.cs New high-throughput render-to-string facade + paging integration.
src/PSTextMate/Utilities/VTHelpers.cs New VT helpers including ANSI stripping and terminal capability probes.
src/PSTextMate/Utilities/VTConversion.cs Renamed/refactored VT parsing utilities; updated style/link handling.
src/PSTextMate/Utilities/TextMateResolver.cs Cleaned up redundant using directives.
src/PSTextMate/Utilities/StringExtensions.cs Reintroduced slimmed StringExtensions in new namespace/layout.
src/PSTextMate/Utilities/StringBuilderPool.cs Minor formatting/clarity tweaks for pooling helper.
src/PSTextMate/Utilities/Streams.cs New PSCmdlet stream-forwarding wrapper for internal components.
src/PSTextMate/Utilities/SpectreStyleCompat.cs Added compatibility helpers for Spectre Style/link creation.
src/PSTextMate/Utilities/SpectreRenderBridge.cs New ALC-safe rendering bridge for local/foreign Spectre renderables.
src/PSTextMate/Utilities/MarkdownPatterns.cs Reintroduced markdown pattern detection with optimized inline iteration.
src/PSTextMate/Utilities/InlineTextExtractor.cs Optimized string slice extraction to reduce allocations.
src/PSTextMate/Utilities/ImageFile.cs Improved temp file cleanup scheduling + more specific exception handling.
src/PSTextMate/Utilities/Helpers.cs Reintroduced and optimized line splitting + language/extension discovery.
src/PSTextMate/Utilities/Completers.cs Cleaned up redundant using directives.
src/PSTextMate/Utilities/AssemblyInfo.cs Cleaned up redundant using directives; keeps InternalsVisibleTo.
src/PSTextMate/Sixel/SixelRender.cs New in-repo sixel encoding implementation using ImageSharp.
src/PSTextMate/Sixel/Sixel.cs New sixel model struct for cached frame payloads.
src/PSTextMate/Sixel/PixelImage.cs New IRenderable pixel/sixel image renderable with caching + cursor control.
src/PSTextMate/Sixel/ImageSegment.cs Small helper wrappers for segment creation/splitting.
src/PSTextMate/Sixel/ImageCanvas.cs Canvas used to reserve layout space for sixel rendering.
src/PSTextMate/Sixel/Compatibility.cs Terminal probing + sizing helpers for sixel support.
src/PSTextMate/Sixel/CellSize.cs Terminal cell size model.
src/PSTextMate/Rendering/TableRenderer.cs Refactors + safer StringBuilder pooling; minor type alias cleanup.
src/PSTextMate/Rendering/QuoteRenderer.cs Border style changed to rounded.
src/PSTextMate/Rendering/ParagraphRenderer.cs Refactored inline iteration + link styling via compat helpers.
src/PSTextMate/Rendering/MarkdownRenderer.cs Updated Markdig pipeline + spacing preservation logic.
src/PSTextMate/Rendering/ListRenderer.cs Improved nested list rendering preserving link styling.
src/PSTextMate/Rendering/ImageRenderer.cs New image renderer using the in-repo PixelImage + compatibility probing.
src/PSTextMate/Rendering/ImageBlockRenderer.cs Cleaned up redundant using directives.
src/PSTextMate/Rendering/HtmlBlockRenderer.cs Safer exception filtering + small iteration cleanup.
src/PSTextMate/Rendering/HorizontalRuleRenderer.cs New HR renderer with horizontal inset padding.
src/PSTextMate/Rendering/HeadingRenderer.cs Neutralized fallback heading colors to default + removed old fallback method.
src/PSTextMate/Rendering/CodeBlockRenderer.cs Safer exception filtering + formatting/structure fix in comments.
src/PSTextMate/Rendering/BlockRenderer.cs Uses StringBuilderPool for alt-text extraction.
src/PSTextMate/Pager/PagerViewport.cs New viewport engine for measuring/rendering paged slices.
src/PSTextMate/Pager/PagerSearchSession.cs New search session with hit indexing + navigation.
src/PSTextMate/Pager/PagerHighlighting.cs New segment-based query highlighting (row + match styling).
src/PSTextMate/Pager/PagerDocument.cs New search document with lazy text extraction + hyperlink target extraction.
src/PSTextMate/PSTextMate.csproj Dependency updates + new ImageSharp + ALC project reference + InternalsVisibleTo.
src/PSTextMate/Core/TokenProcessor.cs Uses SpectreStyleCompat.ToMarkup for style markup safety.
src/PSTextMate/Core/TextMateProcessor.cs Minor type alias adjustments for registry usage.
src/PSTextMate/Core/StyleHelper.cs Cleaned up redundant using directives.
src/PSTextMate/Core/StandardRenderer.cs Cleaned up redundant using directives.
src/PSTextMate/Core/MarkdownToken.cs Cleaned up redundant using directives.
src/PSTextMate/Core/MarkdownRenderer.cs Cleaned up redundant using directives.
src/PSTextMate/Core/MarkdigTextMateScopeMapper.cs New mapper for Markdig elements → TextMate scopes.
src/PSTextMate/Core/HighlightedText.cs New HighlightedText implementation supporting paging/views and stable gutters.
src/PSTextMate/Core/CacheManager.cs Cleaned up redundant using directives.
src/PSTextMate/Cmdlets/TextMateCmdletBase.cs Added -Page switch; emit logic updated to invoke pager when requested.
src/PSTextMate/Cmdlets/TestTextMate.cs Improved pipeline binding + parameter metadata changes.
src/PSTextMate/Cmdlets/OutPage.cs New Out-Page cmdlet for paging renderables and formatted text output.
src/PSTextMate/Cmdlets/GetTextMateGrammar.cs Minor formatting cleanup.
src/PSTextMate/Cmdlets/FormatTextMateCmdlet.cs Cleaned up redundant using directives.
src/PSTextMate/Cmdlets/FormatPowershell.cs Cleaned up redundant using directives.
src/PSTextMate/Cmdlets/FormatMarkdown.cs Cleaned up redundant using directives.
src/PSTextMate/Cmdlets/FormatCSharp.cs Cleaned up redundant using directives.
src/PSTextMate.ALC/PSTextMate.ALC.csproj New ALC support project.
src/PSTextMate.ALC/LoadContext.cs New AssemblyLoadContext loader for isolating module assembly loading.
src/Core/HighlightedText.cs Removed legacy HighlightedText implementation (replaced under src/PSTextMate).
harness.ps1 Removed direct PwshSpectreConsole import from harness script.
docs/en-us/Out-Page.md New cmdlet help documentation for Out-Page.
build.ps1 Minor formatting/spacing cleanup.
TextMate.slnx Updated solution project paths and includes new projects.
TextMate.build.ps1 Build robustness improvements + added DotNetTest task + updated paths.
README.md Updated feature list + added pager docs and examples.
Module/TextMate.psm1 New module entry point script with ALC-based dynamic assembly loading.
Module/TextMate.psd1 Updated root module, version, description, and exported cmdlets/aliases.
Module/TextMate.format.ps1xml Added formatting view for HighlightedText using Writer.Write(...).
.gitignore Improved bin/obj globs; added ignored utility file.
.editorconfig Suppressed additional IDE diagnostics for developer experience.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

… method

* Improved input handling by checking for pending input before draining.
* Introduced `HasPendingInput` method to encapsulate input availability logic.
* Refactored `RenderToString` method in `SpectreRenderBridge` for better error handling and clarity.
* Updated `Writer` class to use consistent parameter naming conventions.
* Fixed window rectangle calculations in test helper for accurate buffer retrieval.
@trackd trackd merged commit 6ca48ef into main Mar 16, 2026
6 checks passed
@trackd trackd deleted the feature/pager branch March 17, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants