Commit Graph
14 Commits
Author SHA1 Message Date
phranck 5147951420 fix: Remove ESC as quit shortcut - only 'q' quits the app
ESC should only be used for navigation (back to menu), not for quitting.
The 'q' key is the only way to quit the app.
2026-01-28 22:39:04 +01:00
phranck 282585a68b feat: Add Appearance system for consistent UI styling
Appearance controls the visual structure (border style) of UI controls,
while Theme controls colors. Together they create a complete look.

New types:
- Appearance: Defines borderStyle for all controls
- Appearance.ID: Type-safe identifier (no magic strings)
- AppearanceManager: Environment-based cycling (no singleton)
- AppearanceRegistry: Available appearances

Predefined appearances:
- .rounded (default) - Curved corners
- .sharp - 90-degree corners
- .double - Double-line borders
- .heavy - Thick/bold borders
- .ascii - Maximum terminal compatibility (+, -, |)

Updated components to use appearance.borderStyle as default:
- Menu, Button, Panel, Card, Box, Alert, Dialog
- BorderModifier (.border() modifier)

Added 'a' key shortcut to cycle through appearances.

Also added BorderStyle.ascii for ASCII-only terminals.

All 189 tests passing.
2026-01-28 21:44:01 +01:00
phranck 0de5bbd13e fix: Preserve background color after ANSI reset codes
Replace all reset codes in rendered content with 'reset + restore background'
to ensure the theme background persists after styled text ends.

This fixes the issue where text with ANSI formatting would reset the
background color, leaving parts of the terminal with the wrong background.
2026-01-28 21:22:28 +01:00
phranck 497ce9cb56 fix: Apply theme background to all content and status bar
- WindowGroup.renderScene wraps each line with background color code
- StatusBar rendering also uses theme background
- Ensures entire terminal has consistent background color
2026-01-28 21:18:51 +01:00
phranck fd3baee9f7 fix: Fill entire terminal with theme background color
- Add Terminal.fillBackground() method to fill screen with a color
- Add ANSIRenderer.backgroundCode() helper for background escape sequences
- AppRunner now fills screen with theme.background before rendering content
- Remove unnecessary .frame() and .background() from ContentView

This ensures the entire terminal has a consistent background color that
changes when switching themes.
2026-01-28 21:15:41 +01:00
phranck 201d920bdc fix: Apply ThemeManager's current theme to environment during render
The render() method was creating a new EnvironmentValues with the default
theme, overwriting any theme changes made by ThemeManager. Now the current
theme is explicitly set from themeManager.currentTheme.
2026-01-28 20:51:55 +01:00
phranck f00d919c1f feat: Use theme colors in StatusBar and Example App
- StatusBar now uses theme colors by default (statusBarHighlight, statusBarForeground)
- Example App MainMenuPage uses theme colors (accent, border, foreground*)
- Example App HeaderView uses theme colors
- Theme switching ('t' key) now shows visible changes
2026-01-28 20:50:28 +01:00
phranck 544152de02 refactor: Remove ThemeManager singleton, add Environment-based access
- ThemeManager is no longer a singleton
- Access via Environment: @Environment(\.themeManager)
- Type-safe setTheme() API: themeManager.setTheme(.amber)
- ThemeManager injected by AppRunner into environment
- Custom themes supported via init(themes:)
2026-01-28 20:48:00 +01:00
phranck 1d3c9b2a62 feat: Add QuitBehavior and ThemeManager
QuitBehavior:
- .always: Quit works from any screen (default)
- .rootOnly: Quit only works from main screen (no context pushed)
- Quit item hidden in status bar when not allowed

ThemeManager:
- Singleton for managing theme cycling
- cycleTheme() / cyclePreviousTheme() methods
- setTheme(at:) and setTheme(withId:) for direct access
- Automatically updates environment and triggers re-render
- 't' key now cycles themes in AppRunner
2026-01-28 20:44:00 +01:00
phranck 9c96e96460 feat: Add showHelpItem and showThemeItem flags
- System items are now built dynamically based on flags
- showHelpItem (default: true) - controls ? help visibility
- showThemeItem (default: true) - controls t theme visibility
- Quit item is always shown when showSystemItems is true
- Removed unused configureSystemItems method
2026-01-28 20:42:08 +01:00
phranck b9a6cc29ab fix: Show all system items (quit, help, theme) and fix deduplication
- StatusBarState now initializes with all 3 system items
- Added deduplication logic to StatusBar.renderToBuffer
- User items with same shortcut override system items
- Updated Example App to not duplicate 'q quit'
- Updated tests for 3 system items instead of 1
2026-01-28 20:40:52 +01:00
phranck 61a51ef056 refactor: Two-container model for StatusBar (user left, system right)
- StatusBar now has separate userItems and systemItems properties
- User items are sorted by order, then system items (fixed order) appended
- Rendering combines both: [sorted user items] + [system items]
- User items override system items with same shortcut (deduplication)
- StatusBarState passes items separately to StatusBar
- Alignment applies to the combined items
- Updated tests to use userItems property
2026-01-28 20:32:39 +01:00
phranck 04cbf2db8b feat: Add system StatusBar items with stable ordering
- Add StatusBarItemOrder for consistent item positioning
- System items (quit, help, theme) appear on the right side
- User items appear on the left, can override system items
- Separate tracking of user vs system items in StatusBarState
- Add showSystemItems flag to disable system items in tests
- Items sorted by order value (lower = left, higher = right)
- User items override system items with the same shortcut
- Add comprehensive tests for system item behavior (189 total)
2026-01-28 20:23:27 +01:00
phranck 45e73faafb refactor: Rename package from SwiftTUI to TUIKit
BREAKING CHANGE: Package name changed due to name collision with
existing rensbreur/SwiftTUI package.

Changes:
- Rename package from SwiftTUI to TUIKit in Package.swift
- Rename Sources/SwiftTUI to Sources/TUIKit
- Rename Sources/SwiftTUIExample to Sources/TUIKitExample
- Rename Tests/SwiftTUITests to Tests/TUIKitTests
- Rename SwiftTUI.swift to TUIKit.swift
- Update all imports: import SwiftTUI -> import TUIKit
- Update all code references: SwiftTUI.renderToBuffer -> TUIKit.renderToBuffer
- Update documentation comments
- Rename swiftTUIVersion to tuiKitVersion

All 181 tests passing.
2026-01-28 19:32:09 +01:00