core

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2019 License: MIT Imports: 43 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ContentCmds contentCmds

cmds added via init() from "contentcmds" pkg

View Source
var InternalCmds = internalCmds{}

cmds added via init() from "internalcmds" pkg

Functions

func DeleteSession

func DeleteSession(ed *Editor, part *toolbarparser.Part)

func ExecCmd

func ExecCmd(ctx context.Context, dir string, args ...string) ([]byte, error)

func ExecCmdStdin

func ExecCmdStdin(ctx context.Context, dir string, in io.Reader, args ...string) ([]byte, error)

func ExternalCmd

func ExternalCmd(erow *ERow, part *toolbarparser.Part)

func ExternalCmdFromArgs

func ExternalCmdFromArgs(erow *ERow, cargs []string, fend func(error))

func FindFileInfo

func FindFileInfo(name, dir string) (string, os.FileInfo, bool)

Checks in GOROOT/GOPATH, and some C include dirs.

func FindShortcut

func FindShortcut(erow *ERow)

Search/add the toolbar find command and warps the pointer to it.

func HasExecErrNotFound

func HasExecErrNotFound(err error) bool

func InternalCmdFromRootTb

func InternalCmdFromRootTb(ed *Editor, tb *ui.Toolbar)

func InternalCmdFromRowTb

func InternalCmdFromRowTb(erow *ERow)

func ListDirContext

func ListDirContext(ctx context.Context, w io.Writer, filepath string, tree, hidden bool) error

func ListDirERow

func ListDirERow(erow *ERow, filepath string, tree, hidden bool)

func ListSessions

func ListSessions(ed *Editor)

func OpenFileERow

func OpenFileERow(ed *Editor, conf *OpenFileERowConfig)

func OpenSession

func OpenSession(ed *Editor, part *toolbarparser.Part)

func OpenSessionFromString

func OpenSessionFromString(ed *Editor, sessionName string)

func SaveSession

func SaveSession(ed *Editor, part *toolbarparser.Part)

Types

type ByListOrder

type ByListOrder []os.FileInfo

func (ByListOrder) Len

func (a ByListOrder) Len() int

func (ByListOrder) Less

func (a ByListOrder) Less(i, j int) bool

func (ByListOrder) Swap

func (a ByListOrder) Swap(i, j int)

type ColumnState

type ColumnState struct {
	StartPercent float64
	Rows         []*RowState
}

func NewColumnState

func NewColumnState(ed *Editor, col *ui.Column) *ColumnState

type ContentCmd

type ContentCmd struct {
	Name string // for removal and error msgs
	Fn   ContentCmdFn
}

type ContentCmdFn

type ContentCmdFn func(ctx context.Context, erow *ERow, index int) (_ error, handled bool)

type DndHandler

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

func NewDndHandler

func NewDndHandler(ed *Editor) *DndHandler

func (*DndHandler) OnDrop

func (h *DndHandler) OnDrop(ev *event.DndDrop)

func (*DndHandler) OnPosition

func (h *DndHandler) OnPosition(ev *event.DndPosition)

type EEventId

type EEventId int
const (
	PostNewERowEEventId EEventId = iota
	PostFileSaveEEventId
	PreRowCloseEEventId
	RowStateChangeEEventId
)

type EEvents

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

Editor events.

func NewEEvents

func NewEEvents() *EEvents

func (*EEvents) Register

func (eevs *EEvents) Register(eid EEventId, fn func(interface{})) *evreg.Regist

type ERow

type ERow struct {
	Ed     *Editor
	Row    *ui.Row
	Info   *ERowInfo
	Exec   *ERowExec
	TbData toolbarparser.Data
	// contains filtered or unexported fields
}

func NewERow

func NewERow(ed *Editor, info *ERowInfo, rowPos *ui.RowPos) *ERow

func (*ERow) CancelContentCmd

func (erow *ERow) CancelContentCmd()

func (*ERow) Flash

func (erow *ERow) Flash()

func (*ERow) MakeIndexVisibleAndFlash

func (erow *ERow) MakeIndexVisibleAndFlash(index int)

func (*ERow) MakeRangeVisibleAndFlash

func (erow *ERow) MakeRangeVisibleAndFlash(index int, len int)

func (*ERow) Reload

func (erow *ERow) Reload()

func (*ERow) TextAreaAppendBytes

func (erow *ERow) TextAreaAppendBytes(p []byte)

func (*ERow) TextAreaAppendBytesAsync

func (erow *ERow) TextAreaAppendBytesAsync(p []byte) <-chan struct{}

func (*ERow) TextAreaWriter

func (erow *ERow) TextAreaWriter() io.WriteCloser

