plugins
This commit is contained in:
parent
6a2171bbc6
commit
cfaaa2e84b
5 changed files with 32 additions and 32 deletions
|
|
@ -24,19 +24,19 @@ func newGuildsTree() *GuildsTree {
|
|||
root: tview.NewTreeNode(""),
|
||||
}
|
||||
|
||||
gt.SetGraphics(cfg.Theme.GuildsTree.Graphics)
|
||||
gt.SetGraphics(config.Theme.GuildsTree.Graphics)
|
||||
gt.SetRoot(gt.root)
|
||||
gt.SetTopLevel(1)
|
||||
gt.SetSelectedFunc(gt.onSelected)
|
||||
|
||||
gt.SetBackgroundColor(tcell.GetColor(cfg.Theme.GuildsTree.BackgroundColor))
|
||||
gt.SetBackgroundColor(tcell.GetColor(config.Theme.GuildsTree.BackgroundColor))
|
||||
|
||||
gt.SetTitle("Guilds")
|
||||
gt.SetTitleColor(tcell.GetColor(cfg.Theme.GuildsTree.TitleColor))
|
||||
gt.SetTitleColor(tcell.GetColor(config.Theme.GuildsTree.TitleColor))
|
||||
gt.SetTitleAlign(tview.AlignLeft)
|
||||
|
||||
padding := cfg.Theme.GuildsTree.BorderPadding
|
||||
gt.SetBorder(cfg.Theme.GuildsTree.Border)
|
||||
padding := config.Theme.GuildsTree.BorderPadding
|
||||
gt.SetBorder(config.Theme.GuildsTree.Border)
|
||||
gt.SetBorderPadding(padding[0], padding[1], padding[2], padding[3])
|
||||
|
||||
return gt
|
||||
|
|
@ -149,7 +149,7 @@ func (gt *GuildsTree) onSelected(n *tview.TreeNode) {
|
|||
gt.selectedChannel = c
|
||||
messagesText.SetTitle(gt.channelToString(*c))
|
||||
|
||||
ms, err := discordState.Messages(ref, cfg.MessagesLimit)
|
||||
ms, err := discordState.Messages(ref, config.MessagesLimit)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return
|
||||
|
|
|
|||
8
main.go
8
main.go
|
|
@ -12,9 +12,9 @@ import (
|
|||
var (
|
||||
token string
|
||||
|
||||
plugins []*Plugin
|
||||
cfg *Config
|
||||
config *Config
|
||||
discordState *State
|
||||
plugins = make(map[string]*Plugin)
|
||||
|
||||
app = tview.NewApplication()
|
||||
flex = tview.NewFlex()
|
||||
|
|
@ -41,7 +41,7 @@ func main() {
|
|||
fmt.Println(p.Name())
|
||||
}
|
||||
|
||||
cfg, err = newConfig()
|
||||
config, err = newConfig()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ func main() {
|
|||
flex.AddItem(guildsTree, 0, 1, true)
|
||||
flex.AddItem(right, 0, 4, false)
|
||||
|
||||
app.EnableMouse(cfg.Mouse)
|
||||
app.EnableMouse(config.Mouse)
|
||||
app.SetRoot(flex, true)
|
||||
|
||||
err = app.Run()
|
||||
|
|
|
|||
|
|
@ -23,14 +23,14 @@ func newMessageInput() *MessageInput {
|
|||
}
|
||||
|
||||
mi.SetInputCapture(mi.onInputCapture)
|
||||
mi.SetFieldBackgroundColor(tcell.GetColor(cfg.Theme.MessageInput.BackgroundColor))
|
||||
mi.SetBackgroundColor(tcell.GetColor(cfg.Theme.MessageInput.BackgroundColor))
|
||||
mi.SetFieldBackgroundColor(tcell.GetColor(config.Theme.MessageInput.BackgroundColor))
|
||||
mi.SetBackgroundColor(tcell.GetColor(config.Theme.MessageInput.BackgroundColor))
|
||||
|
||||
mi.SetTitleColor(tcell.GetColor(cfg.Theme.MessageInput.TitleColor))
|
||||
mi.SetTitleColor(tcell.GetColor(config.Theme.MessageInput.TitleColor))
|
||||
mi.SetTitleAlign(tview.AlignLeft)
|
||||
|
||||
padding := cfg.Theme.MessageInput.BorderPadding
|
||||
mi.SetBorder(cfg.Theme.MessageInput.Border)
|
||||
padding := config.Theme.MessageInput.BorderPadding
|
||||
mi.SetBorder(config.Theme.MessageInput.Border)
|
||||
mi.SetBorderPadding(padding[0], padding[1], padding[2], padding[3])
|
||||
|
||||
return mi
|
||||
|
|
@ -43,13 +43,13 @@ func (mi *MessageInput) reset() {
|
|||
|
||||
func (mi *MessageInput) onInputCapture(event *tcell.EventKey) *tcell.EventKey {
|
||||
switch event.Name() {
|
||||
case cfg.Keys.MessageInput.Send:
|
||||
case config.Keys.MessageInput.Send:
|
||||
mi.sendAction()
|
||||
return nil
|
||||
case cfg.Keys.MessageInput.LaunchEditor:
|
||||
case config.Keys.MessageInput.LaunchEditor:
|
||||
messageInput.launchEditorAction()
|
||||
return nil
|
||||
case cfg.Keys.MessageInput.Cancel:
|
||||
case config.Keys.MessageInput.Cancel:
|
||||
mi.reset()
|
||||
return nil
|
||||
}
|
||||
|
|
@ -93,7 +93,7 @@ func (mi *MessageInput) sendAction() {
|
|||
}
|
||||
|
||||
func (mi *MessageInput) launchEditorAction() {
|
||||
e := cfg.Editor
|
||||
e := config.Editor
|
||||
if e == "default" {
|
||||
e = os.Getenv("EDITOR")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,14 +35,14 @@ func newMessagesText() *MessagesText {
|
|||
app.Draw()
|
||||
})
|
||||
|
||||
mt.SetBackgroundColor(tcell.GetColor(cfg.Theme.MessagesText.BackgroundColor))
|
||||
mt.SetBackgroundColor(tcell.GetColor(config.Theme.MessagesText.BackgroundColor))
|
||||
|
||||
mt.SetTitle("Messages")
|
||||
mt.SetTitleColor(tcell.GetColor(cfg.Theme.MessagesText.TitleColor))
|
||||
mt.SetTitleColor(tcell.GetColor(config.Theme.MessagesText.TitleColor))
|
||||
mt.SetTitleAlign(tview.AlignLeft)
|
||||
|
||||
padding := cfg.Theme.MessagesText.BorderPadding
|
||||
mt.SetBorder(cfg.Theme.MessagesText.Border)
|
||||
padding := config.Theme.MessagesText.BorderPadding
|
||||
mt.SetBorder(config.Theme.MessagesText.Border)
|
||||
mt.SetBorderPadding(padding[0], padding[1], padding[2], padding[3])
|
||||
|
||||
return mt
|
||||
|
|
@ -71,7 +71,7 @@ func (mt *MessagesText) createMessage(m *discord.Message) error {
|
|||
mt.buf.WriteByte(' ')
|
||||
|
||||
mt.buf.WriteByte('[')
|
||||
mt.buf.WriteString(cfg.Theme.MessagesText.AuthorColor)
|
||||
mt.buf.WriteString(config.Theme.MessagesText.AuthorColor)
|
||||
mt.buf.WriteByte(']')
|
||||
mt.buf.WriteString(m.Author.Username)
|
||||
mt.buf.WriteString("[-] ")
|
||||
|
|
@ -95,12 +95,12 @@ func (mt *MessagesText) createMessage(m *discord.Message) error {
|
|||
|
||||
func (mt *MessagesText) createHeader(m *discord.Message) {
|
||||
mt.buf.WriteByte('[')
|
||||
mt.buf.WriteString(cfg.Theme.MessagesText.AuthorColor)
|
||||
mt.buf.WriteString(config.Theme.MessagesText.AuthorColor)
|
||||
mt.buf.WriteByte(']')
|
||||
mt.buf.WriteString(m.Author.Username)
|
||||
mt.buf.WriteString("[-] ")
|
||||
|
||||
if cfg.Timestamps {
|
||||
if config.Timestamps {
|
||||
mt.buf.WriteString("[::d]")
|
||||
mt.buf.WriteString(m.Timestamp.Format(time.Kitchen))
|
||||
mt.buf.WriteString("[::-] ")
|
||||
|
|
@ -144,19 +144,19 @@ func (mt *MessagesText) onHighlighted(added, removed, remaining []string) {
|
|||
|
||||
func (mt *MessagesText) onInputCapture(event *tcell.EventKey) *tcell.EventKey {
|
||||
switch event.Name() {
|
||||
case cfg.Keys.MessagesText.Reply:
|
||||
case config.Keys.MessagesText.Reply:
|
||||
mt.replyAction(false)
|
||||
return nil
|
||||
case cfg.Keys.MessagesText.ReplyMention:
|
||||
case config.Keys.MessagesText.ReplyMention:
|
||||
mt.replyAction(true)
|
||||
return nil
|
||||
case cfg.Keys.MessagesText.SelectPrevious:
|
||||
case config.Keys.MessagesText.SelectPrevious:
|
||||
mt.selectPreviousAction()
|
||||
return nil
|
||||
case cfg.Keys.MessagesText.SelectNext:
|
||||
case config.Keys.MessagesText.SelectNext:
|
||||
mt.selectNextAction()
|
||||
return nil
|
||||
case cfg.Keys.MessagesText.Cancel:
|
||||
case config.Keys.MessagesText.Cancel:
|
||||
guildsTree.selectedChannel = nil
|
||||
|
||||
messagesText.reset()
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ func loadPlugins() error {
|
|||
return err
|
||||
}
|
||||
|
||||
plugins = append(plugins, p)
|
||||
plugins[p.Name()] = p
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue