mirror of https://github.com/icedream/icecon.git
added command history
parent
06af870346
commit
d11db9738f
|
@ -27,6 +27,9 @@ var (
|
||||||
|
|
||||||
dlg *mainDialog
|
dlg *mainDialog
|
||||||
dlgOriginalTitle string
|
dlgOriginalTitle string
|
||||||
|
|
||||||
|
history []string
|
||||||
|
historyIndex = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -124,10 +127,35 @@ func runGraphicalUi() (err error) {
|
||||||
|
|
||||||
// Handle input
|
// Handle input
|
||||||
dlg.ui.rconInput.KeyPress().Attach(func(key walk.Key) {
|
dlg.ui.rconInput.KeyPress().Attach(func(key walk.Key) {
|
||||||
|
// handle history (arrow up/down)
|
||||||
|
if key == walk.KeyUp || key == walk.KeyDown {
|
||||||
|
if len(history) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if key == walk.KeyUp {
|
||||||
|
if historyIndex == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
historyIndex -= 1
|
||||||
|
dlg.ui.rconInput.SetText(history[historyIndex])
|
||||||
|
}else{
|
||||||
|
if (historyIndex + 1) >= len(history) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
historyIndex += 1
|
||||||
|
dlg.ui.rconInput.SetText(history[historyIndex])
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if key != walk.KeyReturn {
|
if key != walk.KeyReturn {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if address == nil {
|
if address == nil {
|
||||||
uiLogError("No server configured.")
|
uiLogError("No server configured.")
|
||||||
return
|
return
|
||||||
|
@ -138,6 +166,10 @@ func runGraphicalUi() (err error) {
|
||||||
|
|
||||||
uiLog(address.String() + "> " + cmd)
|
uiLog(address.String() + "> " + cmd)
|
||||||
sendRcon(cmd)
|
sendRcon(cmd)
|
||||||
|
|
||||||
|
// add to history
|
||||||
|
history = append(history, cmd)
|
||||||
|
historyIndex = len(history)
|
||||||
})
|
})
|
||||||
|
|
||||||
// When window is initialized we can let a secondary routine print all
|
// When window is initialized we can let a secondary routine print all
|
||||||
|
|
Loading…
Reference in New Issue