Add default keybindings for navigation
This commit is contained in:
parent
a5a6e1ebf6
commit
c17ca03bda
2 changed files with 22 additions and 3 deletions
19
discordo.go
19
discordo.go
|
|
@ -58,7 +58,7 @@ func main() {
|
|||
channelsTreeView = ui.NewChannelsTreeView(channelsTreeNode, onChannelsTreeViewSelected, config.Theme)
|
||||
messagesTextView = ui.NewMessagesTextView(onMessagesTextViewChanged, config.Theme)
|
||||
mainFlex = ui.NewMainFlex(guildsDropDown, channelsTreeView, messagesTextView)
|
||||
app = ui.NewApp()
|
||||
app = ui.NewApp(onAppInputCapture)
|
||||
|
||||
token := util.GetPassword("token")
|
||||
if token != "" {
|
||||
|
|
@ -76,6 +76,23 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
func onAppInputCapture(event *tcell.EventKey) *tcell.EventKey {
|
||||
switch event.Name() {
|
||||
case "Ctrl+G":
|
||||
app.SetFocus(guildsDropDown)
|
||||
case "Ctrl+J":
|
||||
app.SetFocus(channelsTreeView)
|
||||
case "Ctrl+K":
|
||||
app.SetFocus(messagesTextView)
|
||||
case "Ctrl+L":
|
||||
if messageInputField != nil {
|
||||
app.SetFocus(messageInputField)
|
||||
}
|
||||
}
|
||||
|
||||
return event
|
||||
}
|
||||
|
||||
func onMessagesTextViewChanged() {
|
||||
app.Draw()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
package ui
|
||||
|
||||
import (
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
func NewApp() *tview.Application {
|
||||
func NewApp(onAppInputCapture func(event *tcell.EventKey) *tcell.EventKey) *tview.Application {
|
||||
app := tview.NewApplication().
|
||||
EnableMouse(true)
|
||||
EnableMouse(true).
|
||||
SetInputCapture(onAppInputCapture)
|
||||
|
||||
return app
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue