drawutil

package
v1.3.14 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CursorHalfHit = false
View Source
var WrapLineIndentTabs = 0.0
View Source
var WrapLineRune = rune('←') // positioned at the start of wrapped line (left)
View Source
var WrapWordLimit = 0

Functions

func Intersect added in v1.3.0

func Intersect(r, s image.Rectangle) image.Rectangle

Differs from image.Rectangle.Intersect in that it return {r.Min,r.Min} on empty.

func RectInset added in v1.3.0

func RectInset(r image.Rectangle, xn, yn int) image.Rectangle

Differs from image.Rectangle.Inset in that it accepts x and y args.

Types

type Annotation added in v1.3.14

type Annotation struct {
	Offset     int
	Bytes      []byte
	NotesBytes []byte // used for arrival index
}

type AnnotationGroup added in v1.3.14

type AnnotationGroup struct {
	sync.RWMutex
	Anns []*Annotation
}

func NewAnnotationGroup added in v1.3.14

func NewAnnotationGroup(n int) *AnnotationGroup

func (*AnnotationGroup) On added in v1.3.14

func (ag *AnnotationGroup) On() bool

type ColorizeGroup added in v1.3.14

type ColorizeGroup struct {
	Off bool
	Ops []*ColorizeOp
}

type ColorizeOp added in v1.3.14

type ColorizeOp struct {
	Offset    int
	Fg, Bg    color.Color
	ProcColor func(fg, bg color.Color) (fg2, bg2 color.Color)
	Line      bool
	SetNil    bool
}

type Decoration added in v1.3.14

type Decoration struct {
	Offset    int
	Kind      DecorationKind
	Fg        color.Color
	Thickness int
}

type DecorationGroup added in v1.3.14

type DecorationGroup struct {
	Off     bool
	Entries []*Decoration
}

type DecorationKind added in v1.3.14

type DecorationKind uint8
const (
	DecorationHorizontalRule DecorationKind = iota + 1
)

type Drawer

type Drawer interface {
	Reader() iorw.ReaderAt
	SetReader(iorw.ReaderAt)
	ContentChanged()
	TextDrawerOptions() *TextDrawerOptions
	TextDrawerOptionsChanged()

	FontFace() *fontutil.FontFace
	SetFontFace(*fontutil.FontFace)
	LineHeight() int
	SetFg(color.Color)

	Bounds() image.Rectangle
	SetBounds(image.Rectangle)

	// rune offset  (set text view position; save/restore view in session file)
	RuneOffset() int
	SetRuneOffset(int)

	LocalPointOf(index int) image.Point
	LocalIndexOf(image.Point) int
	AnnotationsIndexOf(image.Point) (int, int, bool)

	Measure() image.Point
	Draw(img draw.Image)

	// specialized: covers editor row button margin
	FirstLineOffsetX() int
	SetFirstLineOffsetX(x int)

	// cursor
	SetCursorOffset(int)

	// scrollable utils
	ScrollOffset() image.Point
	SetScrollOffset(image.Point)
	ScrollSize() image.Point
	ScrollViewSize() image.Point
	ScrollPageSizeY(up bool) int
	ScrollWheelSizeY(up bool) int

	// visibility utils
	RangeVisible(offset, n int) bool
	RangeVisibleOffset(offset, n int, align RangeAlignment) int
}

type RangeAlignment added in v1.3.8

type RangeAlignment int
const (
	RAlignKeep         RangeAlignment = iota
	RAlignKeepOrBottom                // keep if visible, or bottom
	RAlignAuto
	RAlignTop
	RAlignBottom
	RAlignCenter
)

type SyntaxComment added in v1.3.11

type SyntaxComment struct {
	Start string
	End   string // empty for single line comment
}

func (*SyntaxComment) IsLine added in v1.3.11

func (syc *SyntaxComment) IsLine() bool

type TextDrawerOptions added in v1.3.14

type TextDrawerOptions struct {
	LineWrap struct {
		On     bool
		Fg, Bg color.Color
	}
	Cursor struct {
		On         bool
		Fg         color.Color
		AddedWidth int
	}
	IndexOf struct {
		HalfHit bool
	}
	TextContrast struct {
		On bool
		Bg color.Color
	}
	Colorize struct {
		Groups []*ColorizeGroup
	}
	Decorations struct {
		Groups []*DecorationGroup
	}
	Annotations struct {
		On       bool
		Fg, Bg   color.Color
		Selected struct {
			EntryIndex int
			Fg, Bg     color.Color
		}
		Entries *AnnotationGroup // must be ordered by offset
	}
	WordHighlight struct {
		On     bool
		Fg, Bg color.Color
		Group  ColorizeGroup
	}
	ParenthesisHighlight struct {
		On     bool
		Fg, Bg color.Color
		Group  ColorizeGroup
	}
	ContentColorize struct {
		Git struct {
			On       bool
			AddFg    color.Color
			DeleteFg color.Color
		}
		Group ColorizeGroup
	}
	SyntaxHighlight struct {
		On      bool
		Comment struct {
			SCs    []*SyntaxComment
			Fg, Bg color.Color
		}
		String struct {
			Fg, Bg color.Color
		}
		Group ColorizeGroup
	}
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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