view

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompositeMoveDown

func CompositeMoveDown(ctx Context, textLayout *TextLayout, viewLocalPos int) int

func CompositeMoveUp

func CompositeMoveUp(ctx Context, textLayout *TextLayout, viewLocalPos int) int

func CompositeViewIndex

func CompositeViewIndex(table []int, viewLocalPos int) (Row int, Column int)

func CompositeViewLengthSum added in v0.4.0

func CompositeViewLengthSum(table []int, index int) int

func CompositeViewLengthTable

func CompositeViewLengthTable(ctx Context, textLayout *TextLayout) ([]int, int)

Types

type CharacterReference

type CharacterReference struct {
	StartPosition model.Position
	Bytes         int
	LineWrap      bool
}

type Context

type Context struct {
	Resolver      TextViewResolver
	Document      model.Document
	FoldManager   FoldManager
	TextSelection TextSelection
}

Context is rendering parameter set of basic.

func (Context) GetSegment

func (ctx Context) GetSegment(e model.Element, rangeIndex int) model.Segment

GetSegment returns Range at specified index.

func (Context) GetText

func (ctx Context) GetText(e model.Element) string

GetText returns text of Element

type FoldBlockView

type FoldBlockView struct {
}

func (*FoldBlockView) ConvertModel

func (fv *FoldBlockView) ConvertModel(ctx Context, textLayout *TextLayout, viewLocalPos int) CharacterReference

func (*FoldBlockView) ConvertPos

func (fv *FoldBlockView) ConvertPos(ctx Context, textLayout *TextLayout, viewLocalPos int) (ViewLocalX int, ViewLocalY int)

func (*FoldBlockView) ConvertViewLocalPos

func (fv *FoldBlockView) ConvertViewLocalPos(ctx Context, textLayout *TextLayout, bytePos model.Position) int

func (*FoldBlockView) Draw

func (fv *FoldBlockView) Draw(ctx Context, textLayout *TextLayout, renderer Renderer)

func (*FoldBlockView) FindFoldElementAt added in v0.4.0

func (fv *FoldBlockView) FindFoldElementAt(ctx Context, textLayout *TextLayout, viewLocalPos int) (model.Element, int, bool)

func (*FoldBlockView) Layout

func (fv *FoldBlockView) Layout(ctx Context, textLayout *TextLayout, x, y, w, h int)

func (*FoldBlockView) Measure added in v0.4.0

func (fv *FoldBlockView) Measure(ctx Context, e model.Element, width int, height int) *TextLayout

func (*FoldBlockView) MoveDown

func (fv *FoldBlockView) MoveDown(ctx Context, textLayout *TextLayout, viewLocalPos int) int

func (*FoldBlockView) MoveLeft

func (fv *FoldBlockView) MoveLeft(ctx Context, textLayout *TextLayout, viewLocalPos int) int

func (*FoldBlockView) MoveLength

func (fv *FoldBlockView) MoveLength(ctx Context, textLayout *TextLayout) int

func (*FoldBlockView) MoveRight

func (fv *FoldBlockView) MoveRight(ctx Context, textLayout *TextLayout, viewLocalPos int) int

func (*FoldBlockView) MoveUp

func (fv *FoldBlockView) MoveUp(ctx Context, textLayout *TextLayout, viewLocalPos int) int

func (*FoldBlockView) ShouldBeforeInsertionNewLineOnLineBegin

func (fv *FoldBlockView) ShouldBeforeInsertionNewLineOnLineBegin(ctx Context, textLayout *TextLayout, viewLocalPos int) bool

func (*FoldBlockView) ShouldRemoveLastCharacter

func (fv *FoldBlockView) ShouldRemoveLastCharacter(ctx Context, textLayout *TextLayout, viewLocalPos int) (model.Element, bool)

func (*FoldBlockView) ShouldRemoveWithLine

func (fv *FoldBlockView) ShouldRemoveWithLine(ctx Context, textLayout *TextLayout, viewLocalPos int) (int, bool)

func (*FoldBlockView) ShouldRemoveWithSpecifiedColumnAfter

func (fv *FoldBlockView) ShouldRemoveWithSpecifiedColumnAfter(ctx Context, textLayout *TextLayout, viewLocalPos int) (model.Position, bool)

