termsafe

package
v0.17.3 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 3 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 termsafe keeps note text from acting on the terminal. A note's bytes are data: they may show as text, but never as control sequences.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clean

func Clean(s string) string

Clean is the last step before bytes reach a terminal: it keeps text, newlines, tabs and colours and drops every other control sequence, with the bidirectional overrides that make text read in a different order than it is stored.

func Line

func Line(s string) string

Line is Visible for text that must stay on one row, such as a file name: a newline or tab shows as a picture too.

func Visible

func Visible(s string) string

Visible makes untrusted text safe to lay out and draw: each control rune becomes a one-cell picture of itself, such as ␛, and an invalid byte U+FFFD. Newlines and tabs stay, and so does the line a CRLF ends.

Types

type Writer

type Writer struct{ W io.Writer }

Writer passes everything written to it through Clean. Each Write is cleaned on its own: a sequence split across two writes loses its escape in the first, so the rest arrives as text.

func (Writer) Write

func (w Writer) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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