output

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copy From https://github.com/c-bata/go-prompt

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copy From https://github.com/c-bata/go-prompt

Index

Constants

This section is empty.

Variables

View Source
var (
	// NewStandardOutputWriter returns ConsoleWriter object to write to stdout.
	// This generates VT100 escape sequences because almost terminal emulators
	// in POSIX OS built on top of a VT100 specification.
	// Deprecated: Please use NewStdoutWriter
	NewStandardOutputWriter = NewStdoutWriter
)

Functions

This section is empty.

Types

type Color

type Color int

Color represents color on terminal.

const (
	// DefaultColor represents a default color.
	DefaultColor Color = iota

	// Black represents a black.
	Black
	// DarkRed represents a dark red.
	DarkRed
	// DarkGreen represents a dark green.
	DarkGreen
	// Brown represents a brown.
	Brown
	// DarkBlue represents a dark blue.
	DarkBlue
	// Purple represents a purple.
	Purple
	// Cyan represents a cyan.
	Cyan
	// LightGray represents a light gray.
	LightGray

	// DarkGray represents a dark gray.
	DarkGray
	// Red represents a red.
	Red
	// Green represents a green.
	Green
	// Yellow represents a yellow.
	Yellow
	// Blue represents a blue.
	Blue
	// Fuchsia represents a fuchsia.
	Fuchsia
	// Turquoise represents a turquoise.
	Turquoise
	// White represents a white.
	White
)

type ConsoleWriter

type ConsoleWriter interface {

	// WriteRaw to write raw byte array.
	WriteRaw(data []byte)
	// Write to write safety byte array by removing control sequences.
	Write(data []byte)
	// WriteStr to write raw string.
	WriteRawStr(data string)
	// WriteStr to write safety string by removing control sequences.
	WriteStr(data string)

	// Flush to flush buffer.
	Flush() error
	// Clear  clear not flush buffer
	Clear()

	// EraseScreen erases the screen with the background colour and moves the cursor to home.
	EraseScreen()
	// EraseUp erases the screen from the current line up to the top of the screen.
	EraseUp()
	// EraseDown erases the screen from the current line down to the bottom of the screen.
	EraseDown()
	// EraseStartOfLine erases from the current cursor position to the start of the current line.
	EraseStartOfLine()
	// EraseEndOfLine erases from the current cursor position to the end of the current line.
	EraseEndOfLine()
	// EraseLine erases the entire current line.
	EraseLine()

	// ShowCursor stops blinking cursor and show.
	ShowCursor()
	// HideCursor hides cursor.
	HideCursor()
	// CursorGoTo sets the cursor position where subsequent text will begin.
	CursorGoTo(row, col int)
	// CursorUp moves the cursor up by 'n' rows; the default count is 1.
	CursorUp(n int)
	// CursorDown moves the cursor down by 'n' rows; the default count is 1.
	CursorDown(n int)
	// CursorForward moves the cursor forward by 'n' columns; the default count is 1.
	CursorForward(n int)
	// CursorBackward moves the cursor backward by 'n' columns; the default count is 1.
	CursorBackward(n int)
	// AskForCPR asks for a cursor position report (CPR).
	AskForCPR()
	// SaveCursor saves current cursor position.
	SaveCursor()
	// UnSaveCursor restores cursor position after a Save Cursor.
	UnSaveCursor()

	// ScrollDown scrolls display down one line.
	ScrollDown()
	// ScrollUp scroll display up one line.
	ScrollUp()

	// SetTitle sets a title of terminal window.
	SetTitle(title string)
	// ClearTitle clears a title of terminal window.
	ClearTitle()

	// SetColor sets text and background colors. and specify whether text is bold.
	SetColor(fg, bg Color, bold bool)
}

ConsoleWriter is an interface to abstract output layer.

func NewConsoleWriter

func NewConsoleWriter(w io.Writer) ConsoleWriter

NewConsoleWriter new console writer

func NewStderrWriter

func NewStderrWriter() ConsoleWriter

NewStderrWriter returns ConsoleWriter object to write to stderr. This generates VT100 escape sequences because almost terminal emulators in POSIX OS built on top of a VT100 specification.

func NewStdoutWriter

func NewStdoutWriter() ConsoleWriter

NewStdoutWriter returns ConsoleWriter object to write to stdout. This generates VT100 escape sequences because almost terminal emulators in POSIX OS built on top of a VT100 specification.

type DisplayAttribute

type DisplayAttribute int

DisplayAttribute represents display attributes like Blinking, Bold, Italic and so on.

