Panels

Term.Panels.PanelType
Panel

Renderable with a panel surrounding some content:

    ╭──────────╮
    │ my panel │
    ╰──────────╯

When constructing a Panel, several keyword arguments can be used to set its appearance:

  • box::Symbol sets the Box type for the Panel's border
  • style::String sets the box's style (e.g., color)
  • title::Union{String,Nothing} sets the Panel's title
  • title_style::Union{Nothing,String} sets the title's style
  • title_justify::Symbol sets the location of the title
  • subtitle::Union{String,Nothing} sets the Panel's subtitle
  • subtitle_style::Union{Nothing,String} sets the subtitle's style
  • subtitle_justify::Symbol sets the location of the subtitle
  • justify::Symbol sets text's alignment (:left, :rigth, :center, :justify)
source
Term.Panels.PanelMethod
Panel(
    content::Union{AbstractString,AbstractRenderable},
    ::Val{false},
    padding::Padding;
    height::Union{Nothing,Int} = nothing,
    width::Int = 80,
    kwargs...,
)

Construct a Panel fitting content to it.

Tip

Content that is too large to fit in the given width will be trimmed. To avoid trimming, set fit=true when calling panel.

source
Term.Panels.PanelMethod
Panel(
    content::Union{AbstractString,AbstractRenderable},
    ::Val{true},
    padding::Padding;
    height::Union{Nothing,Int} = nothing,
    width::Union{Nothing,Int} = nothing,
    trim::Bool = true,
    kwargs...,
)

Construct a Panel fitting the content's width.

Warning

If the content is larger than the console terminal's width, it will get trimmed to avoid overflow, unless trim=false is given.

source
Term.Panels.PanelMethod
Panel(
    content::Union{AbstractString,AbstractRenderable};
    fit::Bool = false,
    padding::Union{Nothing,Padding,NTuple} = nothing,
    kwargs...,
)

Construct a Panel around an AbstractRenderable or AbstractString.

This is the main Panel-creating function, it dispatches to other methods based on the value of fit to either fith the Panel to its content or vice versa.

kwargs can be used to set various aspects of the Panel's appearance like the presence and style of titles, box type etc... see render below.

source
Term.Panels.PanelMethod
Panel(renderables; kwargs...)

Panel constructor for creating a panel out of multiple renderables at once.

source
Term.Panels.PanelMethod
Panel(; 
    fit::Bool = false,
    height::Int = 2,
    width::Int = 80,
    padding::Union{Vector,Padding,NTuple} = Padding(0, 0, 0, 0),
    kwargs...,  
)

Construct a Panel with no content.

Examples

julia> Panel(height=5, width=10)
╭────────╮
│        │
│        │
│        │
╰────────╯

julia> Panel(height=3, width=5)
╭───╮
│   │
╰───╯
source
Term.Panels.fix_layout_widthMethod
fix_layout_width(panel_call::Expr, depth::Int)::Expr

Go through an Expr with a :call to a Panel and add a keyword argument expression with the correct width (using parse_layout_args). Also go through any other argument to the call to fix inner panels' width.

source
Term.Panels.parse_layout_argsFunction
function parse_layout_args end

Parse the arguments of a Expr(:call, :Panel, ...) to add a keyword argument to fix the panel's width. A few diferent menthods are defined to handle different combinations of args/kwargs for the Panel call.

source
Term.Panels.renderMethod
render(
    content;
    box::Symbol = :ROUNDED,
    style::String = "default",
    title::Union{String,Nothing} = nothing,
    title_style::Union{Nothing,String} = nothing,
    title_justify::Symbol = :left,
    subtitle::Union{String,Nothing} = nothing,
    subtitle_style::Union{Nothing,String} = nothing,
    subtitle_justify::Symbol = :left,
    justify::Symbol = :left,
    text_justify::Bool=false,
    panel_measure::Measure,
    content_measure::Measure,
    Δw::Int,
    Δh::Int,
    padding::Padding,
)::Panel

Construct a Panel's content.

source
Term.Panels.@nested_panelsMacro
macro nested_panels(layout_call)

Macro to automate layout of multiple nested Panel. The width of the panels is automatically adjusted based on the depth of eeach nested level.

Uses fix_layout_width recursively to add a keyword argument width to each Panel.

source