Documentation ¶
Overview ¶
Package editor implements buffers representing views into a piece of text.
Package editor implements the functionality of the jk editor
Index ¶
- Variables
- type Buffer
- type Cursor
- type Editor
- func (e *Editor) AddFile(filename string) error
- func (e *Editor) AddLogFile(fname string)
- func (e *Editor) Do(k keys.Keypress) error
- func (e *Editor) Draw()
- func (e *Editor) Interpret(sexp, in string) ([]byte, error)
- func (e *Editor) InterpretInternal(parts []string) error
- func (e *Editor) Log(things ...interface{})
- func (e *Editor) NewEmptyFile() error
- func (e *Editor) NextView()
- func (e *Editor) RegisterMode(name string, mode Mode)
- func (e *Editor) RunInterpreter()
- func (e *Editor) ViewWithBuffer(a WriteBuffer, m string, x, y, w, h int) (View, error)
- type EditorFunc
- type Mode
- type ModeFunc
- type View
- func (v *View) AlternateTag()
- func (v *View) ClearPoint()
- func (v *View) DeleteBackwards()
- func (v *View) Do(k keys.Keypress) error
- func (v *View) Draw()
- func (v *View) ExecInsertUnderCursor() error
- func (v *View) InsertChar(c byte)
- func (v *View) MoveCursor(dc, dr int)
- func (v *View) SetCursor(row, column int)
- func (v *View) SetMode(m *Mode, n string)
- func (v *View) SetPoint()
- func (v *View) TogglePoint()
- type WriteBuffer
Constants ¶
This section is empty.
Variables ¶
var LogItAll *log.Logger
LogItAll logs _everything_
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer interface { GetLine(lineno int) (string, error) // The returned line shouldn't be changed Lines() int // Returns the number of lines in the buffer Len() int // The number of bytes in the buffer OffsetOf(line, column int) int64 }
A Buffer holds text - these methods enable a view to display a buffer
type Cursor ¶
type Cursor struct {
Line, Column int
}
A Cursor indicates where the cursor is 0, 0 is the first position in a file
type Editor ¶
type Editor struct {
// contains filtered or unexported fields
}
An Editor edits shit
func (*Editor) AddLogFile ¶
AddLogFile sets the file the editor logs to
func (*Editor) InterpretInternal ¶
func (*Editor) NewEmptyFile ¶
NewEmptyFile creates a view with an empty buffer
func (*Editor) RegisterMode ¶
RegisterMode registers a mode for use in the editor with a name to be referred to as
func (*Editor) ViewWithBuffer ¶
ViewWithBuffer creates a new view and area with the given buffer in the editor.
type EditorFunc ¶
An EditorFunc is a function that can be bound to a keypress
type Mode ¶
type Mode struct { OnEnter func(v *View) error OnExit func(v *View) error EventMap map[keys.Keypress]ModeFunc }
A Mode is used to map keypresses into events in the editor
type View ¶
type View struct {
// contains filtered or unexported fields
}
A View contains a buffer and knows how to draw it to an area
func (*View) AlternateTag ¶
func (v *View) AlternateTag()
func (*View) ClearPoint ¶
func (v *View) ClearPoint()
func (*View) DeleteBackwards ¶
func (v *View) DeleteBackwards()
DeleteBackwards deletes one character backwards
func (*View) ExecInsertUnderCursor ¶
func (*View) InsertChar ¶
InsertChar inserts the single rune r at the cursor
func (*View) MoveCursor ¶
MoveCursor moves the cursor relative to where it is now
func (*View) TogglePoint ¶
func (v *View) TogglePoint()
type WriteBuffer ¶
type WriteBuffer interface { io.WriterAt Buffer Write(name string) error // Writes the file to the named string Delete(n, off int64) // Deletes n bytes forwards from off Load(from io.Reader, name string) error Get() (string, error) FromTo(off1, off2 int64) (string, error) }
func BufferizeFile ¶
func BufferizeFile(fname string) (WriteBuffer, error)
BufferizeFile returns a Buffer initialized with a file