mirror of
https://github.com/phranck/TUIkit.git
synced 2026-06-20 09:54:37 +00:00
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.
41 lines
1.0 KiB
Swift
41 lines
1.0 KiB
Swift
//
|
|
// TUIKit.swift
|
|
// TUIKit
|
|
//
|
|
// A SwiftUI-like framework for Terminal User Interfaces.
|
|
//
|
|
// TUIKit enables creating TUI applications with a declarative,
|
|
// SwiftUI-like syntax - without ncurses or other low-level libraries.
|
|
//
|
|
|
|
/// The current version of TUIKit.
|
|
public let tuiKitVersion = "0.1.0"
|
|
|
|
/// Executes a view closure and renders it once.
|
|
///
|
|
/// This is useful for simple CLI tools that don't need a full App.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// ```swift
|
|
/// renderOnce {
|
|
/// VStack {
|
|
/// Text("Hello, TUIKit!")
|
|
/// .bold()
|
|
/// .foregroundColor(.cyan)
|
|
/// Divider()
|
|
/// Text("Version \(tuiKitVersion)")
|
|
/// .dim()
|
|
/// }
|
|
/// }
|
|
/// ```
|
|
///
|
|
/// - Parameter content: A ViewBuilder closure that defines the view to render.
|
|
@discardableResult
|
|
public func renderOnce<Content: View>(@ViewBuilder content: () -> Content) -> Int {
|
|
let view = content()
|
|
let renderer = ViewRenderer()
|
|
renderer.render(view)
|
|
return 0 // TODO: Return actual line count
|
|
}
|