Skip to content

Commit

Permalink
Delete unnecessary string Rune[ and ] in keymap
Browse files Browse the repository at this point in the history
  • Loading branch information
ymtdzzz committed Jul 2, 2024
1 parent 9f040c6 commit 862bc60
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tuiexporter/internal/tui/component/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package component

import (
"log"
"regexp"
"strings"

"github.com/gdamore/tcell/v2"
Expand All @@ -17,6 +18,8 @@ const (
PAGE_DEBUG_LOG = "DebugLog"
)

var keyMapRegex = regexp.MustCompile(`Rune|\[|\]`)

type KeyMaps map[tcell.EventKey]string

type TUIPages struct {
Expand Down Expand Up @@ -179,7 +182,7 @@ func (p *TUIPages) createTracePage(store *telemetry.Store) *tview.Flex {
*tcell.NewEventKey(tcell.KeyRune, '/', tcell.ModNone): "Search traces",
*tcell.NewEventKey(tcell.KeyEsc, ' ', tcell.ModNone): "(search) Cancel",
*tcell.NewEventKey(tcell.KeyEnter, ' ', tcell.ModNone): "(search) Confirm",
*tcell.NewEventKey(tcell.KeyCtrlL, ' ', tcell.ModNone): "Clear all data",
*tcell.NewEventKey(tcell.KeyRune, 'L', tcell.ModCtrl): "Clear all data",
})
page = attatchTab(page, PAGE_TRACES)

Expand Down Expand Up @@ -343,7 +346,7 @@ func (p *TUIPages) createLogPage(store *telemetry.Store) *tview.Flex {
*tcell.NewEventKey(tcell.KeyRune, '/', tcell.ModNone): "Search logs",
*tcell.NewEventKey(tcell.KeyEsc, ' ', tcell.ModNone): "(search) Cancel",
*tcell.NewEventKey(tcell.KeyEnter, ' ', tcell.ModNone): "(search) Confirm",
*tcell.NewEventKey(tcell.KeyCtrlL, ' ', tcell.ModNone): "Clear all data",
*tcell.NewEventKey(tcell.KeyRune, 'L', tcell.ModCtrl): "Clear all data",
*tcell.NewEventKey(tcell.KeyRune, 'y', tcell.ModNone): "Copy Log to clipboard",
})
pageContainer = attatchTab(pageContainer, PAGE_LOGS)
Expand Down Expand Up @@ -389,7 +392,7 @@ func attatchTab(p tview.Primitive, name string) *tview.Flex {
func attatchCommandList(p tview.Primitive, keys KeyMaps) *tview.Flex {
keytexts := []string{}
for k, v := range keys {
keytexts = append(keytexts, k.Name()+": "+v)
keytexts = append(keytexts, keyMapRegex.ReplaceAllString(k.Name(), "")+": "+v)
}

command := tview.NewTextView().SetText(strings.Join(keytexts, ", "))
Expand Down

0 comments on commit 862bc60

Please sign in to comment.