mirror of
https://github.com/boolean-maybe/tiki
synced 2026-04-21 13:37:20 +00:00
111 lines
3.3 KiB
Go
111 lines
3.3 KiB
Go
package plugin
|
|
|
|
import (
|
|
"github.com/gdamore/tcell/v2"
|
|
|
|
"github.com/boolean-maybe/tiki/config"
|
|
"github.com/boolean-maybe/tiki/ruki"
|
|
)
|
|
|
|
// Plugin interface defines the common methods for all plugins
|
|
type Plugin interface {
|
|
GetName() string
|
|
GetDescription() string
|
|
GetActivationKey() (tcell.Key, rune, tcell.ModMask)
|
|
GetFilePath() string
|
|
GetConfigIndex() int
|
|
GetType() string
|
|
IsDefault() bool
|
|
}
|
|
|
|
// BasePlugin holds the common fields for all plugins
|
|
type BasePlugin struct {
|
|
Name string // display name shown in caption
|
|
Description string // short description shown in header info section
|
|
Key tcell.Key // tcell key constant (e.g. KeyCtrlH)
|
|
Rune rune // printable character (e.g. 'L')
|
|
Modifier tcell.ModMask // modifier keys (Alt, Shift, Ctrl, etc.)
|
|
Foreground config.Color // caption text color
|
|
Background config.Color // caption background color
|
|
FilePath string // source file path (for error messages)
|
|
ConfigIndex int // index in workflow.yaml views array (-1 if not from a config file)
|
|
Type string // plugin type: "tiki" or "doki"
|
|
Default bool // true if this view should open on startup
|
|
}
|
|
|
|
func (p *BasePlugin) GetName() string {
|
|
return p.Name
|
|
}
|
|
|
|
func (p *BasePlugin) GetDescription() string {
|
|
return p.Description
|
|
}
|
|
|
|
func (p *BasePlugin) GetActivationKey() (tcell.Key, rune, tcell.ModMask) {
|
|
return p.Key, p.Rune, p.Modifier
|
|
}
|
|
|
|
func (p *BasePlugin) GetFilePath() string {
|
|
return p.FilePath
|
|
}
|
|
|
|
func (p *BasePlugin) GetConfigIndex() int {
|
|
return p.ConfigIndex
|
|
}
|
|
|
|
func (p *BasePlugin) GetType() string {
|
|
return p.Type
|
|
}
|
|
|
|
func (p *BasePlugin) IsDefault() bool {
|
|
return p.Default
|
|
}
|
|
|
|
// TikiPlugin is a task-based plugin (like default Kanban board)
|
|
type TikiPlugin struct {
|
|
BasePlugin
|
|
Lanes []TikiLane // lane definitions for this plugin
|
|
ViewMode string // default view mode: "compact" or "expanded" (empty = compact)
|
|
Actions []PluginAction // shortcut actions applied to the selected task
|
|
TaskID string // optional tiki associated with this plugin (code-only, not from workflow config)
|
|
}
|
|
|
|
// DokiPlugin is a documentation-based plugin
|
|
type DokiPlugin struct {
|
|
BasePlugin
|
|
Fetcher string // "file" or "internal"
|
|
Text string // content text (for internal)
|
|
URL string // resource URL (for file)
|
|
}
|
|
|
|
// PluginActionConfig represents a shortcut action in YAML or config definitions.
|
|
type PluginActionConfig struct {
|
|
Key string `yaml:"key" mapstructure:"key"`
|
|
Label string `yaml:"label" mapstructure:"label"`
|
|
Action string `yaml:"action" mapstructure:"action"`
|
|
}
|
|
|
|
// PluginAction represents a parsed shortcut action bound to a key.
|
|
type PluginAction struct {
|
|
Rune rune
|
|
Label string
|
|
Action *ruki.ValidatedStatement
|
|
}
|
|
|
|
// PluginLaneConfig represents a lane in YAML or config definitions.
|
|
type PluginLaneConfig struct {
|
|
Name string `yaml:"name" mapstructure:"name"`
|
|
Columns int `yaml:"columns" mapstructure:"columns"`
|
|
Width int `yaml:"width" mapstructure:"width"`
|
|
Filter string `yaml:"filter" mapstructure:"filter"`
|
|
Action string `yaml:"action" mapstructure:"action"`
|
|
}
|
|
|
|
// TikiLane represents a parsed lane definition.
|
|
type TikiLane struct {
|
|
Name string
|
|
Columns int
|
|
Width int // lane width as a percentage (0 = equal share of remaining space)
|
|
Filter *ruki.ValidatedStatement
|
|
Action *ruki.ValidatedStatement
|
|
}
|