cio

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

Package cio contains input/output functions for the packet command. The command has different input and output styles depending on whether standard input and output are terminals; that knowledge is encapsulated in this package.

The user of this package must call the Detect function prior to anything else, and must call it again whenever anything might have changed the desired input/output style (e.g., redirection of standard input or output, change in terminal width, etc.).

Index

Constants

View Source
const IndentMarker = '⇥'

IndentMarker marks the indentation level for wrapped lines in a block of running text. If a line contains this character (before the first wrap) point, all wrapped continuations of that line will be indented to the location of this character. This character is not included in the output.

Variables

View Source
var (
	// InputIsTerm is true if the standard input is a terminal.
	InputIsTerm bool
	// OutputIsTerm is true if the standard output is a terminal.
	OutputIsTerm bool
	// Width is the width of the screen in characters (or our best guess).
	Width int
)
View Source
var SuppressStatus bool

Functions

func BulletinScheduleTable

func BulletinScheduleTable(bulletins map[string]*config.BulletinConfig)

func Confirm

func Confirm(f string, args ...any)

func Detect

func Detect()

Detect determines whether or not standard input and output are terminals, the screen width, and the initial state of the terminal.

func EndMessageList

func EndMessageList(s string)

func EndNameValueList

func EndNameValueList()

func Error

func Error(f string, args ...any)

func ListMessage

func ListMessage(li *ListItem)

func ReadCommand

func ReadCommand() (line string, err error)

func ShowNameValue

func ShowNameValue(name, value string, nameWidth int)

func StartEdit

func StartEdit()

func Status

func Status(f string, args ...any)

func Welcome

func Welcome(f string, args ...any)

func WrapText

func WrapText(s string) (wrapped string)

WrapText wraps a string to fit within the screen width. It gives special control over the indentation of wrapped lines. By default, wrapped lines are indented the same amount as the initial unwrapped line. However, if the pre-wrapped line contains a "⇥" character that appears before the first wrap point, all wrapped lines are indented to the location of that character (which is not included in the output).

Types

type EditResult

type EditResult byte

EditResult is the result of an EditField operation.

const (
	// ResultEOF says that the edit was terminated by reaching end of file
	// on standard input.  (This only happens in batch mode.)
	ResultEOF EditResult = '\004'
	// ResultNext says that the editor should move on to the next field.
	ResultNext EditResult = 'v'
	// ResultPrevious says that the edit should move back to the previous
	// field.
	ResultPrevious EditResult = '^'
	// ResultDone says that the edit should stop.
	ResultDone EditResult = '\033'
)

Values for EditResult:

func EditField

func EditField(f *message.Field, labelWidth int) (EditResult, error)

type ListItem

type ListItem struct {
	Handling string // "I", "P", "R", "B" for bulletin
	Flag     string // "DRAFT", "QUEUE", "NO RCPT", "HAVE RCPT", "NEW"
	Time     time.Time
	From     string
	LMI      string
	To       string
	Subject  string
	NoHeader bool
}

Jump to

Keyboard shortcuts

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