backend

package module
v0.0.0-...-3e883f0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2017 License: BSD-2-Clause Imports: 24 Imported by: 0

README

lime-backend

Build Status Coverage Status Go Report Card GoDoc

Bountysource Bounties Bountysource Raised

Gitter

This is the backend code for Lime. For more information about the project, please see limetext/lime.

Documentation

Overview

The backend package defines the very soul of Lime.

Some highlevel concepts follow.

Frontend

Lime is designed with the goal of having a clear frontend and backend separation to allow and hopefully simplify the creation of multiple frontend versions.

The two most active frontends are at the time of writing this one for terminals based on termbox-go and a GUI application based on Qt's QML scripting language.

There's also a Proof of Concept html frontend.

Editor

The Editor singleton represents the most fundamental interface that frontends use to access the backend. It keeps a list of editor windows, handles input, detects file changes as well as communicate back to the frontend as needed.

Window

At any time there can be multiple windows of the editor open. Each Window can have a different layout, settings and status.

View

The View class defines a "view" into a specific backing buffer. Multiple views can share the same backing buffer. For instance viewing the same buffer in split view, or viewing the buffer with one syntax definition in one view and another syntax definition in the other.

It is very closely related to the view defined in the Model-view-controller paradigm, and contains settings pertaining to exactly how a buffer is shown to the user.

Command

The command interface defines actions to be executed either for the whole application, a specific window or a specific view.

Key bindings

Key bindings define a sequence of key-presses, a Command and the command's arguments to be executed upon that sequence having been pressed.

Key bindings can optionally have multiple contexts associated with it which allows the exact same key sequence to have different meaning depending on context.

See http://godoc.org/github.com/limetext/backend#QueryContextCallback for details.

Settings

Many of the components have their own key-value Settings object associated with it, but settings are also nested. In other words, if the settings key does not exist in the current object's settings, its parent's settings object is queried next which in turn will query its parent if its settings object didn't contain the key neither.

Index

Constants

View Source
const (
	// Prompt save as dialog
	PROMPT_SAVE_AS = 1 << iota
	// User should only be able to select folders
	PROMPT_ONLY_FOLDER
	// User can select multiple files
	PROMPT_SELECT_MULTIPLE
)
View Source
const (
	CLASS_WORD_START = 1 << iota
	CLASS_WORD_END
	CLASS_PUNCTUATION_START
	CLASS_PUNCTUATION_END
	CLASS_SUB_WORD_START
	CLASS_SUB_WORD_END
	CLASS_LINE_START
	CLASS_LINE_END
	CLASS_EMPTY_LINE
	CLASS_MIDDLE_WORD
	CLASS_WORD_START_WITH_PUNCTUATION
	CLASS_WORD_END_WITH_PUNCTUATION
	CLASS_OPENING_PARENTHESIS
	CLASS_CLOSING_PARENTHESIS

	DEFAULT_SEPARATORS = "[!\"#$%&'()*+,\\-./:;<=>?@\\[\\\\\\]^`{|}~]"
)
View Source
const (
	LITERAL = 1 << iota
	IGNORECASE
)

Variables

View Source
var (
	OnNew               ViewEvent //< Called when a new view is created
	OnLoad              ViewEvent //< Called when loading a view's buffer has finished
	OnActivated         ViewEvent //< Called when a view gains input focus.
	OnDeactivated       ViewEvent //< Called when a view loses input focus.
	OnPreClose          ViewEvent //< Called when a view is about to be closed.
	OnClose             ViewEvent //< Called when a view has been closed.
	OnPreSave           ViewEvent //< Called just before a view's buffer is saved.
	OnPostSave          ViewEvent //< Called after a view's buffer has been saved.
	OnModified          ViewEvent //< Called when the contents of a view's underlying buffer has changed.
	OnSelectionModified ViewEvent //< Called when a view's Selection/cursor has changed.
	OnStatusChanged     ViewEvent //< Called when a view's status has changed.

	OnNewWindow      WindowEvent //< Called when a new window has been created.
	OnProjectChanged WindowEvent

	OnQueryContext QueryContextEvent //< Called when context is being queried.

	OnInit InitEvent //< Called once at program startup

	OnPackagesPathAdd    PathEvent
	OnPackagesPathRemove PathEvent
	OnDefaultPathAdd     PathEvent
	OnUserPathAdd        PathEvent

	OnAddFolder    ProjectEvent
	OnRemoveFolder ProjectEvent
)

