editor

package
Version: v0.0.0-...-a543747 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2017 License: Apache-2.0 Imports: 13 Imported by: 0

README

editor

The editor provides low-level management of text being edited.

Documentation

Overview

Package editor implements the core text editing functions of gott. Many of these functions are accessed only through operations; this makes it possible to easily repeat and undo them. An editor manages multiple windows; windows are rectangular subdivisions of a screen and each window edits an associated buffer. It is possible for multiple windows to concurrently edit a single buffer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer struct {
	Name     string
	ReadOnly bool

	Highlighted bool
	// contains filtered or unexported fields
}

A Buffer represents a file being edited. Buffers are displayed in windows but also may be manipulated offscreen.

func NewBuffer

func NewBuffer() *Buffer

func (*Buffer) AppendBytes

func (b *Buffer) AppendBytes(bytes []byte)

func (*Buffer) DeleteCharacters

func (b *Buffer) DeleteCharacters(row int, col int, count int, joinLines bool) string

func (*Buffer) DeleteRow

func (b *Buffer) DeleteRow(row int)

func (*Buffer) FirstPositionInRowAfterCol

func (b *Buffer) FirstPositionInRowAfterCol(row int, col int, text string) int

func (*Buffer) GetBytes

func (b *Buffer) GetBytes() []byte

func (*Buffer) GetCharacterAtCursor

func (b *Buffer) GetCharacterAtCursor(cursor gott.Point) rune

func (*Buffer) GetFileName

func (b *Buffer) GetFileName() string

func (*Buffer) GetName

func (b *Buffer) GetName() string

func (*Buffer) GetReadOnly

func (b *Buffer) GetReadOnly() bool

func (*Buffer) GetRowCount

func (b *Buffer) GetRowCount() int

func (*Buffer) GetRowLength

func (b *Buffer) GetRowLength(i int) int

func (*Buffer) InsertCharacter

func (b *Buffer) InsertCharacter(row, col int, c rune)

func (*Buffer) LastPositionInRowBeforeCol

func (b *Buffer) LastPositionInRowBeforeCol(row int, col int, text string) int

func (*Buffer) LoadBytes

func (b *Buffer) LoadBytes(bytes []byte) []byte

func (*Buffer) SetFileName

func (b *Buffer) SetFileName(name string)

func (*Buffer) SetNameAndReadOnly

func (b *Buffer) SetNameAndReadOnly(name string, readOnly bool)

func (*Buffer) TextFromPosition

func (b *Buffer) TextFromPosition(row, col int) string

type Editor

type Editor struct {
	// contains filtered or unexported fields
}

The Editor manages text editing in associated buffers and windows. There is typically only one editor in a gott instance.

func NewEditor

func NewEditor() *Editor

func (*Editor) AppendBytes

func (e *Editor) AppendBytes(b []byte)

func (*Editor) BackspaceChar

func (e *Editor) BackspaceChar() rune

func (*Editor) Bytes

func (e *Editor) Bytes() []byte

func (*Editor) ChangeWordAtCursor

func (e *Editor) ChangeWordAtCursor(multiplier int, text string) (string, int)

func (*Editor) CloseActiveWindow

func (e *Editor) CloseActiveWindow()

func (*Editor) CloseInsert

func (e *Editor) CloseInsert()

func (*Editor) CreateWindow

func (e *Editor) CreateWindow() gott.Window

func (*Editor) DeleteCharactersAtCursor

func (e *Editor) DeleteCharactersAtCursor(multiplier int, undo bool, finallyDeleteRow bool) string

func (*Editor) DeleteRowsAtCursor

func (e *Editor) DeleteRowsAtCursor(multiplier int) string

func (*Editor) DeleteWordsAtCursor

func (e *Editor) DeleteWordsAtCursor(multiplier int) string

func (*Editor) GetActiveWindow

func (e *Editor) GetActiveWindow() gott.Window

func (*Editor) GetCursor

func (e *Editor) GetCursor() gott.Point

func (*Editor) GetFileName

func (e *Editor) GetFileName() string

func (*Editor) GetInsertOperation

func (e *Editor) GetInsertOperation() gott.InsertOperation

func (*Editor) GetPasteMode

func (e *Editor) GetPasteMode() int

