Layout
Term.Layout.PaddingTerm.Layout.PlaceHolderTerm.Layout.PlaceHolderTerm.Layout.SpacerTerm.Layout.hLineTerm.Layout.hLineTerm.Layout.hLineTerm.Layout.hLineTerm.Layout.hLineTerm.Layout.hLineTerm.Layout.vLineTerm.Layout.vLineTerm.Layout.vLineTerm.Layout.vLineTerm.Layout.centerTerm.Layout.center!Term.Layout.cvstackTerm.Layout.hstackTerm.Layout.hstackTerm.Layout.leftalignTerm.Layout.leftalign!Term.Layout.lvstackTerm.Layout.padTerm.Layout.padTerm.Layout.padTerm.Layout.padTerm.Layout.padTerm.Layout.padTerm.Layout.padTerm.Layout.pad!Term.Layout.pad!Term.Layout.rightalignTerm.Layout.rightalign!Term.Layout.rvstackTerm.Layout.vertical_padTerm.Layout.vertical_padTerm.Layout.vertical_padTerm.Layout.vertical_padTerm.Layout.vertical_padTerm.Layout.vertical_pad!Term.Layout.vertical_pad!Term.Layout.vstack
Term.Layout.Padding — TypePaddingStores information about ammount of padding.
Term.Layout.PlaceHolder — Typemutable struct PlaceHolder <: AbstractLayoutElement
segments::Vector{Segment}
measure::Measure
endA renderable used as a place holder when creating layouts (e.g. with grid).
Examples
println(PlaceHolder(25, 10))
╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲
╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲
╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲
╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲
╲ ╲ ╲ (25 × 10) ╲ ╲ ╲ ╲
╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲
╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲
╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲
╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲
╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ Term.Layout.PlaceHolder — MethodPlaceHolder(
h::In,
w::Int;
style::String = "dim",
text::Union{Nothing,String} = nothing,
)Create a PlaceHolder with additional style information.
Term.Layout.Spacer — Type SpacerA box of empty text with given width and height.
Term.Layout.hLine — TypehLineA 1-line renderable made of repeated character from a Box.
Term.Layout.hLine — MethodhLine(text::AbstractString; style::Union{String, Nothing}=nothing, box::Symbol=TERM_THEME[].box)Construct an hLine as wide as the stdout with centered text.
Term.Layout.hLine — MethodhLine(width::Number, style::Union{String, Nothing}; box::Symbol=TERM_THEME[].box)Create a styled hLine of given width.
Term.Layout.hLine — MethodhLine(width::Number, text::String; style::Union{String, Nothing}=nothing, box::Symbol=TERM_THEME[].box)Creates an hLine object with texte centered horizontally.
Term.Layout.hLine — MethodhLine(ren::AbstractRenderable; kwargs)Construct an hLine with same width as a renderable.
Term.Layout.hLine — MethodhLine(; style::Union{String, Nothing}=nothing, box::Symbol=TERM_THEME[].box)Construct an hLine as wide as the stdout.
Term.Layout.vLine — TypevLineA multi-line renderable with each line made of a | to create a vertical line.
Term.Layout.vLine — MethodvLine(
height::Int;
style::String = TERM_THEME[].line,
box::Symbol = TERM_THEME[].box,
char::Union{Char,Nothing} = nothing,
)Create a vLine given a height and, optionally, style information.
Term.Layout.vLine — MethodvLine(ren::AbstractRenderable; kwargs...)Construct a vLine with the same height as a renderable.
Term.Layout.vLine — MethodvLine(; style::Union{String, Nothing}=nothing, box::Symbol=:ROUNDED)Create a vLine as tall as the stdout console.
Term.Layout.center! — Methodcenter!(renderables::RenderablesUnion... )In place version of center.
Examples
p1 = Panel(; width=25)
p2 = Panel(; width=50)
center!(p1, p2)
print(p1/p2)
╭───────────────────────╮
╰───────────────────────╯
╭────────────────────────────────────────────────╮
╰────────────────────────────────────────────────╯Term.Layout.center — Methodcenter(renderables::RenderablesUnion... )Pad two (or more) renderables so that they have the same width and they are centered.
NOTE: the renderables returned have different type and potentially different size from the inputs
Examples
p1 = Panel(; width=25)
p2 = Panel(; width=50)
p1, p2 = center(p1, p2)
print(p1/p2)
╭───────────────────────╮
╰───────────────────────╯
╭────────────────────────────────────────────────╮
╰────────────────────────────────────────────────╯Term.Layout.cvstack — Methodlvstack(renderables::RenderablesUnion...)Center align renderables and then vertically stack.
Term.Layout.hstack — Methodhstack(renderables...)Horizonatlly stack a variable number of renderables.
Term.Layout.hstack — Methodhstack(r1::RenderablesUnion, r2::RenderablesUnion )Horizontally stack two renderables to give a new renderable.
Term.Layout.leftalign! — Methodleftalign!(renderables::RenderablesUnion...)In place version of leftalign.
Examples
```julia p1 = Panel(; width=25) p2 = Panel(; width=50) leftalign!(p1, p2) print(p1/p2)
╭───────────────────────╮ ╰───────────────────────╯ ╭────────────────────────────────────────────────╮ ╰────────────────────────────────────────────────╯
Term.Layout.leftalign — Methodleftalign(renderables::RenderablesUnion...)Pad two (or more) renderables so that they have the same width and they are left-aligned.
NOTE: the renderables returned have different type and potentially different size from the inputs
Examples
p1 = Panel(; width=25)
p2 = Panel(; width=50)
p1, p2 = leftalign(p1, p2)
print(p1/p2)
╭───────────────────────╮
╰───────────────────────╯
╭────────────────────────────────────────────────╮
╰────────────────────────────────────────────────╯Term.Layout.lvstack — Methodlvstack(renderables::RenderablesUnion...)Left align renderables and then vertically stack.
Term.Layout.pad — Functionpad(s::Segment, left::Int = 0, right::Int = 0; kwargs...)Pad a segment.
Term.Layout.pad — Functionpad(text::AbstractString, left::Int = 0, right::Int = 0)Pad a string by a fixed ammount to the left and to the right.
Term.Layout.pad — Functionpad(segments::AbstractVector{Segment}, left::Int = 0, right::Int = 0)Pad a renderable's segments to the left and the right.
Term.Layout.pad! — Methodpad!(ren::AbstractRenderable, left::Int, right::Int)In place version for padding a renderable.
Term.Layout.pad! — Methodpad!(ren::AbstractRenderable; width::Int)In place version for padding a renderable to achieve a given width.
Term.Layout.pad — Methodfunction pad(text::AbstractString, target_width::Int, method::Symbol, lw::Int; bg = nothing)::Stringcomplete string padding but knowing line width of the string. Useful in cases the line width needs to be enforced instead of obtained through width(text), e.g. when paddnig a Link's text.
Term.Layout.pad — Methodpad(text::AbstractString, target_width::Int, method::Symbol)::StringPad a string to width: target_width by adding empty spaces strings " ". Where the spaces are added depends on the justification method ∈ (:left, :center, :right, :justify).
Examples
julia> pad("ciao", 10, :left)
"ciao "
julia> pad("ciao", 10, :center)
" ciao "
julia> pad("ciao", 10, :right)
" ciao"Term.Layout.pad — Methodpad(ren::AbstractRenderable, left::Int, right::Int)Pad an AbstractRenderable by padding each of its segments.
Term.Layout.pad — Methodpad(ren::AbstractRenderable; width::Int)Pad a renderable to achieve a target width.
The padding is added to the left and to the right as needed to achieve the target width. The resulting renderable object will be center in the target space.
Example
julia> pad(RenderableText("ciao"); width=10)
ciao Term.Layout.rightalign! — Methodrightalign!(renderables::RenderablesUnion... )In place version of rightalign.
Examples
p1 = Panel(; width=25)
p2 = Panel(; width=50)
rightalign!(p1, p2)
print(p1/p2)
╭───────────────────────╮
╰───────────────────────╯
╭────────────────────────────────────────────────╮
╰────────────────────────────────────────────────╯Term.Layout.rightalign — Methodrightalign(renderables::RenderablesUnion... )Pad two (or more) renderables so that they have the same width and they are right aligned.
NOTE: the renderables returned have different type and potentially different size from the inputs
Examples
p1 = Panel(; width=25)
p2 = Panel(; width=50)
p1, p2 = rightalign(p1, p2)
print(p1/p2)
╭───────────────────────╮
╰───────────────────────╯
╭────────────────────────────────────────────────╮
╰────────────────────────────────────────────────╯Term.Layout.rvstack — Methodlvstack(renderables::RenderablesUnion...)Right align renderables and then vertically stack.
Term.Layout.vertical_pad — Functionvertical_pad(text::AbstractString, above::Int = 0, below::Int = 0)Vertical pad a string by a fixed ammount to above and below.
Term.Layout.vertical_pad — Functionvertical_pad(segments::AbstractVector{Segment}, above::Int = 0, below::Int = 0)Pad a renderable's segments to the above and the below.
Term.Layout.vertical_pad! — Methodverti0cal_pad!(ren::AbstractRenderable, above::Int, below::Int)In place version for vertically padding a renderable.
Term.Layout.vertical_pad! — Methodpad!(ren::AbstractRenderable; width::Int)In place version for padding a renderable to achieve a given width.
Term.Layout.vertical_pad — Methodverticalpad(text, targetheight::Int, method::Symbol)::String
Vertically pad a string to height: target_height by adding empty strings above/below " ". Where the spaces are added depends on the justification method ∈ (:top, :center, :bottom).
Term.Layout.vertical_pad — Methodvertical_pad(ren::AbstractRenderable, above::Int, below::Int)Pad a renderable, vertically.
Term.Layout.vertical_pad — Methodvertical_pad(ren::AbstractRenderable; height::Int)
Vertical pad a renderable to achieve a target height.
Term.Layout.vstack — Methodvstack(renderables...)Vertically stack a variable number of renderables to give a new renderable