editor

package
v0.0.0-...-ffa1618 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2015 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package editor implements buffers representing views into a piece of text.

Package editor implements the functionality of the jk editor

Index

Constants

This section is empty.

Variables

View Source
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 New

func New() *Editor

New creates and initializes a new editor

func (*Editor) AddFile

func (e *Editor) AddFile(filename string) error

AddFile opens the file with the given name and gives it a view

func (*Editor) AddLogFile

func (e *Editor) AddLogFile(fname string)

AddLogFile sets the file the editor logs to

func (*Editor) Do

func (e *Editor) Do(k keys.Keypress) error

Do handles events

func (*Editor) Draw

func (e *Editor) Draw()

Draw draws the editor to the screen

func (*Editor) Interpret

func (e *Editor) Interpret(sexp, in string) ([]byte, error)

func (*Editor) InterpretInternal

func (e *Editor) InterpretInternal(parts []string) error

func (*Editor) Log

func (e *Editor) Log(things ...interface{})

Log writes to the editor's logfile

func (*Editor) NewEmptyFile

func (e *Editor) NewEmptyFile() error

NewEmptyFile creates a view with an empty buffer

func (*Editor) NextView

func (e *Editor) NextView()

func (*Editor) RegisterMode

func (e *Editor) RegisterMode(name string, mode Mode)

RegisterMode registers a mode for use in the editor with a name to be referred to as

func (*Editor) RunInterpreter

func (e *Editor) RunInterpreter()

runs in its own goroutine?

func (*Editor) ViewWithBuffer

func (e *Editor) ViewWithBuffer(a WriteBuffer, m string, x, y, w, h int) (View, error)

ViewWithBuffer creates a new view and area with the given buffer in the editor.

type EditorFunc

type EditorFunc func(e *Editor, args ...string) error

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

func Insert

func Insert() Mode

Insert builds insert mode :)

func Normal

func Normal(e *Editor) Mode

Normal returns a simple normal mode for testing

type ModeFunc

type ModeFunc func(v *View, count int) error

A ModeFunc is a function that can be executed by a keypress in a mode

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) Do

func (v *View) Do(k keys.Keypress) error

Do tells a view to handle a keypress according to its mode

func (*View) Draw

func (v *View) Draw()

Draw draws a View into its area

func (*View) ExecInsertUnderCursor

func (v *View) ExecInsertUnderCursor() error

func (*View) InsertChar

func (v *View) InsertChar(c byte)

InsertChar inserts the single rune r at the cursor

func (*View) MoveCursor

func (v *View) MoveCursor(dc, dr int)

MoveCursor moves the cursor relative to where it is now

func (*View) SetCursor

func (v *View) SetCursor(row, column int)

SetCursor sets the cursor to absolute coordinates in the file

func (*View) SetMode

func (v *View) SetMode(m *Mode, n string)

SetMode sets a view's mode, so that it handles events per that mode

func (*View) SetPoint

func (v *View) SetPoint()

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

Jump to

Keyboard shortcuts

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