Documentation ¶
Overview ¶
Package ui is the user interface of the editor.
Index ¶
- type Col
- func (c *Col) Add(row Row)
- func (c *Col) Click(pt image.Point, button int)
- func (c *Col) Del(r Row)
- func (c *Col) Draw(dirty bool, drawImage draw.Image)
- func (c *Col) HandleBounds() image.Rectangle
- func (c *Col) Move(pt image.Point)
- func (c *Col) Resize(size image.Point)
- func (c *Col) Tick() bool
- func (c *Col) Wheel(pt image.Point, x, y int)
- type Row
- type Sheet
- func (s *Sheet) Body() *TextBox
- func (s *Sheet) Click(pt image.Point, button int) (int, [2]int64)
- func (s *Sheet) Draw(dirty bool, drawImg draw.Image)
- func (s *Sheet) Get() error
- func (s *Sheet) HandleBounds() image.Rectangle
- func (s *Sheet) Move(pt image.Point)
- func (s *Sheet) Put() error
- func (s *Sheet) Resize(size image.Point)
- func (s *Sheet) SetTitle(title string)
- func (s *Sheet) Tick() bool
- func (s *Sheet) Title() string
- func (s *Sheet) Update([]syntax.Highlight, edit.Diffs, rope.Rope) []syntax.Highlight
- func (s *Sheet) Wheel(pt image.Point, x, y int)
- type TextBox
- func (b *TextBox) Change(diffs edit.Diffs)
- func (b *TextBox) Click(pt image.Point, button int) (int, [2]int64)
- func (b *TextBox) Copy() error
- func (b *TextBox) Cut() error
- func (b *TextBox) Dir(x, y int)
- func (b *TextBox) Draw(dirty bool, img draw.Image)
- func (b *TextBox) Edit(t string) (edit.Diffs, error)
- func (b *TextBox) Focus(focus bool)
- func (b *TextBox) Mod(m int)
- func (b *TextBox) Move(pt image.Point)
- func (b *TextBox) Paste() error
- func (b *TextBox) Resize(size image.Point)
- func (b *TextBox) Rune(r rune)
- func (b *TextBox) SetText(text rope.Rope)
- func (b *TextBox) Text() rope.Rope
- func (b *TextBox) Tick() bool
- func (b *TextBox) Wheel(_ image.Point, x, y int)
- type Win
- func (w *Win) Add() *Col
- func (w *Win) Click(pt image.Point, button int)
- func (w *Win) Del(c *Col)
- func (w *Win) Draw(dirty bool, drawImg draw.Image)
- func (w *Win) Focus(focus bool)
- func (w *Win) Mod(m int)
- func (w *Win) Move(pt image.Point)
- func (w *Win) OutputBytes(data []byte)
- func (w *Win) OutputString(str string)
- func (w *Win) Resize(size image.Point)
- func (w *Win) Tick() bool
- func (w *Win) Wheel(pt image.Point, x, y int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Col ¶
type Col struct { Row // focus // contains filtered or unexported fields }
A Col is a column of sheets.
func (*Col) HandleBounds ¶
HandleBounds returns the bounding box of the handle.
type Row ¶
type Row interface { // Draw draws the element to the image. // If dirty is true the element should redraw itself in its entirity. // If dirty is false, the element need only redraw // parts that have changed since the last call to Draw. Draw(dirty bool, img draw.Image) // Focus handles a focus state change. // The focus is either true (in focus) or false (out of focus). Focus(focus bool) // Resize handles a resize event. Resize(size image.Point) // Tick returns whether the row need be redrawn. // It is intended to be called at regular intervals // in order to drive asynchronous events. Tick() bool // Move handles mouse cursor moving events. Move(pt image.Point) // Click handles mouse button events. // // The absolute value of the argument indicates the mouse button. // A positive value indicates the button was pressed. // A negative value indicates the button was released. // // The first return value is the button ultimately pressed // (this can differ from the argument button, for example, // if modifier keys are being held). // If the button is < 0, the second return value is the clicked address. Click(pt image.Point, button int) (int, [2]int64) // Wheel handles mouse wheel events. // -y is roll up. // +y is roll down. // -x is roll left. // +x is roll right. Wheel(pt image.Point, x, y int) // Dir handles keyboard directional events. // // These events are generated by the arrow keys, // page up and down keys, and the home and end keys. // Exactly one of x or y must be non-zero. // // If the absolute value is 1, then it is treated as an arrow key // in the corresponding direction (x-horizontal, y-vertical, // negative-left/up, positive-right/down). // If the absolute value is math.MinInt16, it is treated as a home event. // If the absolute value is math.MathInt16, it is end. // Otherwise, if the value for y is non-zero it is page up/down. // Other non-zero values for x are currently ignored. // // Dir only handles key press events, not key releases. Dir(x, y int) // Mod handles modifier key state change events. // // The absolute value of the argument indicates the modifier key. // A positive value indicates the key was pressed. // A negative value indicates the key was released. Mod(m int) // Rune handles typing events. // // The argument is a rune indicating the glyph typed // after interpretation by any system-dependent // keyboard/layout mapping. // For example, if the 'a' key is pressed // while the shift key is held, // the argument would be the letter 'A'. // // If the rune is positive, the event is a key press, // if negative, a key release. Rune(r rune) }
The Row interface is implemented by UI elements that sit in a column, draw, and react to user input events.
All corrdinates below are relative to the row, with 0,0 in the upper left.
type Sheet ¶
type Sheet struct { *TextBox // the focus element: the tag or the body. // contains filtered or unexported fields }
A Sheet is a tag and a body. TODO: better document the Sheet type.
func (*Sheet) Get ¶
Get loads the body of the sheet with the contents of the file at the path of the sheet's title.
func (*Sheet) HandleBounds ¶
HandleBounds returns the bounding box of the handle.
func (*Sheet) Put ¶
Put writes the contents of the body of the sheet to the file at the path of the sheet's title.
func (*Sheet) Title ¶
Title returns the title of the sheet. The title is the first space-terminated string in the tag, or if the first rune of the tag is ' , it is the first ' terminated string with \' as an escaped ' and \\ as an escaped \.
type TextBox ¶
type TextBox struct {
// contains filtered or unexported fields
}
TextBox is an editable text box UI widget.
func NewTextBox ¶
NewTextBox returns a new, empty text box. The styles are:
0: default style 1: 1-click selection style 2: 2-click selection style 3: 3-click selection style
func (*TextBox) Click ¶
Click handles a mouse button press or release event. The first return value is the button ultimately pressed (this can differ from the argument button, for example, if modifier keys are being held). If the button is < 0, the second return value is the clicked address. The third return value is whether the text box image needs to be redrawn.
The absolute value of the argument indicates the mouse button. A positive value indicates the button was pressed. A negative value indicates the button was released.
func (*TextBox) Cut ¶
Cut copies the selected text into the system clipboard and deletes it from the text box.
func (*TextBox) Dir ¶
Dir handles a keyboard directional event and returns whether the text box image needs to be redrawn.
These events are generated by the arrow keys, page up and down keys, and the home and end keys. Exactly one of x or y must be non-zero.
If the absolute value is 1, then it is treated as an arrow key in the corresponding direction (x-horizontal, y-vertical, negative-left/up, positive-right/down). If the absolute value is math.MinInt16, it is treated as a home event. If the absolute value is math.MathInt16, it is end. Otherwise, if the value for y is non-zero it is page up/down. Other non-zero values for x are currently ignored.
Dir only handles key press events, not key releases.
func (*TextBox) Edit ¶
Edit performs an edit on the text of the text box and returns the diffs applied to the text. If more than 0 diffs are returned, the text box needs to be redrawn.
func (*TextBox) Move ¶
Move handles the event of the mouse cursor moving to a point and returns whether the text box image needs to be redrawn.
func (*TextBox) Resize ¶
Resize handles a resize event. The text box must always be redrawn after being resized.
func (*TextBox) Rune ¶
Rune handles the event of a rune being typed and returns whether the text box image needs to be redrawn.
The argument is a rune indicating the glyph typed after interpretation by any system-dependent keyboard/layout mapping. For example, if the 'a' key is pressed while the shift key is held, the argument would be the letter 'A'.
If the rune is positive, the event is a key press, if negative, a key release.
func (*TextBox) SetText ¶
SetText sets the text of the text box. The text box always must be redrawn after setting the text.
type Win ¶
type Win struct { *Col // focus // contains filtered or unexported fields }
A Win is a window of columns of sheets.
func (*Win) OutputBytes ¶
OutputBytes appends bytes to the Output sheet and ensures that the Output sheet is visible. It is safe for concurrent calls.
func (*Win) OutputString ¶
OutputString appends a string to the Output sheet and ensures that the Output sheet is visible. It is safe for concurrent calls.