Remove treeview search logic, since it is now a part of tview
MODIFY
internal/syntax/formatter.go
internal/syntax/formatter.go
@@ -168,7 +168,7 @@ var ttyTables = map[int]*ttyTable{
}
func entryToEscapeSequence(table *ttyTable, entry chroma.StyleEntry) string {
- out := ""
+ var out string
if entry.Colour.IsSet() {
out += table.foreground[findClosest(table, entry.Colour)]
}

MODIFY
internal/ui/tview/treeview/treeview.go
internal/ui/tview/treeview/treeview.go
package treeview
import (
- "strings"
- "time"
-
"github.com/Bios-Marcel/tview"
"github.com/gdamore/tcell"
)
@@ -30,48 +27,3 @@ func CreateFocusTextViewOnTypeInputHandler(treeView *tview.Box, app *tview.Appli
return eventHandler
}
-
-func CreateSearchOnTypeInuptHandler(treeView *tview.TreeView, rootNode *tview.TreeNode, jumpTime *time.Time, jumpBuffer *string) func(event *tcell.EventKey) *tcell.EventKey {
- var traversalFunction func(node *tview.TreeNode) bool
- traversalFunction = func(node *tview.TreeNode) bool {
- if len(node.GetChildren()) > 0 {
- for _, subNode := range node.GetChildren() {
- returnValue := traversalFunction(subNode)
- if returnValue {
- return true
- }
- }
- } else if node.IsSelectable() {
- if strings.HasPrefix(strings.ToLower(node.GetText()), *jumpBuffer) {
- treeView.SetCurrentNode(node)
- return true
- }
- }
-
- return false
- }
-
- eventHandler := func(event *tcell.EventKey) *tcell.EventKey {
- if time.Since(*jumpTime) > (500 * time.Millisecond) {
- *jumpBuffer = ""
- }
-
- *jumpTime = time.Now()
-
- if event.Rune() != 0 {
- *jumpBuffer += string(event.Rune())
- *jumpBuffer = strings.ToLower(*jumpBuffer)
-
- for _, node := range rootNode.GetChildren() {
- stopIterating := traversalFunction(node)
- if stopIterating {
- return nil
- }
- }
- }
-
- return event
- }
-
- return eventHandler
-}

MODIFY
internal/ui/window.go
internal/ui/window.go
@@ -529,24 +529,10 @@ func NewWindow(doRestart chan bool, app *tview.Application, discord *discordgo.S
window.userList = NewUserTree(window.session.State)
if config.GetConfig().OnTypeInListBehaviour == config.SearchOnTypeInList {
- var guildJumpBuffer string
- var guildJumpTime time.Time
- guildList.SetInputCapture(treeview.CreateSearchOnTypeInuptHandler(
- guildList, guildRootNode, &guildJumpTime, &guildJumpBuffer))
- var channelJumpBuffer string
- var channelJumpTime time.Time
- channelTree.internalTreeView.SetInputCapture(treeview.CreateSearchOnTypeInuptHandler(
- channelTree.internalTreeView, channelTree.internalTreeView.GetRoot(),
- &channelJumpTime, &channelJumpBuffer))
- var userJumpBuffer string
- var userJumpTime time.Time
- window.userList.SetInputCapture(treeview.CreateSearchOnTypeInuptHandler(
- window.userList.internalTreeView, window.userList.rootNode, &userJumpTime, &userJumpBuffer))
- var privateJumpBuffer string
- var privateJumpTime time.Time
- window.privateList.SetInputCapture(treeview.CreateSearchOnTypeInuptHandler(
- window.privateList.GetComponent(), window.privateList.internalTreeView.GetRoot(),
- &privateJumpTime, &privateJumpBuffer))
+ guildList.SetSearchOnTypeEnabled(true)
+ channelTree.internalTreeView.SetSearchOnTypeEnabled(true)
+ window.userList.internalTreeView.SetSearchOnTypeEnabled(true)
+ window.privateList.internalTreeView.SetSearchOnTypeEnabled(true)
} else if config.GetConfig().OnTypeInListBehaviour == config.FocusMessageInputOnTypeInList {
guildList.SetInputCapture(treeview.CreateFocusTextViewOnTypeInputHandler(
guildList.Box, window.app, window.messageInput.internalTextView))

Remove treeview search logic, since it is now a part of tview