A modernized port of the Free Vision (FV) text-mode UI framework from Free Pascal to modern Delphi (12+).
Free Vision is a classic console-based GUI toolkit originally derived from Borland's Turbo Vision. This modern variant uses Delphi CLASS syntax instead of the legacy Turbo Pascal OBJECT syntax, providing better IDE integration, proper inheritance, and modern memory management.
- Complete TUI Framework: Windows, dialogs, menus, status bars, buttons, input fields, and more
- Modern Architecture: Interfaces (
IFVDrawable,ISerializable), RTL generics (TObjectList<T>,TStringList) - Full Unicode Support: Double-width characters, emoji, and CJK glyphs rendered correctly throughout the framework via
TDrawCell-based drawing system - Text Editor: Full-featured editor with find/replace, clipboard, undo, and file operations
- Hex Editor: Binary file viewer/editor with hex and ASCII modes
- String Grid: Spreadsheet-like grid with sorting, editing, selection, and CSV import/export
- Standard Dialogs: Message boxes, file open/save dialogs, color selection, ASCII table
- Advanced Controls: Tab controls, outline/tree views, progress gauges, timed dialogs
- Layout Components: Splitter panels with draggable divider, accordion with collapsible sections
- Extended Widgets: Toolbar, breadcrumb navigation, combo box dropdown, progress bar, editor gutter with pluggable providers, toast notifications
- SIXEL Graphics: Adaptive 256-color SIXEL encoder, direct SIXEL canvas drawing, and BMP/SIXEL image viewer
- Input Validation: Built-in validators for ranges, patterns, and lookups
- JSON Serialization: Views implement
ISerializablefor state persistence - Windows Console: Native Windows Console API for display and input
- Terminal Emulator: Pseudo-terminal windows using Windows ConPTY
SIXEL support is optimized for Windows Terminal sessions and integrates with the normal Free Vision view system.
TSixelEncoder(src/SixelEncoder.pas): convertsTPixelGriddata ($00RRGGBB) to SIXEL DCS strings using adaptive palette quantization (up to 256 registers)TSixelView(src/SixelView.pas): renders pre-encoded SIXEL data from memory or.sixel/.six/.sxlfilesTSixelCanvasView(src/SixelView.pas): direct pixel drawing API for generated/animated graphics (SetPixel,FillRect,DrawLine,Clear)TImageWindow/TImageView(src/ImageView.pas): loads both BMP and SIXEL files, supports scrolling and safe viewport cropping before SIXEL encoding
Windows Terminal supports true-color text attributes, but SIXEL itself remains palette-based.
Practical limit is still 256 color registers per emitted SIXEL image, so quality depends on quantization and dithering choices.
TSixelEncoder supports error-diffusion dithering to reduce visible color banding:
- Auto-enabled for coarser quantization steps
- Force on:
FV_SIXEL_DITHER=1(also acceptson,true) - Force off:
FV_SIXEL_DITHER=0(also acceptsoff,false)
If terminal pixel cell detection is wrong, you can override with:
FV_CELL_W=<pixels>FV_CELL_H=<pixels>
Test -> New Components contains:
Image Viewer(BMP + SIXEL files)SIXEL Spectrometer(direct animated bar rendering onTSixelCanvasView)SIXEL Animated Sine(direct animated waveform drawing onTSixelCanvasView)
System clipboard support is provided by src/FVClipboard.pas and is shared across editor-style controls.
| Function | Description |
|---|---|
ClipboardSetText(const Text: string): Boolean |
Writes Unicode text to Windows clipboard |
ClipboardGetText: string |
Reads text from Windows clipboard |
ClipboardHasText: Boolean |
Returns whether text data is available |
Ctrl+Ins: copy selectionShift+Ins: paste clipboard text
The Test menu includes clipboard-focused examples:
Test -> Editor -> ClipboardTest -> New Components -> Clipboard
The terminal component (TTerminalWindow) provides a VT100-compatible terminal emulator using Windows ConPTY. It supports running command-line applications including other Free Vision apps.
The terminal uses Ctrl+A as the escape prefix (like GNU screen):
| Key Sequence | Action |
|---|---|
| Ctrl+A, then any key | Exit capture mode, send key to outer app |
| Ctrl+A, Ctrl+A | Send literal Ctrl+A to child process |
| Ctrl+A, M | Toggle terminal mouse mode (passthrough/select) |
| Ctrl+C / Ctrl+Ins | Copy terminal selection to clipboard |
| Ctrl+V / Shift+Ins | Paste clipboard text to terminal process |
| Right click | Copy selection, or paste when no selection |
| Shift+PageUp/Down | Scroll through scrollback buffer |
| Mouse wheel | Scroll through scrollback buffer |
After exiting capture mode with Ctrl+A:
- Click on the terminal to re-enter capture mode
- Press Enter or Esc to re-enter capture mode
The terminal window title shows the current mouse mode:
Mouse:Passforwards mouse to child apps that enable VT mouse reportingMouse:Selectkeeps mouse local for text selection/scrollingMouse:Selectkeeps keyboard capture, so typing continues while mouse stays local- New terminal windows start in
Mouse:Select; useCtrl+A, Mto switch to passthrough - Entering alternate screen (
?1049/?1047/?47) auto-switches toMouse:Pass, then restores previous mode on exit
- VT100/ANSI escape sequence support
- Scrollback buffer with configurable size
- Text selection with mouse (double-click for word selection)
- Copy/paste support (Ctrl+C/Ctrl+Ins copy selection, Ctrl+V/Shift+Ins paste)
- Visual bell
- Window title from OSC sequences
- Session logging
- Text reflow on resize
The TStringGrid component (Grid.pas) provides a spreadsheet-like data grid for console applications.
- Sortable columns with visual indicators
- Cell editing (F2 or direct typing)
- Row and cell selection modes
- Clipboard support (copy/paste)
- Undo support
- Column resizing and auto-fit
- Fixed header rows
- JSON serialization for layout
The grid supports RFC 4180-compliant CSV files:
// Load CSV file
Grid.LoadFromCSV('data.csv');
// Save to CSV
Grid.SaveToCSV('output.csv');
// With options
var Opts := TCSVOptions.Create;
Opts.Delimiter := cdSemicolon; // or cdComma, cdTab, cdPipe, cdAuto
Opts.CustomDelimiter := '~'; // Override with any character
Opts.UseFixedHeaderRow := True; // Headers as fixed row 0
Opts.Encoding := ceUTF8BOM; // UTF-8 with BOM (Excel compatible)
Grid.LoadFromCSV('data.csv', Opts);
Opts.Free;| Property | Default | Description |
|---|---|---|
Delimiter |
cdComma |
Field delimiter (comma, semicolon, tab, pipe, auto-detect) |
CustomDelimiter |
#0 |
Override delimiter with any character |
Encoding |
ceUTF8BOM |
File encoding (UTF-8 BOM, UTF-8, ANSI) |
HasHeaders |
True |
First row contains column headers |
UseFixedHeaderRow |
False |
Put headers in fixed row 0 |
TrimWhitespace |
False |
Trim spaces from values |
AutoCreateColumns |
True |
Create columns from CSV structure |
The THexEditor component (HexEdit.pas) provides a binary file viewer and editor.
- Classic hex editor layout (address | hex bytes | ASCII)
- Dual editing modes: hex nibbles or ASCII characters
- Selection support with keyboard (Shift+arrows) and mouse
- Modified byte highlighting
- File load/save operations
- Pluggable data source interface (
IHexDataSource)
| Key | Action |
|---|---|
| Arrow keys | Navigate bytes |
| Tab | Toggle between hex and ASCII mode |
| Shift+Arrows | Extend selection |
| 0-9, A-F | Edit hex nibble (in hex mode) |
| Any printable | Edit ASCII character (in ASCII mode) |
| Home/End | Jump to start/end of row |
| Ctrl+Home/End | Jump to start/end of file |
| Page Up/Down | Scroll by page |
var
HexEdit: THexEditor;
Source: TMemoryHexSource;
begin
Source := TMemoryHexSource.Create;
Source.LoadFromFile('data.bin');
HexEdit := THexEditor.Create(Bounds, Source);
// ... add to window
// Save changes
Source.SaveToFile('data.bin');
end;The framework uses a TDrawCell-based drawing system where each screen cell stores a full string instead of a single Char. This allows proper rendering of:
- Emoji: Characters like
CheckMark,CrossMark,Diamondrendered as true Unicode glyphs - CJK characters: Double-width East Asian characters occupy two screen cells
- Surrogate pairs: Code points above U+FFFF (e.g. emoji) handled via Delphi's UTF-16 surrogate pair encoding
- Box-drawing characters: Full set of Unicode box-drawing and block elements (
FVBoxChars.pas)
The rendering pipeline (TDrawBuffer -> WriteBuf -> UnicodeCharBuf -> VT escape sequences) preserves full Unicode fidelity from view drawing through to terminal output.
- Delphi 12.x or later
- Windows 32-bit or 64-bit target
- Open
FVTest.dprojin the Delphi IDE - Build and run the project
- Explore the Test menu to see various components in action
program MyApp;
uses
App, Views, Menus, Drivers;
type
TMyApp = class(TApplication)
procedure InitMenuBar; override;
procedure InitStatusLine; override;
end;
procedure TMyApp.InitMenuBar;
var
R: TRect;
begin
GetExtent(R);
R.B.Y := R.A.Y + 1;
MenuBar := TMenuBar.Create(R, NewMenu(
NewSubMenu('~F~ile', hcNoContext, NewMenu(
NewItem('E~x~it', 'Alt-X', kbAltX, cmQuit, hcNoContext, nil)),
nil)));
end;
procedure TMyApp.InitStatusLine;
var
R: TRect;
begin
GetExtent(R);
R.A.Y := R.B.Y - 1;
StatusLine := TStatusLine.Create(R,
NewStatusDef(0, $FFFF,
NewStatusKey('~Alt-X~ Exit', kbAltX, cmQuit, nil),
nil));
end;
var
App: TMyApp;
begin
App := TMyApp.Create;
App.Run;
App.Free;
end.src/
FVCommon.pas - Platform types (Sw_Word, PString, etc.)
FVInterfaces.pas - Interface definitions (IFVDrawable, ISerializable, etc.)
FVSerialization.pas - JSON serialization helpers
FVClipboard.pas - Windows clipboard integration helpers
Objects.pas - Stream classes, string utilities
Video.pas - Console output (Windows Console API)
Drivers.pas - Keyboard and mouse input handling
Views.pas - View hierarchy (TView, TGroup, TWindow, etc.)
Menus.pas - Menu system (TMenuBar, TMenuBox, TStatusLine)
App.pas - Application framework (TApplication)
Dialogs.pas - Dialog controls (TDialog, TButton, TInputLine, etc.)
Grid.pas - TStringGrid with CSV import/export
HexEdit.pas - THexEditor binary viewer/editor
SixelEncoder.pas - Adaptive SIXEL encoder (palette + dithering)
SixelView.pas - TSixelView + TSixelCanvasView for SIXEL rendering
ImageView.pas - BMP/SIXEL viewer window and scrollable image view
Validate.pas - Input validation
MsgBox.pas - Message box helpers
StdDlg.pas - Standard file dialogs
Editors.pas - Text editor components
ColorSel.pas - Color selection dialog
Outline.pas - Tree/outline view
Tabs.pas - Tab control
Statuses.pas - Progress gauges
Gadgets.pas - Clock and heap views
ProgressBar.pas - Progress bar indicator
Breadcrumb.pas - Clickable path navigation
ToolBar.pas - Horizontal button bar
ComboBox.pas - Dropdown select control
Splitter.pas - Draggable panel divider + split group container
Accordion.pas - Collapsible section stack
EditorGutter.pas - Multi-column editor gutter (line numbers, bookmarks, breakpoints, diff)
Notification.pas - Auto-dismissing toast popups
See ARCHITECTURE.md for detailed class hierarchies and diagrams.
- Uses modern Delphi
CLASSsyntax with proper inheritance andoverride - All view classes derive directly from
TObject(no intermediate base class) - Views implement interfaces:
IFVDrawable,IFVEventHandler,IFVDataAware,ISerializable - Uses RTL generics:
TObjectList<T>,TStringList(no custom collection classes) TClass.Create/Object.Freeinstead ofNew(P, Init)/Dispose(P, Done)- Pointer types aliased for compatibility:
PView = TView ShortStringused for FV string types (Sw_String,PString)- Windows Console API for video output and input
- Range checking should be OFF at project level
- New edge-cases, oversights or errors may be introduced in this project
- Corruption in ASCII Table display
- Corruption in TStringGrid with wide Unicode characters
This library is distributed under the GNU Lesser General Public License (LGPL) with the following linking exception:
As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.
See COPYING.TXT for the complete license text.
- Original Turbo Vision by Borland International
- Free Vision by the Free Pascal Development Team
- Delphi port by Claude Code (Anthropic)
Bug reports and contributions are welcome. Please ensure any modifications maintain compatibility with the original Free Vision API where possible.