Import std.term.region
std.term.region
Laying out a screen's cells in rows and columns.
std.term's regions: a Region of a screen's cells, which splits into rows or columns by Constraints, as a full-screen app lays out its panes: a size that's Fixed, a Percent of what there is, at least a Min, or a share of what's left, Fill.
std/term/region.fb
Types
Region
struct
Public Struct Region Implements Hashable, Printable
A rectangle of a screen's cells: its top-left Column and Row, from 0, and its Width and Height.
Examples
Local screen = Region(0, 0, 80, 24)
Local rows = screen.SplitRows(Constraint.Fixed(1), Constraint.Fill(), Constraint.Fixed(1))
Expect(rows[0].Height == 1 && rows[1].Height == 22 && rows[2].Row == 23)
Local columns = rows[1].SplitColumns(Constraint.Percent(25), Constraint.Fill())
Expect(columns[0].Width == 20 && columns[1].Column == 20)-
Its left column, from 0.
-
Its top row, from 0.
-
How many columns wide it is.
-
How many rows high it is.
-
The column just past its right edge, and the row just past its bottom.
-
The row just past its bottom.
-
Whether it has no cells.
-
Whether the cell at
columnandrowis in it. -
It without
margincells on each side, or empty where there aren't that many. -
It without
horizontalcells on its left and right, andverticalones on its top and bottom. -
The cells it has in common with
other, which may be none. -
Its rows, top to bottom, as the
sizessay, each its whole width. -
Its columns, left to right, as the
sizessay, each its whole height. -
Like "(3, 4) 20x10".
ConstraintKind
enum
Public Enum ConstraintKind
How a Constraint sizes its part.
-
A number of cells.
-
A percent of the cells there are.
-
At least a number of cells, and a share of what's left like a Fill of 1.
-
A share of what's left by its weight, beside the other Fills'.
Constraint
struct
Public Struct Constraint Implements Hashable, Printable
How big one part of a split is: a Fixed number of cells, a Percent of the cells there are, at least a Min of them and a share of what's left like a Fill of 1, or a Fill, a share of what's left by its weight beside the other Fills'.
Examples
Expect("{Constraint.Fixed(3)}" == "Fixed(3)")
Local parts = Region(0, 0, 10, 1).SplitColumns(Constraint.Min(2), Constraint.Fill(3))
Expect(parts[0].Width + parts[1].Width == 10)-
What kind of constraint it is.
-
Its cells, percent, or weight, as its Kind has it.
-
sizecells. Panics for a negativesize. -
percentof the cells there are, rounded down. Panics for a percent below 0 or past 100. -
At least
sizecells, and a share of what's left, as a Fill of 1. Panics for a negativesize. -
A share of what's left, by
weightbeside the other Fills' weights: a Fill of 2 gets twice a Fill of 1's. Panics for a negativeweight. -
Like "Fixed(3)" or "Fill(1)".
Report an issue with this page or with FutureBlitz on GitHub.