Build Status |
---|
DisplayArray provides arrays that index character in text width unit. And therefore maintains an immutable display size for terminal emulators.
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
- Using package
julia> using DisplayStructure; const DS = DisplayStructure;
- Declare an area
julia> area = DS.DisplayArray(DS.Rectangle(20, 100))
DisplayArray(size=(20, 100), background char=Char(32))
- Declare a label
julia> str = "會動的字串"; width = textwidth(str); label = DS.DisplayRow(width)
DisplayRow(size=10, background char=Char(32))
julia> label[1:end] = str
"會動的字串"
- 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
, one can easily construct a hierarchical display structure.
- Using package
julia> using DisplayStructure; const DS = DisplayStructure;
- 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
end;
julia> form = gen_form();
- 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.