core

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 49 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ContentCmds contentCmds

global cmds added via init() from "contentcmds" pkg

View Source
var InternalCmds = internalCmds{}

cmds added via init() from "internalcmds" pkg

Functions

func AddFindShortcut added in v1.3.7

func AddFindShortcut(erow *ERow)

func AddNewFileShortcut added in v1.3.7

func AddNewFileShortcut(erow *ERow)

func AddReloadShortcut added in v1.3.7

func AddReloadShortcut(erow *ERow)

func AddReplaceShortcut added in v1.3.7

func AddReplaceShortcut(erow *ERow)

func CompareFileInfos added in v1.3.8

func CompareFileInfos(a, b os.FileInfo) int

func ContentCmdFromTextArea added in v1.1.0

func ContentCmdFromTextArea(erow *ERow, index int)

func DeleteSession

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

func ExternalCmd

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

func ExternalCmdFromArgs

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

func FindFileInfo

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

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

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, subs, hiddens bool) error

func ListDirERow

func ListDirERow(erow *ERow, filepath string, subs, hiddens bool)

func ListSessions

func ListSessions(ed *Editor)

func OpenFileERow

func OpenFileERow(ed *Editor, conf *OpenFileERowConfig)

TODO: make it UI safe? rename to openfileerowasync?

func OpenSession

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

func OpenSessionFromString

func OpenSessionFromString(ed *Editor, sessionName string)

func RunEditor added in v1.3.1

func RunEditor(opt *Options) error

func SaveSession

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

func Version added in v1.3.1

func Version() string

Types

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(any)) *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 ExistingERowOrNewBasic added in v1.3.0

func ExistingERowOrNewBasic(ed *Editor, name string) (_ *ERow, isNew bool)

Used for ex. in: +messages, +sessions.

func ExistingERowOrNewLoaded added in v1.3.0

func ExistingERowOrNewLoaded(ed *Editor, name string) (_ *ERow, isNew bool, _ error)

func NewBasicERow added in v1.3.0

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

func NewLoadedERow added in v1.3.0

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

func NewLoadedERowOrNewBasic added in v1.3.0

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

Allows creating rows in place even if a file/dir doesn't exist anymore (ex: show non-existent files rows in a saved session).

func (*ERow) AppendBytesClearHistory added in v1.3.8

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

Not UI safe.

func (*ERow) AppendBytesClearHistory2 added in v1.3.8

func (erow *ERow) AppendBytesClearHistory2(p []byte) error

func (*ERow) CancelContentCmd

func (erow *ERow) CancelContentCmd()

func (*ERow) CancelInternalCmd added in v1.1.0

func (erow *ERow) CancelInternalCmd()

func (*ERow) Flash

func (erow *ERow) Flash()

UI Safe

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() error

func (*ERow) TextAreaReadWriteCloser added in v1.3.0

func (erow *ERow) TextAreaReadWriteCloser() io.ReadWriteCloser

func (*ERow) ToolbarSetStrAfterNameClearHistory

func (erow *ERow) ToolbarSetStrAfterNameClearHistory(s string)

func (*ERow) UpdateToolbarNameEncoding added in v1.3.0

func (erow *ERow) UpdateToolbarNameEncoding()

type ERowExec

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

func NewERowExec

func NewERowExec(erow *ERow) *ERowExec

func (*ERowExec) RunAsync added in v1.3.0

func (ee *ERowExec) RunAsync(fn func(context.Context, io.ReadWriter) error)

func (*ERowExec) RunAsyncWithCancel added in v1.3.8

func (ee *ERowExec) RunAsyncWithCancel(fn func(context.Context, io.ReadWriter) error) (context.Context, context.CancelFunc)

func (*ERowExec) Stop

func (ee *ERowExec) Stop()

type ERowInfo

type ERowInfo struct {
	Ed    *Editor
	ERows []*ERow // added order
	// contains filtered or unexported fields
}

