cellbuf

package module
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2025 License: MIT Imports: 16 Imported by: 11

Documentation

Index

Constants

View Source
const (
	NoUnderline     = ansi.NoUnderlineStyle
	SingleUnderline = ansi.SingleUnderlineStyle
	DoubleUnderline = ansi.DoubleUnderlineStyle
	CurlyUnderline  = ansi.CurlyUnderlineStyle
	DottedUnderline = ansi.DottedUnderlineStyle
	DashedUnderline = ansi.DashedUnderlineStyle
)

These are the available underline styles.

View Source
const DefaultTabInterval = 8

DefaultTabInterval is the default tab interval.

Variables

View Source
var (
	// BlankCell is a cell with a single space, width of 1, and no style or link.
	BlankCell = Cell{Rune: ' ', Width: 1}

	// EmptyCell is just an empty cell used for comparisons and as a placeholder
	// for wide cells.
	EmptyCell = Cell{}
)
View Source
var ErrInvalidDimensions = errors.New("invalid dimensions")

ErrInvalidDimensions is returned when the dimensions of a window are invalid for the operation.

View Source
var ErrOutOfBounds = errors.New("out of bounds")

ErrOutOfBounds is returned when the given x, y position is out of bounds.

Functions

func Clear added in v0.0.6

func Clear(s CellBuffer)

Clear clears the cell buffer with blank cells.

func ClearRect added in v0.0.12

func ClearRect(s CellBuffer, rect Rectangle)

ClearRect clears the rectangle within the cell buffer with blank cells.

func Fill

func Fill(s CellBuffer, c *Cell)

Fill fills the cell buffer with the given cell.

func FillRect added in v0.0.12

func FillRect(s CellBuffer, c *Cell, rect Rectangle)

FillRect fills the rectangle within the cell buffer with the given cell. This will not fill cells outside the bounds of the cell buffer.

func Height

func Height(s string) int

Height returns the height of a string.

func ReadLink(p []byte, link *Link)

ReadLink reads a hyperlink escape sequence from a data buffer.

func ReadStyle added in v0.0.7

func ReadStyle(params ansi.Params, pen *Style)

ReadStyle reads a Select Graphic Rendition (SGR) escape sequences from a list of parameters.

func ReadStyleColor added in v0.0.7

func ReadStyleColor(params ansi.Params, c *color.Color) int

ReadStyleColor reads a color from a list of parameters. See ansi.ReadStyleColor for more information.

func Render

func Render(d CellBuffer) string

Render returns a string representation of the grid with ANSI escape sequences.

func RenderLine

func RenderLine(d CellBuffer, n int) (w int, line string)

RenderLine returns a string representation of the yth line of the grid along with the width of the line.

func SetContent added in v0.0.2

func SetContent(s CellBuffer, str string)

SetContent clears the cell buffer with blank cells, and sets the given string as its content. If the height or width of the string exceeds the height or width of the cell buffer, it will be truncated.

func SetContentRect added in v0.0.12

func SetContentRect(s CellBuffer, str string, rect Rectangle)

SetContentRect clears the rectangle within the cell buffer with blank cells, and sets the given string as its content. If the height or width of the string exceeds the height or width of the cell buffer, it will be truncated.

func Wrap added in v0.0.12

func Wrap(s string, limit int, breakpoints string) string

Wrap returns a string that is wrapped to the specified limit applying any ANSI escape sequences in the string. It tries to wrap the string at word boundaries, but will break words if necessary.

The breakpoints string is a list of characters that are considered breakpoints for word wrapping. A hyphen (-) is always considered a breakpoint.

Note: breakpoints must be a string of 1-cell wide rune characters.

Types

type AttrMask

type AttrMask uint8

AttrMask is a bitmask for text attributes that can change the look of text. These attributes can be combined to create different styles.

const (
	BoldAttr AttrMask = 1 << iota
	FaintAttr
	ItalicAttr
	SlowBlinkAttr
	RapidBlinkAttr
	ReverseAttr
	ConcealAttr
	StrikethroughAttr

	ResetAttr AttrMask = 0
)

These are the available text attributes that can be combined to create different styles.

func (AttrMask) Contains added in v0.0.13

func (a AttrMask) Contains(attr AttrMask) bool

Contains returns whether the attribute mask contains the attribute.

type Buffer

type Buffer struct {
	// Lines holds the lines of the buffer.
	Lines []Line
}

Buffer is a 2D grid of cells representing a screen or terminal.

func NewBuffer added in v0.0.6

