prototty render
Definition of types and traits for describing how to render a type to a grid of characters (such as a terminal).
Example
Let's make a title element which renders a single line of text, within a fixed width rectangle of height 1. The entire source code for this example is in the "examples/title" directory in this repo.
extern crate prototty_render;
use *;
// Define a type representing the element
// Define a type representing how the element will be rendered.
;
// Describe how a TitleView renders a Title by implementing View.
// What if we want a way to rendered titles centered within their width?
;
// Let's demonstrate both of these in action by rendering a title
// twice - once left aligned, an once centered:
;
We can now render a Title
with 3 of different views:
TitleView
renders aTitle
left-alignedCenteredTitleView
renders aTitle
centered within its widthDemoTitleView
renders aTitle
twice, using the other two views
This isn't much use by itself. To actually get something onto a screen, we'll need a frontend. Continue this example in:
Or see how to decorate it with a border in prototty-common.