Fixes the help text issue. Moved some hard-coded strings to the translation files.

This commit is contained in:
Sean E. Russell 2020-06-20 08:33:01 -05:00
parent c0a06128a2
commit 9a56571373
7 changed files with 165 additions and 145 deletions

View File

@ -21,8 +21,8 @@ import (
"github.com/VictoriaMetrics/metrics" "github.com/VictoriaMetrics/metrics"
jj "github.com/cloudfoundry-attic/jibber_jabber" jj "github.com/cloudfoundry-attic/jibber_jabber"
ui "github.com/gizak/termui/v3" ui "github.com/gizak/termui/v3"
"github.com/jdkeke142/lingo-toml"
"github.com/shibukawa/configdir" "github.com/shibukawa/configdir"
"github.com/xxxserxxx/lingo"
"github.com/xxxserxxx/opflag" "github.com/xxxserxxx/opflag"
"github.com/xxxserxxx/gotop/v4" "github.com/xxxserxxx/gotop/v4"
@ -107,9 +107,9 @@ func parseArgs() error {
if *list != "" { if *list != "" {
switch *list { switch *list {
case "layouts": case "layouts":
fmt.Println(_layouts) fmt.Println(tr.Value("help.layouts"))
case "colorschemes": case "colorschemes":
fmt.Println(_colorschemes) fmt.Println(tr.Value("help.colorschemes"))
case "paths": case "paths":
fmt.Println(tr.Value("help.paths")) fmt.Println(tr.Value("help.paths"))
paths := make([]string, 0) paths := make([]string, 0)
@ -122,9 +122,9 @@ func parseArgs() error {
case "devices": case "devices":
listDevices() listDevices()
case "keys": case "keys":
fmt.Println(tr.Value("widget.help")) fmt.Println(tr.Value("help.help"))
case "widgets": case "widgets":
fmt.Println(_widgets) fmt.Println(tr.Value("help.widgets"))
default: default:
fmt.Printf(tr.Value("error.unknownopt", *list)) fmt.Printf(tr.Value("error.unknownopt", *list))
os.Exit(1) os.Exit(1)
@ -508,25 +508,3 @@ func listDevices() {
} }
} }
} }
const _layouts = `Built-in layouts:
default
minimal
battery
kitchensink`
const _colorschemes = `Built-in colorschemes:
default
default-dark (for white background)
solarized
solarized16-dark
solarized16-light
monokai
vice`
const _widgets = `Widgets that can be used in layouts:
cpu - CPU load graph
mem - Physical & swap memory use graph
temp - Sensor temperatures
disk - Physical disk partition use
power - A battery bar
net - Network load
procs - Interactive process list`

4
go.mod
View File

@ -7,15 +7,17 @@ require (
github.com/distatus/battery v0.9.0 github.com/distatus/battery v0.9.0
github.com/gizak/termui/v3 v3.1.0 github.com/gizak/termui/v3 v3.1.0
github.com/go-ole/go-ole v1.2.4 // indirect github.com/go-ole/go-ole v1.2.4 // indirect
github.com/jdkeke142/lingo-toml v0.0.0-20200508150411-0ad65ccb786d
github.com/mattn/go-runewidth v0.0.4 github.com/mattn/go-runewidth v0.0.4
github.com/nsf/termbox-go v0.0.0-20200418040025-38ba6e5628f1 github.com/nsf/termbox-go v0.0.0-20200418040025-38ba6e5628f1
github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0 github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0
github.com/shirou/gopsutil v2.20.3+incompatible github.com/shirou/gopsutil v2.20.3+incompatible
github.com/stretchr/testify v1.4.0 github.com/stretchr/testify v1.4.0
github.com/xxxserxxx/lingo v1.1.0
github.com/xxxserxxx/opflag v1.0.5 github.com/xxxserxxx/opflag v1.0.5
golang.org/x/sys v0.0.0-20200316230553-a7d97aace0b0 golang.org/x/sys v0.0.0-20200316230553-a7d97aace0b0
howett.net/plist v0.0.0-20200419221736-3b63eb3a43b5 // indirect howett.net/plist v0.0.0-20200419221736-3b63eb3a43b5 // indirect
) )
go 1.14 go 1.14
replace github.com/jdkeke142/lingo-toml => github.com/xxxserxxx/lingo v0.0.0-20200619152803-440e0ec753ec

6
go.sum
View File

@ -37,10 +37,8 @@ github.com/valyala/fastrand v1.0.0 h1:LUKT9aKer2dVQNUi3waewTbKV+7H17kvWFNKs2Obdk
github.com/valyala/fastrand v1.0.0/go.mod h1:HWqCzkrkg6QXT8V2EXWvXCoow7vLwOFN002oeRzjapQ= github.com/valyala/fastrand v1.0.0/go.mod h1:HWqCzkrkg6QXT8V2EXWvXCoow7vLwOFN002oeRzjapQ=
github.com/valyala/histogram v1.0.1 h1:FzA7n2Tz/wKRMejgu3PV1vw3htAklTjjuoI6z3d4KDg= github.com/valyala/histogram v1.0.1 h1:FzA7n2Tz/wKRMejgu3PV1vw3htAklTjjuoI6z3d4KDg=
github.com/valyala/histogram v1.0.1/go.mod h1:lQy0xA4wUz2+IUnf97SivorsJIp8FxsnRd6x25q7Mto= github.com/valyala/histogram v1.0.1/go.mod h1:lQy0xA4wUz2+IUnf97SivorsJIp8FxsnRd6x25q7Mto=
github.com/xxxserxxx/lingo v1.0.1 h1:lPexOb0HEqYB50EaJdjaYFNATT8JhTcXljbQmCuXygE= github.com/xxxserxxx/lingo v0.0.0-20200619152803-440e0ec753ec h1:72Kid6wRHf4IZq0oJyJZGo4FuIyJeKqN4n9MEh2l744=
github.com/xxxserxxx/lingo v1.0.1/go.mod h1:C2teIFiBLAmEhpLzRkwk7wP5R0eOoveXVYqD+5KOkAs= github.com/xxxserxxx/lingo v0.0.0-20200619152803-440e0ec753ec/go.mod h1:Kji1cjs9t6xDSLWuz6vP6ockOTT1rIdMLnNryfHXVuw=
github.com/xxxserxxx/lingo v1.1.0 h1:UaA0oNyen0vGWNHD6eow+uCfBu7hhypwb28RxQSnprY=
github.com/xxxserxxx/lingo v1.1.0/go.mod h1:C2teIFiBLAmEhpLzRkwk7wP5R0eOoveXVYqD+5KOkAs=
github.com/xxxserxxx/opflag v1.0.5 h1:2H4Qtl1qe+dSkEcGt+fBe2mQ8z14MgkWPqcLaoa6k90= github.com/xxxserxxx/opflag v1.0.5 h1:2H4Qtl1qe+dSkEcGt+fBe2mQ8z14MgkWPqcLaoa6k90=
github.com/xxxserxxx/opflag v1.0.5/go.mod h1:GWZtb3/tGGj5W1GE/JTyJAuqgxDxl1+jqDGAGM+P/p4= github.com/xxxserxxx/opflag v1.0.5/go.mod h1:GWZtb3/tGGj5W1GE/JTyJAuqgxDxl1+jqDGAGM+P/p4=
golang.org/x/sys v0.0.0-20200316230553-a7d97aace0b0 h1:4Khi5GeNOkZS5DqSBRn4Sy7BE6GuxwOqARPqfurkdNk= golang.org/x/sys v0.0.0-20200316230553-a7d97aace0b0 h1:4Khi5GeNOkZS5DqSBRn4Sy7BE6GuxwOqARPqfurkdNk=

View File

@ -7,6 +7,64 @@ total="Total"
paths="Loadable colorschemes & layouts, and the config file, are searched for, in order:" paths="Loadable colorschemes & layouts, and the config file, are searched for, in order:"
log="The log file is in {0}" log="The log file is in {0}"
written="Config written to {0}" written="Config written to {0}"
help="""
Quit: q or <C-c>
Process navigation:
- k and <Up>: up
- j and <Down>: down
- <C-u>: half page up
- <C-d>: half page down
- <C-b>: full page up
- <C-f>: full page down
- gg and <Home>: jump to top
- G and <End>: jump to bottom
Process actions:
- <Tab>: toggle process grouping
- dd: kill selected process or group of processes with SIGTERM (15)
- d3: kill selected process or group of processes with SIGQUIT (3)
- d9: kill selected process or group of processes with SIGKILL (9)
Process sorting:
- c: CPU
- m: Mem
- p: PID
Process filtering:
- /: start editing filter
- (while editing):
- <Enter>: accept filter
- <C-c> and <Escape>: clear filter
CPU and Mem graph scaling:
- h: scale in
- l: scale out
Network:
- b: toggle between mbps and scaled bytes per second
"""
layouts = """Built-in layouts:
default
minimal
battery
kitchensink"""
colorschemes = """Built-in colorschemes:
default
default-dark (for white background)
solarized
solarized16-dark
solarized16-light
monokai
vice"""
widgets = """Widgets that can be used in layouts:
cpu - CPU load graph
mem - Physical & swap memory use graph
temp - Sensor temperatures
disk - Physical disk partition use
power - A battery bar
net - Network load
procs - Interactive process list"""
[args] [args]
@ -61,43 +119,6 @@ temp=" Temperatures "
net=" Network Usage " net=" Network Usage "
netint=" Network Usage: {0} " netint=" Network Usage: {0} "
mem=" Memory Usage " mem=" Memory Usage "
help="""
Quit: q or <C-c>
Process navigation:
- k and <Up>: up
- j and <Down>: down
- <C-u>: half page up
- <C-d>: half page down
- <C-b>: full page up
- <C-f>: full page down
- gg and <Home>: jump to top
- G and <End>: jump to bottom
Process actions:
- <Tab>: toggle process grouping
- dd: kill selected process or group of processes with SIGTERM (15)
- d3: kill selected process or group of processes with SIGQUIT (3)
- d9: kill selected process or group of processes with SIGKILL (9)
Process sorting:
- c: CPU
- m: Mem
- p: PID
Process filtering:
- /: start editing filter
- (while editing):
- <Enter>: accept filter
- <C-c> and <Escape>: clear filter
CPU and Mem graph scaling:
- h: scale in
- l: scale out
Network:
- b: toggle between mbps and scaled bytes per second
"""
[widget.net.err] [widget.net.err]

View File

@ -7,6 +7,64 @@ total="latoT"
paths="redro ni ,rof dehcraes era ,elif gifnoc eht dna ,stuoyal & semehcsroloc elbadaoL:" paths="redro ni ,rof dehcraes era ,elif gifnoc eht dna ,stuoyal & semehcsroloc elbadaoL:"
log="ni si elif gol ehT {0}" log="ni si elif gol ehT {0}"
written="ot nettirw gifnoC {0}" written="ot nettirw gifnoC {0}"
help="""
>c-C< ro q :tiuQ
:noitagivan ssecorP
pu :>pU< dna k -
nwod :>nwoD< dna j -
pu egap flah :>u-C< -
nwod egap flah :>d-C< -
pu egap lluf :>b-C< -
nwod egap lluf :>f-C< -
pot ot pmuj :>emoH< dna gg -
mottob ot pmuj :>dnE< dna G -
:snoitca ssecorP
gnipuorg ssecorp elggot :>baT< -
)51( MRETGIS htiw sessecorp fo puorg ro ssecorp detceles llik :dd -
)3( TIUQGIS htiw sessecorp fo puorg ro ssecorp detceles llik :3d -
)9( LLIKGIS htiw sessecorp fo puorg ro ssecorp detceles llik :9d -
:gnitros ssecorP
UPC :c -
meM :m -
DIP :p -
:gniretlif ssecorP
retlif gnitide trats :/ -
:)gnitide elihw( -
retlif tpecca :>retnE< -
retlif raelc :>epacsE< dna >c-C< -
:gnilacs hparg meM dna UPC
ni elacs :h -
tuo elacs :l -
:krowteN
dnoces rep setyb delacs dna spbm neewteb elggot :b -
"""
layouts = """stuoyal ni-tliuB:
tluafed
laminim
yrettab
knisnehctik"""
colorschemes = """semehcsroloc ni-tliuB:
tluafed
)dnuorgkcab etihw rof( krad-tluafed
deziralos
krad-61deziralos
thgil-61deziralos
iakonom
eciv"""
widgets = """stuoyal ni desu eb nac taht stegdiW:
hparg daol UPC - upc
hparg esu yromem paws & lacisyhP - mem
serutarepmet rosneS - pmet
esu noititrap ksid lacisyhP - ksid
rab yrettab A - rewop
daol krowteN - ten
tsil ssecorp evitcaretnI - scorp"""
[args] [args]
@ -61,43 +119,6 @@ temp=" serutarepmeT "
net=" egasU krowteN " net=" egasU krowteN "
netint=" egasU krowteN: {0} " netint=" egasU krowteN: {0} "
mem=" egasU yromeM " mem=" egasU yromeM "
help="""
>c-C< ro q :tiuQ
:noitagivan ssecorP
pu :>pU< dna k -
nwod :>nwoD< dna j -
pu egap flah :>u-C< -
nwod egap flah :>d-C< -
pu egap lluf :>b-C< -
nwod egap lluf :>f-C< -
pot ot pmuj :>emoH< dna gg -
mottob ot pmuj :>dnE< dna G -
:snoitca ssecorP
gnipuorg ssecorp elggot :>baT< -
)51( MRETGIS htiw sessecorp fo puorg ro ssecorp detceles llik :dd -
)3( TIUQGIS htiw sessecorp fo puorg ro ssecorp detceles llik :3d -
)9( LLIKGIS htiw sessecorp fo puorg ro ssecorp detceles llik :9d -
:gnitros ssecorP
UPC :c -
meM :m -
DIP :p -
:gniretlif ssecorP
retlif gnitide trats :/ -
:)gnitide elihw( -
retlif tpecca :>retnE< -
retlif raelc :>epacsE< dna >c-C< -
:gnilacs hparg meM dna UPC
ni elacs :h -
tuo elacs :l -
:krowteN
dnoces rep setyb delacs dna spbm neewteb elggot :b -
"""
[widget.net.err] [widget.net.err]

View File

@ -7,6 +7,43 @@ total="总计"
paths="按顺序从以下位置优先读取配色方案、布局方案和配置文件:" paths="按顺序从以下位置优先读取配色方案、布局方案和配置文件:"
log="日志文件位于 {0}" log="日志文件位于 {0}"
written="配置文件已写入 {0}" written="配置文件已写入 {0}"
help="""
退: q or <C-c>
:
- k <Up>:
- j <Down>:
- <C-u>:
- <C-d>:
- <C-b>:
- <C-f>:
- gg <Home>:
- G <End>:
:
- <Tab>:
- dd: SIGTERM (15)
- d3: SIGTERM (3)
- d9: SIGTERM (9)
:
- c: CPU
- m:
- p:
:
- /:
- ():
- <Enter>:
- <C-c> <Escape>:
CPU :
- h:
- l:
:
- b: mbps
"""
[args] [args]
@ -61,43 +98,6 @@ temp=" 温度 "
net=" 网络使用率 " net=" 网络使用率 "
netint=" 网络使用率: {0} " netint=" 网络使用率: {0} "
mem=" 内存使用率 " mem=" 内存使用率 "
help="""
退: q or <C-c>
:
- k <Up>:
- j <Down>:
- <C-u>:
- <C-d>:
- <C-b>:
- <C-f>:
- gg <Home>:
- G <End>:
:
- <Tab>:
- dd: SIGTERM (15)
- d3: SIGTERM (3)
- d9: SIGTERM (9)
:
- c: CPU
- m:
- p:
:
- /:
- ():
- <Enter>:
- <C-c> <Escape>:
CPU :
- h:
- l:
:
- b: mbps
"""
[widget.net.err] [widget.net.err]

View File

@ -5,7 +5,7 @@ import (
"strings" "strings"
ui "github.com/gizak/termui/v3" ui "github.com/gizak/termui/v3"
"github.com/xxxserxxx/lingo" lingo "github.com/jdkeke142/lingo-toml"
) )
var tr lingo.Translations var tr lingo.Translations
@ -17,7 +17,7 @@ type HelpMenu struct {
func NewHelpMenu(tra lingo.Translations) *HelpMenu { func NewHelpMenu(tra lingo.Translations) *HelpMenu {
tr = tra tr = tra
keyBinds = tr.Value("widgets.help") keyBinds = tr.Value("help.help")
return &HelpMenu{ return &HelpMenu{
Block: *ui.NewBlock(), Block: *ui.NewBlock(),
} }