func (*Editor) GetPasteText

func (e *Editor) GetPasteText() string

func (*Editor) Gofmt

func (e *Editor) Gofmt(filename string, inputBytes []byte) (outputBytes []byte, err error)

Run the gofmt tool.

func (*Editor) HalfPageDown

func (e *Editor) HalfPageDown(multiplier int)

func (*Editor) HalfPageUp

func (e *Editor) HalfPageUp(multiplier int)

func (*Editor) InsertChar

func (e *Editor) InsertChar(c rune)

func (*Editor) InsertRow

func (e *Editor) InsertRow()

func (*Editor) InsertText

func (e *Editor) InsertText(text string, position int) (gott.Point, int)

func (*Editor) JoinRow

func (e *Editor) JoinRow(multiplier int) []gott.Point

func (*Editor) KeepCursorInRow

func (e *Editor) KeepCursorInRow()

func (*Editor) LayoutWindows

func (e *Editor) LayoutWindows()

func (*Editor) ListWindows

func (e *Editor) ListWindows()

func (*Editor) LoadBytes

func (e *Editor) LoadBytes(b []byte)

func (*Editor) MoveCursor

func (e *Editor) MoveCursor(direction int, multiplier int)

func (*Editor) MoveCursorBackBeforeCurrentWord

func (e *Editor) MoveCursorBackBeforeCurrentWord() int

func (*Editor) MoveCursorBackToFirstNonSpace

func (e *Editor) MoveCursorBackToFirstNonSpace() int

func (*Editor) MoveCursorBackToStartOfCurrentWord

func (e *Editor) MoveCursorBackToStartOfCurrentWord()

func (*Editor) MoveCursorBackward

func (e *Editor) MoveCursorBackward() int

func (*Editor) MoveCursorForward

func (e *Editor) MoveCursorForward() int

func (*Editor) MoveCursorToLine

func (e *Editor) MoveCursorToLine(line int)

func (*Editor) MoveCursorToNextWord

func (e *Editor) MoveCursorToNextWord(multiplier int)

func (*Editor) MoveCursorToPreviousWord

func (e *Editor) MoveCursorToPreviousWord(multiplier int)

func (*Editor) MoveCursorToStartOfLine

func (e *Editor) MoveCursorToStartOfLine()

func (*Editor) MoveCursorToStartOfLineBelowCursor

func (e *Editor) MoveCursorToStartOfLineBelowCursor()

func (*Editor) MoveForwardToFirstNonSpace

func (e *Editor) MoveForwardToFirstNonSpace()

func (*Editor) MoveToBeginningOfLine

func (e *Editor) MoveToBeginningOfLine()

func (*Editor) MoveToEndOfLine

func (e *Editor) MoveToEndOfLine()

func (*Editor) PageDown

func (e *Editor) PageDown(multiplier int)

func (*Editor) PageUp

func (e *Editor) PageUp(multiplier int)

func (*Editor) Perform

func (e *Editor) Perform(op gott.Operation, multiplier int)

func (*Editor) PerformSearchBackward

func (e *Editor) PerformSearchBackward(text string)

func (*Editor) PerformSearchForward

func (e *Editor) PerformSearchForward(text string)

func (*Editor) PerformUndo

func (e *Editor) PerformUndo()

func (*Editor) PurgeIfOffscreenDuplicate

func (e *Editor) PurgeIfOffscreenDuplicate(w *Window)

func (*Editor) ReadFile

func (e *Editor) ReadFile(path string) error

func (*Editor) RenderWindows

func (e *Editor) RenderWindows(d gott.Display)

func (*Editor) Repeat

func (e *Editor) Repeat()

func (*Editor) ReplaceCharacterAtCursor

func (e *Editor) ReplaceCharacterAtCursor(cursor gott.Point, c rune) rune

func (*Editor) ReverseCaseCharactersAtCursor

func (e *Editor) ReverseCaseCharactersAtCursor(multiplier int)

func (*Editor) SelectWindow

func (e *Editor) SelectWindow(number int) error

func (*Editor) SelectWindowNext

func (e *Editor) SelectWindowNext() error

func (*Editor) SelectWindowPrevious

func (e *Editor) SelectWindowPrevious() error

func (*Editor) SetCursor

