file

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2018 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFileExt added in v0.6.0

func GetFileExt(filename string) string

GetFileExt returns the filename extension.

Types

type BufferHist

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

BufferHist manages a history of buffer states.

func NewBufferHist

func NewBufferHist(buffer buffer.Buffer, cursor cursor.MultiCursor) *BufferHist

NewBufferHist creates a new BufferHist object initialized with the current state.

func (*BufferHist) Current

func (bh *BufferHist) Current() (buffer.Buffer, cursor.MultiCursor)

Current returns the current buffer snapshot..

func (*BufferHist) ForceSnapshot added in v0.3.3

func (bh *BufferHist) ForceSnapshot(buff buffer.Buffer, mc cursor.MultiCursor)

ForceSnapshot forces a snapshot rather than requesting one.

func (*BufferHist) Next

func (bh *BufferHist) Next() (buffer.Buffer, cursor.MultiCursor)

Next bumps the current pointer to the next state (redo).

func (*BufferHist) NextSaved added in v0.3.4

func (bh *BufferHist) NextSaved() (buffer.Buffer, cursor.MultiCursor)

NextSaved bumps the current pointer to the next saved state (macro redo).

func (*BufferHist) Prev

func (bh *BufferHist) Prev() (buffer.Buffer, cursor.MultiCursor)

Prev bumps the current pointer to the previous state (undo).

func (*BufferHist) PrevSaved added in v0.3.4

func (bh *BufferHist) PrevSaved() (buffer.Buffer, cursor.MultiCursor)

PrevSaved bumps the current pointer to the previous saved state (macro undo).

func (*BufferHist) Snapshot

func (bh *BufferHist) Snapshot(buff buffer.Buffer, mc cursor.MultiCursor)

Snapshot places a snapshot request onto the snapshot queue.

func (*BufferHist) SnapshotSaved added in v0.3.4

func (bh *BufferHist) SnapshotSaved()

SnapshotSaved toggles on the "saved" attribute for the current state.

type BufferState added in v0.3.4

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

BufferState contains a snapshot of the buffer state, including multicursor positions.

func NewBufferState added in v0.3.4

func NewBufferState(buff buffer.Buffer, mc cursor.MultiCursor) *BufferState

NewBufferState creates a new buffer state snapshot from the current state.

type File

type File struct {
	MultiCursor cursor.MultiCursor

	// For autocompletion. Passed in by editor.
	AutoComplete func(prefix string) []string

	Name        string
	SyntaxRules *syntaxcolor.SyntaxRules
	// contains filtered or unexported fields
}

File contains all the details about a given file. This includes: name, buffer, buffer history, file-specific settings, etc.

func NewFile

func NewFile(name string, flushChan chan struct{}, screen *terminal.Screen,
	cfg config.Config, wg *sync.WaitGroup) *File

NewFile creates a new File object. It reads in the specified file and ingests the specified configuration.

func (*File) AddCursor

func (file *File) AddCursor()

AddCursor sets the current main cursor as a new multicursor member.

func (*File) AddCursorCol

func (file *File) AddCursorCol()

AddCursorCol creates a multicursor set along a column.

func (*File) AllLineBa added in v0.6.0

func (file *File) AllLineBa(term string)

AllLineBa is like SearchLineBa, but can return multiple matches on the same line.

func (*File) AllLineFo added in v0.6.0

func (file *File) AllLineFo(term string)

AllLineFo is like SearchLineFo, but can return multiple matches on the same line.

func (*File) AskReplace added in v0.3.1

func (file *File) AskReplace(searchTerm, replaceTerm string, row, col int, replaceAll bool) error

AskReplace replaces each instance of searchTerm with replaceTerm, asking the user for confirmation each time.

func (*File) Backspace

func (file *File) Backspace()

Backspace removes the character before the cursor.

func (*File) ClearCursors

func (file *File) ClearCursors()

ClearCursors clears out the multicursors.

func (*File) Close

func (file *File) Close() bool

Close doesn't actually close anything (b/c garbage collection will take care of it. Close just checks with the user and returns true if the file should close.

func (*File) ColorBracketMatch added in v0.5.0

func (file *File) ColorBracketMatch(rows int)

ColorBracketMatch colorizes a matching bracket character.

func (*File) ComputeIndent added in v0.3.1

func (file *File) ComputeIndent()

ComputeIndent sets the tabString and tabHealth based on the current indentation.

func (*File) CursorAlign added in v0.4.2

func (file *File) CursorAlign()

CursorAlign inserts spaces into each cursor position, in order to align the cursors vertically.

func (*File) CursorDown

func (file *File) CursorDown(n int)

CursorDown moves the cursor down n rows.

