Rewrite native Go/C extensions as pure Ruby#8
Open
khasinski wants to merge 7 commits intomarcoroth:mainfrom
Open
Rewrite native Go/C extensions as pure Ruby#8khasinski wants to merge 7 commits intomarcoroth:mainfrom
khasinski wants to merge 7 commits intomarcoroth:mainfrom
Conversation
Replace Go/CGo/C native extensions with pure Ruby implementations. Only runtime dependency is unicode-display_width for terminal width calculation. New modules: Ansi (escape sequences), Color (profile detection, hex/ ANSI256 resolution), ColorBlend (LUV/HCL blending), Renderer (layout join/place), Immutable (shared builder pattern), List, Tree. Existing modules rewritten: Style (full render pipeline), Table (column auto-fit, width distribution, border rendering), Border (character definitions for all border types). Also updates CI workflow, Rakefile, Gemfile.lock, and RBS type signatures to remove Go/compile steps and match the new pure Ruby API.
36 new tests covering: ANSI code verification, tab conversion, style getters, word wrapping, combined styles, empty content, border_row, border_style on tables, Ansi module, Color module, inheritance, nested trees/lists.
HEADER_ROW and style_func were declared in both lipgloss.rbs and table.rbs, causing steep to fail. Remove duplicates from per-file RBS files since lipgloss.rbs has the complete declarations.
Update RBS signatures to declare all new modules, constants, and private methods. Configure Steepfile to downgrade metaprogramming- related diagnostics (define_method, allocate, instance_variable_set) that steep cannot resolve.
Auto-correct layout, style, and lint offenses. Add rubocop exclusions for metrics and naming cops on render methods and color math code that use short variable names (r, g, b) and have inherent complexity.
Reorder Style render pipeline to match Go lipgloss: ANSI styling before padding, inline strips input newlines, height applied after padding. Split apply_width_and_alignment into apply_wrapping and apply_horizontal_alignment. Fix JoinHorizontal to normalize line widths within blocks before joining. Add column shrinking to Table distribute_width (shrink widest first). Implement table height property. Change Table style_func to lazy block evaluation. Add Ansi.truncate for shared ANSI-aware truncation with RESET emit. Fix enumerator style spacing in List/Tree. Move rubocop file-level excludes to inline disables. Split pure_ruby_test.rb into feature-specific test files. Add 18 new tests covering all fixes.
khasinski
commented
Mar 8, 2026
| # First line of subtree (the root) | ||
| sub_root = sub_lines[0] | ||
| styled_prefix = if @enumerator_style | ||
| "#{@enumerator_style.render(prefix.rstrip)} " |
Contributor
Author
There was a problem hiding this comment.
Behavior change vs native ext: re-adds space after styled enumerator symbol. Native ext omitted it, but Go lipgloss v1.1.0 uses PaddingRight(1) to add the space. Same change in list.rb:60.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
unicode-display_widthfor terminal width calculationNew modules
Ansi-- escape sequence generation and strippingColor-- profile detection, hex/ANSI256 resolution, adaptive colorsColorBlend-- LUV/HCL color space blendingRenderer-- layout join/place functionsImmutable-- shared builder pattern for Style, Table, List, TreeList-- 6 enumerator types, nesting supportTree-- recursive nesting, two enumerator stylesRewritten modules
Style-- full render pipeline (tabs, max_width, alignment, padding, border, margins, ANSI)Table-- column auto-fit, width distribution, border rendering, style_funcBorder-- character definitions for all border types