Layout

Term.Layout.PlaceHolder — Type
mutable struct PlaceHolder <: AbstractLayoutElement
    segments::Vector{Segment}
    measure::Measure
end

A renderable used as a place holder when creating layouts (e.g. with grid).

Examples


println(PlaceHolder(25, 10))

╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲
╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲
╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲
╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲
╲ ╲ ╲ (25 × 10) ╲ ╲ ╲ ╲
╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲
╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲
╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲
╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲
╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲
source
Term.Layout.PlaceHolder — Method
PlaceHolder(
    h::In,
    w::Int;
    style::String = "dim",
    text::Union{Nothing,String} = nothing,
)

Create a PlaceHolder with additional style information.

source
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.

source
Term.Layout.hLine — Method
hLine(width::Number, style::Union{String, Nothing}; box::Symbol=TERM_THEME[].box)

Create a styled hLine of given width.

source
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.

source
Term.Layout.hLine — Method
hLine(ren::AbstractRenderable; kwargs)

Construct an hLine with same width as a renderable.

source
Term.Layout.hLine — Method
hLine(; style::Union{String, Nothing}=nothing, box::Symbol=TERM_THEME[].box)

Construct an hLine as wide as the stdout.

source
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.

source
Term.Layout.vLine — Method
vLine(ren::AbstractRenderable; kwargs...)

Construct a vLine with the same height as a renderable.

source
Term.Layout.vLine — Method
vLine(; style::Union{String, Nothing}=nothing, box::Symbol=:ROUNDED)

Create a vLine as tall as the stdout console.

source
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)

             ╭───────────────────────╮
             ╰───────────────────────╯
╭────────────────────────────────────────────────╮
╰────────────────────────────────────────────────╯
source
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)

             ╭───────────────────────╮
             ╰───────────────────────╯
╭────────────────────────────────────────────────╮
╰────────────────────────────────────────────────╯
source
Term.Layout.cvstack — Method
lvstack(renderables::RenderablesUnion...)

Center align renderables and then vertically stack.

source
Term.Layout.hstack — Method
hstack(r1::RenderablesUnion, r2::RenderablesUnion   )

Horizontally stack two renderables to give a new renderable.

source
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)

╭───────────────────────╮ ╰───────────────────────╯ ╭────────────────────────────────────────────────╮ ╰────────────────────────────────────────────────╯

source
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)


╭───────────────────────╮
╰───────────────────────╯
╭────────────────────────────────────────────────╮
╰────────────────────────────────────────────────╯
source
Term.Layout.lvstack — Method
lvstack(renderables::RenderablesUnion...)

Left align renderables and then vertically stack.

source
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.

source
Term.Layout.pad — Function
pad(s::Segment, left::Int = 0, right::Int = 0; kwargs...)

Pad a segment.

source
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.

source
Term.Layout.pad! — Method
pad!(ren::AbstractRenderable, left::Int, right::Int)

In place version for padding a renderable.

source
Term.Layout.pad! — Method
pad!(ren::AbstractRenderable; width::Int)

In place version for padding a renderable to achieve a given width.

source
Term.Layout.pad — Method
function pad(text::AbstractString, target_width::Int, method::Symbol, lw::Int; bg = nothing)::String

complete 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.

source
Term.Layout.pad — Method
pad(text::AbstractString, target_width::Int, method::Symbol)::String

Pad 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"
source
Term.Layout.pad — Method

pad(ren::AbstractRenderable, left::Int, right::Int)

Pad an AbstractRenderable by padding each of its segments.

source
Term.Layout.pad — Method

pad(ren::AbstractRenderable; width::Int)

Pad a renderable to achieve a target width.

Note

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
source
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)

                         ╭───────────────────────╮
                         ╰───────────────────────╯
╭────────────────────────────────────────────────╮
╰────────────────────────────────────────────────╯
source
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)

                         ╭───────────────────────╮
                         ╰───────────────────────╯
╭────────────────────────────────────────────────╮
╰────────────────────────────────────────────────╯
source
Term.Layout.rvstack — Method
lvstack(renderables::RenderablesUnion...)

Right align renderables and then vertically stack.

source
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.

source
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.

source
Term.Layout.vertical_pad! — Method
verti0cal_pad!(ren::AbstractRenderable, above::Int, below::Int)

In place version for vertically padding a renderable.

source
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).

source
Term.Layout.vstack — Method
vstack(renderables...)

Vertically stack a variable number of renderables to give a new renderable

source