func (*File) CursorGoTo

func (file *File) CursorGoTo(row, col int)

CursorGoTo moves the cursor to a row, col position. If row is negative, then it specifies from the end of the file.

func (*File) CursorLeft

func (file *File) CursorLeft()

CursorLeft moves the cursor one column to the left.

func (*File) CursorRight

func (file *File) CursorRight()

CursorRight moves the cursor one column to the right.

func (*File) CursorUnalign added in v0.4.2

func (file *File) CursorUnalign()

CursorUnalign removes whitespace (except for 1 space) immediately preceding each cursor position. Effectively, it undoes a CursorAlign.

func (*File) CursorUp

func (file *File) CursorUp(n int)

CursorUp moves the cursor up n rows.

func (*File) Cut

func (file *File) Cut() []string

Cut cuts the current line and adds to the copy buffer.

func (*File) CutToEndOfLine added in v0.4.1

func (file *File) CutToEndOfLine()

CutToEndOfLine cuts the text from the cursor to the end of the line.

func (*File) CutToStartOfLine added in v0.4.1

func (file *File) CutToStartOfLine()

CutToStartOfLine cuts the text from the cursor to the start of the line.

func (*File) Delete

func (file *File) Delete()

Delete deletes the character under the cursor.

func (*File) EndOfLine

func (file *File) EndOfLine()

EndOfLine moves the cursors to the end of the line.

func (*File) FileChanged added in v0.5.0

func (file *File) FileChanged() bool

FileChanged checks to see if underlying file changed.

func (*File) Flush

func (file *File) Flush()

Flush writes the buffer contents to the screen.

func (*File) Fmt added in v0.5.0

func (file *File) Fmt(selection ...bool) error

Fmt runs a code formatter on the text buffer and updates the buffer. For Go code, this calls the go format library. For all else, it runs an external command. If 'selection' is specified, then formatting is done only on selected lines.

func (*File) ForceSnapshot added in v0.3.3

func (file *File) ForceSnapshot()

ForceSnapshot saves a snapshot of the buffer state, even if it hasn't changed since the last snapshot.

func (*File) GetCursor

func (file *File) GetCursor(idx int) (int, int)

GetCursor returns the row, col position for the specified multi-cursor index.

func (*File) GetRowCol added in v0.7.0

func (file *File) GetRowCol(idx int) (int, int)

func (*File) InsertChar

func (file *File) InsertChar(ch rune)

InsertChar insters a character (rune) into the current cursor position.

func (*File) InsertStr added in v0.7.0

func (file *File) InsertStr(str string)

func (*File) IsModified

func (file *File) IsModified() bool

IsModified checks to see if a file has been modified.

func (*File) Justify

func (file *File) Justify()

Justify justifies the marked text.

func (*File) Length added in v0.3.3

func (file *File) Length() int

Length returns the number of lines in the buffer.

func (*File) MarkedSearch added in v0.3.3

func (file *File) MarkedSearch(searchTerm string, loop bool) (row, col int, err error)

MarkedSearch searches for searchTerm in the text limited by the muticursor extent.

func (*File) Newline

func (file *File) Newline()

Newline breaks the current line into two.

func (*File) NextWord

func (file *File) NextWord()

NextWord moves the cursor to the next word.

func (*File) NotifyUser added in v0.3.1

func (file *File) NotifyUser(msg string)

NotifyUser displays a message to the user.

func (*File) PageDown added in v0.3.1

func (file *File) PageDown()

PageDown moves the cursor half a screen down.

func (*File) PageUp added in v0.3.1

func (file *File) PageUp()

PageUp moves the cursor have a screen up.

func (*File) Paste

func (file *File) Paste(strs []string)

Paste inserts the copy buffer into buffer at the current line.

func (*File) PrevWord

func (file *File) PrevWord()

PrevWord moves the cursor to the previous word.

func (*File) ReadFile

func (file *File) ReadFile(name string, wgs ...*sync.WaitGroup)

ReadFile reads in a file (if it exists).

func (*File) Redo

func (file *File) Redo()

Redo sets the buffer state ahead one in the buffer history.

func (*File) RedoSaved added in v0.3.4

func (file *File) RedoSaved()

RedoSaved is like UndoSaved, but the other direction in time.

func (*File) Refresh

func (file *File) Refresh()

Refresh redraws the screen.

func (*File) Reload added in v0.5.0

func (file *File) Reload(wgs ...*sync.WaitGroup)

Reload re-reads a file from disk.

func (*File) RequestFlush added in v0.3.1

func (file *File) RequestFlush()

RequestFlush places a flush request on the flush channel.

func (*File) RequestSave added in v0.3.1

func (file *File) RequestSave()

RequestSave places a save request on the save channel.

func (*File) Save

func (file *File) Save()

Save saves a file.

func (*File) ScrollDown

func (file *File) ScrollDown()

ScrollDown shifts the screen down one row.

func (*File) ScrollLeft

func (file *File) ScrollLeft()

ScrollLeft shifts the view screen to the left.

func (*File) ScrollRight

func (file *File) ScrollRight()

ScrollRight shifts the view screen to the right.

func (*File) ScrollUp

func (file *File) ScrollUp()

ScrollUp shifts the screen up one row.

func (*File) SearchFromCursor added in v0.3.3

func (file *File) SearchFromCursor(searchTerm string) (row, col int, err error)

SearchFromCursor searches the current buffer, starting from the cursor position.

func (*File) SearchFromStart added in v0.3.3

func (file *File) SearchFromStart(searchTerm string) (row, col int, err error)

SearchFromStart searches the buffer from the start of the file.

func (*File) SearchLineBa added in v0.4.2

func (file *File) SearchLineBa(term string)

SearchLineBa searches backward (to the left) on each marked line. It sets a cursor on each line where a match was found.

func (*File) SearchLineFo added in v0.4.2

func (file *File) SearchLineFo(term string)

SearchLineFo searches forward (to the right) on each multicursor marked line. It sets a cursor on each line where a match was found.

func (*File) SetCompleter added in v0.7.0

func (file *File) SetCompleter(f func(prefix string) []string)

func (*File) SetLineLen added in v0.7.0

func (file *File) SetLineLen()

func (*File) SetTabStr added in v0.4.4

func (file *File) SetTabStr()

SetTabStr manually sets the tab string, and disables auto-tab-detection.

func (*File) SetTabWidth added in v0.6.0

func (file *File) SetTabWidth()

SetTabWidth sets the tab display width.

func (*File) Slice

func (file *File) Slice(nRows, nCols int) []string

Slice returns a 2D slice of the buffer.

func (*File) Snapshot

func (file *File) Snapshot()

Snapshot saves a snapshot of the buffer state, but only if it has changed.

func (*File) SnapshotSaved added in v0.3.4

func (file *File) SnapshotSaved()

SnapshotSaved saves a special "saved" snapshot when the user saves (or opens) a file.

func (*File) StartOfLine

func (file *File) StartOfLine()

StartOfLine moves the cursors to the start of the line. If they are already at the start, the moves them to the first non-whitespace character.

func (*File) ToCorpus added in v0.7.0

func (file *File) ToCorpus(row, col int) string

ToCorpus returns a string representation of the text buffer, with the current token removed. It is used for autocomplete.

func (*File) ToString added in v0.4.1

func (file *File) ToString() string

ToString returns a string representation of the text buffer. It uses the original newline (from the input file) as the line separator.

func (*File) ToggleAutoFmt added in v0.5.0

func (file *File) ToggleAutoFmt()

ToggleAutoFmt toggles the auto-format setting.

func (*File) ToggleAutoIndent

func (file *File) ToggleAutoIndent()

ToggleAutoIndent toggles the autoindent setting.

func (*File) ToggleAutoTab added in v0.3.1

func (file *File) ToggleAutoTab()

ToggleAutoTab toggles the autotab setting.

func (*File) ToggleMCMode added in v0.6.1

func (file *File) ToggleMCMode()

ToggleMCMode cycles among the available multicursor navigation modes.

func (*File) UnJustify added in v0.7.0

func (file *File) UnJustify()

func (*File) Undo

func (file *File) Undo()

Undo reverts the buffer state to the last snapshot.

func (*File) UndoSaved added in v0.3.4

func (file *File) UndoSaved()

UndoSaved reverts the buffer state to the last *saved* snapshot.

func (*File) UnsetTabStr added in v0.4.4

func (file *File) UnsetTabStr()

UnsetTabStr (re)enables auto-tab detaction.

func (*File) WriteStatus

func (file *File) WriteStatus(row, col int)

WriteStatus writes the status line.

type Timer added in v0.3.3

type Timer struct {
	Rate float64
	// contains filtered or unexported fields
}

Timer continually measures the rate at which things happen.

func MakeTimer added in v0.3.3

func MakeTimer() Timer

MakeTimer creates a new Timer instance.

func (*Timer) Tick added in v0.3.3

func (timer *Timer) Tick() float64

Tick updates the continually monitored rate and returns its current value.

Directories

Path Synopsis
Package buffer provides a single editable text buffer.
Package buffer provides a single editable text buffer.
Package cursor handles all the cursor and multicursor stuff.
Package cursor handles all the cursor and multicursor stuff.

Jump to

Keyboard shortcuts

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