micro: github.com/zyedidia/micro/internal/buffer Index | Files

package buffer

import "github.com/zyedidia/micro/internal/buffer"

Index

Package Files

autocomplete.go backup.go buffer.go cursor.go eventhandler.go line_array.go loc.go message.go save.go search.go serialize.go settings.go stack.go

Constants

const (
    DSUnchanged    = 0
    DSAdded        = 1
    DSModified     = 2
    DSDeletedAbove = 3
)
const (

    // TextEventInsert represents an insertion event
    TextEventInsert = 1
    // TextEventRemove represents a deletion event
    TextEventRemove = -1
    // TextEventReplace represents a replace event
    TextEventReplace = 0
)
const (
    // Line ending file formats
    FFAuto = 0 // Autodetect format
    FFUnix = 1 // LF line endings (unix style '\n')
    FFDos  = 2 // CRLF line endings (dos style '\r\n')
)
const (
    MTInfo = iota
    MTWarning
    MTError
)
const LargeFileThreshold = 50000

LargeFileThreshold is the number of bytes when fastdirty is forced because hashing is too slow

Variables

var (
    // BTDefault is a default buffer
    BTDefault = BufType{0, false, false, true}
    // BTHelp is a help buffer
    BTHelp = BufType{1, true, true, true}
    // BTLog is a log buffer
    BTLog = BufType{2, true, true, false}
    // BTScratch is a buffer that cannot be saved (for scratch work)
    BTScratch = BufType{3, false, true, false}
    // BTRaw is is a buffer that shows raw terminal events
    BTRaw = BufType{4, false, true, false}
    // BTInfo is a buffer for inputting information
    BTInfo = BufType{5, false, true, false}

    // ErrFileTooLarge is returned when the file is too large to hash
    // (fastdirty is automatically enabled)
    ErrFileTooLarge = errors.New("File is too large to hash")
)
var BracePairs = [][2]rune{
    {'(', ')'},
    {'{', '}'},
    {'[', ']'},
}

func BufferComplete Uses

func BufferComplete(b *Buffer) ([]string, []string)

BufferComplete autocompletes based on previous words in the buffer

func ByteOffset Uses

func ByteOffset(pos Loc, buf *Buffer) int

ByteOffset is just like ToCharPos except it counts bytes instead of runes

func DiffLA Uses

func DiffLA(a, b Loc, buf *LineArray) int

Diff returns the distance between two locations

func ExecuteTextEvent Uses

func ExecuteTextEvent(t *TextEvent, buf *SharedBuffer)

ExecuteTextEvent runs a text event

func FileComplete Uses

func FileComplete(b *Buffer) ([]string, []string)

FileComplete autocompletes filenames

func GetArg Uses

func GetArg(b *Buffer) (string, int)

GetArg gets the most recent word (separated by ' ' only)

func GetWord Uses

func GetWord(b *Buffer) ([]byte, int)

GetWord gets the most recent word separated by any separator (whitespace, punctuation, any non alphanumeric character)

func InBounds Uses

func InBounds(pos Loc, buf *Buffer) bool

InBounds returns whether the given location is a valid character position in the given buffer

func UndoTextEvent Uses

func UndoTextEvent(t *TextEvent, buf *SharedBuffer)

UndoTextEvent undoes a text event

func WriteLog Uses

func WriteLog(s string)

WriteLog writes a string to the log buffer

type BufType Uses

type BufType struct {
    Kind     int
    Readonly bool // The buffer cannot be edited
    Scratch  bool // The buffer cannot be saved
    Syntax   bool // Syntax highlighting is enabled
}

The BufType defines what kind of buffer this is

type Buffer Uses

type Buffer struct {
    *EventHandler
    *SharedBuffer

    StartCursor Loc
    // contains filtered or unexported fields
}

Buffer stores the main information about a currently open file including the actual text (in a LineArray), the undo/redo stack (in an EventHandler) all the cursors, the syntax highlighting info, the settings for the buffer and some misc info about modification time and path location. The syntax highlighting info must be stored with the buffer because the syntax highlighter attaches information to each line of the buffer for optimization purposes so it doesn't have to rehighlight everything on every update.

