Documentation ¶
Overview ¶
Package editor provides a graphical, editable text area widget.
Index ¶
- Variables
- type Editor
- func (ed *Editor) CanRedo() bool
- func (ed *Editor) CanUndo() bool
- func (ed *Editor) Contents() []byte
- func (ed *Editor) Dirty() bool
- func (ed *Editor) Draw(dst *image.RGBA, dr image.Rectangle) int
- func (ed *Editor) FindNext(s string) (address.Selection, bool)
- func (ed *Editor) GetDot() address.Selection
- func (ed *Editor) GetDotContents() string
- func (ed *Editor) JumpTo(addr string) bool
- func (ed *Editor) LastAddress() address.Simple
- func (ed *Editor) Load(s []byte)
- func (ed *Editor) Replace(s string)
- func (ed *Editor) Saved() bool
- func (ed *Editor) SendKeyEvent(e key.Event)
- func (ed *Editor) SendMouseEvent(e mouse.Event)
- func (ed *Editor) SendRedo()
- func (ed *Editor) SendUndo()
- func (ed *Editor) SetDot(a address.Selection)
- func (ed *Editor) SetFont(face font.Face)
- func (ed *Editor) SetOpts(opts *OptionSet)
- func (ed *Editor) SetSaved()
- type OptionSet
Constants ¶
This section is empty.
Variables ¶
var AcmeBlueTheme = &OptionSet{ Text: image.Black, BG1: image.NewUniform(color.RGBA{R: 0xEA, G: 0xFF, B: 0xFF, A: 0xFF}), BG2: image.NewUniform(color.RGBA{R: 0x88, G: 0x88, B: 0xCC, A: 0xFF}), Sel: image.NewUniform(color.RGBA{R: 0x9F, G: 0xEB, B: 0xEA, A: 0xFF}), Cursor: acmeCursor(image.NewUniform(color.RGBA{R: 0xEA, G: 0xFF, B: 0xFF, A: 0xFF})), AutoIndent: true, ScrollBar: true, }
var AcmeYellowTheme = &OptionSet{ Text: image.Black, BG1: image.NewUniform(color.RGBA{R: 0xFF, G: 0xFF, B: 0xEA, A: 0xFF}), BG2: image.NewUniform(color.RGBA{R: 0xA0, G: 0xA0, B: 0x4B, A: 0xFF}), Sel: image.NewUniform(color.RGBA{R: 0xEE, G: 0xEE, B: 0x9E, A: 0xFF}), Cursor: acmeCursor(image.NewUniform(color.RGBA{R: 0xFF, G: 0xFF, B: 0xEA, A: 0xFF})), AutoIndent: true, ScrollBar: true, }
var SimpleTheme = &OptionSet{ Text: image.Black, BG1: image.White, BG2: image.NewUniform(color.Gray{Y: 0xA0}), Sel: image.NewUniform(color.RGBA{R: 0x90, G: 0xB0, B: 0xD0, A: 0xFF}), Cursor: simpleCursor, }
Functions ¶
This section is empty.
Types ¶
type Editor ¶
type Editor struct { B2Action func(string) // define an action for the middle mouse button B3Action func(string) // define an action for the right mouse button // contains filtered or unexported fields }
An Editor is a graphical, editable text area widget, intended to be compatible with golang.org/x/exp/shiny, or any other graphical window package capable of drawing a widget via an image.RGBA. See sigint.ca/cmd/edit for an example program using this type.
func NewEditor ¶
NewEditor returns a new Editor with a clipping rectangle defined by size, a font face, and an OptionSet opts. If opts is nil, editor.SimpleTheme will be used.
func (*Editor) CanRedo ¶
CanRedo reports whether the Editor has a following history state which can be applied.
func (*Editor) CanUndo ¶
CanUndo reports whether the Editor has a previous history state which can be applied.
func (*Editor) Dirty ¶
Dirty reports whether the next call to Draw will result in a different image than the previous call.
func (*Editor) Draw ¶
Draw draws the editor onto dst within the bounding rectangle dr, and returns the height in pixels of the text that was drawn.
func (*Editor) FindNext ¶
FindNext searches for s in the Editor's text buffer, and selects the first match starting from the current selection, possibly wrapping around to the beginning of the buffer. If there are no matches, the selection is unchanged.
func (*Editor) GetDotContents ¶
func (*Editor) LastAddress ¶
func (*Editor) Load ¶
Load replaces the contents of the Editor's text buffer with s, and resets the Editor's history.
func (*Editor) Replace ¶
Replace replaces the current selection with s, updating the Editor's history.
func (*Editor) Saved ¶
Saved reports whether the Editor has been modified since the last time SetSaved was called.
func (*Editor) SendKeyEvent ¶
SendKeyEvent sends a key event to be interpreted by the Editor.
func (*Editor) SendMouseEvent ¶
SendMouseEvent sends a mouse event to be interpreted by the Editor.
func (*Editor) SendRedo ¶
func (ed *Editor) SendRedo()
SendRedo attempts to apply the Editor's next history state, if it exists.
func (*Editor) SendUndo ¶
func (ed *Editor) SendUndo()
SendUndo attempts to apply the Editor's previous history state, if it exists.