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
- Variables
- func BulletinScheduleTable()
- func Confirm(f string, args ...any)
- func Detect()
- func EndMessageList(s string)
- func EndNameValueList()
- func Error(f string, args ...any)
- func ListMessage(li *ListItem)
- func ReadCommand() (line string, err error)
- func ShowNameValue(name, value string, nameWidth int)
- func StartEdit()
- func Status(f string, args ...any)
- func Welcome(f string, args ...any)
- func WrapText(s string) (wrapped string)
- type EditResult
- type ListItem
Constants ¶
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 ¶
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 )
var SuppressStatus bool
Functions ¶
func BulletinScheduleTable ¶
func BulletinScheduleTable()
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 ListMessage ¶
func ListMessage(li *ListItem)
func ReadCommand ¶
func ShowNameValue ¶
func WrapText ¶
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: