TBMANLIB_ConsoleComponents Package
Author: woeoio.
The TBMANLIB_ConsoleComponents contributed package is a set of text-interface components for console programs. It has progress bars (cProgressBar), small line charts (cSparkline), bar charts (cVBar), a table (cDataGrid), bordered panels (cConsolePanel), a manager that places panels in a grid, a sidebar or a header and footer (cConsoleLayout), colour themes (cConsoleTheme), and helpers for colours and positions (cColorHelper, cLayoutHelper). The components draw into the screen buffer of the full-screen mode of cConsole, in the package TBMANLIB_ConsoleCore; the program then writes the buffer to the console with Refresh. This section documents version 0.0.0.0, published on TWINSERV on 1 February 2026 with no licence declared. The package describes itself as “TBMAN: Text UI (TUI) component library base on ConsoleCore”.
Note
The tools that check this documentation’s samples run a sample and compare what it prints with Debug.Print. They cannot yet read what a program writes to a console. So the samples on these pages are compiled, and what the components draw on the console has not been checked by running them. Statements about what a component draws follow the package’s source, and will be checked once the tools can capture a console.
Dim con As New cConsole
Dim layout As cConsoleLayout
Dim bar As cProgressBar
Dim theme As cConsoleTheme = mConsoleThemeFactory.CreateHTOP()
con.EnterFullScreenMode ' the components need the buffer of this mode
Set layout = New cConsoleLayout(con)
Set bar = New cProgressBar(con)
layout.AddPanel "main", 0, 0, con.Width, 5, "Copying"
layout.Render theme
bar.RenderWithLabel 2, 2, con.Width - 4, 62, "files"
con.Refresh
con.ReadKey True
con.Restore
Warning
In version 0.0.0.0 the components that take a cConsole cannot be used with the published package TBMANLIB_ConsoleCore. The package compiles, but the constructors of cProgressBar, cSparkline, cVBar, cDataGrid, cConsoleLayout and cLayoutHelper, and the members of cConsolePanel that take a cConsoleBuffer, raise error -2147467262, No such interface supported, when they are given an object of the published ConsoleCore, and a program cannot read the ConsoleRect and ConsolePosition values that the components return. The two packages has the details. Only cConsoleTheme, the module mConsoleThemeFactory, cColorHelper and the geometry of cConsolePanel work. The outputs that the samples on these pages show are those of the code of the two packages compiled into one project, and not of a project that references the two packages.
Using the package
The two packages
Like ConsoleCore, the package is meant for a console application; see Which project it needs.
A component names types of ConsoleCore in its constructor and its parameters: cConsole, cConsoleBuffer, ConsoleColor, ConsoleRect and others. The references of a package are not visible to the project that uses it, so a program that creates a component, or names one of these types, references TBMANLIB_ConsoleCore as well as this package. Both are added as Importing a package from TWINSERV describes. TWINSERV lists both packages at version 0.0.0.0.
The project file of this package lists ConsoleCore as an embedded reference: a copy of version 1.0.0.0, named New project, with the identifier {EAEAEAEA-EAEA-EAEA-EAEA-EAEAEAEAEA00}. The published package is version 0.0.0.0, named TBMANLIB_ConsoleCore, with an identifier of its own. The six source files of the embedded copy are the same as those of the published package; its project data differs in the identifier, the name and the description, and it does not declare its package visibility as public.
The components are compiled against the embedded copy, whose types are not those of the published package, although they have the same names. A project that references both therefore meets two sets of types, and this is the result:
- Objects. Passing a cConsole or a cConsoleBuffer of the published package to a component compiles. At run time the call raises error -2147467262, No such interface supported: the constructors of cProgressBar, cSparkline, cVBar, cDataGrid, cConsoleLayout and cLayoutHelper do, and so do Render and ClearContent of cConsolePanel.
- Structures. A ConsoleRect or ConsolePosition that a component returns, such as the Rect field of cConsolePanel, or the result of ContentRect, CenterRect, Center or Grid, has the type of the embedded copy. The compiler refuses to read a member of it (TB5027, [ConsoleRect] does not contain ‘Left’, or it is inaccessible in this context) and to assign it to a ConsoleRect variable or pass it to ConsoleRect_Contains (TB5028, Unable to convert type ‘ConsoleRect’ to type ‘ConsoleRect’).
- Enumerations. A ConsoleColor is a number, so the colour members work: cConsoleTheme, mConsoleThemeFactory and cColorHelper give and take colours, and cConsolePanel keeps its style fields.
- Nested enumerations. The enumerations of the components, such as PanelBorderStyle, are written without the class:
PanelBorderStyle.Double. The formcConsolePanel.PanelBorderStyle.Doubleis refused (TB5079, Unrecognized symbol ‘cConsolePanel’).
A program that references only this package cannot create a cConsole, and a component cannot be created without one. The members that this documentation describes for the components are the members of the package’s code; the sample outputs show what that code prints when it is compiled together with the code of ConsoleCore.
How a component works
Every component keeps what its constructor was given and draws only into the buffer. The pattern for a drawing component is:
- Create a cConsole and call EnterFullScreenMode.
- Create the component with the console:
Set bar = New cProgressBar(con). - Call the component’s
Rendermembers to draw into the buffer. - Call Refresh to show the buffer.
cProgressBar, cSparkline, cVBar and cDataGrid take console.Buffer in their constructor and keep it. If the console is not in full-screen mode at that moment, Buffer is Nothing, the component holds Nothing, and its first draw raises error 91, Object variable or With block variable not set. A component keeps the buffer it was given: after ExitFullScreenMode and a new EnterFullScreenMode the console has a new buffer, and the component still draws into the old one, which the console no longer shows. cConsolePanel and the themes take no console, and cConsoleLayout reads the buffer of the console each time it draws.
The components do not clear the area they draw in, except where a page says so, do not check that what they draw lies inside the buffer (cells outside it are dropped), and do not flush. A bar drawn over earlier text leaves the rest of that text in place.
Positions are columns and rows of the buffer, counted from 0 at the top left, in that order. A component draws on a black background unless a parameter sets another; the defaults of each member are in its entry. The bars, borders and charts use characters such as U+2588 and U+2500, so the font of the console has to contain them.
Defects in version 0.0.0.0
- cSparkline with the Braille character set draws a chart taller than 4 dots with its character rows in reverse order, and draws nothing for a value equal to the minimum when the height is a multiple of 4.
- cDataGrid raises error 9 in Render unless all four of its arrays are set; SetRowColors is indexed like the data array, header included; ScrollTo only selects a row and scrolls nothing; its properties can be set and not read.
- cConsoleLayout.Resize computes the scale factors after it stores the new size, so they are always 1 and no panel changes. AddPanel with a name in use raises error 457 after it has added the panel to the list, which then counts it. The first panel added becomes the root panel whatever method adds it.
- cConsoleLayout.SplitHorizontal makes a left and a right panel, and cLayoutHelper.SplitHorizontal makes a top and a bottom rectangle.
- cColorHelper.BrightenColor returns 16 for DarkGray, which is not a ConsoleColor. DimColor of a dark colour returns DarkGray. IntensityColor ignores its base colour, and GradientColor is a three-step choice, not a gradient.
- cVBar has a style, Custom, that draws the same character as Block, and cProgressBar.RenderWithBrackets draws no percentage.
Classes and modules
- cConsoleLayout – a set of named panels, with splits, a grid, a sidebar and a header and footer
- cConsolePanel – a rectangle with a border, a title and padding, and the content area inside it
- cConsoleTheme – a set of 14 named colours, and the three ready-made themes of mConsoleThemeFactory
- cDataGrid – a table of text with column widths, alignments and a selected row
- cProgressBar – horizontal and vertical progress bars
- cSparkline – a small line or bar chart of a series of values
- cVBar – vertical bar charts, single, grouped and as a history
- Helpers – cColorHelper picks colours for values, and cLayoutHelper computes rectangles and positions in the console window
See Also
- TBMANLIB_ConsoleCore package – the console, the screen buffer and the types that the components use
- cConsole class – the full-screen mode and Refresh
- cConsoleBuffer class – the grid that the components draw into
- Importing a package from TWINSERV – adding a published package to a project