Functions

func DefaultName

func DefaultName(cmd interface{}) string

Types

type ApplicationCommand

type ApplicationCommand interface {
	Command

	// Execute this command
	Run() error

	// Returns whether this command is checked or not.
	// Used to display a checkbox in the user interface
	// for boolean commands.
	IsChecked() bool
}

The ApplicationCommand interface extends the base Command interface with functionality specific for ApplicationCommands.

type Args

type Args map[string]interface{}

The Args type is just a generic string key and interface{} value map type used to serialize command arguments.

type BypassUndoCommand

type BypassUndoCommand struct {
	DefaultCommand
}

The BypassUndoCommand is the same as the DefaultCommand type, except that its implementation of BypassUndo returns true rather than false.

func (*BypassUndoCommand) BypassUndo

func (b *BypassUndoCommand) BypassUndo() bool

The BypassUndoCommand defaults to bypassing the undo stack.

type ColorScheme

type ColorScheme interface {
	render.ColourScheme
	Name() string
}

Any color scheme view should implement this interface also it should register it self from editor.AddColorSCheme

type Command

type Command interface {
	// Returns whether the Command is enabled or not.
	IsEnabled() bool

	// Returns whether the Command is visible in menus,
	// the goto anything panel or other user interface
	// that lists available commands.
	IsVisible() bool

	// Returns the textual description of the command.
	Description() string

	// Whether or not this Command bypasses the undo stack.
	BypassUndo() bool
}

The Command interface implements the basic interface that is shared between the different more specific command type interfaces.

In the traditional Model-view-controller design, Commands are roughly equivalent to the action-taking controller piece.

type CommandHandler

type CommandHandler interface {
	Unregister(string) error
	RegisterWithDefault(cmd interface{}) error
	Register(name string, cmd interface{}) error
	// TODO(q): Do the commands need to be split in separate lists?
	RunWindowCommand(*Window, string, Args) error
	RunTextCommand(*View, string, Args) error
	RunApplicationCommand(string, Args) error
}

type CustomDefault

type CustomDefault interface {
	Default(key string) interface{}
}

type CustomInit

type CustomInit interface {
	Init(args Args) error
}

The CustomInit interface can be optionally implemented by a Command and will be called instead of the default command initialization code.

type CustomSet

type CustomSet interface {
	Set(v interface{}) error
}

The CustomSet interface can be optionally implemented by struct members of a concrete command struct.

If implemented, it'll be called by the default Command initialization code with the data gotten from the Args map.

type DefaultCommand

type DefaultCommand struct{}

The DefaultCommand implements the default operation of the basic Command interface and is recommended to be used as the base when creating new Commands.

func (*DefaultCommand) BypassUndo

func (d *DefaultCommand) BypassUndo() bool

The default is to not bypass the undo stack.

func (*DefaultCommand) Description

func (d *DefaultCommand) Description() string

By default the string "TODO" is return as the description.

func (*DefaultCommand) IsEnabled

func (d *DefaultCommand) IsEnabled() bool

By default a command is enabled.

func (*DefaultCommand) IsVisible

func (d *DefaultCommand) IsVisible() bool

By default a command is visible.

type Edit

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

The Edit object is an internal type passed as an argument to a TextCommand. All text operations need to be associated with a valid Edit object.

Think of it a bit like an SQL transaction.

func (*Edit) Apply

func (e *Edit) Apply()

Applies the action of this Edit object. Should typically not be manually called.

func (*Edit) String

func (e *Edit) String() string

Returns a string describing this Edit object. Should typically not be manually called.

func (*Edit) Undo

func (e *Edit) Undo()

Reverses the application of this Edit object. Should typically not be manually called.

type Editor

type Editor struct {
	text.HasSettings
	keys.HasKeyBindings
	*watch.Watcher
	// contains filtered or unexported fields
}

func GetEditor

func GetEditor() *Editor

func (*Editor) ActiveWindow

func (e *Editor) ActiveWindow() *Window

func (*Editor) AddColorScheme

