screenbuf

package
v0.0.0-...-eb155b1 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ScreenBuf

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

ScreenBuf is a convenient way to write to terminal screens. It creates, clears and, moves up or down lines as needed to write the output to the terminal using ANSI escape codes.

func New

func New(w io.Writer) *ScreenBuf

New creates and initializes a new ScreenBuf.

func (*ScreenBuf) Clear

func (s *ScreenBuf) Clear() error

Clear clears all previous lines and the output starts from the top.

func (*ScreenBuf) Flush

func (s *ScreenBuf) Flush() error

Flush writes any buffered data to the underlying io.Writer, ensuring that any pending data is displayed.

func (*ScreenBuf) Reset

func (s *ScreenBuf) Reset()

Reset truncates the underlining buffer and marks all its previous lines to be cleared during the next Write.

func (*ScreenBuf) Write

func (s *ScreenBuf) Write(b []byte) (int, error)

Write writes a single line to the underlining buffer. If the ScreenBuf was previously reset, all previous lines are cleared and the output starts from the top. Lines with \r or \n will cause an error since they can interfere with the terminal ability to move between lines.

func (*ScreenBuf) WriteString

func (s *ScreenBuf) WriteString(str string) (int, error)

WriteString is a convenient function to write a new line passing a string. Check ScreenBuf.Write() for a detailed explanation of the function behaviour.

Jump to

Keyboard shortcuts

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