mirror of https://github.com/icedream/icecon.git
added command history
parent
06af870346
commit
d11db9738f
|
@ -27,6 +27,9 @@ var (
|
|||
|
||||
dlg *mainDialog
|
||||
dlgOriginalTitle string
|
||||
|
||||
history []string
|
||||
historyIndex = 0
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -124,6 +127,31 @@ func runGraphicalUi() (err error) {
|
|||
|
||||
// Handle input
|
||||
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 {
|
||||
return
|
||||
}
|
||||
|
@ -138,6 +166,10 @@ func runGraphicalUi() (err error) {
|
|||
|
||||
uiLog(address.String() + "> " + 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
|
||||
|
|
Loading…
Reference in New Issue