var (
    // OpenBuffers is a list of the currently open buffers
    OpenBuffers []*Buffer
    // LogBuf is a reference to the log buffer which can be opened with the
    // `> log` command
    LogBuf *Buffer
)

func GetLogBuf Uses

func GetLogBuf() *Buffer

GetLogBuf returns the log buffer

func NewBuffer Uses

func NewBuffer(r io.Reader, size int64, path string, startcursor Loc, btype BufType) *Buffer

NewBuffer creates a new buffer from a given reader with a given path Ensure that ReadSettings and InitGlobalSettings have been called before creating a new buffer Places the cursor at startcursor. If startcursor is -1, -1 places the cursor at an autodetected location (based on savecursor or :LINE:COL)

func NewBufferFromFile Uses

func NewBufferFromFile(path string, btype BufType) (*Buffer, error)

NewBufferFromFile opens a new buffer using the given path It will also automatically handle `~`, and line/column with filename:l:c It will return an empty buffer if the path does not exist and an error if the file is a directory

func NewBufferFromString Uses

func NewBufferFromString(text, path string, btype BufType) *Buffer

NewBufferFromString creates a new buffer containing the given string

func (*Buffer) AddCursor Uses

func (b *Buffer) AddCursor(c *Cursor)

AddCursor adds a new cursor to the list

func (*Buffer) AddMessage Uses

func (b *Buffer) AddMessage(m *Message)

func (*Buffer) ApplyBackup Uses

func (b *Buffer) ApplyBackup(fsize int64) bool

ApplyBackup applies the corresponding backup file to this buffer (if one exists) Returns true if a backup was applied

func (*Buffer) Autocomplete Uses

func (b *Buffer) Autocomplete(c Completer) bool

Autocomplete starts the autocomplete process

func (*Buffer) Backup Uses

func (b *Buffer) Backup(checkTime bool) error

Backup saves the current buffer to ConfigDir/backups

func (*Buffer) ClearAllMessages Uses

func (b *Buffer) ClearAllMessages()

func (*Buffer) ClearCursors Uses

func (b *Buffer) ClearCursors()

ClearCursors removes all extra cursors

func (*Buffer) ClearMatches Uses

func (b *Buffer) ClearMatches()

ClearMatches clears all of the syntax highlighting for the buffer

func (*Buffer) ClearMessages Uses

func (b *Buffer) ClearMessages(owner string)

func (*Buffer) Close Uses

func (b *Buffer) Close()

Close removes this buffer from the list of open buffers

func (*Buffer) CycleAutocomplete Uses

func (b *Buffer) CycleAutocomplete(forward bool)

CycleAutocomplete moves to the next suggestion

func (*Buffer) DiffStatus Uses

func (b *Buffer) DiffStatus(lineN int) DiffStatus

DiffStatus returns the diff status for a line in the buffer

func (*Buffer) ExternallyModified Uses

func (b *Buffer) ExternallyModified() bool

ExternallyModified returns whether the file being edited has been modified by some external process

func (*Buffer) FileType Uses

func (b *Buffer) FileType() string

FileType returns the buffer's filetype

func (*Buffer) FindMatchingBrace Uses

func (b *Buffer) FindMatchingBrace(braceType [2]rune, start Loc) (Loc, bool, bool)

FindMatchingBrace returns the location in the buffer of the matching bracket It is given a brace type containing the open and closing character, (for example '{' and '}') as well as the location to match from TODO: maybe can be more efficient with utf8 package returns the location of the matching brace if the boolean returned is true then the original matching brace is one character left of the starting location

func (*Buffer) FindNext Uses

func (b *Buffer) FindNext(s string, start, end, from Loc, down bool, useRegex bool) ([2]Loc, bool, error)

FindNext finds the next occurrence of a given string in the buffer It returns the start and end location of the match (if found) and a boolean indicating if it was found May also return an error if the search regex is invalid

func (*Buffer) Fini Uses

func (b *Buffer) Fini()

Fini should be called when a buffer is closed and performs some cleanup

func (*Buffer) GetActiveCursor Uses

func (b *Buffer) GetActiveCursor() *Cursor

GetActiveCursor returns the main cursor in this buffer

func (*Buffer) GetCursor Uses

func (b *Buffer) GetCursor(n int) *Cursor

GetCursor returns the nth cursor

func (*Buffer) GetCursors Uses

func (b *Buffer) GetCursors() []*Cursor

GetCursors returns the list of cursors in this buffer

func (*Buffer) GetName Uses

func (b *Buffer) GetName() string

GetName returns the name that should be displayed in the statusline for this buffer

func (*Buffer) GetSuggestions Uses

func (b *Buffer) GetSuggestions()

func (*Buffer) IndentString Uses

func (b *Buffer) IndentString(tabsize int) string

IndentString returns this buffer's indent method (a tabstop or n spaces depending on the settings)

func (*Buffer) Insert Uses

func (b *Buffer) Insert(start Loc, text string)

Insert inserts the given string of text at the start location

func (*Buffer) Line Uses

func (b *Buffer) Line(i int) string

Line returns the string representation of the given line number

func (*Buffer) MergeCursors Uses

func (b *Buffer) MergeCursors()

MergeCursors merges any cursors that are at the same position into one cursor

func (*Buffer) Modified Uses

func (b *Buffer) Modified() bool

Modified returns if this buffer has been modified since being opened

func (*Buffer) MoveLinesDown Uses

func (b *Buffer) MoveLinesDown(start int, end int)

MoveLinesDown moves the range of lines down one row

func (*Buffer) MoveLinesUp Uses

func (b *Buffer) MoveLinesUp(start int, end int)

MoveLinesUp moves the range of lines up one row

func (*Buffer) NumCursors Uses

func (b *Buffer) NumCursors() int

NumCursors returns the number of cursors

func (*Buffer) ReOpen Uses

func (b *Buffer) ReOpen() error

ReOpen reloads the current buffer from disk

func (*Buffer) RelocateCursors Uses

func (b *Buffer) RelocateCursors()

RelocateCursors relocates all cursors (makes sure they are in the buffer)

func (*Buffer) Remove Uses

func (b *Buffer) Remove(start, end Loc)

Remove removes the characters between the start and end locations

func (*Buffer) RemoveBackup Uses

func (b *Buffer) RemoveBackup()

RemoveBackup removes any backup file associated with this buffer

func (*Buffer) RemoveCursor Uses

func (b *Buffer) RemoveCursor(i int)

func (*Buffer) ReplaceRegex Uses

func (b *Buffer) ReplaceRegex(start, end Loc, search *regexp.Regexp, replace []byte) (int, int)

ReplaceRegex replaces all occurrences of 'search' with 'replace' in the given area and returns the number of replacements made and the number of runes added or removed

func (*Buffer) Retab Uses

func (b *Buffer) Retab()

Retab changes all tabs to spaces or vice versa

func (*Buffer) RuneAt Uses

func (b *Buffer) RuneAt(loc Loc) rune

RuneAt returns the rune at a given location in the buffer

func (*Buffer) Save Uses

func (b *Buffer) Save() error

Save saves the buffer to its default path

func (*Buffer) SaveAs Uses

func (b *Buffer) SaveAs(filename string) error

SaveAs saves the buffer to a specified path (filename), creating the file if it does not exist

func (*Buffer) SaveAsWithSudo Uses

func (b *Buffer) SaveAsWithSudo(filename string) error

func (*Buffer) SaveWithSudo Uses

func (b *Buffer) SaveWithSudo() error

func (*Buffer) Serialize Uses

func (b *Buffer) Serialize() error

Serialize serializes the buffer to config.ConfigDir/buffers

func (*Buffer) SetCurCursor Uses

func (b *Buffer) SetCurCursor(n int)

SetCurCursor sets the current cursor

func (*Buffer) SetCursors Uses

func (b *Buffer) SetCursors(c []*Cursor)

SetCursors resets this buffer's cursors to a new list

func (*Buffer) SetDiffBase Uses

func (b *Buffer) SetDiffBase(diffBase []byte)

SetDiffBase sets the text that is used as the base for diffing the buffer content

