@@ -21,7 +21,6 @@ import (
2121 "strings"
2222 "sync"
2323 "time"
24- "unicode/utf8"
2524)
2625
2726const (
9089
9190 currentScreenWidth int
9291 currentScreenHeight int
93- screenOffsetX int
9492)
9593
9694type StyleConfig struct {
@@ -381,20 +379,7 @@ Use --show-panels to show all available panels.`,
381379 close (exit )
382380 return nil
383381 }
384-
385- if ev .Key () == tcell .KeyLeft {
386- if screenOffsetX > 0 {
387- screenOffsetX --
388- if err := refresh (screen , dataFetcher , parsedLayout , false ); err != nil {
389- panic (err )
390- }
391- }
392- } else if ev .Key () == tcell .KeyRight {
393- screenOffsetX ++
394- if err := refresh (screen , dataFetcher , parsedLayout , false ); err != nil {
395- panic (err )
396- }
397- } else if pressedKey == '?' {
382+ if pressedKey == '?' {
398383 showHelp (screen )
399384 if err := refresh (screen , dataFetcher , parsedLayout , true ); err != nil {
400385 panic (err )
@@ -423,7 +408,6 @@ Use --show-panels to show all available panels.`,
423408 (pressedKey >= 'a' && pressedKey <= 'z' && pressedKey <= lastPanelCode ) {
424409 updateExpanded (pressedKey , screen , dataFetcher , parsedLayout )
425410 }
426-
427411 }
428412 }
429413 },
@@ -620,19 +604,16 @@ func refresh(screen tcell.Screen, dataFetcher fetcher.Fetcher, parsedLayout []st
620604func showHelp (screen tcell.Screen ) {
621605 help := []string {
622606 "" ,
623- " Monitor Cluster CLI Help " ,
607+ " Monitor Cluster CLI Help " ,
624608 "" ,
625- " - 'p' toggle panel row padding" ,
626- " - '+' increase max height of all panels" ,
627- " - '-' decrease max height of all panels" ,
628- " - '0' reset max height of all panels" ,
629- " - '->' scroll right in text" ,
630- " - '<-' scroll left in text" ,
631- " " ,
632- " - Key in [] to expand that panel" ,
633- " - ESC / CTRL-C to exit monitoring" ,
609+ " - 'p' to toggle panel row padding" ,
610+ " - '+' to increase max height of all panels" ,
611+ " - '-' to decrease max height of all panels" ,
612+ " - '0' to reset max height of all panels" ,
613+ " - Key in [] to expand that panel" ,
614+ " - ESC / CTRL-C to exit monitoring" ,
634615 " " ,
635- " Press any key to exit help." ,
616+ " Press any key to exit help." ,
636617 }
637618
638619 inHelp = true
@@ -644,10 +625,10 @@ func showHelp(screen tcell.Screen) {
644625 x := currentScreenWidth / 2 - 25
645626 y := currentScreenHeight / 2 - lenHelp
646627
647- drawBox (screen , x , y , x + 50 , y + lenHelp + 2 , boxStyle , "Help" )
628+ drawBox (screen , x , y , x + 53 , y + lenHelp + 2 , boxStyle , "Help" )
648629
649630 for line := 1 ; line <= lenHelp ; line ++ {
650- drawText (screen , x + 1 , y + line , x + currentScreenWidth - 1 , y + currentScreenHeight - 1 , textStyle , help [line - 1 ], true )
631+ drawText (screen , x + 1 , y + line , x + currentScreenWidth - 1 , y + currentScreenHeight - 1 , textStyle , help [line - 1 ])
651632 }
652633 screen .Show ()
653634 _ = screen .PollEvent ()
@@ -1662,7 +1643,6 @@ func drawHeader(screen tcell.Screen, w, h int, cluster config.Cluster, dataFetch
16621643 title string
16631644 padding = " "
16641645 height = "0"
1665- scroll = "S0 "
16661646 )
16671647 if cluster .ClusterName == "" && ignoreRESTErrors {
16681648 title = errorContent + " from " + dataFetcher .GetURL ()
@@ -1676,73 +1656,43 @@ func drawHeader(screen tcell.Screen, w, h int, cluster config.Cluster, dataFetch
16761656 } else if heightAdjust > 0 {
16771657 height = fmt .Sprintf ("+%v " , heightAdjust )
16781658 }
1679-
1680- if screenOffsetX > 0 {
1681- scroll = fmt .Sprintf ("S+%v " , screenOffsetX )
1682- }
1683-
1684- title = fmt .Sprintf ("Coherence CLI: %s - %s %s %s ESC to quit. %s %s%s(%v)" ,
1685- time .Now ().Format (time .DateTime ), cluster .ClusterName , version [0 ], additionalMonitorMsg , padding , height , scroll , lastDuration )
1659+ title = fmt .Sprintf ("Coherence CLI: %s - %s (%s) ESC to quit %s. %s%s(%v)" ,
1660+ time .Now ().Format (time .DateTime ), cluster .ClusterName , version [0 ], additionalMonitorMsg , padding , height , lastDuration )
16861661 titleLen := len (title )
16871662 if titleLen < w - 2 {
16881663 title = fmt .Sprintf ("%s%-*s" , title , w - titleLen - 2 , " " )
16891664 }
16901665 }
1691- drawText (screen , 1 , 0 , w - 1 , h - 1 , textStyle .Reverse (true ), title , true )
1666+ drawText (screen , 1 , 0 , w - 1 , h - 1 , textStyle .Reverse (true ), title )
16921667}
16931668
16941669// drawText draws text on the screen.
1695- func drawText (s tcell.Screen , x1 , y1 , x2 , y2 int , style tcell.Style , text string , header ... bool ) {
1696- var scrollX = screenOffsetX
1697-
1698- if len (header ) > 0 && header [0 ] {
1699- scrollX = 0
1700- }
1701-
1670+ func drawText (s tcell.Screen , x1 , y1 , x2 , y2 int , style tcell.Style , text string ) {
17021671 row := y1
17031672 col := x1
17041673 currentStyle := style
17051674
1706- visibleCols := x2 - x1
1707- displayedCols := 0
1708- charsSkipped := 0
1709-
1710- for i := 0 ; i < len (text ); {
1711- // Handle control characters
1712- switch text [i ] {
1675+ for _ , r := range text {
1676+ switch r {
17131677 case '\x01' : // startRed
17141678 currentStyle = currentStyle .Foreground (tcell .ColorRed )
1715- i ++
17161679 continue
17171680 case '\x02' : // startYellow
17181681 currentStyle = currentStyle .Foreground (tcell .ColorYellow )
1719- i ++
17201682 continue
1721- case '\x03' : // end color
1683+ case '\x03' : // endColor
1684+ // Reset to the originally passed style
17221685 currentStyle = style
1723- i ++
17241686 continue
17251687 }
17261688
1727- // Decode the next rune
1728- r , size := utf8 .DecodeRuneInString (text [i :])
1729- i += size
1730-
1731- if charsSkipped < scrollX {
1732- charsSkipped ++
1733- continue
1734- }
1735-
1736- // Draw the character
17371689 s .SetContent (col , row , r , nil , currentStyle )
17381690 col ++
1739- displayedCols ++
1740-
17411691 if col >= x2 {
17421692 row ++
17431693 col = x1
17441694 }
1745- if row > y2 || displayedCols >= visibleCols {
1695+ if row > y2 {
17461696 break
17471697 }
17481698 }
@@ -1780,7 +1730,7 @@ func drawBox(s tcell.Screen, x1, y1, x2, y2 int, style tcell.Style, title string
17801730 s .SetContent (x2 , y2 , tcell .RuneLRCorner , nil , style )
17811731 }
17821732
1783- drawText (s , x1 + 2 , y1 , x2 - 1 , y2 - 1 , titleStyle , title , true )
1733+ drawText (s , x1 + 2 , y1 , x2 - 1 , y2 - 1 , titleStyle , title )
17841734}
17851735
17861736// getValidPanelTypes returns the list of panels for the --help command.
0 commit comments