func NewBuffer(width int, height int) *Buffer

NewBuffer creates a new buffer with the given width and height. This is a convenience function that initializes a new buffer and resizes it.

func (*Buffer) Bounds added in v0.0.7

func (b *Buffer) Bounds() Rectangle

Bounds returns the bounds of the buffer.

func (*Buffer) Cell added in v0.0.2

func (b *Buffer) Cell(x int, y int) *Cell

Cell implements Screen.

func (*Buffer) Clear added in v0.0.7

func (b *Buffer) Clear()

Clear clears the buffer with space cells and rectangle.

func (*Buffer) ClearRect added in v0.0.7

func (b *Buffer) ClearRect(rect Rectangle)

ClearRect clears the buffer with space cells within the specified rectangles. Only cells within the rectangle's bounds are affected.

func (*Buffer) DeleteCell added in v0.0.7

func (b *Buffer) DeleteCell(x, y, n int, c *Cell)

DeleteCell deletes cells at the given position, with the given optional cell, within the specified rectangles. If no rectangles are specified, it deletes cells in the entire buffer. This follows terminal ansi.DCH behavior.

func (*Buffer) DeleteCellRect added in v0.0.7

func (b *Buffer) DeleteCellRect(x, y, n int, c *Cell, rect Rectangle)

DeleteCellRect deletes cells at the given position, with the given optional cell, within the rectangle bounds. Only cells within the rectangle's bounds are affected, following terminal ansi.DCH behavior.

func (*Buffer) DeleteLine added in v0.0.7

func (b *Buffer) DeleteLine(y, n int, c *Cell)

DeleteLine deletes n lines at the given line position, with the given optional cell, within the specified rectangles. If no rectangles are specified, it deletes lines in the entire buffer.

func (*Buffer) DeleteLineRect added in v0.0.7

func (b *Buffer) DeleteLineRect(y, n int, c *Cell, rect Rectangle)

DeleteLineRect deletes lines at the given line position, with the given optional cell, within the rectangle bounds. Only cells within the rectangle's bounds are affected. Lines are shifted up within the bounds and new blank lines are created at the bottom. This follows terminal ansi.DL behavior.

func (*Buffer) Fill added in v0.0.7

func (b *Buffer) Fill(c *Cell)

Fill fills the buffer with the given cell and rectangle.

func (*Buffer) FillRect added in v0.0.7

func (b *Buffer) FillRect(c *Cell, rect Rectangle)

FillRect fills the buffer with the given cell and rectangle.

func (*Buffer) Height

func (b *Buffer) Height() int

Height implements Screen.

func (*Buffer) InsertCell added in v0.0.7

func (b *Buffer) InsertCell(x, y, n int, c *Cell)

InsertCell inserts new cells at the given position, with the given optional cell, within the specified rectangles. If no rectangles are specified, it inserts cells in the entire buffer. This follows terminal ansi.ICH behavior.

func (*Buffer) InsertCellRect added in v0.0.7

func (b *Buffer) InsertCellRect(x, y, n int, c *Cell, rect Rectangle)

InsertCellRect inserts new cells at the given position, with the given optional cell, within the rectangle bounds. Only cells within the rectangle's bounds are affected, following terminal ansi.ICH behavior.

func (*Buffer) InsertLine added in v0.0.7

func (b *Buffer) InsertLine(y, n int, c *Cell)

InsertLine inserts n lines at the given line position, with the given optional cell, within the specified rectangles. If no rectangles are specified, it inserts lines in the entire buffer. Only cells within the rectangle's horizontal bounds are affected. Lines are pushed out of the rectangle bounds and lost. This follows terminal ansi.IL behavior. It returns the pushed out lines.

func (*Buffer) InsertLineRect added in v0.0.7

func (b *Buffer) InsertLineRect(y, n int, c *Cell, rect Rectangle)

InsertLineRect inserts new lines at the given line position, with the given optional cell, within the rectangle bounds. Only cells within the rectangle's horizontal bounds are affected. Lines are pushed out of the rectangle bounds and lost. This follows terminal ansi.IL behavior.

func (*Buffer) Line added in v0.0.7

func (b *Buffer) Line(y int) Line

Line returns a pointer to the line at the given y position. If the line does not exist, it returns nil.

func (*Buffer) Resize

func (b *Buffer) Resize(width int, height int)

Resize resizes the buffer to the given width and height.

func (*Buffer) SetCell added in v0.0.2

func (b *Buffer) SetCell(x, y int, c *Cell) bool

