module
TUI::TypeStyle
Overview
Maps a column's data type to a Cell Style for display. Prefers a precise portable-type tag (e.g. "int32", "bool") when the caller has one; otherwise falls back to sniffing common substrings in a raw SQL type_text, so it still gives reasonable coloring against databases with no portable-type metadata.
Intentionally narrow: this only covers types generic enough to appear across any SQL-backed app (numbers, bools, times, bytes). Domain-specific coloring — foreign keys, enums, validation errors — depends on app-specific schema metadata and belongs in the app's own DataSource, not here.
Defined in:
tui/widgets/type_style.crConstant Summary
-
TYPE_TEXT_HINTS =
{:cyan => ["INT", "SERIAL"] of ::String, :yellow => ["REAL", "FLOAT", "DOUBLE", "NUMERIC", "DECIMAL"] of ::String, :green => ["BOOL"] of ::String, :blue => ["DATE", "TIME", "STAMP"] of ::String, :magenta => ["BLOB", "BYTE", "BINARY"] of ::String} -
Color => substrings to look for (case-insensitively) in a raw SQL type_text, checked in declaration order by #for_type_text — the fallback path used when no portable_type is available.