func (e *Editor) AddColorScheme(path string, cs ColorScheme)

func (*Editor) AddPackagesPath

func (e *Editor) AddPackagesPath(p string)

func (*Editor) AddSyntax

func (e *Editor) AddSyntax(path string, s Syntax)

func (*Editor) Arch

func (e *Editor) Arch() string

func (*Editor) Clipboard

func (e *Editor) Clipboard() clipboard.Clipboard

Clipboard returns the currently active clipboard.

func (*Editor) ColorSchemes

func (e *Editor) ColorSchemes()

TODO: should generate sth like sublime text color schemes menu

func (*Editor) CommandHandler

func (e *Editor) CommandHandler() CommandHandler

func (*Editor) Console

func (e *Editor) Console() *View

func (*Editor) DefaultPath

func (e *Editor) DefaultPath() string

func (*Editor) Frontend

func (e *Editor) Frontend() Frontend

func (*Editor) GetClipboard

func (e *Editor) GetClipboard() string

GetClipboard returns the contents of the clipboard. It assumes the text was not captured from an auto-expanded cursor. It exists for Sublime Text API compatibility.

func (*Editor) GetColorScheme

func (e *Editor) GetColorScheme(path string) ColorScheme

func (*Editor) GetSyntax

func (e *Editor) GetSyntax(path string) Syntax

func (*Editor) HandleInput

func (e *Editor) HandleInput(kp keys.KeyPress)

func (*Editor) Init

func (e *Editor) Init()

func (*Editor) LogCommands

func (e *Editor) LogCommands(l bool)

func (*Editor) LogInput

func (e *Editor) LogInput(l bool)

func (*Editor) NewWindow

func (e *Editor) NewWindow() *Window

func (*Editor) PackagesPath

func (e *Editor) PackagesPath() string

func (*Editor) Plat

func (e *Editor) Plat() string

func (*Editor) Platform

func (e *Editor) Platform() string

func (*Editor) RemovePackagesPath

func (e *Editor) RemovePackagesPath(p string)

func (*Editor) RunCommand

func (e *Editor) RunCommand(name string, args Args)

func (*Editor) SetActiveWindow

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

func (*Editor) SetClipboard

func (e *Editor) SetClipboard(s string)

SetClipboard modifies the contents of the clipboard. It assumes the text was not captured from an auto-expanded cursor. It exists for Sublime Text API compatibility.

func (*Editor) SetDefaultPath

func (e *Editor) SetDefaultPath(p string)

func (*Editor) SetFrontend

func (e *Editor) SetFrontend(f Frontend)

func (*Editor) SetUserPath

func (e *Editor) SetUserPath(p string)

func (*Editor) Syntaxes

func (e *Editor) Syntaxes()

TODO: should generate sth like sublime text syntaxes menu the name in the menu should come from defined name inside syntax file or the syntax file name

func (*Editor) UseClipboard

func (e *Editor) UseClipboard(c clipboard.Clipboard)

UseClipboard replaces the existing clipboard with c.

func (*Editor) UserPath

func (e *Editor) UserPath() string

func (*Editor) Version

func (e *Editor) Version() string

func (*Editor) Windows

func (e *Editor) Windows() []*Window

type Folder

type Folder struct {
	Path                string   `json:"path"`
	Name                string   `json:"name"`
	ExcludePatterns     []string `json:"folder_exclude_patterns"`
	IncludePatterns     []string `json:"folder_include_patterns"`
	FileExcludePatterns []string `json:"file_exclude_patterns"`
	FileIncludePatterns []string `json:"file_include_patterns"`
	FollowSymlinks      bool     `json:"follow_symlinks"`
}

Represents each folder in sublime-project file

type Folders

type Folders []*Folder

type Frontend

type Frontend interface {
	// Probe the frontend for the currently
	// visible region of the given view.
	VisibleRegion(v *View) text.Region

	// Make the frontend show the specified region of the
	// given view.
	Show(v *View, r text.Region)

	// Sets the status message shown in the status bar
	StatusMessage(string)

	// Displays an error message to the user
	ErrorMessage(string)

	// Displays a message dialog to the user
	MessageDialog(string)

	// Displays an ok / cancel dialog to the user.
	// "okname" if provided will be used as the text
	// instead of "Ok" for the ok button.
	// Returns true when ok was pressed, and false when
	// cancel was pressed.
	OkCancelDialog(msg string, okname string) bool

	// Displays file dialog, returns the selected files.
	// folder is the path file dialog will show.
	Prompt(title, folder string, flags int) []string
}

