terminals

package
v0.0.0-...-6ee1af2 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2016 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnsiTerminal

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

AnsiTerminal is a 256-color terminal based on the ANSI escape codes (https://en.wikipedia.org/wiki/ANSI_escape_code)

func (*AnsiTerminal) Clear

func (terminal *AnsiTerminal) Clear()

func (*AnsiTerminal) DisableTextBold

func (terminal *AnsiTerminal) DisableTextBold()

func (*AnsiTerminal) DisableTextHidden

func (terminal *AnsiTerminal) DisableTextHidden()

func (*AnsiTerminal) DisableTextUnderlined

func (terminal *AnsiTerminal) DisableTextUnderlined()

func (*AnsiTerminal) DrawHorizontalProgressBar

func (terminal *AnsiTerminal) DrawHorizontalProgressBar(
	row int,
	column int,
	maxLineLength int,
	fractionalValue float64)

func (*AnsiTerminal) EnableTextBold

func (terminal *AnsiTerminal) EnableTextBold()

func (*AnsiTerminal) EnableTextHidden

func (terminal *AnsiTerminal) EnableTextHidden()

func (*AnsiTerminal) EnableTextUnderlined

func (terminal *AnsiTerminal) EnableTextUnderlined()

func (*AnsiTerminal) Escape

func (terminal *AnsiTerminal) Escape(escapeFormatString string, args ...interface{})

func (*AnsiTerminal) GetColumns

func (terminal *AnsiTerminal) GetColumns() int

func (*AnsiTerminal) GetRows

func (terminal *AnsiTerminal) GetRows() int

func (*AnsiTerminal) HideCursor

func (terminal *AnsiTerminal) HideCursor()

func (*AnsiTerminal) MoveCursor

func (terminal *AnsiTerminal) MoveCursor(row int, column int)

func (*AnsiTerminal) PrintCenteredInRow

func (terminal *AnsiTerminal) PrintCenteredInRow(row int, text string)

func (*AnsiTerminal) ResetStyle

func (terminal *AnsiTerminal) ResetStyle()

func (*AnsiTerminal) SetBackgroundColor

func (terminal *AnsiTerminal) SetBackgroundColor(colorCode int)

func (*AnsiTerminal) SetForegroundColor

func (terminal *AnsiTerminal) SetForegroundColor(colorCode int)

func (*AnsiTerminal) ShowCursor

func (terminal *AnsiTerminal) ShowCursor()

func (*AnsiTerminal) SupportsANSI

func (terminal *AnsiTerminal) SupportsANSI() bool

type BashTerminal

type BashTerminal struct {
	AnsiTerminal
}

BashTerminal is a terminal provided by the Bash shell

func NewBashTerminal

func NewBashTerminal() *BashTerminal

NewBashTerminal creates an ANSI terminal implemented by the Bash shell running the program

type Terminal

type Terminal interface {
	/*
	  GetRows returns the number of rows (as characters) in the terminal
	*/
	GetRows() int

	/*
	  GetColumns returns the number of columns (as characters) in the terminal
	*/
	GetColumns() int

	/*
		  Clear empties the terminal, ensuring that the background color
			is applied to the whole screen, then moves the cursor to its
			upper-left corner
	*/
	Clear()

	/*
		  MoveCursor moves the cursor to the given row and column -
			both values are 1-based
	*/
	MoveCursor(row int, column int)

	/*
		ResetStyle resets the style (including colors) of the terminal
		to its default parameters
	*/
	ResetStyle()

	/*
		EnableTextHidden enables the Hidden text style - also hiding user input
	*/
	EnableTextHidden()

	/*
		DisableTextHidden disables the Hidden text style - also showing user input
	*/
	DisableTextHidden()

	/*
	  EnableTextBold enables the Bold text style
	*/
	EnableTextBold()

	/*
	  DisableTextBold disables the Bold text style
	*/
	DisableTextBold()

	/*
		EnableTextUnderlined enables the Underlined text style
	*/
	EnableTextUnderlined()

	/*
		DisableTextUnderlined enables the Underlined text style
	*/
	DisableTextUnderlined()

	/*
	  ShowCursor shows the input cursor
	*/
	ShowCursor()

	/*
	  HideCursor hides the input cursor
	*/
	HideCursor()

	/*
	  SetBackgroundColor sets the color code for the text background
	*/
	SetBackgroundColor(colorCode int)

	/*
	  SetForegroundColor sets the color code for the text
	*/
	SetForegroundColor(colorCode int)

	/*
		PrintCenteredInRow prints the given text on the given row,
		horizontally centering it
	*/
	PrintCenteredInRow(row int, text string)

	/*
		DrawHorizontalProgressBar draws a horizontal progress bar starting
		at the given row and column and having an internal line long at most
		"maxLineLength" characters.
		The given fractional value must be in the [0; 1] range
	*/
	DrawHorizontalProgressBar(
		row int,
		column int,
		maxLineLength int,
		fractionalValue float64)

	/*
		SupportsANSI returns true if the terminal supports the ANSI escape codes
	*/
	SupportsANSI() bool

	/*
		Escape prints an escape sequence according to the terminal's specific format,
		employing the escapeFormatString - which gets formatted via the
		provided optional args
	*/
	Escape(escapeFormatString string, args ...interface{})
}

Terminal is a text-based user interface

Jump to

Keyboard shortcuts

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