Caller is responsible for closing the writer at the end.

func (*ERow) ToolbarSetStrAfterNameClearHistory

func (erow *ERow) ToolbarSetStrAfterNameClearHistory(s string)

type ERowExec

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

func NewERowExec

func NewERowExec(erow *ERow) *ERowExec

func (*ERowExec) Start

func (eexec *ERowExec) Start(fexec func(context.Context, io.Writer) error)

func (*ERowExec) Stop

func (eexec *ERowExec) Stop()

type ERowInfo

type ERowInfo struct {
	ERows []*ERow

	Ed *Editor
	// contains filtered or unexported fields
}

Editor Row Info.

func NewERowInfo

func NewERowInfo(ed *Editor, name string) *ERowInfo

Not to be created directly. Only the editor instance will check if another info already exists.

func (*ERowInfo) AddERow

func (info *ERowInfo) AddERow(erow *ERow)

func (*ERowInfo) Dir

func (info *ERowInfo) Dir() string

func (*ERowInfo) ERowsInUIOrder

func (info *ERowInfo) ERowsInUIOrder() []*ERow

func (*ERowInfo) EqualToBytesHash

func (info *ERowInfo) EqualToBytesHash(size int, hash []byte) bool

func (*ERowInfo) FileInfoErr

func (info *ERowInfo) FileInfoErr() error

func (*ERowInfo) HasFileinfo

func (info *ERowInfo) HasFileinfo() bool

func (*ERowInfo) IsDir

func (info *ERowInfo) IsDir() bool

func (*ERowInfo) IsFileButNotDir

func (info *ERowInfo) IsFileButNotDir() bool

func (*ERowInfo) IsNotExist

func (info *ERowInfo) IsNotExist() bool

func (*ERowInfo) IsSpecial

func (info *ERowInfo) IsSpecial() bool

func (*ERowInfo) Name

func (info *ERowInfo) Name() string

func (*ERowInfo) NewDirERow

func (info *ERowInfo) NewDirERow(rowPos *ui.RowPos) (*ERow, error)

func (*ERowInfo) NewERow

func (info *ERowInfo) NewERow(rowPos *ui.RowPos) (*ERow, error)

func (*ERowInfo) NewERowCreateOnErr

func (info *ERowInfo) NewERowCreateOnErr(rowPos *ui.RowPos) (*ERow, error)

func (*ERowInfo) NewFileERow

func (info *ERowInfo) NewFileERow(rowPos *ui.RowPos) (*ERow, error)

func (*ERowInfo) ReloadDir

func (info *ERowInfo) ReloadDir(erow *ERow) error

func (*ERowInfo) ReloadFile

func (info *ERowInfo) ReloadFile() error

func (*ERowInfo) RemoveERow

func (info *ERowInfo) RemoveERow(erow *ERow)

func (*ERowInfo) SaveFile

func (info *ERowInfo) SaveFile() error

Save file and update rows.

func (*ERowInfo) SetRowsBytes

func (info *ERowInfo) SetRowsBytes(b []byte)

func (*ERowInfo) SetRowsStrFromMaster

func (info *ERowInfo) SetRowsStrFromMaster(erow *ERow)

func (*ERowInfo) UpdateActiveRowState

func (info *ERowInfo) UpdateActiveRowState(erow *ERow)

func (*ERowInfo) UpdateAnnotationsEditedRowState

func (info *ERowInfo) UpdateAnnotationsEditedRowState(v bool)

func (*ERowInfo) UpdateAnnotationsRowState

func (info *ERowInfo) UpdateAnnotationsRowState(v bool)

func (*ERowInfo) UpdateDiskEvent

func (info *ERowInfo) UpdateDiskEvent()

Should be called under UI goroutine.

func (*ERowInfo) UpdateDuplicateHighlightRowState

func (info *ERowInfo) UpdateDuplicateHighlightRowState()

func (*ERowInfo) UpdateDuplicateRowState

func (info *ERowInfo) UpdateDuplicateRowState()

func (*ERowInfo) UpdateEditedRowState

func (info *ERowInfo) UpdateEditedRowState()

func (*ERowInfo) UpdateExistsRowState

func (info *ERowInfo) UpdateExistsRowState()

func (*ERowInfo) UpdateFsDifferRowState

func (info *ERowInfo) UpdateFsDifferRowState()

type EdAnnotationsRequester

type EdAnnotationsRequester int
const (
	EdAnnReqGoDebug EdAnnotationsRequester = iota
	EdAnnReqInlineComplete
)

type Editor