The Frontend interface defines the API for functionality that is frontend specific.

type InitCallback

type InitCallback func()

The InitCallback allows complex (i.e. time consuming) initiation code to be deferred until after the UI is up and running.

type InitEvent

type InitEvent []InitCallback

The InitEvent is executed once at startup, after the UI is up and running and is typically used by feature modules to defer heavy initialization work such as scanning for plugins, loading key bindings, macros etc.

func (*InitEvent) Add

func (ie *InitEvent) Add(i InitCallback)

Add the InitCallback to the InitEvent to be called during initialization. This should be called in a module's init() function.

type PathEvent

type PathEvent []PathEventCallback

A PathEvent is simply a bunch of PathEventCallbacks.

func (*PathEvent) Add

func (pe *PathEvent) Add(cb PathEventCallback)

type PathEventCallback

type PathEventCallback func(name string)

Dealing with package events

type Project

type Project struct {
	text.HasSettings
	// contains filtered or unexported fields
}

func (*Project) AddFolder

func (p *Project) AddFolder(path string)

func (*Project) Close

func (p *Project) Close()

func (*Project) FileChanged

func (p *Project) FileChanged(name string)

func (*Project) FileName

func (p *Project) FileName() string

func (*Project) Folder

func (p *Project) Folder(path string) *Folder

func (*Project) Folders

func (p *Project) Folders() []string

func (*Project) Load

func (p *Project) Load(name string) error

func (*Project) MarshalJSON

func (p *Project) MarshalJSON() ([]byte, error)

func (*Project) RemoveFolder

func (p *Project) RemoveFolder(path string)

func (*Project) SaveAs

func (p *Project) SaveAs(name string) error

Marshals project struct to json then writes it to a file with given name

func (*Project) SetName

func (p *Project) SetName(name string)

func (*Project) UnmarshalJSON

func (p *Project) UnmarshalJSON(data []byte) error

func (*Project) Window

func (p *Project) Window() *Window

type ProjectEvent

type ProjectEvent []ProjectEventCallback

func (*ProjectEvent) Add

func (pe *ProjectEvent) Add(cb ProjectEventCallback)

type ProjectEventCallback

type ProjectEventCallback func(w *Window, name string)

type QueryContextCallback

type QueryContextCallback func(v *View, key string, operator util.Op, operand interface{}, match_all bool) QueryContextReturn

The context is queried when trying to figure out what action should be performed when certain conditions are met.

Context is just a string identifier, an optional comparison operator, an optional operand, and an optional match_all boolean. The data of the context is optionally provided together with a key binding and the key's action will only be considered if the context conditions are met.

Exactly how these values are interpreted is up to the individual context handlers, which may be fully customized by implementing the callback in a plugin.

For instance pressing the key 'j' will have a different meaning when in a VI command mode emulation and when in a VI insert mode emulation. A plugin would then define two key binding entries for 'j', describe the key binding context to be able to discern which action is appropriate when 'j' is then pressed.

type QueryContextEvent

type QueryContextEvent []QueryContextCallback

A QueryContextEvent is simply a bunch of QueryContextCallbacks.

func (*QueryContextEvent) Add

Add the provided QueryContextCallback to the QueryContextEvent. TODO(.): Support removing QueryContextCallbacks?

func (QueryContextEvent) Call

func (qe QueryContextEvent) Call(v *View, key string, operator util.Op, operand interface{}, match_all bool) QueryContextReturn

Searches for a QueryContextCallback and returns the result of the first callback being able to deal with this context, or Unknown if no such callback was found. TODO: should calling be exported?

type QueryContextReturn

type QueryContextReturn int

The return value returned from a QueryContextCallback.

const (
	True    QueryContextReturn = iota //< Returned when the context query matches.
	False                             //< Returned when the context query does not match.
	Unknown                           //< Returned when the QueryContextCallback does not know how to deal with the given context.
)