func (e *Editor) SetCursor(cursor gott.Point)

func (*Editor) SetInsertOperation

func (e *Editor) SetInsertOperation(insert gott.InsertOperation)

func (*Editor) SetPasteBoard

func (e *Editor) SetPasteBoard(text string, mode int)

func (*Editor) SetSize

func (e *Editor) SetSize(s gott.Size)

func (*Editor) SplitWindowHorizontally

func (e *Editor) SplitWindowHorizontally()

func (*Editor) SplitWindowVertically

func (e *Editor) SplitWindowVertically()

func (*Editor) WriteFile

func (e *Editor) WriteFile(path string) error

func (*Editor) YankRow

func (e *Editor) YankRow(multiplier int)

type GoHighlighter

type GoHighlighter struct {
	// contains filtered or unexported fields
}

The GoHighlighter highlights Go code.

func NewGoHighlighter

func NewGoHighlighter() *GoHighlighter

func (*GoHighlighter) Highlight

func (h *GoHighlighter) Highlight(b *Buffer)

type Row

type Row struct {
	// contains filtered or unexported fields
}

A Row manages a row of text in a buffer. Rows contain color information to support syntax highlighting.

func NewRow

func NewRow(text string) *Row

Upon creation, we replace any tabs with spaces

func (*Row) DeleteChar

func (r *Row) DeleteChar(col int) rune

delete character at col and return the deleted character

func (*Row) FirstPositionAfterCol

func (r *Row) FirstPositionAfterCol(col int, text string) int

func (*Row) GetColors

func (r *Row) GetColors() []gott.Color

Colors in this slice can be modified but most not be appended or deleted.

func (*Row) GetString

func (r *Row) GetString() string

Get a string version of the row contents.

func (*Row) GetText

func (r *Row) GetText() []rune

Characters in this slice can be modified but must not be appended or deleted.

func (*Row) InsertChar

func (r *Row) InsertChar(col int, c rune)

func (*Row) Join

func (r *Row) Join(other *Row)

joins rows by appending the passed-in row to the current row

func (*Row) LastPositionBeforeCol

func (r *Row) LastPositionBeforeCol(col int, text string) int

func (*Row) Length

func (r *Row) Length() int

Get the row length.

func (*Row) ReplaceChar

func (r *Row) ReplaceChar(col int, c rune) rune

replace character at col and return the replaced character

func (*Row) SetText

func (r *Row) SetText(text []rune)

Setting the text ensure that a colors array exists with the appropriate length.

func (*Row) Split

func (r *Row) Split(col int) *Row

splits row at col, return a new row containing the remaining text.

func (*Row) TextFromColumn

func (r *Row) TextFromColumn(col int) string

returns the text after a specified column

type Window

type Window struct {
	// contains filtered or unexported fields
}

A Window instance manages a rectangular area onscreen. A window can be a view of a buffer or a container for two other windows. When a window contains text, it also has an associated cursor position. Many editing operations are implemented in Window to allow cursor management.

func NewWindow

func NewWindow(e gott.Editor) *Window

func (*Window) AppendBlankRow

func (w *Window) AppendBlankRow()

func (*Window) BackspaceChar

func (w *Window) BackspaceChar() rune

func (*Window) ChangeWordAtCursor

func (w *Window) ChangeWordAtCursor(multiplier int, text string) (string, int)

func (*Window) Close

func (w *Window) Close() gott.Window

func (*Window) Copy

func (w *Window) Copy() *Window

func (*Window) DeleteCharactersAtCursor

func (w *Window) DeleteCharactersAtCursor(multiplier int, undo bool, finallyDeleteRow bool) string

func (*Window) DeleteRowsAtCursor

func (w *Window) DeleteRowsAtCursor(multiplier int) string

func (*Window) DeleteWordsAtCursor

func (w *Window) DeleteWordsAtCursor(multiplier int) string

func (*Window) FindWindow

func (w *Window) FindWindow(number int) gott.Window

func (*Window) GetBuffer

func (w *Window) GetBuffer() gott.Buffer

func (*Window) GetChildNext

func (w *Window) GetChildNext() gott.Window

func (*Window) GetChildPrevious

func (w *Window) GetChildPrevious() gott.Window

func (*Window) GetCursor