type Editor struct {
	UI             *ui.UI
	HomeVars       *HomeVars
	Watcher        fswatcher.Watcher
	RowReopener    *RowReopener
	ERowInfos      map[string]*ERowInfo
	GoDebug        *GoDebugInstance
	LSProtoMan     *lsproto.Manager
	InlineComplete *InlineComplete
	Plugins        *Plugins
	EEvents        *EEvents // used by plugins
	// contains filtered or unexported fields
}

func NewEditor

func NewEditor(opt *Options) (*Editor, error)

func (*Editor) ActiveERow

func (ed *Editor) ActiveERow() (*ERow, bool)

func (*Editor) CanModifyAnnotations

func (ed *Editor) CanModifyAnnotations(req EdAnnotationsRequester, ta *ui.TextArea, option string) bool

func (*Editor) Close

func (ed *Editor) Close()

func (*Editor) ERows

func (ed *Editor) ERows() []*ERow

func (*Editor) EnsureOneColumn

func (ed *Editor) EnsureOneColumn()

func (*Editor) Error

func (ed *Editor) Error(err error)

func (*Editor) Errorf

func (ed *Editor) Errorf(f string, a ...interface{})

func (*Editor) ExistingOrNewERow

func (ed *Editor) ExistingOrNewERow(name string) (_ *ERow, isnew bool)

Used for: +messages, +sessions.

func (*Editor) GoodRowPos

func (ed *Editor) GoodRowPos() *ui.RowPos

func (*Editor) Messagef

func (ed *Editor) Messagef(f string, a ...interface{})

func (*Editor) NewColumn

func (ed *Editor) NewColumn() *ui.Column

func (*Editor) NodeERow

func (ed *Editor) NodeERow(node widget.Node) (*ERow, bool)

func (*Editor) ReadERowInfo

func (ed *Editor) ReadERowInfo(name string) *ERowInfo

func (*Editor) RunAsyncBusyCursor

func (ed *Editor) RunAsyncBusyCursor(node widget.Node, fn func())

func (*Editor) SetAnnotations

func (ed *Editor) SetAnnotations(req EdAnnotationsRequester, ta *ui.TextArea, on bool, selIndex int, entries []*drawer4.Annotation)

type GDDataIndex

type GDDataIndex struct {
	FilesIndex           map[string]int
	GlobalArrivalIndex   int
	SelectedArrivalIndex int

	Afds  []*debug.AnnotatorFileData // file index -> file afd
	Files []*GDFileMsgs              // file index -> file msgs
}

GoDebug data Index

func NewGDDataIndex

func NewGDDataIndex() *GDDataIndex

type GDFileMsgs

type GDFileMsgs struct {
	// all annotations received
	Lines []GDLineMsgs

	// current annotation entries to be shown with a file
	AnnEntries        []*drawer4.Annotation
	AnnEntriesLMIndex []int // line messages index

	SelectedLine int
}

func NewGDFileMsgs

func NewGDFileMsgs(n int) *GDFileMsgs

type GDLineMsg

type GDLineMsg struct {
	GlobalArrivalIndex int
	DLine              *debug.LineMsg
	// contains filtered or unexported fields
}

type GDLineMsgs

type GDLineMsgs struct {
	Msgs []*GDLineMsg
}

type GoDebugInstance

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

func NewGoDebugInstance

func NewGoDebugInstance(ed *Editor) *GoDebugInstance

func (*GoDebugInstance) CancelAndClear

func (gdi *GoDebugInstance) CancelAndClear()

func (*GoDebugInstance) SelectAnnotation

func (gdi *GoDebugInstance) SelectAnnotation(erow *ERow, annIndex, offset int, typ ui.TASelAnnType)

func (*GoDebugInstance) Start

func (gdi *GoDebugInstance) Start(erow *ERow, args []string) error

func (*GoDebugInstance) UpdateUIERowInfo

func (gdi *GoDebugInstance) UpdateUIERowInfo(info *ERowInfo)

type HomeVars

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

func NewHomeVars

func NewHomeVars() *HomeVars

func (*HomeVars) Decode

func (hv *HomeVars) Decode(filename string) string

func (*HomeVars) Encode

func (hv *HomeVars) Encode(filename string) string

func (*HomeVars) ParseToolbarVars

func (hv *HomeVars) ParseToolbarVars(strs ...string)

type InfoFloatBoxWrap

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

func NewInfoFloatBox

func NewInfoFloatBox(ed *Editor) *InfoFloatBoxWrap

func (*InfoFloatBoxWrap) Cancel

func (ifbw *InfoFloatBoxWrap) Cancel()

func (*InfoFloatBoxWrap) NewCtx

func (ifbw *InfoFloatBoxWrap) NewCtx(ctx context.Context) context.Context

type InlineComplete

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

func NewInlineComplete