Editor Row Info.

func (*ERowInfo) AddERow

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

func (*ERowInfo) CancelCmd added in v1.3.1

func (info *ERowInfo) CancelCmd()

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) FirstERow added in v1.1.1

func (info *ERowInfo) FirstERow() (*ERow, bool)

func (*ERowInfo) HandleRWEvWrite2 added in v1.3.0

func (info *ERowInfo) HandleRWEvWrite2(erow *ERow, ev *iorw.RWEvWrite2)

func (*ERowInfo) HasFileinfo

func (info *ERowInfo) HasFileinfo() bool

func (*ERowInfo) HasRowState added in v1.1.0

func (info *ERowInfo) HasRowState(st ui.RowState) 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) 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) 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 ERowTermIO added in v1.3.0

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

func NewERowTermIO added in v1.3.0

func NewERowTermIO(erow *ERow) *ERowTermIO

func (*ERowTermIO) AddToRead added in v1.3.0

func (tio *ERowTermIO) AddToRead(b []byte)

func (*ERowTermIO) Close added in v1.3.0

func (tio *ERowTermIO) Close() error

func (*ERowTermIO) Init added in v1.3.0

func (tio *ERowTermIO) Init(tf *TerminalFilter)

func (*ERowTermIO) Read added in v1.3.0

func (tio *ERowTermIO) Read(b []byte) (int, error)

func (*ERowTermIO) WriteOp added in v1.3.0

func (tio *ERowTermIO) WriteOp(op any) error

type EdAnnotationsRequester

type EdAnnotationsRequester int
const (
	EareqGoDebug EdAnnotationsRequester = iota
	EareqGoDebugStart
	EareqInlineComplete
)

type Editor

type Editor struct {
	UI                *ui.UI
	HomeVars          *HomeVars
	Watcher           fswatcher.Watcher
	RowReopener       *RowReopener
	GoDebug           *GoDebugManager
	LSProtoMan        *lsproto.Manager
	InlineComplete    *InlineComplete
	Plugins           *Plugins
	EEvents           *EEvents // editor events (used by plugins)
	FsCaseInsensitive bool     // filesystem
	// contains filtered or unexported fields
}

func (*Editor) ActiveERow

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

func (*Editor) CanModifyAnnotations

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

func (*Editor) Close

func (ed *Editor) Close()

func (*Editor) DeleteERowInfo added in v1.1.0

func (ed *Editor) DeleteERowInfo(name string)

func (*Editor) ERowInfo added in v1.1.0

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

func (*Editor) ERowInfoKey added in v1.1.0

func (ed *Editor) ERowInfoKey(name string) string

func (*Editor) ERowInfos

func (ed *Editor) ERowInfos() []*ERowInfo

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 ...any)

func (*Editor) GoodRowPos

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

func (*Editor) Message added in v1.1.0

func (ed *Editor) Message(s string)

func (*Editor) Messagef

func (ed *Editor) Messagef(f string, a ...any)

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) RunAsyncBusyCursor2 added in v1.3.8

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

Caller should call done function in the end.

func (*Editor) SetAnnotations

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

func (*Editor) SetERowInfo added in v1.1.0

func (ed *Editor) SetERowInfo(name string, info *ERowInfo)

type GDDataIndex

type GDDataIndex struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

GoDebug data Index

func NewGDDataIndex

func NewGDDataIndex(gdi *GoDebugInstance) *GDDataIndex

func (*GDDataIndex) FilesIndex

func (di *GDDataIndex) FilesIndex(name string) (int, bool)

func (*GDDataIndex) FilesIndexKey added in v1.1.0

func (di *GDDataIndex) FilesIndexKey(name string) string

type GDFileMsgs

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

func NewGDFileMsgs

func NewGDFileMsgs(n int) *GDFileMsgs

type GDMsg added in v1.3.7

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

type GDOffsetMsg added in v1.3.7

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

type GoDebugInstance

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

