Documentation ¶
Index ¶
- Variables
- func GracefulPanic(e *Editor)
- type Alignment
- 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) *Window
- func (e *Editor) RunCommand(id 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, } 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) error { return nil }, }, "normal": { Name: "Normal mode", Func: func(e *Editor) error { e.Win().Mode = "normal" return nil }, }, "write": { Name: "Write file", Func: func(e *Editor) error { panic("not implemented") }, }, "w": Alias("write"), "quit": { Name: "quit editor", Func: func(e *Editor) 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 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
func (*DumbPlugin) Update ¶
func (p *DumbPlugin) Update(e *Editor, event tcell.Event) tcell.Event
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 ¶
func (*Editor) RunCommand ¶
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 StyleSection ¶
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 Borders tcell.Color Error tcell.Style Red tcell.Color Yellow tcell.Color Pink tcell.Color Blue tcell.Color LightBlue tcell.Color Purple tcell.Color NormalModeAccent tcell.Color InsertModeAccent 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 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.