SetCell sets the cell at the given x, y position.

func (*Buffer) String added in v0.0.7

func (b *Buffer) String() (s string)

String returns the string representation of the buffer.

func (*Buffer) Width

func (b *Buffer) Width() int

Width implements Screen.

type Cell

type Cell struct {
	// The style of the cell. Nil style means no style. Zero value prints a
	// reset sequence.
	Style Style

	// Link is the hyperlink of the cell.
	Link Link

	// Comb is the combining runes of the cell. This is nil if the cell is a
	// single rune or if it's a zero width cell that is part of a wider cell.
	Comb []rune

	// Width is the mono-space width of the grapheme cluster.
	Width int

	// Rune is the main rune of the cell. This is zero if the cell is part of a
	// wider cell.
	Rune rune
}

Cell represents a single cell in the terminal screen.

func NewCell added in v0.0.7

func NewCell(r rune, comb ...rune) (c *Cell)

NewCell returns a new cell. This is a convenience function that initializes a new cell with the given content. The cell's width is determined by the content using runewidth.RuneWidth. This will only account for the first combined rune in the content. If the content is empty, it will return an empty cell with a width of 0.

func NewCellString added in v0.0.7

func NewCellString(s string) (c *Cell)

NewCellString returns a new cell with the given string content. This is a convenience function that initializes a new cell with the given content. The cell's width is determined by the content using runewidth.StringWidth. This will only use the first combined rune in the string. If the string is empty, it will return an empty cell with a width of 0.

func NewGraphemeCell added in v0.0.7

func NewGraphemeCell(s string) (c *Cell)

NewGraphemeCell returns a new cell. This is a convenience function that initializes a new cell with the given content. The cell's width is determined by the content using uniseg.FirstGraphemeClusterInString. This is used when the content is a grapheme cluster i.e. a sequence of runes that form a single visual unit. This will only return the first grapheme cluster in the string. If the string is empty, it will return an empty cell with a width of 0.

func (*Cell) Append added in v0.0.9

func (c *Cell) Append(r ...rune)

Append appends runes to the cell without changing the width. This is useful when we want to use the cell to store escape sequences or other runes that don't affect the width of the cell.

func (*Cell) Blank added in v0.0.7

func (c *Cell) Blank() *Cell

Blank makes the cell a blank cell by setting the rune to a space, comb to nil, and the width to 1.

func (*Cell) Clear added in v0.0.7

func (c *Cell) Clear() bool

Clear returns whether the cell consists of only attributes that don't affect appearance of a space character.

func (*Cell) Clone added in v0.0.7

func (c *Cell) Clone() (n *Cell)

Clone returns a copy of the cell.

func (Cell) Empty

func (c Cell) Empty() bool

Empty returns whether the cell is an empty cell. An empty cell is a cell with a width of 0, a rune of 0, and no combining runes.

func (*Cell) Equal

func (c *Cell) Equal(o *Cell) bool

Equal returns whether the cell is equal to the other cell.

func (*Cell) Reset

func (c *Cell) Reset()

Reset resets the cell to the default state zero value.

func (Cell) String added in v0.0.7

func (c Cell) String() string

String returns the string content of the cell excluding any styles, links, and escape sequences.

type CellBuffer added in v0.0.12

type CellBuffer interface {
	// Cell returns the cell at the given position.
	Cell(x, y int) *Cell
	// SetCell sets the cell at the given position to the given cell. It
	// returns whether the cell was set successfully.
	SetCell(x, y int, c *Cell) bool
	// Bounds returns the bounds of the cell buffer.
	Bounds() Rectangle
}

CellBuffer is a cell buffer that represents a set of cells in a screen or a grid.

type Cursor added in v0.0.7

type Cursor struct {
	Style
	Link
	Position
}

Cursor represents a terminal Cursor.

type Line added in v0.0.7

type Line []*Cell

Line represents a line in the terminal. A nil cell represents an blank cell, a cell with a space character and a width of 1. If a cell has no content and a width of 0, it is a placeholder for a wide cell.

func (Line) At added in v0.0.7

func (l Line) At(x int) *Cell

At returns the cell at the given x position. If the cell does not exist, it returns nil.

func (Line) Len added in v0.0.7

func (l Line) Len() int

Len returns the length of the line.

func (Line) Set added in v0.0.7

func (l Line) Set(x int, c *Cell) bool

Set sets the cell at the given x position. If a wide cell is given, it will set the cell and the following cells to EmptyCell. It returns true if the cell was set.

func (Line) String added in v0.0.7

func (l Line) String() (s string)

String returns the string representation of the line. Any trailing spaces are removed.

func (Line) Width added in v0.0.7

func (l Line) Width() int

Width returns the width of the line.

type Link struct {
	URL    string
	Params string
}

Link represents a hyperlink in the terminal screen.

func ConvertLink(h Link, p colorprofile.Profile) Link

Convert converts a hyperlink to respect the given color profile.

func (Link) Empty

func (h Link) Empty() bool

Empty returns whether the hyperlink is empty.

func (*Link) Equal

func (h *Link) Equal(o *Link) bool

Equal returns whether the hyperlink is equal to the other hyperlink.

func (*Link) Reset

func (h *Link) Reset()

Reset resets the hyperlink to the default state zero value.

func (Link) String

func (h Link) String() string

String returns a string representation of the hyperlink.

type Position added in v0.0.6

type Position = image.Point

Position represents an x, y position.

func Pos added in v0.0.6

func Pos(x, y int) Position

Pos is a shorthand for Position{X: x, Y: y}.

type Rectangle added in v0.0.6

type Rectangle = image.Rectangle

Rectange represents a rectangle.

func Rect added in v0.0.6

func Rect(x, y, w, h int) Rectangle

Rect is a shorthand for Rectangle.

type Screen added in v0.0.2

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

Screen represents the terminal screen.

func NewScreen added in v0.0.7

func NewScreen(w io.Writer, width, height int, opts *ScreenOptions) (s *Screen)

NewScreen creates a new Screen.

func (*Screen) Bounds added in v0.0.7

func (s *Screen) Bounds() Rectangle

Bounds implements Window.

func (*Screen) Cell added in v0.0.2

func (s *Screen) Cell(x int, y int) *Cell

Cell implements Window.

func (*Screen) Clear added in v0.0.7

func (s *Screen) Clear() bool

Clear clears the screen with blank cells. This is a convenience method for Screen.Fill with a nil cell.

func (*Screen) ClearRect added in v0.0.7

func (s *Screen) ClearRect(r Rectangle) bool

ClearRect clears the given rectangle with blank cells. This is a convenience method for Screen.FillRect with a nil cell.

func (*Screen) Close added in v0.0.7

func (s *Screen) Close() (err error)

Close writes the final screen update and resets the screen.

func (*Screen) EnterAltScreen added in v0.0.7

func (s *Screen) EnterAltScreen()

EnterAltScreen enters the alternate screen buffer.

func (*Screen) ExitAltScreen added in v0.0.7

func (s *Screen) ExitAltScreen()

ExitAltScreen exits the alternate screen buffer.

func (*Screen) Fill added in v0.0.7

func (s *Screen) Fill(cell *Cell) bool

Fill implements Window.

func (*Screen) FillRect added in v0.0.7

func (s *Screen) FillRect(cell *Cell, r Rectangle) bool

FillRect implements Window.

func (*Screen) Flush added in v0.0.9

func (s *Screen) Flush() (err error)

Flush flushes the buffer to the screen.

func (*Screen) Height added in v0.0.2

func (s *Screen) Height() int

Height returns the height of the screen.

func (*Screen) HideCursor added in v0.0.7

func (s *Screen) HideCursor()

HideCursor hides the cursor.

func (*Screen) InsertAbove added in v0.0.7

func (s *Screen) InsertAbove(str string)

InsertAbove inserts string above the screen. The inserted string is not managed by the screen. This does nothing when alternate screen mode is enabled.

func (*Screen) MoveTo added in v0.0.7

func (s *Screen) MoveTo(x, y int)

MoveTo moves the cursor to the given position.

func (*Screen) Redraw added in v0.0.9

func (s *Screen) Redraw()

Redraw forces a full redraw of the screen.

func (*Screen) Render added in v0.0.7

func (s *Screen) Render()

Render renders changes of the screen to the internal buffer. Call Screen.Flush to flush pending changes to the screen.

func (*Screen) Resize added in v0.0.2

func (s *Screen) Resize(width, height int) bool

Resize resizes the screen.

func (*Screen) SetCell added in v0.0.2

func (s *Screen) SetCell(x int, y int, cell *Cell) (v bool)

SetCell implements Window.

func (*Screen) SetColorProfile added in v0.0.7

func (s *Screen) SetColorProfile(p colorprofile.Profile)

SetColorProfile sets the color profile to use when writing to the screen.

func (*Screen) SetMethod added in v0.0.7

func (s *Screen) SetMethod(method ansi.Method)

SetMethod sets the method used to calculate the width of cells.

func (*Screen) SetRelativeCursor added in v0.0.7

func (s *Screen) SetRelativeCursor(v bool)

SetRelativeCursor sets whether to use relative cursor movements.

func (*Screen) ShowCursor added in v0.0.7

func (s *Screen) ShowCursor()

ShowCursor shows the cursor.

func (*Screen) UseBackspaces added in v0.0.11

func (s *Screen) UseBackspaces(v bool)

UseBackspaces sets whether to use backspace characters to move the cursor.

func (*Screen) UseHardTabs added in v0.0.7

func (s *Screen) UseHardTabs(v bool)

UseHardTabs sets whether to use hard tabs to optimize cursor movements.

func (*Screen) Width added in v0.0.2

func (s *Screen) Width() int

Width returns the width of the screen.

type ScreenOptions added in v0.0.7

type ScreenOptions struct {
	// Term is the terminal type to use when writing to the screen. When empty,
	// `$TERM` is used from [os.Getenv].
	Term string
	// Profile is the color profile to use when writing to the screen.
	Profile colorprofile.Profile
	// RelativeCursor is whether to use relative cursor movements. This is
	// useful when alt-screen is not used or when using inline mode.
	RelativeCursor bool
	// AltScreen is whether to use the alternate screen buffer.
	AltScreen bool
	// ShowCursor is whether to show the cursor.
	ShowCursor bool
	// HardTabs is whether to use hard tabs to optimize cursor movements.
	HardTabs bool
	// Backspace is whether to use backspace characters to move the cursor.
	Backspace bool
}

ScreenOptions are options for the screen.

type ScreenWriter added in v0.0.11

type ScreenWriter struct {
	*Screen
}

ScreenWriter represents a writer that writes to a Screen parsing ANSI escape sequences and Unicode characters and converting them into cells that can be written to a cell Buffer.

func NewScreenWriter added in v0.0.11

func NewScreenWriter(s *Screen) *ScreenWriter

NewScreenWriter creates a new ScreenWriter that writes to the given Screen. This is a convenience function for creating a ScreenWriter.

func (*ScreenWriter) Print added in v0.0.11

func (s *ScreenWriter) Print(str string, v ...interface{})

Print prints the string at the current cursor position. It will wrap the string to the width of the screen if it exceeds the width of the screen. This will recognize ANSI ansi.SGR style and ansi.SetHyperlink escape sequences.

func (*ScreenWriter) PrintAt added in v0.0.11

func (s *ScreenWriter) PrintAt(x, y int, str string, v ...interface{})

PrintAt prints the string at the given position. It will wrap the string to the width of the screen if it exceeds the width of the screen. This will recognize ANSI ansi.SGR style and ansi.SetHyperlink escape sequences.

func (*ScreenWriter) PrintCrop added in v0.0.11

func (s *ScreenWriter) PrintCrop(str string, tail string)

PrintCrop prints the string at the current cursor position and truncates the text if it exceeds the width of the screen. Use tail to specify a string to append if the string is truncated. This will recognize ANSI ansi.SGR style and ansi.SetHyperlink escape sequences.

func (*ScreenWriter) PrintCropAt added in v0.0.11

func (s *ScreenWriter) PrintCropAt(x, y int, str string, tail string)

PrintCropAt prints the string at the given position and truncates the text if it exceeds the width of the screen. Use tail to specify a string to append if the string is truncated. This will recognize ANSI ansi.SGR style and ansi.SetHyperlink escape sequences.

func (*ScreenWriter) SetContent added in v0.0.11

func (s *ScreenWriter) SetContent(str string)

SetContent clears the screen with blank cells, and sets the given string as its content. If the height or width of the string exceeds the height or width of the screen, it will be truncated.

This will recognize ANSI ansi.SGR style and ansi.SetHyperlink escape sequences.

func (*ScreenWriter) SetContentRect added in v0.0.11

func (s *ScreenWriter) SetContentRect(str string, rect Rectangle)

SetContentRect clears the rectangle within the screen with blank cells, and sets the given string as its content. If the height or width of the string exceeds the height or width of the screen, it will be truncated.

This will recognize ANSI ansi.SGR style and ansi.SetHyperlink escape sequences.

func (*ScreenWriter) Write added in v0.0.11

func (s *ScreenWriter) Write(p []byte) (n int, err error)

Write writes the given bytes to the screen. This will recognize ANSI ansi.SGR style and ansi.SetHyperlink escape sequences.

type Style

type Style struct {
	Fg      ansi.Color
	Bg      ansi.Color
	Ul      ansi.Color
	Attrs   AttrMask
	UlStyle UnderlineStyle
}

Style represents the Style of a cell.

func ConvertStyle added in v0.0.6

func ConvertStyle(s Style, p colorprofile.Profile) Style

Convert converts a style to respect the given color profile.

func (*Style) Background

func (s *Style) Background(c ansi.Color) *Style

Background sets the background color.

func (*Style) Bold

func (s *Style) Bold(v bool) *Style

Bold sets the bold attribute.

func (*Style) Clear added in v0.0.7

func (s *Style) Clear() bool

Clear returns whether the style consists of only attributes that don't affect appearance of a space character.

func (*Style) Conceal

func (s *Style) Conceal(v bool) *Style

Conceal sets the conceal attribute.

func (Style) DiffSequence

func (s Style) DiffSequence(o Style) string

DiffSequence returns the ANSI sequence that sets the style as a diff from another style.

func (*Style) Empty

func (s *Style) Empty() bool

Empty returns true if the style is empty.

func (*Style) Equal

func (s *Style) Equal(o *Style) bool

Equal returns true if the style is equal to the other style.

func (*Style) Faint

func (s *Style) Faint(v bool) *Style

Faint sets the faint attribute.

func (*Style) Foreground

func (s *Style) Foreground(c ansi.Color) *Style

Foreground sets the foreground color.

func (*Style) Italic

func (s *Style) Italic(v bool) *Style

Italic sets the italic attribute.

func (s *Style) RapidBlink(v bool) *Style

RapidBlink sets the rapid blink attribute.

func (*Style) Reset

func (s *Style) Reset() *Style

Reset resets the style to default.

func (*Style) Reverse

func (s *Style) Reverse(v bool) *Style

Reverse sets the reverse attribute.

func (Style) Sequence

func (s Style) Sequence() string

Sequence returns the ANSI sequence that sets the style.

func (s *Style) SlowBlink(v bool) *Style

SlowBlink sets the slow blink attribute.

func (*Style) Strikethrough

func (s *Style) Strikethrough(v bool) *Style

Strikethrough sets the strikethrough attribute.

func (*Style) Underline

func (s *Style) Underline(v bool) *Style

Underline sets the underline attribute. This is a syntactic sugar for UnderlineStyle.

func (*Style) UnderlineColor

func (s *Style) UnderlineColor(c ansi.Color) *Style

UnderlineColor sets the underline color.

func (*Style) UnderlineStyle

func (s *Style) UnderlineStyle(style UnderlineStyle) *Style

UnderlineStyle sets the underline style.

type TabStops added in v0.0.7

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

TabStops represents horizontal line tab stops.

func DefaultTabStops added in v0.0.7

func DefaultTabStops(cols int) *TabStops

DefaultTabStops creates a new set of tab stops with the default interval.

func NewTabStops added in v0.0.7

func NewTabStops(width, interval int) *TabStops

NewTabStops creates a new set of tab stops from a number of columns and an interval.

func (*TabStops) Clear added in v0.0.7

func (ts *TabStops) Clear()

Clear removes all tab stops.

func (TabStops) Find added in v0.0.7

func (ts TabStops) Find(col, delta int) int

Find returns the prev/next tab stop before/after the given column and delta. If delta is positive, it returns the next tab stop after the given column. If delta is negative, it returns the previous tab stop before the given column. If delta is zero, it returns the given column.

func (TabStops) IsStop added in v0.0.7

func (ts TabStops) IsStop(col int) bool

IsStop returns true if the given column is a tab stop.

func (TabStops) Next added in v0.0.7

func (ts TabStops) Next(col int) int

Next returns the next tab stop after the given column.

func (TabStops) Prev added in v0.0.7

func (ts TabStops) Prev(col int) int

Prev returns the previous tab stop before the given column.

func (*TabStops) Reset added in v0.0.7

func (ts *TabStops) Reset(col int)

Reset removes the tab stop at the given column.

func (*TabStops) Resize added in v0.0.7

func (ts *TabStops) Resize(width int)

Resize resizes the tab stops to the given width.

func (*TabStops) Set added in v0.0.7

func (ts *TabStops) Set(col int)

Set adds a tab stop at the given column.

type UnderlineStyle

type UnderlineStyle = ansi.UnderlineStyle

UnderlineStyle is the style of underline to use for text.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