The frame: a laid out diagram on the terminal's cell grid. A layout makes
one, and each painter reads it. Cells are 0-based: c is the column, r
the row.
| Field | Holds |
|---|---|
groups | frames round other elements: { c, r, w, h, style, line, dividers } |
boxes | node shapes: { c, r, w, h, shape, style, line } |
routes | edges: { points, line, head, tail, style } |
texts | labels: { c, r, text, style, knockout } |
kind | the diagram type, "flowchart" or "sequence"; nil on a frame built by hand |
title | the diagram's name for a reader who cannot see it, or nil: the source's accTitle |
descr | the diagram's description, which may hold newlines, or nil: the source's accDescr |
A box's outline runs through the centres of its border cells: rows r
and r + h - 1, columns c and c + w - 1. The cells inside hold its
label, so a stroke never enters a label cell.
A route's points are { c, r } pairs. Two points in a row differ in one
coordinate. An end point is the cell of what the route meets: a box's
border cell, or a cell of another route. The route joins that cell's
line, unless a marker stands in front of it. A head marker takes the
cell before the last point, a tail marker the cell after the first.
A text is one line. knockout marks a text that lies on a stroke, an
edge's label for one: a painter clears the stroke under it.
A divider of a group, { r, line }, is a rule across the group at row
r.
The paint order is groups, boxes, routes, texts.
| Name | Signature |
|---|---|
| new | new(cols, rows) -> frame |
| fit | fit(shape, label_cols, label_rows, pad) -> w, h, dc, dr |
| cells | cells(points) -> cells |
| check | check(frame) -> ok, err |
new(
cols,rows) ->frame
Make an empty frame
fit(
shape,label_cols,label_rows,pad) ->w,h,dc,dr
Size a box of a shape round a label
Returns the box's width and height in cells, and the offset of the
label's first cell from the box's first cell. pad is the blank columns
kept on each side of the label, 1 when not given.
A shape whose outline leans or curves into the box takes columns or rows from the label area, and the box grows by them: a subroutine's inner sides, a cylinder's lid, a pill's round ends, a rhombus's points, a leaning side.
cells(
points) ->cells
List the cells of a route's points
points are { c, r } pairs as a route holds them. Returns each cell the
line through them passes, once and in order, as { c, r } pairs: the
first point, the cells of each segment, a corner once. Two points in a
row must differ in one coordinate, as check asks of a route.
check(
frame) ->ok,err
Check a frame against the rules its painters rely on
Refuses an element outside the frame, a box or a group too small to have an inside, an unknown shape, line or marker, a route whose neighbouring points differ in both coordinates, a route too short for its markers, a text that holds a newline, an unknown kind, and a title or a description that is no string. A painter given a checked frame raises nothing.