func NewInlineComplete(ed *Editor) *InlineComplete

func (*InlineComplete) CancelAndClear

func (ic *InlineComplete) CancelAndClear()

func (*InlineComplete) CancelOnCursorChange

func (ic *InlineComplete) CancelOnCursorChange()

func (*InlineComplete) Complete

func (ic *InlineComplete) Complete(erow *ERow, ev *ui.TextAreaInlineCompleteEvent) bool

func (*InlineComplete) IsOn

func (ic *InlineComplete) IsOn(ta *ui.TextArea) bool

type InternalCmd

type InternalCmd struct {
	Name       string
	RootTbOnly bool
	Fn         func(args *InternalCmdArgs) error
}

type InternalCmdArgs

type InternalCmdArgs struct {
	Ctx  context.Context
	Ed   *Editor
	ERow *ERow // could be nil if cmd is RootTbOnly
	Part *toolbarparser.Part
}

type OpenFileERowConfig

type OpenFileERowConfig struct {
	FilePos *parseutil.FilePos
	RowPos  *ui.RowPos

	CancelIfExistent      bool
	NewIfNotExistent      bool
	NewIfOffsetNotVisible bool

	FlashRowsIfNotFlashed bool
	FlashVisibleOffsets   bool // flashes rows if not flashed
}

type Options

type Options struct {
	Font        string
	FontSize    float64
	FontHinting string
	DPI         float64

	TabWidth     int
	WrapLineRune int

	ColorTheme     string
	CommentsColor  int
	StringsColor   int
	ScrollBarWidth int
	ScrollBarLeft  bool
	Shadows        bool

	SessionName string
	Filenames   []string

	UseMultiKey bool

	Plugins string

	LSProtos RegistrationsOpt
}

type Plug

type Plug struct {
	Path   string
	Plugin *plugin.Plugin
}

type Plugins

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

func NewPlugins

func NewPlugins(ed *Editor) *Plugins

func (*Plugins) AddPath

func (p *Plugins) AddPath(path string) error

func (*Plugins) RunAutoComplete

func (p *Plugins) RunAutoComplete(ctx context.Context, cfb *ui.ContextFloatBox) (_ error, handled bool)

Runs all plugins until it finds one that returns handled=true and has no errors.

func (*Plugins) RunToolbarCmd

func (p *Plugins) RunToolbarCmd(erow *ERow, part *toolbarparser.Part) bool

type PostFileSaveEEvent

type PostFileSaveEEvent struct {
	Info *ERowInfo
}

type PostNewERowEEvent

type PostNewERowEEvent struct {
	ERow *ERow
}

type PreRowCloseEEvent

type PreRowCloseEEvent struct {
	ERow *ERow
}

type RegistrationsOpt

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

implements flag.Value interface

func (*RegistrationsOpt) MustSet

func (ro *RegistrationsOpt) MustSet(s string)

func (*RegistrationsOpt) Set

func (ro *RegistrationsOpt) Set(s string) error

func (*RegistrationsOpt) String

func (ro *RegistrationsOpt) String() string

type RowReopener

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

func NewRowReopener

func NewRowReopener(ed *Editor) *RowReopener

func (*RowReopener) Add

func (rr *RowReopener) Add(row *ui.Row)

func (*RowReopener) Reopen

func (rr *RowReopener) Reopen()

type RowState

type RowState struct {
	TbStr         string
	TbCursorIndex int
	TaCursorIndex int
	TaOffsetIndex int
	StartPercent  float64
}

Used in sessions and reopenrow.

func NewRowState

func NewRowState(row *ui.Row) *RowState

func (*RowState) OpenERow

func (state *RowState) OpenERow(ed *Editor, rowPos *ui.RowPos) (*ERow, bool, error)

func (*RowState) RestorePos

func (state *RowState) RestorePos(erow *ERow)

type RowStateChangeEEvent

type RowStateChangeEEvent struct {
	ERow  *ERow // duplicate rows also emit state change events.
	State ui.RowState
	Value bool // the new value
}

type Session

type Session struct {
	Name      string
	RootTbStr string
	Columns   []*ColumnState
}

func NewSessionFromEditor

func NewSessionFromEditor(ed *Editor) *Session

type Sessions

type Sessions struct {
	Sessions []*Session
}

func NewSessions

func NewSessions(filename string) (*Sessions, error)

type TerminalFilter

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

Maintains state through different write calls.

func NewTerminalFilter

func NewTerminalFilter(erow *ERow, rd io.ReadCloser) *TerminalFilter

func (*TerminalFilter) Close

func (tf *TerminalFilter) Close() error

func (*TerminalFilter) Read

func (tf *TerminalFilter) Read(p []byte) (int, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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