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 — Type
PaddingStores information about ammount of padding.
Term.Layout.PlaceHolder — Type
mutable 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 — Method
PlaceHolder(
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 — Type
hLineA 1-line renderable made of repeated character from a Box.
Term.Layout.hLine — Method
hLine(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 — Method
hLine(width::Number, style::Union{String, Nothing}; box::Symbol=TERM_THEME[].box)Create a styled hLine of given width.
Term.Layout.hLine — Method
hLine(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 — Method
hLine(ren::AbstractRenderable; kwargs)Construct an hLine with same width as a renderable.
Term.Layout.hLine — Method
hLine(; style::Union{String, Nothing}=nothing, box::Symbol=TERM_THEME[].box)Construct an hLine as wide as the stdout.
Term.Layout.vLine — Type
vLineA multi-line renderable with each line made of a | to create a vertical line.
Term.Layout.vLine — Method
vLine(
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 — Method
vLine(ren::AbstractRenderable; kwargs...)Construct a vLine with the same height as a renderable.
Term.Layout.vLine — Method
vLine(; style::Union{String, Nothing}=nothing, box::Symbol=:ROUNDED)Create a vLine as tall as the stdout console.
Term.Layout.center! — Method
center!(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 — Method
center(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 — Method
lvstack(renderables::RenderablesUnion...)Center align renderables and then vertically stack.
Term.Layout.hstack — Method
hstack(renderables...)Horizonatlly stack a variable number of renderables.
Term.Layout.hstack — Method
hstack(r1::RenderablesUnion, r2::RenderablesUnion )Horizontally stack two renderables to give a new renderable.
Term.Layout.leftalign! — Method
leftalign!(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 — Method
leftalign(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 — Method
lvstack(renderables::RenderablesUnion...)Left align renderables and then vertically stack.
Term.Layout.pad — Function
pad(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 — Function
pad(segments::AbstractVector{Segment}, left::Int = 0, right::Int = 0)Pad a renderable's segments to the left and the right.
Term.Layout.pad — Function
pad(s::Segment, left::Int = 0, right::Int = 0; kwargs...)Pad a segment.
Term.Layout.pad! — Method
pad!(ren::AbstractRenderable, left::Int, right::Int)In place version for padding a renderable.
Term.Layout.pad! — Method
pad!(ren::AbstractRenderable; width::Int)In place version for padding a renderable to achieve a given width.
Term.Layout.pad — Method
function 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 — Method
pad(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 — Method
pad(ren::AbstractRenderable, left::Int, right::Int)Pad an AbstractRenderable by padding each of its segments.
Term.Layout.pad — Method
pad(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! — Method
rightalign!(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 — Method
rightalign(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 — Method
lvstack(renderables::RenderablesUnion...)Right align renderables and then vertically stack.
Term.Layout.vertical_pad — Function
vertical_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 — Function
vertical_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! — Method
verti0cal_pad!(ren::AbstractRenderable, above::Int, below::Int)In place version for vertically padding a renderable.
Term.Layout.vertical_pad! — Method
pad!(ren::AbstractRenderable; width::Int)In place version for padding a renderable to achieve a given width.
Term.Layout.vertical_pad — Method
verticalpad(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 — Method
vertical_pad(ren::AbstractRenderable, above::Int, below::Int)Pad a renderable, vertically.
Term.Layout.vertical_pad — Method
vertical_pad(ren::AbstractRenderable; height::Int)
Vertical pad a renderable to achieve a target height.
Term.Layout.vstack — Method
vstack(renderables...)Vertically stack a variable number of renderables to give a new renderable