|
@@ -1,37 +1,17 @@
|
|
|
package main
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
- "github.com/ayntgl/discordgo"
|
|
|
|
|
- "github.com/gdamore/tcell/v2"
|
|
|
|
|
"github.com/rivo/tview"
|
|
"github.com/rivo/tview"
|
|
|
"github.com/zalando/go-keyring"
|
|
"github.com/zalando/go-keyring"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
const service = "discordo"
|
|
const service = "discordo"
|
|
|
|
|
|
|
|
-var (
|
|
|
|
|
- app *tview.Application
|
|
|
|
|
- loginForm *tview.Form
|
|
|
|
|
- guildsTreeView *tview.TreeView
|
|
|
|
|
- messagesTextView *tview.TextView
|
|
|
|
|
- messageInputField *tview.InputField
|
|
|
|
|
- mainFlex *tview.Flex
|
|
|
|
|
-
|
|
|
|
|
- conf *config
|
|
|
|
|
- session *discordgo.Session
|
|
|
|
|
- selectedChannel *discordgo.Channel
|
|
|
|
|
- selectedMessage *discordgo.Message
|
|
|
|
|
-)
|
|
|
|
|
-
|
|
|
|
|
func main() {
|
|
func main() {
|
|
|
conf = loadConfig()
|
|
conf = loadConfig()
|
|
|
tview.Styles = conf.Theme
|
|
tview.Styles = conf.Theme
|
|
|
|
|
|
|
|
- app = tview.NewApplication()
|
|
|
|
|
- app.
|
|
|
|
|
- EnableMouse(conf.Mouse).
|
|
|
|
|
- SetInputCapture(onAppInputCapture)
|
|
|
|
|
-
|
|
|
|
|
|
|
+ app = newApplication()
|
|
|
guildsTreeView = newGuildsTreeView()
|
|
guildsTreeView = newGuildsTreeView()
|
|
|
messagesTextView = newMessagesTextView()
|
|
messagesTextView = newMessagesTextView()
|
|
|
messageInputField = newMessageInputField()
|
|
messageInputField = newMessageInputField()
|
|
@@ -70,19 +50,6 @@ func main() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func onAppInputCapture(e *tcell.EventKey) *tcell.EventKey {
|
|
|
|
|
- switch e.Name() {
|
|
|
|
|
- case conf.Keybindings.GuildsTreeViewFocus:
|
|
|
|
|
- app.SetFocus(guildsTreeView)
|
|
|
|
|
- case conf.Keybindings.MessagesTextViewFocus:
|
|
|
|
|
- app.SetFocus(messagesTextView)
|
|
|
|
|
- case conf.Keybindings.MessageInputFieldFocus:
|
|
|
|
|
- app.SetFocus(messageInputField)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return e
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
func onLoginFormLoginButtonSelected() {
|
|
func onLoginFormLoginButtonSelected() {
|
|
|
email := loginForm.GetFormItem(0).(*tview.InputField).GetText()
|
|
email := loginForm.GetFormItem(0).(*tview.InputField).GetText()
|
|
|
password := loginForm.GetFormItem(1).(*tview.InputField).GetText()
|
|
password := loginForm.GetFormItem(1).(*tview.InputField).GetText()
|