func (*FoldBlockView) ShouldRemoveWithSpecifiedRangeColumns

func (fv *FoldBlockView) ShouldRemoveWithSpecifiedRangeColumns(ctx Context, textLayout *TextLayout, viewLocalPos int) (model.Range, bool)

func (*FoldBlockView) ShouldRemoveWithSpecifiedRangeLines

func (fv *FoldBlockView) ShouldRemoveWithSpecifiedRangeLines(ctx Context, textLayout *TextLayout, viewLocalPos int) (model.Range, bool)

type FoldManager

type FoldManager interface {
	IsFolded(doc model.Document, e model.Element) bool
}

type GhostView

type GhostView struct {
}

func (*GhostView) ConvertModel

func (g *GhostView) ConvertModel(ctx Context, textLayout *TextLayout, viewLocalPos int) CharacterReference

func (*GhostView) ConvertPos

func (g *GhostView) ConvertPos(ctx Context, textLayout *TextLayout, viewLocalPos int) (ViewLocalX int, ViewLocalY int)

func (*GhostView) ConvertViewLocalPos

func (g *GhostView) ConvertViewLocalPos(ctx Context, textLayout *TextLayout, bytePos model.Position) int

func (*GhostView) Draw

func (g *GhostView) Draw(ctx Context, textLayout *TextLayout, renderer Renderer)

func (*GhostView) FindFoldElementAt added in v0.4.0

func (g *GhostView) FindFoldElementAt(ctx Context, textLayout *TextLayout, viewLocalPos int) (model.Element, int, bool)

func (*GhostView) Layout

func (g *GhostView) Layout(ctx Context, textLayout *TextLayout, x, y, w, h int)

func (*GhostView) Measure added in v0.4.0

func (g *GhostView) Measure(ctx Context, e model.Element, width int, height int) *TextLayout

func (*GhostView) MoveDown

func (g *GhostView) MoveDown(ctx Context, textLayout *TextLayout, viewLocalPos int) int

func (*GhostView) MoveLeft

func (g *GhostView) MoveLeft(ctx Context, textLayout *TextLayout, viewLocalPos int) int

func (*GhostView) MoveLength

func (g *GhostView) MoveLength(ctx Context, textLayout *TextLayout) int

func (*GhostView) MoveRight

func (g *GhostView) MoveRight(ctx Context, textLayout *TextLayout, viewLocalPos int) int

func (*GhostView) MoveUp

func (g *GhostView) MoveUp(ctx Context, textLayout *TextLayout, viewLocalPos int) int

func (*GhostView) ShouldBeforeInsertionNewLineOnLineBegin

func (g *GhostView) ShouldBeforeInsertionNewLineOnLineBegin(ctx Context, textLayout *TextLayout, viewLocalPos int) bool

func (*GhostView) ShouldRemoveLastCharacter

func (g *GhostView) ShouldRemoveLastCharacter(ctx Context, textLayout *TextLayout, viewLocalPos int) (model.Element, bool)

func (*GhostView) ShouldRemoveWithLine

func (g *GhostView) ShouldRemoveWithLine(ctx Context, textLayout *TextLayout, viewLocalPos int) (int, bool)

func (*GhostView) ShouldRemoveWithSpecifiedColumnAfter

func (g *GhostView) ShouldRemoveWithSpecifiedColumnAfter(ctx Context, textLayout *TextLayout, viewLocalPos int) (model.Position, bool)

func (*GhostView) ShouldRemoveWithSpecifiedRangeColumns

func (g *GhostView) ShouldRemoveWithSpecifiedRangeColumns(ctx Context, textLayout *TextLayout, viewLocalPos int) (model.Range, bool)

func (*GhostView) ShouldRemoveWithSpecifiedRangeLines

func (g *GhostView) ShouldRemoveWithSpecifiedRangeLines(ctx Context, textLayout *TextLayout, viewLocalPos int) (model.Range, bool)

type LinebaseTextView

type LinebaseTextView interface {
	TextView

	ConvertRelativeX(ctx Context, textLayout *TextLayout, viewLocalPos int) int

	MoveFirstLine(ctx Context, textLayout *TextLayout, relX int) int

	MoveLastLine(ctx Context, textLayout *TextLayout, relX int) int
}

type PlainTextView

type PlainTextView struct {
}

func (*PlainTextView) ConvertModel

func (p *PlainTextView) ConvertModel(ctx Context, textLayout *TextLayout, viewLocalPos int) CharacterReference

func (*PlainTextView) ConvertPos

func (p *PlainTextView) ConvertPos(ctx Context, textLayout *TextLayout, viewLocalPos int) (ViewLocalX int, ViewLocalY int)

func (*PlainTextView) ConvertRelativeX

func (p *PlainTextView) ConvertRelativeX(ctx Context, textLayout *TextLayout, viewLocalPos int) int

func (*PlainTextView) ConvertViewLocalPos

func (p *PlainTextView) ConvertViewLocalPos(ctx Context, textLayout *TextLayout, bytePos model.Position) int

func (*PlainTextView) Draw

func (p *PlainTextView) Draw(ctx Context, textLayout *TextLayout, renderer Renderer)

func (*PlainTextView) FindFoldElementAt added in v0.4.0

func (p *PlainTextView) FindFoldElementAt(ctx Context, textLayout *TextLayout, viewLocalPos int) (model.Element, int, bool)

func (*PlainTextView) Layout

func (p *PlainTextView) Layout(ctx Context, textLayout *TextLayout, x, y, w, h int)

func (*PlainTextView) Measure added in v0.4.0

func (p *PlainTextView) Measure(ctx Context, e model.Element, width int, height int) *TextLayout

func (*PlainTextView) MoveDown

func (p *PlainTextView) MoveDown(ctx Context, textLayout *TextLayout, viewLocalPos int) int

func (*PlainTextView) MoveFirstLine

func (p *PlainTextView) MoveFirstLine(ctx Context, textLayout *TextLayout, relX int) int

func (*PlainTextView) MoveLastLine

func (p *PlainTextView) MoveLastLine(ctx Context, textLayout *TextLayout, relX int) int

func (*PlainTextView) MoveLeft

func (p *PlainTextView) MoveLeft(ctx Context, textLayout *TextLayout, viewLocalPos int) int

func (*PlainTextView) MoveLength

func (p *PlainTextView) MoveLength(ctx Context, textLayout *TextLayout) int

func (*PlainTextView) MoveRight

func (p *PlainTextView) MoveRight(ctx Context, textLayout *TextLayout, viewLocalPos int) int

func (*PlainTextView) MoveUp

func (p *PlainTextView) MoveUp(ctx Context, textLayout *TextLayout, viewLocalPos int) int

func (*PlainTextView) ShouldBeforeInsertionNewLineOnLineBegin

func (p *PlainTextView) ShouldBeforeInsertionNewLineOnLineBegin(ctx Context, textLayout *TextLayout, viewLocalPos int) bool

func (*PlainTextView) ShouldRemoveLastCharacter

func (p *PlainTextView) ShouldRemoveLastCharacter(ctx Context, textLayout *TextLayout, viewLocalPos int) (model.Element, bool)

func (*PlainTextView) ShouldRemoveWithLine

func (p *PlainTextView) ShouldRemoveWithLine(ctx Context, textLayout *TextLayout, viewLocalPos int) (int, bool)

func (*PlainTextView) ShouldRemoveWithSpecifiedColumnAfter

func (p *PlainTextView) ShouldRemoveWithSpecifiedColumnAfter(ctx Context, textLayout *TextLayout, viewLocalPos int) (model.Position, bool)

func (*PlainTextView) ShouldRemoveWithSpecifiedRangeColumns

func (p *PlainTextView) ShouldRemoveWithSpecifiedRangeColumns(ctx Context, textLayout *TextLayout, viewLocalPos int) (model.Range, bool)

func (*PlainTextView) ShouldRemoveWithSpecifiedRangeLines

func (p *PlainTextView) ShouldRemoveWithSpecifiedRangeLines(ctx Context, textLayout *TextLayout, viewLocalPos int) (model.Range, bool)

type Renderer

type Renderer interface {
	// SetContent put rune at specified position.
	SetContent(x int, y int, primary rune, combining []rune, style tcell.Style)

	// Translate returns renderer of after coordinate translate.
	// region will be reseted.
	Translate(offsetX int, offsetY int) Renderer

	// Translate returns renderer of after clip.
	Region(width int, height int) Renderer
}

