Documentation ¶
Index ¶
- Constants
- Variables
- func Rpt(min, max image.Point) image.Rectangle
- type Fontmetrics
- type Frame
- func (f *Frame) Charofpt(pt image.Point) int
- func (f *Frame) Clear(freeall bool)
- func (f *Frame) Delete(p0, p1 int) int
- func (f *Frame) DrawSel(pt image.Point, p0, p1 int, highlighted bool)
- func (f *Frame) Drawsel0(pt image.Point, p0, p1 int, back *draw.Image, text *draw.Image) image.Point
- func (f *Frame) GetFrameFillStatus() FrameFillStatus
- func (f *Frame) GetSelectionExtent() (int, int)
- func (f *Frame) Init(r image.Rectangle, ft *draw.Font, b *draw.Image, cols [NumColours]*draw.Image)
- func (f *Frame) InitTick()
- func (f *Frame) Insert(r []rune, p0 int)
- func (f *Frame) Insure(bn int, n uint)
- func (f *Frame) Logboxes(message string)
- func (f *Frame) Maxtab(m int)
- func (f *Frame) Ptofchar(p int) image.Point
- func (f *Frame) Redraw()
- func (f *Frame) Select(mc draw.Mousectl)
- func (f *Frame) SelectPaint(p0, p1 image.Point, col *draw.Image)
- func (f *Frame) SetRects(r image.Rectangle, b *draw.Image)
- func (f *Frame) SetSelectionExtent(p0, p1 int)
- func (f *Frame) Tick(pt image.Point, ticked bool)
- type FrameFillStatus
Constants ¶
const ( ColBack = iota ColHigh ColBord ColText ColHText NumColours )
Variables ¶
var ( DELTA = 25 TMPSIZE = 256 )
Functions ¶
Types ¶
type Fontmetrics ¶
type Fontmetrics interface { BytesWidth([]byte) int DefaultHeight() int Impl() *draw.Font StringWidth(string) int RunesWidth(r []rune) int }
Fontmetrics lets tests mock the calls into draw for measuring the width of UTF8 slices.
type Frame ¶
type Frame struct { // TODO(rjk): Remove public access if possible. Font Fontmetrics Display *draw.Display // on which the frame is displayed Background *draw.Image // on which the frame appears Cols [NumColours]*draw.Image // background and text colours Rect image.Rectangle // in which the text appears Entire image.Rectangle // size of full frame // TODO(rjk): Figure out what. Scroll func(*Frame, int) // function provided by application // contains filtered or unexported fields }
func NewFrame ¶
NewFrame creates a new Frame with Font ft, background image b, colours cols, and of the size r
func (*Frame) Clear ¶
Clear frees the internal structures associated with f, permitting another Init or SetRects on the Frame. It does not clear the associated display. If f is to be deallocated, the associated Font and Image must be freed separately. The resize argument should be non-zero if the frame is to be redrawn with a different font; otherwise the frame will maintain some data structures associated with the font.
/To resize a Frame, use Clear and Init and then Insert to recreate the /display. If a Frame is being moved but not resized, that is, if the /shape of its containing rectangle is unchanged, it is sufficient to /use Draw to copy the containing rectangle from the old to the new /location and then call SetRects to establish the new geometry. (It is /unnecessary to call InitTick unless the font size has changed.) No /redrawing is necessary.
func (*Frame) Delete ¶
Delete deletes from the Frame the text between p0 and p1; p1 points at the first rune beyond the deletion.
func (*Frame) DrawSel ¶
DrawSel repaints a section of the frame, delimited by character positions p0 and p1, either with plain background or entirely highlighted, according to the flag highlighted, managing the tick appropriately. The point pt0 is the geometrical location of p0 on the screen; like all of the selection-helper routines' Point arguments, it must be a value generated by Ptofchar.
Clarification of semantics: the point of this routine is to redraw the state of the Frame with selection p0,p1. In particular, this requires updating f.p0 and f.p1 so that other entry points (e.g. Insert) can (transparently) remove a pre-existing selection.
Note that the original code does not remove the pre-existing selection. I (rjk) claim that this is clearly the wrong semantics. This function should arrange for the drawn selection on return to be p0, p1
func (*Frame) Drawsel0 ¶
func (f *Frame) Drawsel0(pt image.Point, p0, p1 int, back *draw.Image, text *draw.Image) image.Point
TODO(rjk): This function is convoluted. Drawsel0 is a lower-level routine, taking as arguments a background color back and text color text. It assumes that the tick is being handled (removed beforehand, replaced afterwards, as required) by its caller. The selection is delimited by character positions p0 and p1. The point pt0 is the geometrical location of p0 on the screen and must be a value generated by Ptofchar.
Commentary: this function should conceivably not be part of the public API
Function does not mutate f.p0, f.p1 (well... actually, it does.)
func (*Frame) GetFrameFillStatus ¶
func (f *Frame) GetFrameFillStatus() FrameFillStatus
GetFrameFillStatus returns a snapshot of the capacity of the frame.
func (*Frame) GetSelectionExtent ¶
GetSelectionExtent returns the rune offsets of the selection maintained by the Frame.
func (*Frame) Init ¶
Init prepares the Frame f so characters drawn in it will appear in the single Font ft. It then calls SetRects and InitTick to initialize the geometry for the Frame. The Image b is where the Frame is to be drawn; Rectangle r defines the limit of the portion of the Image the text will occupy. The Image pointer may be null, allowing the other routines to be called to maintain the associated data structure in, for example, an obscured window.
func (*Frame) Insert ¶
Insert inserts r into Frame f starting at index p0. If a NUL (0) character is inserted, chaos will ensue. Tabs and newlines are handled by the library, but all other characters, including control characters, are just displayed. For example, backspaces are printed; to erase a character, use Delete.
Insert manages the tick and selection.
func (*Frame) Redraw ¶
func (f *Frame) Redraw()
This function is not part of the documented libframe entrypoints. TODO(rjk): discern purpose of this code.
func (*Frame) SetSelectionExtent ¶
SetSelectionExtent sets the rune offsets of the selection maintained by the Frame. p0 and p1 must be values that could be returned by Charofpt. TODO(rjk): It is conceivable that we don't need this. It seems like an egregious abstraction violation that it exists.
type FrameFillStatus ¶
FrameFillStatus is a snapshot of the capacity of the Frame.