Tables
Tables are first defined by the Column class. An array of columns is sent into the table constructor to define the structure of the columns.
There are currently three types of table classes:
- Table - Basic table, the first row is in bold to indicate column headers
- BarTable - There can be an overarching title along the top with no columns and a single title. Below that will be the column headers. Both of these lines are filled with specified text and fill color.
- AlternatingTable - Much like the basic table, but with an alternating soft fill color on * every other line
The following is a BarTable:

The following is a Table with Markup:

Column
A column defines:
- Width - whether it should be calculated based on the widest text in the data, or set statically
- Maximum Width - if it is calculated, the upper limit to prevent a huge column
- Left Padding - spacing on the left side of each text in a cell, normally only useful on the first cell and when the cells have a fill color (adds some breathing space)
- Right Padding - spacing on the right side of each cell, defaulted to three spaces
- Justification - the left, center or right justification for a column
- Text and Fill Colors - Color scheme for the column
The default column is a calculated width, with three spaces along the right side, left justified with no colors. If the data sent into the table has rows with more columns than Columns specified in the constructor, the default Column will be used.
Software Documentation
The following sections lists the software documentation for:
Column Class
Constructor
The column constructor defining two key elements of a column, the header text and whether to calculate the width based on the data, or set a static width.
__construct($headerText = null, $width = null)
Parameters | ||
---|---|---|
Name | Type | Description |
$headerText | string | null | The text of the header for this column or null if none is desired |
$width | int | null | If left null, then it will be calculated based on the widest text, plus any padding, if an integer is sent in, then it will be the overall width (including the padding) |
setHeaderText, getHeaderText, hasHeaderText
Setter and getter for the header text.
setHeaderText($headerText)
getHeaderText()
hasHeaderText()
Parameters | ||
---|---|---|
Name | Type | Description |
$headerText | string | null | The text of the header for this column or null if none is desired |
setWidth, getWidth
Setter and getter for the width. If the width is null, then it will be automatically calculated based on the widest data plus the padding. If it is set as a static number, then it will be overall width (including the headers)
setWidth($width)
getWidth()
Parameters | ||
---|---|---|
Name | Type | Description |
$width | int | null | The width or null if calculated |
setMaximumWidth, getMaximumWidth
Setter and getter for the maximum width. This value is only important when the width is set to be calculated. This number can then be used to create a stop gap width if some data is just too wide.
setMaximumWidth($maximumWidth)
getMaximumWidth()
Parameters | ||
---|---|---|
Name | Type | Description |
$maximumWidth | int | null | The maximum width or null to allow even the widest data to dictate width |
setRightPadding, setLeftPadding, setLeftPadding, getLeftPadding
Setter and getters for the left and right padding. Right padding should be used on every column to breathe space into the table. The left padding is mainly for the first column if there is fill, it helps to put in a one or two blank spaces to breathe.
setRightPadding($rightPadding)
getRightPadding()
setLeftPadding($leftPadding)
getLeftPadding()
Parameters | ||
---|---|---|
Name | Type | Description |
$right(left)Padding | int | The number of blank characters |
setJustification, getJustification
Setter and getter for the justification. You can send in the strings, such as "left", "Right", or the Justification constants such as Justification::LEFT.
setJustification($justification)
getJustification()
Parameters | ||
---|---|---|
Name | Type | Description |
$justification | string | int - either a justification constant from HTML or "left", "Center"...etc | the justification |
setColors, getTextColor, getFillColor
Setter and getters for the column text and fill color.
setColors($textColor = null, $fillColor = null)
getTextColor()
getFillColor()
Parameters | ||
---|---|---|
Name | Type | Description |
$textColor | Any valid Color constructor initial value | The text color |
$fillColor | Any valid Color constructor initial value | The text color |
Table Class
The Table class creates a simple table, which bolds the header, if specified.
Constructor
The Table constructor requires two parameter, the HTML object (which should be only one instance that represents the terminal) and an array of Column object to define the column structure.
__construct($html,$columnDefinitions)
Parameters | ||
---|---|---|
Name | Type | Description |
$clio | Clio | Clio object |
$columnDefinitions | Column[] | An array of Column objects defining column properties, if there are less Column definitions than column data, default Column objedts will be automatically created. |
setColumnDefinition
Set the Column definition for one column.
setColumnDefinition($columnIndex, Column $column)
Parameters | ||
---|---|---|
Name | Type | Description |
$columnIndex | integer | The column index for the defined definition |
$columnDefinitions | Column | A Column object defining column properties |
draw
Draw the data, which is a multidimensional array of rows, which are array of cells for each row.
draw($data)
Parameters | ||
---|---|---|
Name | Type | Description |
$data | string[][] | Array of row data |
BarTable Class
The Bar Title has an (optional) overarching title along the top with no columns and a single title. Below that will be the column headers. Both of these lines are filled with specified text and fill color, with an optional line at the bottom to round it out.
Constructor
The BarTable constructor requires one parameter, the Clio object (which should be only one instance that represents the terminal). A title can also be specified which will span the whole table, as well as whether to have a small stylistic line at the bottom of the table (which works well if there are fill colors).
__construct($clio, $columns, $title = null, $showBottomLine = true)
Parameters | ||
---|---|---|
Name | Type | Description |
$clio | Clio | Clio object |
$columnDefinitions | Column[] | An array of Column objects defining column properties, if there are less Column definitions than column data, default Column objedts will be automatically created. |
$title | string | A title that runs across the entire table |
$showBottomLine | boolean | Whether to show a stylistic line at the bottom of the table. |
setTitle
Set the title for the entire table.
setTitle($text)
Parameters | ||
---|---|---|
Name | Type | Description |
$text | string | The title (which will be truncated if wider than the table) |
setColors
Set the color scheme for the table. The bar text and fill will color the title and the headers, the body text and fill will color the data.
setColors($barText, $barFill, $bodyText, $bodyFill)
Parameters | ||
---|---|---|
Name | Type | Description |
$barText | Any valid Color constructor initial value | The title and header text color |
$barFill | Any valid Color constructor initial value | The title and header fill color |
$bodyText | Any valid Color constructor initial value | The text color of the table data |
$bodyFill | Any valid Color constructor initial value | The fill color of the table data |
setShowBottomLine
Whether to add a closing line at the bottom of the table, which can look nice when the $bodyFill color is set.
setShowBottomLine($showBottomLine)
Parameters | ||
---|---|---|
Name | Type | Description |
$showBottomLine | booolean | Whether to show the bottom line |
draw
Draw the data, which is a multidimensional array of rows, which are array of cells for each row.
draw($data)
Parameters | ||
---|---|---|
Name | Type | Description |
$data | string[][] | Array of row data |
AlternatingTable Class
The AlternatingTable class draws a table similar to the Table class, except there is an alternating color for the rows of data.
Constructor
The AlternatingTable constructor requires one parameter, the HTML object (which should be only one instance that represents the terminal). The alternating background can also be set. It is defaulted to Old Lace, which is a light yellow.
__construct($html, $columns, $alternatingBackground = "oldlace")
Parameters | ||
---|---|---|
Name | Type | Description |
$html | Clio | Clio HTML object |
$columnDefinitions | Column[] | An array of Column objects defining column properties, if there are less Column definitions than column data, default Column objedts will be automatically created. |
$alternatingBackground | Any valid Color constructor initial value | The fill color of every other line |
setAlternatingFill
Set the fill color for everything row.
setAlternatingFill($alternatingBackground)
Parameters | ||
---|---|---|
Name | Type | Description |
$alternatingBackground | Any valid Color constructor initial value | The fill color of every other line |
draw
Draw the data, which is a multidimensional array of rows, which are array of cells for each row.
draw($data)
Parameters | ||
---|---|---|
Name | Type | Description |
$data | string[][] | Array of row data |