type Syntax

type Syntax interface {
	// provides parser for creating syntax highlighter
	Parser(data string) (parser.Parser, error)
	Name() string
	// filetypes this syntax supports
	FileTypes() []string
}

Any syntax definition for view should implement this interface also it should register it self from editor.AddSyntax

type TextCommand

type TextCommand interface {
	Command

	// Execute this command with the specified View and Edit object
	// as the arguments
	Run(*View, *Edit) error
}

The TextCommand interface extends the base Command interface with functionality specific for TextCommands.

type UndoStack

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

func (*UndoStack) Add

func (us *UndoStack) Add(a *Edit)

Adds the provided Edit object to the UndoStack, potentially destroying the old redo stack if one had been created. TODO(.): It would be nice with branched undo histories

func (*UndoStack) GlueFrom

func (us *UndoStack) GlueFrom(mark int)

Glues all edits from the position given by mark, to the current position in the UndoStack, replacing them by a single entry which will now be composite of all those other actions.

In other words, after the glue operation a single "undo" operation will then undo all of those edits and a single redo after that will redo them all again.

func (*UndoStack) Position

func (us *UndoStack) Position() int

Returns the current position in the UndoStack.

func (*UndoStack) Redo

func (us *UndoStack) Redo(hard bool)

Re-applies the next action in the undo stack if there are any actions on the stack that had been undone.

See comment in Undo regarding the use of "hard".

func (*UndoStack) Undo

func (us *UndoStack) Undo(hard bool)

Reverts the last action on the UndoStack.

When the argument "hard" is set to true, the "last action" will be the last action that modified the contents of the buffer (rather than just changing the cursor position). In this case, all actions between the current action and the last "hard" action will be reverted.

type View

type View struct {
	text.HasSettings
	text.HasId
	// contains filtered or unexported fields
}

A View provides a view into a specific underlying buffer with its own set of selections, settings, viewport, etc. Multiple Views can share the same underlying data buffer.

func (*View) AddObserver

func (v *View) AddObserver(ob text.BufferObserver) error

func (*View) AddRegions

func (v *View) AddRegions(key string, regions []text.Region, scope, icon string, flags render.ViewRegionFlags)

AddRegions lets users mark text regions in a view with a scope name, gutter icon and ViewRegionflags which are then optionally used to alter the display of those regions.

Typical uses would be to draw squiggly lines under misspelled words, show an icon in the gutter to indicate a breakpoint, keeping track of snippet or auto-completion fields, highlight code compilation warnings, etc.

The regions will be automatically adjusted as appropriate when the underlying buffer is changed.

func (*View) BeginEdit

func (v *View) BeginEdit() *Edit

Creates a new Edit object. Think of it a bit like starting an SQL transaction. Another Edit object should not be created before ending the previous one.

TODO(.): Is nesting edits ever valid? Perhaps a nil edit should be returned if the previous wasn't ended? What if it will never be ended? Leaving the buffer in a broken state where no more changes can be made to it is obviously not good and is the reason why ST3 removed the ability to manually create Edit objects to stop people from breaking the undo stack.

func (*View) BufferId

func (v *View) BufferId() text.Id

func (*View) ChangeCount

func (v *View) ChangeCount() int

func (*View) Classify

func (v *View) Classify(point int) (res int)

Classifies point, returning a bitwise OR of zero or more of defined flags

func (*View) Close

func (v *View) Close() bool

Initiate the "close" operation of this view. Returns "true" if the view was closed. Otherwise returns "false".

func (*View) CommandHistory

func (v *View) CommandHistory(idx int, modifying_only bool) (name string, args Args, count int)

Returns the CommandHistory entry at the given relative index.

When "modifying_only" is set to true, only commands that actually changed the Buffer in some way (as opposed to just moving the cursor around) are counted as an index. That would be a "hard" command as it is referred to in UndoStack.Undo.

func (*View) EndEdit

func (v *View) EndEdit(edit *Edit)

Ends the given Edit object.

func (*View) Erase

func (v *View) Erase(edit *Edit, r text.Region)

Adds an Erase action of the given Region to the provided Edit object.

func (*View) EraseRegions

func (v *View) EraseRegions(key string)

Removes the Regions associated with the given key from the view.

