Git Product home page Git Product logo

displaystructure.jl's Introduction

Display Structure

Build Status
CI

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

Usage

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
end;

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

Example

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.

displaystructure.jl's People

Contributors

foldfelis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

yonghee-kim

displaystructure.jl's Issues

minor advice: this loop can be remove by array operations.

For loops' performance here, here, and here, can be accelerated.

minor advice: this loop can be remove by array operations.
for example

len = index.pre + index.post + 1
old_len = length(row.context)
new_len = old_len + len
resize!(row.context, new_len)
copyto!(row.context, index.i + len, row.context, index.i, old_len - index.i + 1)
fill!(@view(row.context[index.i:index.i+len]), row.background)

(correctness need to be checked)

_Originally posted by @chengchingwen in #3

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Allow drawing boardless panel?

Hello
Thanks for nice package.

I've noticed that you already support borderless Rectangle but those option is not accessble from Panel

I've made this commit to pass kwargs to the Rectangle from the Panel
YongHee-Kim@87a56dd

here is MWE

using DisplayStructure
DisplayStructure.Panel("TestPanel", [5,12],[1,1];background = '.', border = false) |> render

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.