Layout

Term.Layout.PlaceHolderType
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.PlaceHolderMethod
PlaceHolder(
    h::In,
    w::Int;
    style::String = "dim",
    text::Union{Nothing,String} = nothing,
)

Create a PlaceHolder with additional style information.

source
Term.Layout.hLineMethod
hLine(text::AbstractString; style::Union{String, Nothing}=nothing, box::Symbol=:ROUNDED)

Construct an hLine as wide as the stdout with centered text.

source
Term.Layout.hLineMethod
hLine(width::Number, style::Union{String, Nothing}; box::Symbol=:ROUNDED)

Create a styled hLine of given width.

source
Term.Layout.hLineMethod
hLine(width::Number, text::String; style::Union{String, Nothing}=nothing, box::Symbol=:ROUNDED)

Creates an hLine object with texte centered horizontally.

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

Construct an hLine with same width as a renderable.

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

Construct an hLine as wide as the stdout.

source
Term.Layout.vLineMethod
vLine(height::Number, style::Union{String, Nothing}; box::Symbol=:ROUNDED)

Create a vLine given a height and, optionally, style information.

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

Construct a vLine with the same height as a renderable.

source
Term.Layout.vLineMethod
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.centerMethod
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.cvstackMethod
lvstack(renderables::RenderablesUnion...)

Center align renderables and then vertically stack.

source
Term.Layout.hstackMethod
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.leftalignMethod
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.lvstackMethod
lvstack(renderables::RenderablesUnion...)

Left align renderables and then vertically stack.

source
Term.Layout.padFunction

pad(segments::AbstractVector{Segment}, left::Int = 0, right::Int = 0)

Pad a renderable's segments to the left and the right.

source
Term.Layout.padFunction

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!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.padMethod
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.padMethod

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

Pad an AbstractRenderable by padding each of its segments.

source
Term.Layout.padMethod

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.rightalignMethod
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.rvstackMethod
lvstack(renderables::RenderablesUnion...)

Right align renderables and then vertically stack.

source
Term.Layout.vertical_padFunction
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_padFunction
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!Method
verti0cal_pad!(ren::AbstractRenderable, above::Int, below::Int)

In place version for vertically padding a renderable.

source
Term.Layout.vertical_padMethod

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.vstackMethod
vstack(renderables...)

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

source