textframe

package
v0.0.0-...-015bfa9 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HF_MARKSOFTWRAP uint32 = 1 << iota
	HF_TRUNCATE            // truncates instead of softwrapping
	HF_NOVERTSTOP          // Insert and InsertColor don't stop after they are past the bottom of the visible area
	HF_AUTOINDENT_SOFTWRAP
	HF_AUTOINDENT_WORDWRAP
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ExpandSelectionFn

type ExpandSelectionFn func(kind, start, end int) (int, int)

type Frame

type Frame struct {
	Font font.Face

	Hackflags       uint32
	B               draw.Image      // the image the text will be drawn upon
	R               image.Rectangle // the rectangle occupied by the frame
	VisibleTick     bool
	Colors          [][]image.Uniform
	TabWidth        int
	Flush           func(...image.Rectangle)
	Scroll          FrameScrollFn
	ExpandSelection ExpandSelectionFn
	Top             int
	Tabs            []int

	Offset int

	Sel      util.Sel
	MarkSel  *util.Sel
	SelColor int
	PMatch   util.Sel
	// contains filtered or unexported fields
}

func (*Frame) BytesSize

func (fr *Frame) BytesSize() uintptr

func (*Frame) Clear

func (fr *Frame) Clear()

func (*Frame) CoordToPoint

func (fr *Frame) CoordToPoint(coord image.Point) int

Converts a graphical coordinate to a rune index

func (*Frame) Init

func (fr *Frame) Init(margin int) error

Initializes frame

func (*Frame) Insert

func (fr *Frame) Insert(r1, r2 []rune) (limit image.Point)

Inserts text into the frame, returns the maximum X and Y used

func (*Frame) Inside

func (fr *Frame) Inside(p int) bool

func (*Frame) Invalidate

func (fr *Frame) Invalidate()

func (*Frame) LastPhisicalLineStart

func (fr *Frame) LastPhisicalLineStart(a, b []rune) int

func (*Frame) LimitY

func (fr *Frame) LimitY() int

func (*Frame) LineNo

func (fr *Frame) LineNo() int

func (*Frame) OnClick

func (f *Frame) OnClick(e util.MouseDownEvent, events <-chan util.EventOrRunnable) *mouse.Event

func (*Frame) PointToCoord

func (fr *Frame) PointToCoord(p int) image.Point

Converts rune index into a graphical coordinate

func (*Frame) PushDown

func (fr *Frame) PushDown(ln int, a, b []rune)

func (*Frame) PushUp

func (fr *Frame) PushUp(ln int, drawOpt bool) (newsize int)

Pushes text graphically up by "ln" phisical lines Returns the number of glyphs left in the frame

func (*Frame) Redraw

func (fr *Frame) Redraw(flush bool, predrawRects *[]image.Rectangle)

func (*Frame) RefreshColors

func (fr *Frame) RefreshColors(colors []uint8)

func (*Frame) Select

func (fr *Frame) Select(idx, kind int, button mouse.Button, startPos image.Point, events <-chan util.EventOrRunnable) *mouse.Event

Tracks the mouse position, selecting text, the events channel is from go.wde kind is 1 for character by character selection, 2 for word by word selection, 3 for line by line selection

func (*Frame) SetSelect

func (fr *Frame) SetSelect(idx, kind, start, end int)

Sets extremes of the selection, pass start == end if you want an empty selection idx is the index of the selection

func (*Frame) Size

func (fr *Frame) Size() int

type FrameScrollFn

type FrameScrollFn func(scrollDir int, n int)

Callback when the frame needs to scroll its text If scrollDir is 0 then n is the absolute position to move to If scrollDir is -1 the text should be scrolled back by n lines If scrollDir is +1 the text should be scrolled forward by n lines

type Redrawable

type Redrawable interface {
	Redraw(flush bool)
}

type ScrollFrame

type ScrollFrame struct {
	Flush func(...image.Rectangle)
	Color image.Uniform // color for the scrollbar
	Width int           // horizontal width of the scrollbar
	Fr    Frame         // text frame
	// contains filtered or unexported fields
}

func (*ScrollFrame) Init

func (sfr *ScrollFrame) Init(margin int) error

Initializes the ScrollFrame, will set B, R and Wnd of the underlying Frame itself

func (*ScrollFrame) OnClick

func (sfr *ScrollFrame) OnClick(e util.MouseDownEvent, events <-chan util.EventOrRunnable) (bool, *mouse.Event)

func (*ScrollFrame) Redraw

func (sfr *ScrollFrame) Redraw(flush bool, predrawRects *[]image.Rectangle)

Redraws frame. rdir and rpar are optimization parameters for partial redrawing of the frame during scrolling When rdir > 0, rpar is the number of glyphs that don't need to be redrawn When rdir < 0, rpar is the first glyph that doesn't need to be redrawn

func (*ScrollFrame) ScrollClick

func (sfr *ScrollFrame) ScrollClick(e util.MouseDownEvent, events <-chan util.EventOrRunnable) bool

If the click wasn't in the scrollbar area returns false Otherwise handles the click, until mouse-up is received, then returns true

func (*ScrollFrame) Set

func (sfr *ScrollFrame) Set(top, bodyLen int)

func (*ScrollFrame) SetRects

func (sfr *ScrollFrame) SetRects(b draw.Image, r image.Rectangle)

func (*ScrollFrame) Under

func (sfr *ScrollFrame) Under(p image.Point) bool

Jump to

Keyboard shortcuts

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