func (*View) EraseStatus

func (v *View) EraseStatus(key string)

func (*View) Erased

func (v *View) Erased(changed_buffer text.Buffer, region_removed text.Region, data_removed []rune)

func (*View) ExpandByClass

func (v *View) ExpandByClass(r text.Region, classes int) text.Region

Expands the selection until the point on each side matches the given classes

func (*View) ExtractScope

func (v *View) ExtractScope(point int) text.Region

Returns the Region of the innermost scope that contains "point". See package backend/parser for details.

func (*View) FileChanged

func (v *View) FileChanged(filename string)

func (*View) FileName

func (v *View) FileName() string

func (*View) Find

func (v *View) Find(pat string, pos int, flags int) text.Region

func (*View) FindByClass

func (v *View) FindByClass(point int, forward bool, classes int) int

Finds the next location after point that matches the given classes Searches backward if forward is false

func (*View) FullLine

func (v *View) FullLine(off int) text.Region

func (*View) FullLineR

func (v *View) FullLineR(r text.Region) text.Region

func (*View) GetRegions

func (v *View) GetRegions(key string) (ret []text.Region)

Returns the Regions associated with the given key.

func (*View) GetStatus

func (v *View) GetStatus(key string) string

func (*View) Insert

func (v *View) Insert(edit *Edit, point int, value string) int