func (*Buffer) SetName Uses

func (b *Buffer) SetName(s string)

SetName changes the name for this buffer

func (*Buffer) SetOption Uses

func (b *Buffer) SetOption(option, value string) error

SetOption sets a given option to a value just for this buffer

func (*Buffer) SetOptionNative Uses

func (b *Buffer) SetOptionNative(option string, nativeValue interface{}) error

func (*Buffer) Unserialize Uses

func (b *Buffer) Unserialize() error

Unserialize loads the buffer info from config.ConfigDir/buffers

func (*Buffer) UpdateCursors Uses

func (b *Buffer) UpdateCursors()

UpdateCursors updates all the cursors indicies

func (*Buffer) UpdateDiff Uses

func (b *Buffer) UpdateDiff(callback func(bool))

UpdateDiff computes the diff between the diff base and the buffer content. The update may be performed synchronously or asynchronously. UpdateDiff calls the supplied callback when the update is complete. The argument passed to the callback is set to true if and only if the update was performed synchronously. If an asynchronous update is already pending when UpdateDiff is called, UpdateDiff does not schedule another update, in which case the callback is not called.

func (*Buffer) UpdateModTime Uses

func (b *Buffer) UpdateModTime() (err error)

UpdateModTime updates the modtime of this file

func (*Buffer) UpdateRules Uses

func (b *Buffer) UpdateRules()

UpdateRules updates the syntax rules and filetype for this buffer This is called when the colorscheme changes

func (*Buffer) Write Uses

func (b *Buffer) Write(bytes []byte) (n int, err error)

type Completer Uses

type Completer func(*Buffer) ([]string, []string)

A Completer is a function that takes a buffer and returns info describing what autocompletions should be inserted at the current cursor location It returns a list of string suggestions which will be inserted at the current cursor location if selected as well as a list of suggestion names which can be displayed in an autocomplete box or other UI element

type Cursor Uses

type Cursor struct {
    Loc

    // Last cursor x position
    LastVisualX int

    // The current selection as a range of character numbers (inclusive)
    CurSelection [2]Loc
    // The original selection as a range of character numbers
    // This is used for line and word selection where it is necessary
    // to know what the original selection was
    OrigSelection [2]Loc

    // Which cursor index is this (for multiple cursors)
    Num int
    // contains filtered or unexported fields
}

The Cursor struct stores the location of the cursor in the buffer as well as the selection

func NewCursor Uses

func NewCursor(b *Buffer, l Loc) *Cursor

func (*Cursor) AddLineToSelection Uses

func (c *Cursor) AddLineToSelection()

AddLineToSelection adds the current line to the selection

func (*Cursor) AddWordToSelection Uses

func (c *Cursor) AddWordToSelection()

AddWordToSelection adds the word the cursor is currently on to the selection

func (*Cursor) Buf Uses

func (c *Cursor) Buf() *Buffer

func (*Cursor) CopySelection Uses

func (c *Cursor) CopySelection(target string)

CopySelection copies the user's selection to either "primary" or "clipboard"

func (*Cursor) DeleteSelection Uses

func (c *Cursor) DeleteSelection()

DeleteSelection deletes the currently selected text

func (*Cursor) Deselect Uses

func (c *Cursor) Deselect(start bool)

Deselect closes the cursor's current selection Start indicates whether the cursor should be placed at the start or end of the selection

func (*Cursor) Down Uses

func (c *Cursor) Down()

Down moves the cursor down one line (if possible)

func (*Cursor) DownN Uses

func (c *Cursor) DownN(amount int)

DownN moves the cursor down N lines (if possible)

func (*Cursor) End Uses

func (c *Cursor) End()

End moves the cursor to the end of the line it is on

func (*Cursor) GetCharPosInLine Uses

func (c *Cursor) GetCharPosInLine(b []byte, visualPos int) int

GetCharPosInLine gets the char position of a visual x y coordinate (this is necessary because tabs are 1 char but 4 visual spaces)

func (*Cursor) GetSelection Uses

func (c *Cursor) GetSelection() []byte

GetSelection returns the cursor's selection

func (*Cursor) GetVisualX Uses