Renderer is terminal graphics backend. only tcell supported in currently.

type TabStopTextView

type TabStopTextView interface {
	DrawWithTabStop(ctx Context, textLayout *TextLayout, renderer Renderer, column int) int
	WidthWithTabStop(ctx Context, e model.Element, column int) int
}

type TextLayout

type TextLayout struct {
	Element  model.Element
	Children []*TextLayout

	RelativeX int
	RelativeY int

	Width         int
	Height        int
	MinimumWidth  int
	MinimumHeight int
}

TextLayout is representation a layout at a certain point in time.

type TextSelection added in v0.4.0

type TextSelection struct {
	FromPos CharacterReference
	ToPos   CharacterReference
}

func (TextSelection) Contain added in v0.4.0

func (ts TextSelection) Contain(at model.Position) bool

func (TextSelection) IsZero added in v0.4.0

func (ts TextSelection) IsZero() bool

func (TextSelection) Ordered added in v0.4.0

func (ts TextSelection) Ordered() (First CharacterReference, Last CharacterReference)

type TextView

type TextView interface {
	// Layout is layout this view and contained sub views.
	// x and y is origin of this view, aim left top.
	// w and h is given layout size.
	Layout(ctx Context, textLayout *TextLayout, x, y, w, h int)

	// Draw is rendernig content.
	Draw(ctx Context, textLayout *TextLayout, renderer Renderer)

	// Measure returns TextLayout for this view and contained sub views.
	// calculate only minimum size, at this point.
	Measure(ctx Context, e model.Element, width int, height int) *TextLayout

	// MoveLength returns movable count for cursor in this view.
	// inclusive a subview move count if this view is inclusive a subview.
	MoveLength(ctx Context, textLayout *TextLayout) int

	// MoveUp returns position after cursor up.
	MoveUp(ctx Context, textLayout *TextLayout, viewLocalPos int) int

	// MoveDown returns position after cursor down.
	MoveDown(ctx Context, textLayout *TextLayout, viewLocalPos int) int

	// MoveLeft returns position after cursor left.
	MoveLeft(ctx Context, textLayout *TextLayout, viewLocalPos int) int

	// MoveRight returns position after cursor right.
	MoveRight(ctx Context, textLayout *TextLayout, viewLocalPos int) int

	// ConvertPos returns 2D position from view local position.
	ConvertPos(ctx Context, textLayout *TextLayout, viewLocalPos int) (ViewLocalX int, ViewLocalY int)

	// ConvertModel returns character at specified view local position.
	ConvertModel(ctx Context, textLayout *TextLayout, viewLocalPos int) CharacterReference

	// ConvertViewLocalPos returns view local position at specified byte position.
	// move to inward if byte position is aim to decoration.
	ConvertViewLocalPos(ctx Context, textLayout *TextLayout, bytePos model.Position) int

	FindFoldElementAt(ctx Context, textLayout *TextLayout, viewLocalPos int) (model.Element, int, bool)

	ShouldBeforeInsertionNewLineOnLineBegin(ctx Context, textLayout *TextLayout, viewLocalPos int) bool
	ShouldRemoveWithLine(ctx Context, textLayout *TextLayout, viewLocalPos int) (int, bool)
	ShouldRemoveWithSpecifiedColumnAfter(ctx Context, textLayout *TextLayout, viewLocalPos int) (model.Position, bool)
	ShouldRemoveWithSpecifiedRangeLines(ctx Context, textLayout *TextLayout, viewLocalPos int) (model.Range, bool)
	ShouldRemoveWithSpecifiedRangeColumns(ctx Context, textLayout *TextLayout, viewLocalPos int) (model.Range, bool)
	ShouldRemoveLastCharacter(ctx Context, textLayout *TextLayout, viewLocalPos int) (model.Element, bool)
}

TextView is render a part of text. TextView is should be stateless, and every state is given from parameter.

type TextViewResolver

type TextViewResolver interface {
	Resolve(e model.Element) TextView
}

TextViewResolver resolve TextView from Element. in normally, determine by element type.

Jump to

Keyboard shortcuts

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