Documentation ¶
Index ¶
- Constants
- type ViewPort
- func (t *ViewPort) Banner(msg string)
- func (t *ViewPort) Baud() int
- func (t *ViewPort) Blank()
- func (t *ViewPort) Break()
- func (t *ViewPort) Clear()
- func (t *ViewPort) ClearCurrentLine()
- func (t *ViewPort) Close()
- func (t *ViewPort) CurrentRow() int
- func (t *ViewPort) Delay() int
- func (t *ViewPort) DelayInSec() float64
- func (t *ViewPort) DelayIt()
- func (t *ViewPort) Error(err error, msg ...string)
- func (t *ViewPort) Format(msg string, text string) string
- func (t *ViewPort) Header(msg string)
- func (t *ViewPort) Height() int
- func (t *ViewPort) InfoMessage(msg string)
- func (t *ViewPort) Input(msg string, options string) (output string)
- func (t *ViewPort) InputError(err error, msg ...string)
- func (t *ViewPort) InputPagingInfo(page, ofPages int)
- func (t *ViewPort) NoBaudRate() bool
- func (t *ViewPort) Paragraph(msg []string)
- func (t *ViewPort) Print(msg string)
- func (t *ViewPort) PrintIt(msg string)
- func (t *ViewPort) Println(msg string)
- func (t *ViewPort) ResetDelay()
- func (t *ViewPort) SError(err error, msg ...string) string
- func (t *ViewPort) SetBaud(baudRate int)
- func (t *ViewPort) SetDelayInMin(delayMs int)
- func (t *ViewPort) SetDelayInMs(delayMs int)
- func (t *ViewPort) SetDelayInSec(delayMs float64)
- func (t *ViewPort) SetTerminalSize(width, height int)
- func (t *ViewPort) Shout(msg string)
- func (t *ViewPort) Special(msg string)
- func (t *ViewPort) Spool(msg []byte)
- func (t *ViewPort) TerminalSize() (width, height int)
- func (t *ViewPort) Underline(msg string) string
- func (t *ViewPort) Wait()
- func (t *ViewPort) Width() int
Constants ¶
const InputColumn int = StartColumn + 2
const StartColumn int = 1
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ViewPort ¶
type ViewPort struct { Helpers *hlpr.Helpers // Helper functions Formatters *hlpr.Formatters // Formatter functions Styles *hlpr.Styles // Colour functions // contains filtered or unexported fields }
The ViewPort type represents a terminal screen with properties such as whether it is a terminal, its width and height, and whether it is the first row. @property {bool} isTerminal - A boolean value indicating whether the CRT (Cathode Ray Tube) is a terminal or not. If it is a terminal, it means that it is a device used for input and output of data to and from a computer. If it is not a terminal, it means that it is not used @property {int} width - The width property represents the number of characters that can be displayed horizontally on the terminal screen. @property {int} height - The `height` property represents the number of rows in the terminal or console window. @property {bool} firstRow - The `firstRow` property is a boolean value that indicates whether the current row is the first row of the terminal screen.
func New ¶
func New() ViewPort
The function `New` initializes a new `Crt` struct with information about the terminal size and whether it is a terminal or not.
func NewWithSize ¶
func (*ViewPort) Banner ¶
The `Banner` function is a method of the `Crt` struct. It is responsible for printing a banner message to the console.
func (*ViewPort) Blank ¶
func (t *ViewPort) Blank()
The `Blank()` function is used to print a blank line on the terminal. It calls the `Format()` method of the `Crt` struct to format an empty string with the normal character (`chNormal`). Then, it prints the formatted string using `fmt.Println()`.
func (*ViewPort) Break ¶
func (t *ViewPort) Break()
The `Break()` function is used to print a line break on the terminal. It calls the `row()` method of the `Crt` struct to get the formatted line break string, and then it prints the string using `fmt.Println()`. This creates a visual separation between different sections or blocks of text on the terminal.
func (*ViewPort) ClearCurrentLine ¶
func (t *ViewPort) ClearCurrentLine()
ClearCurrentLine clears the current line in the terminal
func (*ViewPort) Close ¶
func (t *ViewPort) Close()
The `Close()` function is a method of the `Crt` struct. It is used to print a closing line on the terminal. It calls the `row()` method of the `Crt` struct to get the formatted closing line string, and then it prints the string using `fmt.Println()`. This creates a visual separation between different sections or blocks of text on the terminal.
func (*ViewPort) CurrentRow ¶
Get the current row of the terminal
func (*ViewPort) Delay ¶
Get Delay The above code is defining a method called "Delay" for a struct type "Crt". This method returns an integer value, which is the value of the "delay" field of the struct.
func (*ViewPort) DelayInSec ¶
Get Delay in seconds The above code is defining a method called "DelayInSec" for a struct type "Crt". This method returns the delay value of the "Crt" struct in seconds. The delay value is divided by 1000 to convert it from milliseconds to seconds and then returned as a float64.
func (*ViewPort) DelayIt ¶
func (t *ViewPort) DelayIt()
The above code is defining a method called "DelayIt" for a struct type "Crt". This method takes no arguments and has no return value.
func (*ViewPort) Error ¶
The `Error` function is a method of the `Crt` struct. It takes two parameters: `msg` of type string and `err` of type error.
func (*ViewPort) Format ¶
The `Format` function is a method of the `Crt` struct. It takes two parameters: `in` of type string and `t` of type string.
func (*ViewPort) Header ¶
The `Header` function is a method of the `Crt` struct. It is responsible for printing a banner message to the console.
func (*ViewPort) InfoMessage ¶
func (*ViewPort) Input ¶
The `Input` function is a method of the `Crt` struct. It is used to display a prompt for the user for input on the terminal.
func (*ViewPort) InputError ¶
The `InputError` function is a method of the `Crt` struct. It takes a `msg` parameter of type string and prints an error message to the terminal. It uses the `Format` method of the `Crt` struct to format the message with the bold red color and the special character (`chSpecial`). Then, it prints the formatted string using `fmt.Println()`.
func (*ViewPort) InputPagingInfo ¶
The `InputPagingInfo` function is a method of the `Crt` struct. It is used to print information about the current page and total number of pages to the terminal.
Parameters: page: The current page number. ofPages: The total number of pages.
Returns: None.
func (*ViewPort) NoBaudRate ¶
NoBaudRate returns true if the CRT's baud rate is set to col, false otherwise.
func (*ViewPort) Paragraph ¶
Paragraph formats a list of strings as paragraphs, wrapping lines as needed to fit within the terminal width.
func (*ViewPort) Print ¶
The `Print` function is a method of the `Crt` struct. It takes a `msg` parameter of type string and prints it to the terminal. It uses the `Format` method of the `Crt` struct to format the message with the normal character (`chNormal`). Then, it prints the formatted string using `fmt.Println()`.
func (*ViewPort) PrintIt ¶
PrintIt prints a message to the terminal.
If the CRT's baud rate is set to col, the function prints the message without applying any delays or formatting. If the baud rate is non-zero, the function prints the message character by character, with a delay of 1000000 microseconds (1 millisecond) between each character. The function also prints the current row number at the end of the message.
The function returns without printing a new line. To print a new line, use the Println method.
func (*ViewPort) Println ¶
Println prints a message to the terminal and adds a new line.
If the CRT's baud rate is set to col, the function prints the message without applying any delays or formatting. If the baud rate is non-zero, the function prints the message character by character, with a delay of 1000000 microseconds (1 millisecond) between each character. The function also prints the current row number at the end of the message.
The function returns without printing a new line. To print a new line, use the Println method.
func (*ViewPort) ResetDelay ¶
func (t *ViewPort) ResetDelay()
The above code is defining a method called "ResetDelay" for a struct type "Crt". This method is a member of the "Crt" struct and has a receiver of type "*Crt". Inside the method, it calls another method called "defaultDelay" on the receiver "T".
func (*ViewPort) SetBaud ¶
SetBaud sets the baud rate for the CRT.
If the specified baud rate is not supported, an error is returned and the CRT's baud rate is reset to the default value.
func (*ViewPort) SetDelayInMin ¶
The `SetDelayInMin` function is a method of the `Crt` struct. It takes an `int` parameter `delay` and sets the `delay` property of the `Crt` struct to the value of `delay` multiplied by 60000. This function is used to set the delay in milliseconds that should be applied before printing each character to the terminal, but it takes the delay in minutes instead of milliseconds.
func (*ViewPort) SetDelayInMs ¶
The `SetDelayInMs` function is a method of the `Crt` struct. It takes an `int` parameter `delay` and sets the `delay` property of the `Crt` struct to the value of `delay`. This property represents the delay in milliseconds that should be applied before printing each character to the terminal.
func (*ViewPort) SetDelayInSec ¶
The `SetDelayInSec` function is a method of the `Crt` struct. It takes a parameter `delay` of type `interface{}`.
func (*ViewPort) SetTerminalSize ¶
The `SetTerminalSize` function is a method of the `Crt` struct. It takes two parameters, `width` and `height`, which represent the desired width and height of the terminal screen.
func (*ViewPort) Shout ¶
The `Shout` function is a method of the `Crt` struct. It takes a `msg` parameter of type string and prints a formatted message to the terminal.
func (*ViewPort) Special ¶
The `Special` function is a method of the `Crt` struct. It takes a `msg` parameter of type string and prints it to the terminal using the `fmt.Println()` function. The message is formatted with the special character (`chSpecial`) using the `Format` method of the `Crt` struct. This function is used to print a special message or highlight certain text on the terminal.
func (*ViewPort) Spool ¶
Spool prints the contents of a byte slice to the terminal.
The byte slice is split into lines by the t.SymNewline character (\n). For each line, the function determines whether the line is empty. If the line is not empty, it is prepended with " " (two spaces) and printed to the terminal.
If the byte slice is empty, the function returns without printing anything.
The function also prints a blank line after all lines have been printed.
func (*ViewPort) TerminalSize ¶
The `TerminalSize` function is a method of the `Crt` struct. It returns the width and height of the terminal screen. It retrieves the values of the `width` and `height` properties of the `Crt` struct and returns them as integers.
func (*ViewPort) Underline ¶
The `Underline` method of the `Crt` struct is used to format a string with an underline. It takes a `msg` parameter of type string and returns a formatted string with the `msg` surrounded by the underline escape characters (`underline` and `reset`). The `fmt.Sprintf` function is used to concatenate the escape characters and the `msg` string. This method is used to create an underlined text effect when printing to the terminal.