mirror of https://github.com/miguelmota/cointop
toggle help menu
Former-commit-id: d9aad64fd3087c6789de73a7946a16caad9c7fc2 [formerly d9aad64fd3087c6789de73a7946a16caad9c7fc2 [formerly 0fd056c846092e8310cab5dd042e927e8fca74d6 [formerly b3f6d2ec560622cede5c81658302154814f02d9b]]] Former-commit-id: f4da4cdd33244f486f2e29355a20c0b011718518 Former-commit-id: 31cc38d2450cbef3401a1183b1b0519d0043a9de [formerly f8ecf5b286c93e0672058008c9a9651919107633] Former-commit-id: 526df3564e2949dfb4d16f36736fa32a5ef95919pull/15/head
parent
9f7977a065
commit
7b5b39a9e7
@ -1,6 +1,53 @@
|
||||
package cointop
|
||||
|
||||
func (ct *Cointop) openHelp() error {
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/miguelmota/cointop/pkg/pad"
|
||||
)
|
||||
|
||||
func (ct *Cointop) toggleHelp() error {
|
||||
ct.helpvisible = !ct.helpvisible
|
||||
if ct.helpvisible {
|
||||
return ct.showHelp()
|
||||
}
|
||||
return ct.hideHelp()
|
||||
}
|
||||
|
||||
func (ct *Cointop) updateHelp() {
|
||||
str := fmt.Sprintf(" Help %s\n\n", pad.Left("[x] exit", ct.maxtablewidth-11, " "))
|
||||
i := 0
|
||||
for k, v := range ct.shortcutkeys {
|
||||
nl := " "
|
||||
i = i + 1
|
||||
if i%3 == 0 {
|
||||
i = 0
|
||||
nl = "\n"
|
||||
}
|
||||
str = fmt.Sprintf("%s%10s %-40s%s", str, fmt.Sprintf("[%s]", k), v, nl)
|
||||
}
|
||||
|
||||
ct.update(func() {
|
||||
ct.helpview.Clear()
|
||||
ct.helpview.Frame = true
|
||||
fmt.Fprintln(ct.helpview, str)
|
||||
})
|
||||
}
|
||||
|
||||
func (ct *Cointop) showHelp() error {
|
||||
ct.helpvisible = true
|
||||
ct.updateHelp()
|
||||
ct.setActiveView("help")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ct *Cointop) hideHelp() error {
|
||||
ct.helpvisible = false
|
||||
ct.setViewOnBottom("help")
|
||||
ct.update(func() {
|
||||
ct.helpview.Clear()
|
||||
ct.helpview.Frame = false
|
||||
fmt.Fprintln(ct.helpview, "")
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue