layout

package
v0.0.0-...-62d7a36 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ParagraphItemTypeBox     ParagraphItemType = 0
	ParagraphItemTypeGlue                      = iota
	ParagraphItemTypePenalty                   = iota
)
View Source
const (
	ParagraphItemPenaltyNever   ParagraphItemType = 1000
	ParagraphItemPenaltyNeutral                   = 0
	ParagraphItemPenaltyAlways                    = -1000
)

Variables

View Source
var (
	ErrPointIsFromDifferentDocument = errors.New("Point is from different document")
	ErrPointNotFound                = errors.New("Point not found")
)
View Source
var (
	StyleNormal = tcell.StyleDefault.Background(tcell.ColorDarkBlue).Foreground(tcell.ColorLightGray)
	StyleMarkup = StyleNormal.Foreground(tcell.ColorDarkCyan)
)

Functions

This section is empty.

Types

type Cell

type Cell struct {
	// Mainc represents the main rune for this cell. If 0, the cell is the rightmost companion to a
	// wide character and should not be rendered.
	Mainc rune

	// Combc holds any combining runes for the cell.
	Combc []rune

	// Style describes how to render the cell.
	Style tcell.Style

	// StartOffset gives the location within the parent paragraph of the cell's contents.
	StartOffset int

	// EndOFfset gices the location within the parent just after the cell's contents.
	EndOffset int
}

type Layout

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

func NewLayout

func NewLayout(d *document.Document, screenWidth int) (*Layout, error)

func (*Layout) CellLocationForPoint

func (l *Layout) CellLocationForPoint(p *document.Point) (int, int, error)

func (*Layout) Document

func (l *Layout) Document() *document.Document

func (*Layout) LineIterator

func (l *Layout) LineIterator(startLineIndex int) *LineIterator

func (*Layout) ScreenWidth

func (l *Layout) ScreenWidth() int

func (*Layout) SetDocument

func (l *Layout) SetDocument(d *document.Document)

func (*Layout) SetScreenWidth

func (l *Layout) SetScreenWidth(screenWidth int)

func (*Layout) String

func (l *Layout) String() string

type Line

type Line []ParagraphItem

func (Line) EndOffset

func (l Line) EndOffset() int

func (Line) StartOffset

func (l Line) StartOffset() int

type LineIterator

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

func (*LineIterator) Done

func (i *LineIterator) Done() bool

func (*LineIterator) Next

func (i *LineIterator) Next() (int, Line)

type Lines

type Lines []Line

type ParagraphItem

type ParagraphItem struct {
	// Type represents the type of this layout item: box, glue or penalty.
	Type ParagraphItemType

	// Text is the content of this item when rendered on screen. Only applicable to boxes.
	Text string

	// Style is the appearance of this item when rendered on screen.
	Style tcell.Style

	// StartOffset is the lowest inclusive offset within the underlying paragraph represented by
	// this item.
	StartOffset int

	// EndOffset is the lowest offset within the underlying paragraph >= StartOffset which is not
	// represented by this item.
	EndOffset int

	// Penalty gives a penalty for breaking the line at this item. If the penalty is +ve, the line
	// will never be broken. If the penalty is 0, the line _may_ be broken. If the penalty is -ve
	// the line will always be broken.
	//
	// Only glue and penalties can break lines. Penalty is ignored for boxes.
	Penalty ParagraphItemPenalty
}

ParagraphItem represents a layout item within a paragraph. Items may be boxes, glue or penalties.

Boxes are literal horizontal collections of Cells to be rendered. Glue are Cells which are rendered representing the space between words. Penalties represent explicit line-breaking opportunity points.

func (*ParagraphItem) CellCount

func (p *ParagraphItem) CellCount() int

CellCount is the *minimum* number of on-screen cells required to represent the item. Glue, in particular, may be rendered with more cells.

type ParagraphItemPenalty

type ParagraphItemPenalty int

type ParagraphItemType

type ParagraphItemType int

Jump to

Keyboard shortcuts

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