Files
TUIkit/Sources/TUIkit/Rendering/ScrollIndicator.swift
T
phranck e214215610 Refactor: Replace MainActor.assumeIsolated with @preconcurrency Equatable
- Migrate 20 Equatable conformances across 17 files from
  nonisolated + MainActor.assumeIsolated to @preconcurrency Equatable (SE-0423)
- Remove unnecessary import Foundation from 29 source files
- Extract TextFieldHandler clipboard ops into TextFieldHandler+Clipboard.swift
- Extract RenderContext into RenderContext.swift (Renderable.swift 553 -> 279 lines)
- Extract ANSIColor enum into ANSIColor.swift (Color.swift 600 -> 533 lines)
- Add deprecation timeline note for progressBarStyle(_:)
- Migrate test usages from progressBarStyle to trackStyle
2026-02-14 02:10:26 +01:00

40 lines
1.3 KiB
Swift
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 🖥 TUIKit Terminal UI Kit for Swift
// ScrollIndicator.swift
//
// Created by LAYERED.work
// License: MIT
// MARK: - Scroll Direction
/// The direction of a scroll indicator arrow.
enum ScrollDirection {
case up, down
}
// MARK: - Scroll Indicator Rendering
/// Renders a centered scroll indicator line with an arrow and label.
///
/// Used by `_ListCore` and `_TableCore` to show "more above" / "more below"
/// indicators when content extends beyond the visible viewport.
///
/// - Parameters:
/// - direction: Whether the indicator points up or down.
/// - width: The total width available for the indicator line.
/// - palette: The color palette for styling.
/// - Returns: A styled string with a centered scroll indicator.
@MainActor
func renderScrollIndicator(direction: ScrollDirection, width: Int, palette: any Palette) -> String {
let arrow = direction == .up ? "" : ""
let label = direction == .up ? " more above " : " more below "
let styledArrow = ANSIRenderer.colorize(arrow, foreground: palette.foregroundTertiary)
let styledLabel = ANSIRenderer.colorize(label, foreground: palette.foregroundTertiary)
let indicatorWidth = 1 + label.count
let padding = max(0, (width - indicatorWidth) / 2)
return String(repeating: " ", count: padding) + styledArrow + styledLabel
}