Skip to content

Refactor tui render#22

Open
yumosx wants to merge 15 commits intomainfrom
refactor-tui-render
Open

Refactor tui render#22
yumosx wants to merge 15 commits intomainfrom
refactor-tui-render

Conversation

@yumosx
Copy link
Member

@yumosx yumosx commented Feb 26, 2026

No description provided.

- Reorganize helper functions into logical groups with section comments
- Fix nil check for previousLines in TUI render logic
- Reorder parameters in renderChangedLines for better consistency
Restructure code by extracting overlay-related types and functions from type.go to a new overlay.go file to improve code organization and maintainability.
Move regex pattern compilation to package level to avoid repeated compilation
- Add proper signal handling for graceful shutdown in both input and chat examples
- Enhance chat responses with markdown formatting for better visual distinction
Move the cursor rendering logic from Render method to a new renderLineWithCursor function to improve code organization and maintainability. The new method handles all cursor-related display logic including cursor position calculation, marker placement, and padding checks.
Move VisibleWidth and AnsiCodeTracker functionality from utils.go to dedicated files visible_width.go and ansi_tracker.go respectively
…nctions

- Replace custom string splitting and joining with standard library functions
- Use strings.Builder for more efficient string concatenation
- Remove unused helper functions parseCode, splitSemicolon and joinStrings
Add detailed documentation including struct description, method explanations,
and complete usage examples. The documentation covers all functionality
including text formatting, color handling, and line wrapping scenarios.
- Split large Process method into smaller, focused methods
- Add input validation for ANSI code format
- Improve handling of extended color codes (256-color and RGB)
- Better organize standard SGR code processing
- Add comments to clarify code sections
Add new method to clear previous render state and force a fresh render. This is useful when the UI needs to be completely redrawn due to significant changes.
- Extract ANSI code handling into dedicated ansi.go module
- Create text_segment.go for segment type definitions and grapheme utilities
- Add text_slice.go with column-based slicing and segment extraction logic
- Implement text_truncate.go for width-aware text truncation with ellipsis
- Add text_utils.go with background application and whitespace utilities
- Implement text_wrap.go for intelligent text wrapping functionality
- Remove consolidated utils.go file in favor of focused modules
- Improves code organization and maintainability by separating concerns
- Extract ResolveLayout method from TUI to OverlayOption receiver
- Move overlay layout calculation logic to overlay.go for better separation of concerns
- Update compositeOverlays to call options.ResolveLayout instead of t.ResolveOverlayLayout
- Simplify TUI by removing 69-line ResolveOverlayLayout method
- Improves code organization by keeping overlay-specific logic with overlay types
Replace iterative padding with direct slice allocation to improve performance when compositing overlays. Also comment out IDE directories in gitignore.
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.

1 participant