text

package
v0.0.0-...-dfe7f75 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package text is an abstraction layer for different text formats.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WordWrap

func WordWrap(text string, width, maxLines int) []string

WordWrap wraps long lines.

Types

type LineWriter

type LineWriter struct {
	// contains filtered or unexported fields
}

LineWriter wraps an io.Writer with line-based buffering and writes in a separate routine.

func LineBuffered

func LineBuffered(inner io.Writer) *LineWriter

func (*LineWriter) Flush

func (w *LineWriter) Flush() error

func (*LineWriter) Unwrap

func (w *LineWriter) Unwrap() io.Writer

func (*LineWriter) Write

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

type Writer

type Writer interface {
	io.Writer

	Clone(io.Writer) Writer
	Unwrap() io.Writer

	Flush() error

	OK()
	Error()
	Redirect(string)
	Redirectf(string, ...any)
	Status(int, string)
	Statusf(int, string, ...any)
	Title(string)
	Titlef(string, ...any)
	Subtitle(string)
	Subtitlef(string, ...any)
	Text(string)
	Textf(string, ...any)
	Empty()
	Link(string, string)
	Linkf(string, string, ...any)
	Item(string)
	Itemf(string, ...any)
	Quote(string)
	Raw(string, string)
	Separator()
}

Writer builds a textual response. The response is buffered: call [Writer.Flush] to flush the last chunk to the underlying io.Writer.

Directories

Path Synopsis
Package gmap builds gophermaps.
Package gmap builds gophermaps.
Package gmi build Gemini responses.
Package gmi build Gemini responses.
Package guppy builds Guppy responses.
Package guppy builds Guppy responses.
Package plain converts HTML to plain text and vice versa.
Package plain converts HTML to plain text and vice versa.

Jump to

Keyboard shortcuts

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