func (c *Cursor) GetVisualX() int

GetVisualX returns the x value of the cursor in visual spaces

func (*Cursor) Goto Uses

func (c *Cursor) Goto(b Cursor)

Goto puts the cursor at the given cursor's location and gives the current cursor its selection too

func (*Cursor) GotoLoc Uses

func (c *Cursor) GotoLoc(l Loc)

GotoLoc puts the cursor at the given cursor's location and gives the current cursor its selection too

func (*Cursor) HasSelection Uses

func (c *Cursor) HasSelection() bool

HasSelection returns whether or not the user has selected anything

func (*Cursor) Left Uses

func (c *Cursor) Left()

Left moves the cursor left one cell (if possible) or to the previous line if it is at the beginning

func (*Cursor) Relocate Uses

func (c *Cursor) Relocate()

Relocate makes sure that the cursor is inside the bounds of the buffer If it isn't, it moves it to be within the buffer's lines

func (*Cursor) ResetSelection Uses

func (c *Cursor) ResetSelection()

ResetSelection resets the user's selection

func (*Cursor) Right Uses

func (c *Cursor) Right()

Right moves the cursor right one cell (if possible) or to the next line if it is at the end

func (*Cursor) RuneUnder Uses

func (c *Cursor) RuneUnder(x int) rune

RuneUnder returns the rune under the given x position

func (*Cursor) SelectLine Uses

func (c *Cursor) SelectLine()

SelectLine selects the current line

func (*Cursor) SelectTo Uses

func (c *Cursor) SelectTo(loc Loc)

SelectTo selects from the current cursor location to the given location

func (*Cursor) SelectWord Uses

func (c *Cursor) SelectWord()

SelectWord selects the word the cursor is currently on

func (*Cursor) SetBuf Uses

func (c *Cursor) SetBuf(b *Buffer)

func (*Cursor) SetSelectionEnd Uses

func (c *Cursor) SetSelectionEnd(pos Loc)

SetSelectionEnd sets the end of the selection

func (*Cursor) SetSelectionStart Uses

func (c *Cursor) SetSelectionStart(pos Loc)

SetSelectionStart sets the start of the selection

func (*Cursor) Start Uses

func (c *Cursor) Start()

Start moves the cursor to the start of the line it is on

func (*Cursor) StartOfText Uses

func (c *Cursor) StartOfText()

StartOfText moves the cursor to the first non-whitespace rune of the line it is on

func (*Cursor) StoreVisualX Uses

func (c *Cursor) StoreVisualX()

func (*Cursor) Up Uses

func (c *Cursor) Up()

Up moves the cursor up one line (if possible)

func (*Cursor) UpN Uses

func (c *Cursor) UpN(amount int)

UpN moves the cursor up N lines (if possible)

func (*Cursor) WordLeft Uses

func (c *Cursor) WordLeft()

WordLeft moves the cursor one word to the left

func (*Cursor) WordRight Uses

func (c *Cursor) WordRight()

WordRight moves the cursor one word to the right

type Delta Uses

type Delta struct {
    Text  []byte
    Start Loc
    End   Loc
}

A Delta is a change to the buffer

type DiffStatus Uses

type DiffStatus byte

type Element Uses

type Element struct {
    Value *TextEvent
    Next  *Element
}

An Element which is stored in the Stack

type EventHandler Uses

type EventHandler struct {
    UndoStack *TEStack
    RedoStack *TEStack
    // contains filtered or unexported fields
}

EventHandler executes text manipulations and allows undoing and redoing

func NewEventHandler Uses

func NewEventHandler(buf *SharedBuffer, cursors []*Cursor) *EventHandler

NewEventHandler returns a new EventHandler

func (*EventHandler) ApplyDiff Uses

func (eh *EventHandler) ApplyDiff(new string)

ApplyDiff takes a string and runs the necessary insertion and deletion events to make the buffer equal to that string This means that we can transform the buffer into any string and still preserve undo/redo through insert and delete events

func (*EventHandler) Execute Uses

func (eh *EventHandler) Execute(t *TextEvent)

Execute a textevent and add it to the undo stack

func (*EventHandler) Insert Uses

func (eh *EventHandler) Insert(start Loc, textStr string)

Insert creates an insert text event and executes it

func (*EventHandler) InsertBytes Uses

func (eh *EventHandler) InsertBytes(start Loc, text []byte)

InsertBytes creates an insert text event and executes it

func (*EventHandler) MultipleReplace Uses

func (eh *EventHandler) MultipleReplace(deltas []Delta)

MultipleReplace creates an multiple insertions executes them

func (*EventHandler) Redo Uses

func (eh *EventHandler) Redo()

Redo the first event in the redo stack

func (*EventHandler) RedoOneEvent Uses

func (eh *EventHandler) RedoOneEvent()

RedoOneEvent redoes one event

func (*EventHandler) Remove Uses

func (eh *EventHandler) Remove(start, end Loc)

Remove creates a remove text event and executes it

func (*EventHandler) Replace Uses

func (eh *EventHandler) Replace(start, end Loc, replace string)

Replace deletes from start to end and replaces it with the given string

func (*EventHandler) Undo Uses

func (eh *EventHandler) Undo()

Undo the first event in the undo stack

func (*EventHandler) UndoOneEvent Uses

func (eh *EventHandler) UndoOneEvent()

UndoOneEvent undoes one event

type FileFormat Uses

type FileFormat byte

type Line Uses

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

A Line contains the data in bytes as well as a highlight state, match and a flag for whether the highlighting needs to be updated

func Append Uses

func Append(slice []Line, data ...Line) []Line

Append efficiently appends lines together It allocates an additional 10000 lines if the original estimate is incorrect

type LineArray Uses

type LineArray struct {
    Endings FileFormat
    // contains filtered or unexported fields
}

A LineArray simply stores and array of lines and makes it easy to insert and delete in it

func NewLineArray Uses

func NewLineArray(size uint64, endings FileFormat, reader io.Reader) *LineArray

NewLineArray returns a new line array from an array of bytes

func (*LineArray) Bytes Uses

func (la *LineArray) Bytes() []byte

Bytes returns the string that should be written to disk when the line array is saved

func (*LineArray) End Uses

func (la *LineArray) End() Loc

End returns the location of the last character in the buffer

func (*LineArray) LineBytes Uses

func (la *LineArray) LineBytes(n int) []byte

LineBytes returns line n as an array of bytes

func (*LineArray) LinesNum Uses

func (la *LineArray) LinesNum() int

LinesNum returns the number of lines in the buffer

func (*LineArray) Match Uses

func (la *LineArray) Match(lineN int) highlight.LineMatch

Match retrieves the match for the given line number

func (*LineArray) Rehighlight Uses

func (la *LineArray) Rehighlight(lineN int) bool

func (*LineArray) SetMatch Uses

func (la *LineArray) SetMatch(lineN int, m highlight.LineMatch)

SetMatch sets the match at the given line number

func (*LineArray) SetRehighlight Uses

func (la *LineArray) SetRehighlight(lineN int, on bool)

func (*LineArray) SetState Uses

func (la *LineArray) SetState(lineN int, s highlight.State)

SetState sets the highlight state at the given line number

func (*LineArray) Start Uses

func (la *LineArray) Start() Loc

Start returns the start of the buffer

func (*LineArray) State Uses

func (la *LineArray) State(lineN int) highlight.State

State gets the highlight state for the given line number

func (*LineArray) Substr Uses

func (la *LineArray) Substr(start, end Loc) []byte

Substr returns the string representation between two locations

type Loc Uses

type Loc struct {
    X, Y int
}

Loc stores a location

func ParseCursorLocation Uses

func ParseCursorLocation(cursorPositions []string) (Loc, error)

ParseCursorLocation turns a cursor location like 10:5 (LINE:COL) into a loc

func (Loc) Diff Uses

func (l Loc) Diff(b Loc, buf *Buffer) int

Diff returns the difference between two locs

func (Loc) GreaterEqual Uses

func (l Loc) GreaterEqual(b Loc) bool

GreaterEqual returns true if b is greater than or equal to b

func (Loc) GreaterThan Uses

func (l Loc) GreaterThan(b Loc) bool

GreaterThan returns true if b is bigger

func (Loc) LessEqual Uses

func (l Loc) LessEqual(b Loc) bool

LessEqual returns true if b is less than or equal to b

func (Loc) LessThan Uses

func (l Loc) LessThan(b Loc) bool

LessThan returns true if b is smaller

func (Loc) Move Uses

func (l Loc) Move(n int, buf *Buffer) Loc

Move moves a loc n characters

func (Loc) MoveLA Uses

func (l Loc) MoveLA(n int, buf *LineArray) Loc

MoveLA moves the cursor n characters to the left or right It moves the cursor left if n is negative

type Message Uses

type Message struct {
    // The Msg iteslf
    Msg string
    // Start and End locations for the message
    Start, End Loc
    // The Kind stores the message type
    Kind MsgType
    // The Owner of the message
    Owner string
}

Message represents the information for a gutter message

func NewMessage Uses

func NewMessage(owner string, msg string, start, end Loc, kind MsgType) *Message

NewMessage creates a new gutter message

func NewMessageAtLine Uses

func NewMessageAtLine(owner string, msg string, line int, kind MsgType) *Message

NewMessageAtLine creates a new gutter message at a given line

func (*Message) Style Uses

func (m *Message) Style() tcell.Style

type MsgType Uses

type MsgType int

type SerializedBuffer Uses

type SerializedBuffer struct {
    EventHandler *EventHandler
    Cursor       Loc
    ModTime      time.Time
}

The SerializedBuffer holds the types that get serialized when a buffer is saved These are used for the savecursor and saveundo options

type SharedBuffer Uses

type SharedBuffer struct {
    *LineArray
    // Stores the last modification time of the file the buffer is pointing to
    ModTime time.Time
    // Type of the buffer (e.g. help, raw, scratch etc..)
    Type BufType

    // Path to the file on disk
    Path string
    // Absolute path to the file on disk
    AbsPath string

    // Settings customized by the user
    Settings map[string]interface{}

    Suggestions   []string
    Completions   []string
    CurSuggestion int

    Messages []*Message

    // ReloadDisabled allows the user to disable reloads if they
    // are viewing a file that is constantly changing
    ReloadDisabled bool

    // Whether or not suggestions can be autocompleted must be shared because
    // it changes based on how the buffer has changed
    HasSuggestions bool

    // The Highlighter struct actually performs the highlighting
    Highlighter *highlight.Highlighter
    // SyntaxDef represents the syntax highlighting definition being used
    // This stores the highlighting rules and filetype detection info
    SyntaxDef *highlight.Def

    ModifiedThisFrame bool
    // contains filtered or unexported fields
}

SharedBuffer is a struct containing info that is shared among buffers that have the same file open

func (*SharedBuffer) DisableReload Uses

func (b *SharedBuffer) DisableReload()

DisableReload disables future reloads of this sharedbuffer

func (*SharedBuffer) MarkModified Uses

func (b *SharedBuffer) MarkModified(start, end int)

MarkModified marks the buffer as modified for this frame and performs rehighlighting if syntax highlighting is enabled

type TEStack Uses

type TEStack struct {
    Top  *Element
    Size int
}

TEStack is a simple implementation of a LIFO stack for text events

func (*TEStack) Len Uses

func (s *TEStack) Len() int

Len returns the stack's length

func (*TEStack) Peek Uses

func (s *TEStack) Peek() *TextEvent

Peek returns the top element of the stack without removing it

func (*TEStack) Pop Uses

func (s *TEStack) Pop() (value *TextEvent)

Pop removes the top element from the stack and returns its value If the stack is empty, return nil

func (*TEStack) Push Uses

func (s *TEStack) Push(value *TextEvent)

Push a new element onto the stack

type TextEvent Uses

type TextEvent struct {
    C   Cursor

    EventType int
    Deltas    []Delta
    Time      time.Time
}

TextEvent holds data for a manipulation on some text that can be undone

Package buffer imports 35 packages (graph) and is imported by 5 packages. Updated 2020-02-21. Refresh now. Tools for package owners.