type GoDebugManager added in v1.3.0

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

func NewGoDebugManager added in v1.3.0

func NewGoDebugManager(ed *Editor) *GoDebugManager

func (*GoDebugManager) AnnotationFind added in v1.3.0

func (gdm *GoDebugManager) AnnotationFind(s string) error

func (*GoDebugManager) CancelAndClear added in v1.3.0

func (gdm *GoDebugManager) CancelAndClear()

func (*GoDebugManager) Printf added in v1.3.0

func (gdm *GoDebugManager) Printf(format string, args ...any)

func (*GoDebugManager) RunAsync added in v1.3.0

func (gdm *GoDebugManager) RunAsync(startCtx context.Context, erow *ERow, args []string) error

func (*GoDebugManager) SelectAnnotation added in v1.3.0

func (gdm *GoDebugManager) SelectAnnotation(rowPos *ui.RowPos, ev *ui.RootSelectAnnotationEvent)

func (*GoDebugManager) SelectERowAnnotation added in v1.3.0

func (gdm *GoDebugManager) SelectERowAnnotation(erow *ERow, ev *ui.TextAreaSelectAnnotationEvent)

func (*GoDebugManager) Trace added in v1.3.8

func (gdm *GoDebugManager) Trace() error

func (*GoDebugManager) UpdateInfoAnnotations added in v1.3.7

func (gdm *GoDebugManager) UpdateInfoAnnotations(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, caseInsensitive bool)

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
	Fn   InternalCmdFn
}

type InternalCmdArgs

type InternalCmdArgs struct {
	Cmd  *InternalCmd
	Ctx  context.Context
	Ed   *Editor
	Part *toolbarparser.Part
	// contains filtered or unexported fields
}

func (*InternalCmdArgs) ERow

func (args *InternalCmdArgs) ERow() (*ERow, bool)

func (*InternalCmdArgs) ERowOrErr added in v1.3.8

func (args *InternalCmdArgs) ERowOrErr() (*ERow, error)

type InternalCmdFn added in v1.3.0

type InternalCmdFn func(args *InternalCmdArgs) error

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 visible

	PreferedERow *ERow
}

type Options

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

	TabWidth           int
	WrapLineRune       int
	CarriageReturnRune int

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

	SessionName string
	Filenames   []string

	UseMultiKey bool

	Plugins string

	LSProtos     RegistrationsOpt
	PreSaveHooks PreSaveHooksOpt

	ZipSessionsFile bool
}

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 PreSaveHook added in v1.3.1

type PreSaveHook struct {
	Language string
	Exts     []string
	Cmd      string
}

func (*PreSaveHook) String added in v1.3.1

func (h *PreSaveHook) String() string

type PreSaveHooksOpt added in v1.3.1

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

implements flag.Value interface

func (*PreSaveHooksOpt) MustSet added in v1.3.1

func (o *PreSaveHooksOpt) MustSet(s string)

func (*PreSaveHooksOpt) Set added in v1.3.1

func (o *PreSaveHooksOpt) Set(s string) error

func (*PreSaveHooksOpt) String added in v1.3.1

func (o *PreSaveHooksOpt) String() string

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(ed *Editor, 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
}

type TerminalFilter

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

func NewTerminalFilter

func NewTerminalFilter(erow *ERow) *TerminalFilter

func NewTerminalFilter2 added in v1.3.0

func NewTerminalFilter2(tio TerminalIO, erow *ERow) *TerminalFilter

func (*TerminalFilter) Close

func (tf *TerminalFilter) Close() error

func (*TerminalFilter) Read

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

func (*TerminalFilter) Write added in v1.3.0

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

type TerminalIO added in v1.3.0

type TerminalIO interface {
	Init(tf *TerminalFilter)

	Read([]byte) (int, error) // input interface
	AddToRead([]byte)         // add input internally to be read

	WriteOp(any) error // accepted types: {[]byte,string}

	Close() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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