module Sheen
Defined in:
sheen.crsheen/background.cr
sheen/border.cr
sheen/border_painter.cr
sheen/color.cr
sheen/composition.cr
sheen/list.cr
sheen/position.cr
sheen/ranges.cr
sheen/renderer.cr
sheen/style.cr
sheen/style_painter.cr
sheen/table.cr
sheen/table_painter.cr
sheen/table_resizer.cr
sheen/tree.cr
sheen/tree_painter.cr
Constant Summary
-
BLACK =
ANSIColor.new(0) -
BLUE =
ANSIColor.new(4) -
BRIGHT_BLACK =
ANSIColor.new(8) -
BRIGHT_BLUE =
ANSIColor.new(12) -
BRIGHT_CYAN =
ANSIColor.new(14) -
BRIGHT_GREEN =
ANSIColor.new(10) -
BRIGHT_MAGENTA =
ANSIColor.new(13) -
BRIGHT_RED =
ANSIColor.new(9) -
BRIGHT_WHITE =
ANSIColor.new(15) -
BRIGHT_YELLOW =
ANSIColor.new(11) -
BUILD_DATE =
{{ (`date +%F`).stringify.chomp }} -
BUILD_HASH =
{{ (`git rev-parse HEAD`).stringify[0...8] }} -
CYAN =
ANSIColor.new(6) -
GREEN =
ANSIColor.new(2) -
MAGENTA =
ANSIColor.new(5) -
RED =
ANSIColor.new(1) -
VERSION =
{{ (`shards version /srv/crystaldoc.info/github-lowkeyliesmyth-sheen-v0.1.2/src/..`).stringify.chomp }} -
WHITE =
ANSIColor.new(7) -
YELLOW =
ANSIColor.new(3)
Class Method Summary
-
.color(value : TerminalColor) : TerminalColor
Builds a
TerminalColorfrom a hex string, an index string, an integer index, or an existing color returned as-is. -
.color(value : String) : TerminalColor
Builds a
TerminalColorfrom a hex string, an index string, an integer index, or an existing color returned as-is. -
.color(value : Int) : TerminalColor
Builds a
TerminalColorfrom a hex string, an index string, an integer index, or an existing color returned as-is. -
.has_dark_background?(input : IO = STDIN, output : IO = STDOUT, env : Foundation::Env = Foundation::LiveEnv.new) : Bool
Reports whether the terminal renders on a dark background, so that
AdaptiveColorandCompleteAdaptiveColorcan pick the correct light or dark variant. -
.height(string : String) : Int32
Height of string in lines: one more than its newline count.
-
.join_horizontal(pos : Position, strings : Enumerable(String)) : String
Joins the strings collection (eg table row cells) left to right, aligning blocks of differing height along the vertical axis at pos (0.0=top, 0.5=center, 1.0=bottom, or any float in between).
-
.join_horizontal(pos : Position, *strings : String) : String
Joins strings left to right.
-
.join_vertical(pos : Position, strings : Enumerable(String)) : String
Joins strings collection top to bottom, aligning lines of differing width along the horizontal axis at pos (0.0=left, 0.5=center, 1.0=right, or any float in between).
-
.join_vertical(pos : Position, *strings : String) : String
Joins strings top to bottom.
-
.place(width : Int32, height : Int32, h_pos : Position, v_pos : Position, string : String, *, ws_chars : String = " ", ws_foreground : TerminalColor | Nil = nil, ws_background : TerminalColor | Nil = nil, renderer : Renderer = Sheen.renderer) : String
Places string inside a box of width x height, aligning it at h_pos horizontally and v_pos vertically.
-
.place_horizontal(width : Int32, pos : Position, string : String, *, ws_chars : String = " ", ws_foreground : TerminalColor | Nil = nil, ws_background : TerminalColor | Nil = nil, renderer : Renderer = Sheen.renderer) : String
Places string horizontally in a box of width at pos (0.0=left ...
-
.place_vertical(height : Int32, pos : Position, string : String, *, ws_chars : String = " ", ws_foreground : TerminalColor | Nil = nil, ws_background : TerminalColor | Nil = nil, renderer : Renderer = Sheen.renderer) : String
Places string vertically in a box of height at pos (0.0=top ...
-
.renderer : Renderer
Process-global default renderer.
-
.renderer=(renderer : Renderer)
Process-global default renderer.
-
.resolve_value(value : String, profile : Foundation::Profile) : Foundation::SGRColor | Nil
Helper shared by color types.
-
.size(string : String) : Tuple(Int32, Int32)
The
{width, height}of string in cells -
.style(renderer : Renderer = Sheen.renderer, & : Style::Builder -> ) : Style
Builds a Style imperatively.
-
.style_ranges(str : String, ranges : Array(StyleRange)) : String
Styles visible-cell ranges of str, preserving any existing styling as-is in the gaps between ranges.
-
.style_ranges(str : String, *ranges : StyleRange) : String
Styles visible-cell ranges of str, preserving any existing styling as-is in the gaps between ranges.
-
.style_runes(str : String, indices : Enumerable(Int32), matched : Style, unmatched : Style) : String
Applies matched Style to the runes of str at the given indices.
-
.width(string : String) : Int32
Visible cell width of the widest line in string (ANSI-aware, grapheme based).
Class Method Detail
Builds a TerminalColor from a hex string, an index string, an integer index, or an existing color returned as-is.
Builds a TerminalColor from a hex string, an index string, an integer index, or an existing color returned as-is.
Builds a TerminalColor from a hex string, an index string, an integer index, or an existing color returned as-is.
Reports whether the terminal renders on a dark background, so that AdaptiveColor and CompleteAdaptiveColor can pick the correct light or dark variant.
Detection is env-first and TTY-safe:
COLORFGBG(afg;bgpair of ANSI indices)- An OSC11 background query written to output and read from input only when both are real TTYs
- Fallback to Dark (default black background) when nothing else answers
Height of string in lines: one more than its newline count.
Joins the strings collection (eg table row cells) left to right, aligning blocks of differing height along the vertical axis at pos (0.0=top, 0.5=center, 1.0=bottom, or any float in between). Each block's lines are padded to its own widest line so columns stay aligned.
Joins strings left to right. Variadic form that delegates to the collection form.
Joins strings collection top to bottom, aligning lines of differing width along the horizontal axis at pos (0.0=left, 0.5=center, 1.0=right, or any float in between). All lines are padded to the widest line across every block.
Joins strings top to bottom. Variadic form that delegates to the collection form.
Places string inside a box of width x height, aligning it at h_pos horizontally and v_pos vertically. Extra space is filled with whitespace which can be styled via the ws_* keyword options.
If width or height is not larger than string's own width or height, that axis is left unchanged.
Places string horizontally in a box of width at pos (0.0=left ... 1.0=right). Each line pads to fill up the full width, but if width <= the widest line then no change is applied.
Places string vertically in a box of height at pos (0.0=top ... 1.0=bottom). Blank lines fill up the the full block width. If height <= the string's line count then no change is applied.
Process-global default renderer. Configure it directly, eg Sheen.renderer.color_profile = Foundation::Profile::TrueColor.
Or replace it wholesale: Sheen.renderer = Sheen::Renderer.new(io)
Process-global default renderer. Configure it directly, eg Sheen.renderer.color_profile = Foundation::Profile::TrueColor.
Or replace it wholesale: Sheen.renderer = Sheen::Renderer.new(io)
Helper shared by color types. Resolves a color value hex or index string against profile.
Returns nil for empty/invalid value or a colorless profile.
Builds a Style imperatively. Yields a mutable builder and returns the resulting immutable Style.
Sheen.style { |s| s.bold; s.foreground("#FF0000") }.
Styles visible-cell ranges of str, preserving any existing styling as-is in the gaps between ranges. Ranges must be ordered and not overlap.
Each range has its text stripped of ANSI sequences, leaving only a printable content string.
Styles visible-cell ranges of str, preserving any existing styling as-is in the gaps between ranges. Ranges must be ordered and not overlap.
Each range has its text stripped of ANSI sequences, leaving only a printable content string.
Splat convenience version: Sheen.style.ranges(str, r1, r2).
Requires at least one range. Use the array overload version for any possible empty case.
Applies matched Style to the runes of str at the given indices. The rest of the runes get the unmatched Style applied. Each run of same-status runes are rendered as one styled group.
Note that runes are Unicode codepoints and not grapheme clusters. Indices out of bounds are ignored. Returns the reassembled and fully styled string.
Visible cell width of the widest line in string (ANSI-aware, grapheme based).