Documentation
¶
Index ¶
- Variables
- func GracefulPanic(e *Editor)
- type Alignment
- type CharInsertedEvent
- type Command
- type CommandBarEvent
- type CommandFunc
- type DumbPlugin
- type Editor
- func (e *Editor) Buf() buffer.Buffer
- func (e *Editor) Draw() error
- func (e *Editor) FocusWindow(id string) error
- func (e *Editor) GetWindow(id string) *Window
- func (e *Editor) RegisterCommandMap(cmds map[string]Command)
- func (e *Editor) RegisterKeymap(keymap humankey.HumanKeymap) error
- func (e *Editor) RegisterThemeMap(themes map[string]Theme)
- func (e *Editor) RegisterWindow(w Window)
- func (e *Editor) RunCommand(id string, args ...string) error
- func (e *Editor) Setup()
- func (e *Editor) Tab() *Tab
- func (e *Editor) Update() error
- func (e *Editor) Win() *Window
- type EventCaught
- type FemtoError
- type Plugin
- type PluginInfo
- type StyleSection
- type Tab
- type Theme
- type Window
- type WindowFlags
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoKeyAssociated = FemtoError{ Message: "no key associated with pressed key", LogLevel: slog.LevelWarn, } ErrNoCommandFound = FemtoError{ Message: "no command found", LogLevel: slog.LevelError, } ErrArgumentMissing = FemtoError{ Message: "argument missing", LogLevel: slog.LevelError, } ErrKeyUnparsable = FemtoError{ Message: "Cannot parse key", LogLevel: slog.LevelError, } ErrNoWindowFoundForId = FemtoError{ Message: "command not found", LogLevel: slog.LevelError, } )
View Source
var Commands = map[string]Command{ "noop": { Name: "no operation", Func: func(e *Editor, args ...string) error { return nil }, }, "normal": { Name: "Normal mode", Func: func(e *Editor, args ...string) error { e.Win().Mode = "normal" return nil }, }, "quit": { Name: "quit editor", Func: func(e *Editor, args ...string) error { e.Screen.Fini() os.Exit(0) return nil }, }, "q": Alias("quit"), }
Functions ¶
func GracefulPanic ¶
func GracefulPanic(e *Editor)
Panicking without finalizing the screen causes really weird behaviour, So defer this at the top of every main loop function (not for plugins)
Types ¶
type CharInsertedEvent ¶
type CharInsertedEvent struct {
Rune rune
// contains filtered or unexported fields
}
func (*CharInsertedEvent) When ¶
func (c *CharInsertedEvent) When() time.Time
type Command ¶
type Command struct {
Name string
Description string // if empty, takes the Name as Description
Public bool // if public, can be executed in command mode
Func CommandFunc
}
type CommandBarEvent ¶
func (*CommandBarEvent) When ¶
func (c *CommandBarEvent) When() time.Time
type CommandFunc ¶
type DumbPlugin ¶
type DumbPlugin struct {
Info PluginInfo
Commands map[string]Command // if it's a third party plugin, please prefix Commands with your plugin id
Keymap humankey.HumanKeymap
Themes map[string]Theme
}
A plugin that only has a Startup function, and can contribute Commands and Keymap
ideally only use **this**, unless you REALLY need to access the main loop
func (*DumbPlugin) Draw ¶
func (p *DumbPlugin) Draw(e *Editor) error
func (*DumbPlugin) GetInfo ¶
func (p *DumbPlugin) GetInfo() PluginInfo
func (*DumbPlugin) Startup ¶
func (p *DumbPlugin) Startup(e *Editor) error
type Editor ¶
type Editor struct {
Tabs []Tab
TabId int
Keymap humankey.InternalKeymap
Commands map[string]Command
Plugins []Plugin
Themes map[string]Theme
Theme Theme // for simplicity's (and performance) sake, since we won't change theme often, we don't save the id but just the theme itself here
Screen tcell.Screen
Windows []Window
FocusedWindowIndex int // if set to something that isn't -1, overrides the Tab's CurrentWindowId
}
func (*Editor) FocusWindow ¶
func (*Editor) RegisterCommandMap ¶
func (*Editor) RegisterKeymap ¶
func (e *Editor) RegisterKeymap(keymap humankey.HumanKeymap) error
func (*Editor) RegisterThemeMap ¶
func (*Editor) RegisterWindow ¶
type EventCaught ¶
type EventCaught struct {
// contains filtered or unexported fields
}
func (*EventCaught) When ¶
func (c *EventCaught) When() time.Time
type FemtoError ¶
func (FemtoError) Context ¶
func (f FemtoError) Context(msg string) FemtoError
func (FemtoError) Error ¶
func (f FemtoError) Error() string
type Tab ¶
func (*Tab) FocusWindow ¶
Side effect: this also sets editor's FocusedWindowIndex to -1 if a window is found
func (*Tab) RegisterWindow ¶
type Theme ¶
type Theme struct {
Name string
Default tcell.Style
SelectionBG tcell.Color
Borders tcell.Color
Error tcell.Style
Warn tcell.Style
Red tcell.Color
Green tcell.Color
Yellow tcell.Color
Pink tcell.Color
Blue tcell.Color
LightBlue tcell.Color
Purple tcell.Color
NormalModeAccent tcell.Color
InsertModeAccent tcell.Color
VisualModeAccent tcell.Color
}
type Window ¶
type Window struct {
Id string
Alignment Alignment
Size int
Priority int
Shown bool
Flags WindowFlags
// buffer stuff
Buffer buffer.Buffer // to implement interactivity, you just need to make a type InteractiveBuffer and runtime check if its that typ
Selection femath.Range2
Title string // used so scratchpads can have a name in the statusbar
FilePath string // if left empty, will treat buffer as scratchpad
Mode string
Sequence []humankey.InternalKey
StyleSections []StyleSection
BorderStyle tcell.Style
Keymap humankey.HumanKeymap // keymaps that only work here. override editor global keymap
Commands map[string]Command // commands that only work here. overrides editor global commands
}
type WindowFlags ¶
type WindowFlags uint8
const ( WindowFlagReadonly WindowFlags = 1 WindowFlagInteractive WindowFlags = 2 WindowFlagHasBorder WindowFlags = 4 WindowFlagUnfocusable WindowFlags = 8 )
Click to show internal directories.
Click to hide internal directories.