func (w *Window) GetCursor() gott.Point

func (*Window) GetIndex

func (w *Window) GetIndex() int

func (*Window) GetName

func (w *Window) GetName() string

func (*Window) GetNumber

func (w *Window) GetNumber() int

func (*Window) GetParent

func (w *Window) GetParent() gott.Window

func (*Window) GetWindowNext

func (w *Window) GetWindowNext() gott.Window

func (*Window) GetWindowPrevious

func (w *Window) GetWindowPrevious() gott.Window

func (*Window) HalfPageDown

func (w *Window) HalfPageDown(multiplier int)

func (*Window) HalfPageUp

func (w *Window) HalfPageUp(multiplier int)

func (*Window) InsertChar

func (w *Window) InsertChar(c rune)

func (*Window) InsertLineAboveCursor

func (w *Window) InsertLineAboveCursor()

func (*Window) InsertLineBelowCursor

func (w *Window) InsertLineBelowCursor()

func (*Window) InsertRow

func (w *Window) InsertRow()

func (*Window) InsertText

func (w *Window) InsertText(text string, position int) (gott.Point, int)

func (*Window) JoinRow

func (w *Window) JoinRow(multiplier int) []gott.Point

func (*Window) KeepCursorInRow

func (w *Window) KeepCursorInRow()

func (*Window) Layout

func (w *Window) Layout(r gott.Rect)

func (*Window) MoveCursor

func (w *Window) MoveCursor(direction int, multiplier int)

func (*Window) MoveCursorBackBeforeCurrentWord

func (w *Window) MoveCursorBackBeforeCurrentWord() int

func (*Window) MoveCursorBackToFirstNonSpace

func (w *Window) MoveCursorBackToFirstNonSpace() int

func (*Window) MoveCursorBackToStartOfCurrentWord

func (w *Window) MoveCursorBackToStartOfCurrentWord()

func (*Window) MoveCursorBackward

func (w *Window) MoveCursorBackward() int

func (*Window) MoveCursorForward

func (w *Window) MoveCursorForward() int

func (*Window) MoveCursorToNextWord

func (w *Window) MoveCursorToNextWord(multiplier int)

func (*Window) MoveCursorToPreviousWord

func (w *Window) MoveCursorToPreviousWord(multiplier int)

func (*Window) MoveCursorToStartOfLine

func (w *Window) MoveCursorToStartOfLine()

func (*Window) MoveCursorToStartOfLineBelowCursor

func (w *Window) MoveCursorToStartOfLineBelowCursor()

func (*Window) MoveForwardToFirstNonSpace

func (w *Window) MoveForwardToFirstNonSpace()

func (*Window) MoveToBeginningOfLine

func (w *Window) MoveToBeginningOfLine()

func (*Window) MoveToEndOfLine

func (w *Window) MoveToEndOfLine()

func (*Window) PageDown

func (w *Window) PageDown(multiplier int)

func (*Window) PageUp

func (w *Window) PageUp(multiplier int)

func (*Window) PerformSearchBackward

func (w *Window) PerformSearchBackward(text string)

func (*Window) PerformSearchForward

func (w *Window) PerformSearchForward(text string)

func (*Window) Render

func (w *Window) Render(display gott.Display)

draw text in an area defined by origin and size with a specified offset into the buffer

func (*Window) RenderBuffer

func (w *Window) RenderBuffer(display gott.Display)

func (*Window) ReplaceCharacterAtCursor

func (w *Window) ReplaceCharacterAtCursor(cursor gott.Point, c rune) rune

func (*Window) ReverseCaseCharactersAtCursor

func (w *Window) ReverseCaseCharactersAtCursor(multiplier int)

func (*Window) SetCursor

func (w *Window) SetCursor(cursor gott.Point)

func (*Window) SetCursorForDisplay

func (w *Window) SetCursorForDisplay(d gott.Display)

func (*Window) SetParent

func (w *Window) SetParent(p gott.Window)

func (*Window) SplitHorizontally

func (w *Window) SplitHorizontally() (gott.Window, gott.Window)

func (*Window) SplitVertically

func (w *Window) SplitVertically() (gott.Window, gott.Window)

func (*Window) YankRow

func (w *Window) YankRow(multiplier int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL