Documentation ¶
Index ¶
- func IsInsertable(c rune) bool
- type Buffer
- func (b *Buffer) BreakLine()
- func (b *Buffer) DeleteRune()
- func (b *Buffer) FileName() string
- func (b *Buffer) FocusedLine() *Line
- func (b *Buffer) InsertLine(i int, text string)
- func (b *Buffer) InsertRune(c rune)
- func (b *Buffer) Length() int
- func (b *Buffer) PreviousLine() *Line
- func (b *Buffer) RemoveLine(i int)
- func (b *Buffer) Write(path string) error
- type Line
- type TokenType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsInsertable ¶
IsInsertable tells whether a character is insertable into the buffer or not.
Types ¶
type Buffer ¶
type Buffer struct { Config *config.Config // The path to the file and its type. Path string FileType support.FileType // The buffer's lines and condition. Lines []Line IsDirty bool IsReadOnly bool // The cursor's position. The Y value must always be decremented by one when // accessing buffer elements since the editor's title bar occupies the first // row of the screen. CursorDX is the cursor's X position, with compensation // for extra space introduced by rendering tabs. CursorX int CursorDX int CursorY int // The viewport's column and row offsets. OffsetX int OffsetY int }
Buffer represents a text buffer corresponding to a file.
func FromStrings ¶
FromStrings creates a buffer from an array of strings rather than a file.
func (*Buffer) BreakLine ¶
func (b *Buffer) BreakLine()
BreakLine inserts a newline character and breaks the line at the cursor.
func (*Buffer) DeleteRune ¶
func (b *Buffer) DeleteRune()
DeleteRune deletes the rune to the left of the cursor.
func (*Buffer) FocusedLine ¶
FocusedLine returns the buffer's focused line.
func (*Buffer) InsertLine ¶
InsertLine inserts a new line to the buffer at the given index.
func (*Buffer) InsertRune ¶
InsertRune inserts a rune at the cursor's position.
func (*Buffer) PreviousLine ¶ added in v0.5.3
PreviousLine returns the line above the buffer's focused line.
func (*Buffer) RemoveLine ¶
RemoveLine removes the line at the given index from the buffer.
type Line ¶
Line represents a single line in a buffer.
func MakeBufferLine ¶
MakeBufferLine creates a new Line with the given text.
func (*Line) AppendString ¶
AppendString appends a string to the line.
func (*Line) DeleteRune ¶
DeleteRune deletes a rune from the line at the given index.
func (*Line) IndentLength ¶
IndentLength gets the line's level of indentation in columns.
func (*Line) InsertRune ¶
InsertRune inserts a rune into the line at the given index.
type TokenType ¶
type TokenType int
TokenType represents the type of token a rune belongs to.
const ( // TokenTypeText is the default token type. TokenTypeText TokenType = iota // TokenTypeKeyword represents a language keyword. TokenTypeKeyword // TokenTypeNumber represents a number. TokenTypeNumber // TokenTypeString represents a string. TokenTypeString // TokenTypeComment represents a comment. TokenTypeComment )