vga

package
v1.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: GPL-3.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package vga provides shared helpers for rendering 16-color CP437 character/attribute grids and 6-bit VGA palettes into styled HTML fragments.

Index

Constants

View Source
const (
	// PaletteColors is the number of colors in a 4-bit CGA/VGA text palette.
	PaletteColors = 16
	// PaletteBytes is the byte length of an RGB 6-bit VGA DAC palette (16 × 3).
	PaletteBytes = 48
)

Variables

This section is empty.

Functions

func HTML

func HTML(rows [][]Cell, pal Palette, opts Options) *bytes.Buffer

HTML renders rows into a <div>...</div> containing merged <span style="..."> runs.

func Rows

func Rows(cells []Cell, cols int) [][]Cell

Rows reshapes a flat slice of cells into rows of cols cells.

Types

type Cell

type Cell struct {
	Ch   byte
	Attr byte
}

Cell represents a single DOS text-mode character and attribute pair.

type Options

type Options struct {
	ICEColor bool // Treat attribute bit 7 as bright background (16 backgrounds) instead of blink.
	Chars512 bool // Treat attribute bit 3 as glyph bank selector (limits foreground to 8 colors).
	SkipTrim bool // Preserve trailing blank rows when false, trailing blank rows are trimmed.
}

Options controls attribute decoding during HTML rendering.

type Palette

type Palette [PaletteColors]string

Palette holds 16 CSS #rrggbb color strings.

func CGA

func CGA() Palette

CGA returns the default IBM CGA/VGA 16-color text palette.

func ParsePalette

func ParsePalette(raw []byte) (Palette, bool)

ParsePalette parses a 48-byte 6-bit VGA DAC palette (values 0..63) into CSS #rrggbb strings.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL