A renderable 1D and 2D character array.
Author foldfelis
6 Stars
Updated Last
7 Months Ago
Started In
June 2020

Display Structure

Build Status

Display Structure

DisplayArray provides arrays that index character in text width unit. And therefore maintains an immutable display size for terminal emulators.

Quick start

The package can be installed with the Julia package manager. From the Julia REPL, type ] to enter the Pkg REPL mode and run:

pkg> add DisplayStructure


From scratch

  1. Using package
julia> using DisplayStructure; const DS = DisplayStructure;
  1. Declare an area
julia> area = DS.DisplayArray(DS.Rectangle(20, 100))
DisplayArray(size=(20, 100), background char=Char(32))
  1. Declare a label
julia> str = "會動的字串"; width = textwidth(str); label = DS.DisplayRow(width)
DisplayRow(size=10, background char=Char(32))

julia> label[1:end] = str
  1. Render area and label
julia> DS.render(area, pos=(1, 1)); DS.render(label, pos=(5, 5))

Hint: The result may be different from the picture showing bellow. One may need to integrate Terming.jl to completely dominate terminal control.

With DisplayStack

with DisplayStack, one can easily construct a hierarchical display structure.

  1. Using package
julia> using DisplayStructure; const DS = DisplayStructure;
  1. Define a function that returns a DisplayStack
julia> function gen_form()
    display_stack =  DS.DisplayStack()
    push!(display_stack, :form => DS.Panel("Title", [20, 100], [1, 1]))
    push!(display_stack, :str => DS.Label("會動的字串", [5, 5]))

    return display_stack

julia> form = gen_form();
  1. Render it!!
julia> DS.render(form)


The example demonstrates a minimum viable product that shows a border and a string. Integrate with keyboard key reading feature (implemented under Terming.jl), the movable string can be controlled by pressing w, s, a and d, press ESC to quit.

It is recommended that one use Crayons.jl to gain more decorations. A example shows how to integrate with Crayons.

Used By Packages

No packages found.