const (
	// DisplayReset reset all display attributes.
	DisplayReset DisplayAttribute = iota
	// DisplayBold set bold or increases intensity.
	DisplayBold
	// DisplayLowIntensity decreases intensity. Not widely supported.
	DisplayLowIntensity
	// DisplayItalic set italic. Not widely supported.
	DisplayItalic
	// DisplayUnderline set underline
	DisplayUnderline
	// DisplayBlink set blink (less than 150 per minute).
	DisplayBlink
	// DisplayRapidBlink set blink (more than 150 per minute). Not widely supported.
	DisplayRapidBlink
	// DisplayReverse swap foreground and background colors.
	DisplayReverse
	// DisplayInvisible set invisible.  Not widely supported.
	DisplayInvisible
	// DisplayCrossedOut set characters legible, but marked for deletion. Not widely supported.
	DisplayCrossedOut
	// DisplayDefaultFont set primary(default) font
	DisplayDefaultFont
)

type PosixWriter

type PosixWriter struct {
	VT100Writer
	// contains filtered or unexported fields
}

PosixWriter is a ConsoleWriter implementation for POSIX environment. To control terminal emulator, this outputs VT100 escape sequences.

func (*PosixWriter) Flush

func (w *PosixWriter) Flush() error

Flush to flush buffer

type VT100Writer

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

VT100Writer generates VT100 escape sequences.

func (*VT100Writer) AskForCPR

func (w *VT100Writer) AskForCPR()

AskForCPR asks for a cursor position report (CPR).

func (*VT100Writer) Clear

func (w *VT100Writer) Clear()

func (*VT100Writer) ClearTitle

func (w *VT100Writer) ClearTitle()

ClearTitle clears a title of terminal window.

func (*VT100Writer) CursorBackward

func (w *VT100Writer) CursorBackward(n int)

CursorBackward moves the cursor backward by 'n' columns; the default count is 1.

func (*VT100Writer) CursorDown

func (w *VT100Writer) CursorDown(n int)

CursorDown moves the cursor down by 'n' rows; the default count is 1.

func (*VT100Writer) CursorForward

func (w *VT100Writer) CursorForward(n int)

CursorForward moves the cursor forward by 'n' columns; the default count is 1.

func (*VT100Writer) CursorGoTo

func (w *VT100Writer) CursorGoTo(row, col int)

CursorGoTo sets the cursor position where subsequent text will begin.

func (*VT100Writer) CursorUp

func (w *VT100Writer) CursorUp(n int)

CursorUp moves the cursor up by 'n' rows; the default count is 1.

func (*VT100Writer) EraseDown

func (w *VT100Writer) EraseDown()

EraseDown erases the screen from the current line down to the bottom of the screen.

func (*VT100Writer) EraseEndOfLine

func (w *VT100Writer) EraseEndOfLine()

EraseEndOfLine erases from the current cursor position to the end of the current line.

func (*VT100Writer) EraseLine

func (w *VT100Writer) EraseLine()

EraseLine erases the entire current line.

func (*VT100Writer) EraseScreen

func (w *VT100Writer) EraseScreen()

EraseScreen erases the screen with the background colour and moves the cursor to home.

func (*VT100Writer) EraseStartOfLine

func (w *VT100Writer) EraseStartOfLine()

EraseStartOfLine erases from the current cursor position to the start of the current line.

func (*VT100Writer) EraseUp

func (w *VT100Writer) EraseUp()

EraseUp erases the screen from the current line up to the top of the screen.

func (*VT100Writer) HideCursor

func (w *VT100Writer) HideCursor()

HideCursor hides cursor.

func (*VT100Writer) SaveCursor

func (w *VT100Writer) SaveCursor()

SaveCursor saves current cursor position.

func (*VT100Writer) ScrollDown

func (w *VT100Writer) ScrollDown()

ScrollDown scrolls display down one line.

func (*VT100Writer) ScrollUp

func (w *VT100Writer) ScrollUp()

ScrollUp scroll display up one line.

func (*VT100Writer) SetColor

func (w *VT100Writer) SetColor(fg, bg Color, bold bool)

SetColor sets text and background colors. and specify whether text is bold.

func (*VT100Writer) SetDisplayAttributes

func (w *VT100Writer) SetDisplayAttributes(fg, bg Color, attrs ...DisplayAttribute)

SetDisplayAttributes to set VT100 display attributes.

func (*VT100Writer) SetTitle

func (w *VT100Writer) SetTitle(title string)

SetTitle sets a title of terminal window.

func (*VT100Writer) ShowCursor

func (w *VT100Writer) ShowCursor()

ShowCursor stops blinking cursor and show.

func (*VT100Writer) UnSaveCursor

func (w *VT100Writer) UnSaveCursor()

UnSaveCursor restores cursor position after a Save Cursor.

func (*VT100Writer) Write

func (w *VT100Writer) Write(data []byte)

Write to write safety byte array by removing control sequences.

func (*VT100Writer) WriteRaw

func (w *VT100Writer) WriteRaw(data []byte)

WriteRaw to write raw byte array

func (*VT100Writer) WriteRawStr

func (w *VT100Writer) WriteRawStr(data string)

WriteRawStr to write raw string

func (*VT100Writer) WriteStr

func (w *VT100Writer) WriteStr(data string)

WriteStr to write safety string by removing control sequences.

Jump to

Keyboard shortcuts

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