dialog

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package dialog is a small, dependency-free homage to the chunky gray message boxes that classic Windows admin tools flung all over Windows 9x — the kind an overnight script loved to leave waiting on a locked workstation at 3 a.m. It renders that look in the terminal: a double-ruled window, a fake title bar with [_][#][X] controls, an icon gutter, and chunky buttons.

It draws a dialog; it does not pop a real GUI window. That is the joke — and also why it works the same on every platform with zero dependencies. Render() returns the box as a string (so it is trivially testable); the Message / Warn / ErrorBox / AskYesNo helpers print it for you.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AskYesNo

func AskYesNo(title, msg string) bool

AskYesNo renders a Yes/No question and reads the answer from stdin. Anything starting with 'y' is yes; the default (bare Enter / EOF) is no.

func Classic

func Classic()

Classic is the easter egg: the exact flavor of dialog overnight installer jobs used to fling at half the office every morning — drawn here in loving, slightly cursed ASCII.

func ErrorBox

func ErrorBox(title, msg string)

ErrorBox prints an error OK box.

func Message

func Message(title, msg string)

Message prints an informational OK box.

func Splash

func Splash(title, status string)

Splash prints a button-less "loading" box — the terminal descendant of the splash/status boxes overnight installers threw up while they worked. status is the action line, e.g. "Installing Acme Toolbar"; an empty status falls back to "Working".

func SplashBox

func SplashBox(title, status string) string

SplashBox returns the splash box as a string (Splash prints it).

func Warn

func Warn(title, msg string)

Warn prints a warning OK box.

Types

type Dialog

type Dialog struct {
	Title   string   // title-bar text (default "WinAdmin")
	Message string   // body text; '\n' forces a line break, the rest word-wraps
	Buttons []string // button labels (default ["OK"])
	Default int      // index of the focused/default button
	Icon    Icon     // gutter glyph
	Width   int      // body wrap width hint; 0 = a sensible default
	// contains filtered or unexported fields
}

Dialog is a single message box. The zero value renders an empty OK box titled "WinAdmin"; set the fields you care about.

func (Dialog) Render

func (d Dialog) Render() string

Render draws the dialog and returns it as a multi-line string. Every line is padded to the same display width, so it stays aligned wherever it lands.

type Icon

type Icon int

Icon selects the little glyph in the dialog's left gutter, mirroring the classic MB_ICON* family.

const (
	IconNone Icon = iota
	IconInfo
	IconWarning
	IconError
	IconQuestion
)

Jump to

Keyboard shortcuts

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