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 ¶
- type Buffer
- func (b *Buffer) AppendBytes(bytes []byte)
- func (b *Buffer) DeleteCharacters(row int, col int, count int, joinLines bool) string
- func (b *Buffer) DeleteRow(row int)
- func (b *Buffer) FirstPositionInRowAfterCol(row int, col int, text string) int
- func (b *Buffer) GetBytes() []byte
- func (b *Buffer) GetCharacterAtCursor(cursor gott.Point) rune
- func (b *Buffer) GetFileName() string
- func (b *Buffer) GetName() string
- func (b *Buffer) GetReadOnly() bool
- func (b *Buffer) GetRowCount() int
- func (b *Buffer) GetRowLength(i int) int
- func (b *Buffer) InsertCharacter(row, col int, c rune)
- func (b *Buffer) LastPositionInRowBeforeCol(row int, col int, text string) int
- func (b *Buffer) LoadBytes(bytes []byte) []byte
- func (b *Buffer) SetFileName(name string)
- func (b *Buffer) SetNameAndReadOnly(name string, readOnly bool)
- func (b *Buffer) TextFromPosition(row, col int) string
- type Editor
- func (e *Editor) AppendBytes(b []byte)
- func (e *Editor) BackspaceChar() rune
- func (e *Editor) Bytes() []byte
- func (e *Editor) ChangeWordAtCursor(multiplier int, text string) (string, int)
- func (e *Editor) CloseActiveWindow()
- func (e *Editor) CloseInsert()
- func (e *Editor) CreateWindow() gott.Window
- func (e *Editor) DeleteCharactersAtCursor(multiplier int, undo bool, finallyDeleteRow bool) string
- func (e *Editor) DeleteRowsAtCursor(multiplier int) string
- func (e *Editor) DeleteWordsAtCursor(multiplier int) string
- func (e *Editor) GetActiveWindow() gott.Window
- func (e *Editor) GetCursor() gott.Point
- func (e *Editor) GetFileName() string
- func (e *Editor) GetInsertOperation() gott.InsertOperation
- func (e *Editor) GetPasteMode() int
- func (e *Editor) GetPasteText() string
- func (e *Editor) Gofmt(filename string, inputBytes []byte) (outputBytes []byte, err error)
- func (e *Editor) HalfPageDown(multiplier int)
- func (e *Editor) HalfPageUp(multiplier int)
- func (e *Editor) InsertChar(c rune)
- func (e *Editor) InsertRow()
- func (e *Editor) InsertText(text string, position int) (gott.Point, int)
- func (e *Editor) JoinRow(multiplier int) []gott.Point
- func (e *Editor) KeepCursorInRow()
- func (e *Editor) LayoutWindows()
- func (e *Editor) ListWindows()
- func (e *Editor) LoadBytes(b []byte)
- func (e *Editor) MoveCursor(direction int, multiplier int)
- func (e *Editor) MoveCursorBackBeforeCurrentWord() int
- func (e *Editor) MoveCursorBackToFirstNonSpace() int
- func (e *Editor) MoveCursorBackToStartOfCurrentWord()
- func (e *Editor) MoveCursorBackward() int
- func (e *Editor) MoveCursorForward() int
- func (e *Editor) MoveCursorToLine(line int)
- func (e *Editor) MoveCursorToNextWord(multiplier int)
- func (e *Editor) MoveCursorToPreviousWord(multiplier int)
- func (e *Editor) MoveCursorToStartOfLine()
- func (e *Editor) MoveCursorToStartOfLineBelowCursor()
- func (e *Editor) MoveForwardToFirstNonSpace()
- func (e *Editor) MoveToBeginningOfLine()
- func (e *Editor) MoveToEndOfLine()
- func (e *Editor) PageDown(multiplier int)
- func (e *Editor) PageUp(multiplier int)
- func (e *Editor) Perform(op gott.Operation, multiplier int)
- func (e *Editor) PerformSearchBackward(text string)
- func (e *Editor) PerformSearchForward(text string)
- func (e *Editor) PerformUndo()
- func (e *Editor) PurgeIfOffscreenDuplicate(w *Window)
- func (e *Editor) ReadFile(path string) error
- func (e *Editor) RenderWindows(d gott.Display)
- func (e *Editor) Repeat()
- func (e *Editor) ReplaceCharacterAtCursor(cursor gott.Point, c rune) rune
- func (e *Editor) ReverseCaseCharactersAtCursor(multiplier int)
- func (e *Editor) SelectWindow(number int) error
- func (e *Editor) SelectWindowNext() error
- func (e *Editor) SelectWindowPrevious() error
- func (e *Editor) SetCursor(cursor gott.Point)
- func (e *Editor) SetInsertOperation(insert gott.InsertOperation)
- func (e *Editor) SetPasteBoard(text string, mode int)
- func (e *Editor) SetSize(s gott.Size)
- func (e *Editor) SplitWindowHorizontally()
- func (e *Editor) SplitWindowVertically()
- func (e *Editor) WriteFile(path string) error
- func (e *Editor) YankRow(multiplier int)
- type GoHighlighter
- type Row
- func (r *Row) DeleteChar(col int) rune
- func (r *Row) FirstPositionAfterCol(col int, text string) int
- func (r *Row) GetColors() []gott.Color
- func (r *Row) GetString() string
- func (r *Row) GetText() []rune
- func (r *Row) InsertChar(col int, c rune)
- func (r *Row) Join(other *Row)
- func (r *Row) LastPositionBeforeCol(col int, text string) int
- func (r *Row) Length() int
- func (r *Row) ReplaceChar(col int, c rune) rune
- func (r *Row) SetText(text []rune)
- func (r *Row) Split(col int) *Row
- func (r *Row) TextFromColumn(col int) string
- type Window
- func (w *Window) AppendBlankRow()
- func (w *Window) BackspaceChar() rune
- func (w *Window) ChangeWordAtCursor(multiplier int, text string) (string, int)
- func (w *Window) Close() gott.Window
- func (w *Window) Copy() *Window
- func (w *Window) DeleteCharactersAtCursor(multiplier int, undo bool, finallyDeleteRow bool) string
- func (w *Window) DeleteRowsAtCursor(multiplier int) string
- func (w *Window) DeleteWordsAtCursor(multiplier int) string
- func (w *Window) FindWindow(number int) gott.Window
- func (w *Window) GetBuffer() gott.Buffer
- func (w *Window) GetChildNext() gott.Window
- func (w *Window) GetChildPrevious() gott.Window
- func (w *Window) GetCursor() gott.Point
- func (w *Window) GetIndex() int
- func (w *Window) GetName() string
- func (w *Window) GetNumber() int
- func (w *Window) GetParent() gott.Window
- func (w *Window) GetWindowNext() gott.Window
- func (w *Window) GetWindowPrevious() gott.Window
- func (w *Window) HalfPageDown(multiplier int)
- func (w *Window) HalfPageUp(multiplier int)
- func (w *Window) InsertChar(c rune)
- func (w *Window) InsertLineAboveCursor()
- func (w *Window) InsertLineBelowCursor()
- func (w *Window) InsertRow()
- func (w *Window) InsertText(text string, position int) (gott.Point, int)
- func (w *Window) JoinRow(multiplier int) []gott.Point
- func (w *Window) KeepCursorInRow()
- func (w *Window) Layout(r gott.Rect)
- func (w *Window) MoveCursor(direction int, multiplier int)
- func (w *Window) MoveCursorBackBeforeCurrentWord() int
- func (w *Window) MoveCursorBackToFirstNonSpace() int
- func (w *Window) MoveCursorBackToStartOfCurrentWord()
- func (w *Window) MoveCursorBackward() int
- func (w *Window) MoveCursorForward() int
- func (w *Window) MoveCursorToNextWord(multiplier int)
- func (w *Window) MoveCursorToPreviousWord(multiplier int)
- func (w *Window) MoveCursorToStartOfLine()
- func (w *Window) MoveCursorToStartOfLineBelowCursor()
- func (w *Window) MoveForwardToFirstNonSpace()
- func (w *Window) MoveToBeginningOfLine()
- func (w *Window) MoveToEndOfLine()
- func (w *Window) PageDown(multiplier int)
- func (w *Window) PageUp(multiplier int)
- func (w *Window) PerformSearchBackward(text string)
- func (w *Window) PerformSearchForward(text string)
- func (w *Window) Render(display gott.Display)
- func (w *Window) RenderBuffer(display gott.Display)
- func (w *Window) ReplaceCharacterAtCursor(cursor gott.Point, c rune) rune
- func (w *Window) ReverseCaseCharactersAtCursor(multiplier int)
- func (w *Window) SetCursor(cursor gott.Point)
- func (w *Window) SetCursorForDisplay(d gott.Display)
- func (w *Window) SetParent(p gott.Window)
- func (w *Window) SplitHorizontally() (gott.Window, gott.Window)
- func (w *Window) SplitVertically() (gott.Window, gott.Window)
- func (w *Window) YankRow(multiplier int)
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 (*Buffer) AppendBytes ¶
func (*Buffer) DeleteCharacters ¶
func (*Buffer) FirstPositionInRowAfterCol ¶
func (*Buffer) GetFileName ¶
func (*Buffer) GetReadOnly ¶
func (*Buffer) GetRowCount ¶
func (*Buffer) GetRowLength ¶
func (*Buffer) InsertCharacter ¶
func (*Buffer) LastPositionInRowBeforeCol ¶
func (*Buffer) SetFileName ¶
func (*Buffer) SetNameAndReadOnly ¶
func (*Buffer) TextFromPosition ¶
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 (*Editor) AppendBytes ¶
func (*Editor) BackspaceChar ¶
func (*Editor) ChangeWordAtCursor ¶
func (*Editor) CloseActiveWindow ¶
func (e *Editor) CloseActiveWindow()
func (*Editor) CloseInsert ¶
func (e *Editor) CloseInsert()
func (*Editor) CreateWindow ¶
func (*Editor) DeleteCharactersAtCursor ¶
func (*Editor) DeleteRowsAtCursor ¶
func (*Editor) DeleteWordsAtCursor ¶
func (*Editor) GetActiveWindow ¶
func (*Editor) GetFileName ¶
func (*Editor) GetInsertOperation ¶
func (e *Editor) GetInsertOperation() gott.InsertOperation
func (*Editor) GetPasteMode ¶
func (*Editor) GetPasteText ¶
func (*Editor) HalfPageDown ¶
func (*Editor) HalfPageUp ¶
func (*Editor) InsertChar ¶
func (*Editor) InsertText ¶
func (*Editor) KeepCursorInRow ¶
func (e *Editor) KeepCursorInRow()
func (*Editor) LayoutWindows ¶
func (e *Editor) LayoutWindows()
func (*Editor) ListWindows ¶
func (e *Editor) ListWindows()
func (*Editor) MoveCursor ¶
func (*Editor) MoveCursorBackBeforeCurrentWord ¶
func (*Editor) MoveCursorBackToFirstNonSpace ¶
func (*Editor) MoveCursorBackToStartOfCurrentWord ¶
func (e *Editor) MoveCursorBackToStartOfCurrentWord()
func (*Editor) MoveCursorBackward ¶
func (*Editor) MoveCursorForward ¶
func (*Editor) MoveCursorToLine ¶
func (*Editor) MoveCursorToNextWord ¶
func (*Editor) MoveCursorToPreviousWord ¶
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) PerformSearchBackward ¶
func (*Editor) PerformSearchForward ¶
func (*Editor) PerformUndo ¶
func (e *Editor) PerformUndo()
func (*Editor) PurgeIfOffscreenDuplicate ¶
func (*Editor) RenderWindows ¶
func (*Editor) ReplaceCharacterAtCursor ¶
func (*Editor) ReverseCaseCharactersAtCursor ¶
func (*Editor) SelectWindow ¶
func (*Editor) SelectWindowNext ¶
func (*Editor) SelectWindowPrevious ¶
func (*Editor) SetInsertOperation ¶
func (e *Editor) SetInsertOperation(insert gott.InsertOperation)
func (*Editor) SetPasteBoard ¶
func (*Editor) SplitWindowHorizontally ¶
func (e *Editor) SplitWindowHorizontally()
func (*Editor) SplitWindowVertically ¶
func (e *Editor) SplitWindowVertically()
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 (*Row) DeleteChar ¶
delete character at col and return the deleted character
func (*Row) InsertChar ¶
func (*Row) ReplaceChar ¶
replace character at col and return the replaced character
func (*Row) SetText ¶
Setting the text ensure that a colors array exists with the appropriate length.
func (*Row) TextFromColumn ¶
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 (*Window) AppendBlankRow ¶
func (w *Window) AppendBlankRow()
func (*Window) BackspaceChar ¶
func (*Window) ChangeWordAtCursor ¶
func (*Window) DeleteCharactersAtCursor ¶
func (*Window) DeleteRowsAtCursor ¶
func (*Window) DeleteWordsAtCursor ¶
func (*Window) GetChildNext ¶
func (*Window) GetChildPrevious ¶
func (*Window) GetWindowNext ¶
func (*Window) GetWindowPrevious ¶
func (*Window) HalfPageDown ¶
func (*Window) HalfPageUp ¶
func (*Window) InsertChar ¶
func (*Window) InsertLineAboveCursor ¶
func (w *Window) InsertLineAboveCursor()
func (*Window) InsertLineBelowCursor ¶
func (w *Window) InsertLineBelowCursor()
func (*Window) InsertText ¶
func (*Window) KeepCursorInRow ¶
func (w *Window) KeepCursorInRow()
func (*Window) MoveCursor ¶
func (*Window) MoveCursorBackBeforeCurrentWord ¶
func (*Window) MoveCursorBackToFirstNonSpace ¶
func (*Window) MoveCursorBackToStartOfCurrentWord ¶
func (w *Window) MoveCursorBackToStartOfCurrentWord()
func (*Window) MoveCursorBackward ¶
func (*Window) MoveCursorForward ¶
func (*Window) MoveCursorToNextWord ¶
func (*Window) MoveCursorToPreviousWord ¶
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) PerformSearchBackward ¶
func (*Window) PerformSearchForward ¶
func (*Window) Render ¶
draw text in an area defined by origin and size with a specified offset into the buffer