Inserts text at the given position in the provided edit object. Tabs are (sometimes, depending on the View's settings) translated to spaces. The return value is the length of the string that was inserted.

func (*View) Inserted

func (v *View) Inserted(changed_buffer text.Buffer, region_inserted text.Region, data_inserted []rune)

func (*View) IsDirty

func (v *View) IsDirty() bool

Returns whether the underlying Buffer has any unsaved modifications. Note that Scratch buffers are never considered dirty.

func (*View) IsScratch

func (v *View) IsScratch() bool

Checks the scratch property of the view. TODO(.): Couldn't this just be a value in the View's Settings?

func (*View) Line

func (v *View) Line(off int) text.Region

func (*View) LineR

func (v *View) LineR(r text.Region) text.Region

func (*View) Lines

func (v *View) Lines(r text.Region) []text.Region

func (*View) Name

func (v *View) Name() string

func (*View) OverwriteStatus

func (v *View) OverwriteStatus() bool

Sets the overwrite status property of the view. TODO(.): Couldn't this just be a value in the View's Settings?

func (*View) Replace

func (v *View) Replace(edit *Edit, r text.Region, value string)

Adds a Replace action of the given Region to the provided Edit object.

func (*View) RowCol

func (v *View) RowCol(point int) (int, int)

func (*View) Save

func (v *View) Save() error

Saves the file

func (*View) SaveAs

func (v *View) SaveAs(name string) (err error)

Saves the file to the specified filename

func (*View) ScopeName

func (v *View) ScopeName(point int) string

Returns the full concatenated nested scope name at point. See package backend/parser for details.

func (*View) ScoreSelector

func (v *View) ScoreSelector(point int, selector string) int

ScoreSelector() takes a point and a selector string and returns a score as to how good that specific selector matches the scope name at that point.

func (*View) Sel

func (v *View) Sel() *text.RegionSet

Sel() returns a pointer to the RegionSet used by this View to mark possibly multiple cursor positions and selection regions.

Some quick notes: The actual cursor position is always in Region.B. Region{0,0} is a cursor at the start of the text (before any characters in the text).

Region{0,1} has the cursor at position 1 (after the first character), but also selects/highlights the first character. In this instance Region.A = 0, Region.B = 1, Region.Start() returns 0 and Region.End() returns 1.

Region{1,0} has the cursor at position 0 (before the first character), but also selects/highlights the first character. Think holding shift and pressing left on your keyboard. In this instance Region.A = 1, Region.B = 0, Region.Start() returns 0 and Region.End() returns 1.

func (*View) SetFileName

func (v *View) SetFileName(n string) error

func (*View) SetName

func (v *View) SetName(n string) error

func (*View) SetOverwriteStatus

func (v *View) SetOverwriteStatus(s bool)

Checks the overwrite status property of the view. TODO(.): Couldn't this just be a value in the View's Settings?

func (*View) SetScratch

func (v *View) SetScratch(s bool)

Sets the scratch property of the view. TODO(.): Couldn't this just be a value in the View's Settings?

func (*View) SetStatus

func (v *View) SetStatus(key, val string)

func (*View) SetSyntaxFile

func (v *View) SetSyntaxFile(file string)

func (*View) Size

func (v *View) Size() int

func (*View) Status

func (v *View) Status() map[string]string

func (*View) String

func (v *View) String() string

implement the fmt.Stringer interface

func (*View) Substr

func (v *View) Substr(r text.Region) string

func (*View) SubstrR

func (v *View) SubstrR(r text.Region) []rune

func (*View) TextPoint

func (v *View) TextPoint(row, col int) int

func (*View) Transform

func (v *View) Transform(viewport text.Region) render.Recipe

Transform() takes a viewport, gets a colour scheme from editor and returns a Recipe suitable for rendering the contents of this View that is visible in that viewport.

func (*View) UndoStack

func (v *View) UndoStack() *UndoStack

Returns the UndoStack of this view. Tread lightly.

func (*View) Window

func (v *View) Window() *Window

Returns the window this View belongs to.

func (*View) Word

func (v *View) Word(off int) text.Region

func (*View) WordR

func (v *View) WordR(r text.Region) text.Region

type ViewEvent

type ViewEvent []ViewEventCallback

A ViewEvent is simply a bunch of ViewEventCallbacks.

func (*ViewEvent) Add

func (ve *ViewEvent) Add(cb ViewEventCallback)

Add the provided ViewEventCallback to this ViewEvent TODO(.): Support removing ViewEventCallbacks?

func (*ViewEvent) Call

func (ve *ViewEvent) Call(v *View)

Trigger this ViewEvent by calling all the registered callbacks in order of registration. TODO: should calling be exported?

type ViewEventCallback

type ViewEventCallback func(v *View)

An event callback dealing with View events.

type Window

type Window struct {
	text.HasSettings
	text.HasId
	// contains filtered or unexported fields
}

func (*Window) ActiveView

func (w *Window) ActiveView() *View

func (*Window) Close

func (w *Window) Close() bool

Closes the Window and all its Views. Returns "true" if the Window closed successfully. Otherwise returns "false".

func (*Window) CloseAllViews

func (w *Window) CloseAllViews() bool

Closes all of the Window's Views. Returns "true" if all the Views closed successfully. Otherwise returns "false".

func (*Window) NewFile

func (w *Window) NewFile() *View

func (*Window) OpenFile

func (w *Window) OpenFile(filename string, flags int) *View

func (*Window) OpenProject

func (w *Window) OpenProject(name string) *Project

func (*Window) Project

func (w *Window) Project() *Project

func (*Window) SetActiveView

func (w *Window) SetActiveView(v *View)

func (*Window) String

func (w *Window) String() string

implement the fmt.Stringer interface

func (*Window) Views

func (w *Window) Views() []*View

type WindowCommand

type WindowCommand interface {
	Command

	// Execute this command with the specified window as the
	// argument
	Run(*Window) error
}

The WindowCommand interface extends the base Command interface with functionality specific for WindowCommands.

type WindowEvent

type WindowEvent []WindowEventCallback

A WindowEvent is simply a bunch of WindowEventCallbacks.

func (*WindowEvent) Add

func (we *WindowEvent) Add(cb WindowEventCallback)

Add the provided WindowEventCallback to this WindowEvent. TODO(.): Support removing WindowEventCallbacks?

func (*WindowEvent) Call

func (we *WindowEvent) Call(w *Window)

Trigger this WindowEvent by calling all the registered callbacks in order of registration. TODO: should calling be exported?

type WindowEventCallback

type WindowEventCallback func(w *Window)

A WindowEventCallback deals with Window events.

Notes

Bugs

  • Sometimes Sel becomes empty. There should always be at a minimum 1 valid cursor.

Directories

Path Synopsis
The packages package handles lime package management.
The packages package handles lime package management.
The render package defines interfaces and functions to stylize a View's contents with colours, fonts and other metadata.
The render package defines interfaces and functions to stylize a View's contents with colours, fonts and other metadata.

Jump to

Keyboard shortcuts

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