The text-draw Reference Manual

This is the text-draw Reference Manual, version 1.0.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Jul 13 22:09:56 2025 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 text-draw

A utility library to draw nice presentations in pure text.

Maintainer

Yukari Hafner <>

Author

Yukari Hafner <>

Home Page

https://shinmera.github.io/text-draw

Source Control

(GIT https://github.com/Shinmera/text-draw.git)

Bug Tracker

https://github.com/Shinmera/text-draw/issues

License

zlib

Version

1.0.0

Dependency

documentation-utils (system).

Source

text-draw.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 text-draw/text-draw.asd

Source

text-draw.asd.

Parent Component

text-draw (system).

ASDF Systems

text-draw.


3.1.2 text-draw/package.lisp

Source

text-draw.asd.

Parent Component

text-draw (system).

Packages

org.shirakumo.text-draw.


3.1.3 text-draw/toolkit.lisp

Dependency

package.lisp (file).

Source

text-draw.asd.

Parent Component

text-draw (system).

Public Interface
Internals

3.1.4 text-draw/styles.lisp

Dependency

toolkit.lisp (file).

Source

text-draw.asd.

Parent Component

text-draw (system).

Public Interface
Internals

3.1.5 text-draw/draw.lisp

Dependency

styles.lisp (file).

Source

text-draw.asd.

Parent Component

text-draw (system).

Public Interface

3.1.6 text-draw/documentation.lisp

Dependency

draw.lisp (file).

Source

text-draw.asd.

Parent Component

text-draw (system).


4 Packages

Packages are listed by definition order.


4.1 org.shirakumo.text-draw

Source

package.lisp.

Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Macros

Macro: compose (stream &body parts)

Convenience shorthand to composite shapes together.

Each PART should be a list composed of the X and Y offset and the string of the block to compose. Eg:

(compose T
(0 0 (fill 20 11))
(6 4 (box "Hello")))

STREAM should be a format stream designator.

Package

org.shirakumo.text-draw.

Source

draw.lisp.


5.1.2 Ordinary functions

Function: align (text alignment &key stream)

Aligns a text block to produce a fixed width block of lines.

ALIGNMENT designates how the text block is aligned within the box.

STREAM should be a format stream designator.

See ALIGNMENT

Package

org.shirakumo.text-draw.

Source

draw.lisp.

Function: alignment (alignment line width)

Returns the number of characters to insert to achieve the desired alignment.

Returns a cons with the characters on the left and right hand sides of the line to insert.

ALIGNMENT can be one of :LEFT :RIGHT :MIDDLE :CENTER.

Package

org.shirakumo.text-draw.

Source

toolkit.lisp.

Function: arrow (dir &optional type)

Return an arrow character.

DIR can be one of :LEFT :WEST
:RIGHT :EAST
:UP :NORTH
:DOWN :SOUTH :UP-DOWN :NORTH-SOUTH :LEFT-RIGHT :EAST-WEST

TYPE can be one of: :HEAD
:LIGHT-HEAD :EMPTY-HEAD :TRIANGLE
:LIGHT
T :NORMAL
:HEAVY
:LARGE
:VERY-HEAVY :DOUBLE
:CIRCLE :FULL-CIRCLE :DIAMOND :FULL-DIAMOND

Package

org.shirakumo.text-draw.

Source

styles.lisp.

Function: background (type)

Return a background character.

TYPE can be one of: :TRANSPARENT
T :WHITE
:BLACK
:DARK-GRAY
:GRAY
:LIGHT-GRAY

Package

org.shirakumo.text-draw.

Source

styles.lisp.

Function: box (text &key stream width align background)

Surrounds the TEXT with a box.

WIDTH designates the width of the box. If NIL or T the box fits the given text block. If the text is made up of lines that exceed the width of the box, the text is wrapped automatically.

ALIGN designates how the text block is aligned within the box.

BACKGROUND designates the background of the box.

STREAM should be a format stream designator.

See ALIGNMENT
See BACKGROUND
See WRAP

Package

org.shirakumo.text-draw.

Source

draw.lisp.

Function: check (filled &key stream label)

Generates a simple checkbox.

If LABEL is given it is printed next to the checkbox.

STREAM should be a format stream designator.

Package

org.shirakumo.text-draw.

Source

draw.lisp.

Function: composite (a b &key a-offset b-offset stream)

Composites two text blocks together.

A-OFFSET and B-OFFSET should be conses of X and Y offsets to apply to the respective blocks before compositing.

When compositing, B is overlaid on top of A in such a way that any character in B takes precedence unless that character is a whitespace character that isn’t a non-breaking space.

Effectively this means that the non-breaking space is considered "opaque", and all other white space is "transparent."

STREAM should be a format stream designator.

Package

org.shirakumo.text-draw.

Source

draw.lisp.

Function: fill (width height &key stream background)

Fill a block with a background pattern.

STREAM should be a format stream designator.

See BACKGROUND

Package

org.shirakumo.text-draw.

Source

draw.lisp.

Function: horizontal-line (width height &key stream bend start end)

Generates a horizontally oriented line.

START and END if given designate the arrowheads to draw at either end of the line.

BEND can be one of :LEFT :START :RIGHT :END :MIDDLE :CENTER and designates where in the line a bend should be generated when HEIGHT is greater than one.

STREAM should be a format stream designator.

See ARROW

Package

org.shirakumo.text-draw.

Source

draw.lisp.

Function: line (width height &rest args)

Generates a line.

If the width is greater or equal to the height a horizontal line is generated, otherwise a vertical one.

See HORIZONTAL-LINE
See VERTICAL-LINE

Package

org.shirakumo.text-draw.

Source

draw.lisp.

Function: lines (text)

Returns a list of lines from the split text.

Package

org.shirakumo.text-draw.

Source

toolkit.lisp.

Function: node (inputs outputs &key stream label background)

Print a flow chart node with the given input and output ports.

Both INPUTs and OUTPUTs should be lists of port entries. Each port entry should either be the name of the port or a cons consisting of the name and the value connected at that port.

LABEL if given designates the label in the center of the node to print.

BACKGROUND designates the background of the node box.

STREAM should be a format stream designator.

See BACKGROUND

Package

org.shirakumo.text-draw.

Source

draw.lisp.

Function: pad (text size &key stream background)

Pads the text block on all sides by SIZE.

SIZE may either be an integer, or a list designating the padding to add on each side in order of LEFT TOP RIGHT BOTTOM.

BACKGROUND designates the fill character of the padding.

STREAM should be a format stream designator.

See BACKGROUND

Package

org.shirakumo.text-draw.

Source

draw.lisp.

Function: plot (function &key width height left right bottom top stream background)

Generates a plot.

The plot is generated according to the output of FUNCTION for values within the region of [LEFT, RIGHT], and clamped into the range of [BOTTOM, TOP]. If either BOTTOM or TOP are not given, they are computed based on the values of FUNCTION.

The output has an area as given by WIDTH and HEIGHT, which includes a border that denotes the axis values, meaning the actual plot has an area of WIDTH-2 x HEIGHT-2.

STREAM should be a format stream designator.

Package

org.shirakumo.text-draw.

Source

draw.lisp.

Function: progress (percentage &key stream width label)

Prints a simple progress bar filled to PERCENTAGE.

If the percentage is outside of [0,100] then the bar is either entirely empty or entirely full.

When LABEL is T, some of WIDTH is taken up to print the percentage as a number label.

STREAM should be a format stream designator.

Package

org.shirakumo.text-draw.

Source

draw.lisp.

Function: radio (filled &key stream label)

Generates a simple radio button

If LABEL is given it is printed next to the radio button.

STREAM should be a format stream designator.

Package

org.shirakumo.text-draw.

Source

draw.lisp.

Function: rows (&rest parts)

Fuse a couple of parts together via new lines.

Returns a new string with each PART on a line.

Package

org.shirakumo.text-draw.

Source

draw.lisp.

Function: style (text style)

Returns the text transformed into the given style.

STYLE can be one of:

:sans
:bold
:italic
:bold-italic
:serif
:serif-bold
:serif-italic
:serif-bold-italic
:script
:script-bold
:fraktur
:fraktur-bold
:monospace
:doublestruck

Note that by far not all characters support all of these styles. The text is transformed on a best-effort basis.

Package

org.shirakumo.text-draw.

Source

styles.lisp.

Function: table (table &key stream padding borders)

Format tabular data.

The TABLE should be a list of lists, with each inner list being a row and each row having the same number of columns.

BORDERS designates whether borders should be drawn around the cells or not.

PADDING sets the number of spaces to surround each cell’s contents by.

STREAM should be a format stream designator.

Package

org.shirakumo.text-draw.

Source

draw.lisp.

Function: translate (string x y &key stream)

Translates the given string block by X and Y.

This is the same as adding padding on the respective sides of the block.

STREAM should be a format stream designator.

Package

org.shirakumo.text-draw.

Source

draw.lisp.

Function: tree (root children-fun &key stream max-depth key)

Format a tree structure.

ROOT is the first element at the root. CHILDREN-FUN should be a function of one argument (a node in the tree) that returns a SEQUENCE of child nodes for that node.

KEY should be a function that takes a node and whose return value is used to print the node’s entry in the tree.

MAX-DEPTH should be the maximum depth to which the tree is printed. Entries at a depth below that are abbreviated via three dots. If NIL or T are passed, no max depth is applied.

STREAM should be a format stream designator.

Package

org.shirakumo.text-draw.

Source

draw.lisp.

Function: vertical-line (width height &key stream bend start end)

Generates a vertically oriented line.

START and END if given designate the arrowheads to draw at either end of the line.

BEND can be one of :TOP :START :BOTTOM :END :MIDDLE :CENTER and designates where in the line a bend should be generated when WIDTH is greater than one.

STREAM should be a format stream designator.

See ARROW

Package

org.shirakumo.text-draw.

Source

draw.lisp.

Function: width (text)

Returns the width of the text block respecting line feeds.

Package

org.shirakumo.text-draw.

Source

toolkit.lisp.

Function: wrap (line &optional width)

Perform line wrapping on a block of text.

Returns a list of text lines.
Wrapping is performed on every Linefeed and Return, and if the current line exceeds WIDTH number of characters. In the latter case, a line is wrapped at the last whitespace position if there is one within the current line, or at the width if there is not. Whitespace excluding the non-breaking space is trimmed from ends and starts of lines.

Package

org.shirakumo.text-draw.

Source

toolkit.lisp.


5.2 Internals


5.2.1 Special variables

Special Variable: *here*
Package

org.shirakumo.text-draw.

Source

styles.lisp.

Special Variable: *styles*
Package

org.shirakumo.text-draw.

Source

styles.lisp.


5.2.2 Macros

Macro: with-normalized-stream ((stream streamish) &body body)
Package

org.shirakumo.text-draw.

Source

toolkit.lisp.


5.2.3 Ordinary functions

Function: load-styles (&optional file)
Package

org.shirakumo.text-draw.

Source

styles.lisp.

Function: split (string split)
Package

org.shirakumo.text-draw.

Source

toolkit.lisp.

Function: white-char-p (char)
Package

org.shirakumo.text-draw.

Source

toolkit.lisp.

Function: wrap-char-p (char)
Package

org.shirakumo.text-draw.

Source

toolkit.lisp.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   A   B   C   F   H   L   M   N   P   R   S   T   V   W  
Index Entry  Section

A
align: Public ordinary functions
alignment: Public ordinary functions
arrow: Public ordinary functions

B
background: Public ordinary functions
box: Public ordinary functions

C
check: Public ordinary functions
compose: Public macros
composite: Public ordinary functions

F
fill: Public ordinary functions
Function, align: Public ordinary functions
Function, alignment: Public ordinary functions
Function, arrow: Public ordinary functions
Function, background: Public ordinary functions
Function, box: Public ordinary functions
Function, check: Public ordinary functions
Function, composite: Public ordinary functions
Function, fill: Public ordinary functions
Function, horizontal-line: Public ordinary functions
Function, line: Public ordinary functions
Function, lines: Public ordinary functions
Function, load-styles: Private ordinary functions
Function, node: Public ordinary functions
Function, pad: Public ordinary functions
Function, plot: Public ordinary functions
Function, progress: Public ordinary functions
Function, radio: Public ordinary functions
Function, rows: Public ordinary functions
Function, split: Private ordinary functions
Function, style: Public ordinary functions
Function, table: Public ordinary functions
Function, translate: Public ordinary functions
Function, tree: Public ordinary functions
Function, vertical-line: Public ordinary functions
Function, white-char-p: Private ordinary functions
Function, width: Public ordinary functions
Function, wrap: Public ordinary functions
Function, wrap-char-p: Private ordinary functions

H
horizontal-line: Public ordinary functions

L
line: Public ordinary functions
lines: Public ordinary functions
load-styles: Private ordinary functions

M
Macro, compose: Public macros
Macro, with-normalized-stream: Private macros

N
node: Public ordinary functions

P
pad: Public ordinary functions
plot: Public ordinary functions
progress: Public ordinary functions

R
radio: Public ordinary functions
rows: Public ordinary functions

S
split: Private ordinary functions
style: Public ordinary functions

T
table: Public ordinary functions
translate: Public ordinary functions
tree: Public ordinary functions

V
vertical-line: Public ordinary functions

W
white-char-p: Private ordinary functions
width: Public ordinary functions
with-normalized-stream: Private macros
wrap: Public ordinary functions
wrap-char-p: Private ordinary functions