mirror of https://github.com/icedream/icecon.git
added history limit and fixed formatting
parent
d11db9738f
commit
cb9facd9cc
|
@ -74,6 +74,16 @@ func uiUpdateAddress() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func addToHistory(command string) {
|
||||||
|
// limit history to 20 items
|
||||||
|
if len(history) > 20 {
|
||||||
|
history = append(history[:0], history[0+1:]...)
|
||||||
|
}
|
||||||
|
|
||||||
|
history = append(history, command)
|
||||||
|
historyIndex = len(history)
|
||||||
|
}
|
||||||
|
|
||||||
func runGraphicalUi() (err error) {
|
func runGraphicalUi() (err error) {
|
||||||
dlg = new(mainDialog)
|
dlg = new(mainDialog)
|
||||||
if err := dlg.init(); err != nil {
|
if err := dlg.init(); err != nil {
|
||||||
|
@ -140,7 +150,7 @@ func runGraphicalUi() (err error) {
|
||||||
|
|
||||||
historyIndex -= 1
|
historyIndex -= 1
|
||||||
dlg.ui.rconInput.SetText(history[historyIndex])
|
dlg.ui.rconInput.SetText(history[historyIndex])
|
||||||
}else{
|
} else {
|
||||||
if (historyIndex + 1) >= len(history) {
|
if (historyIndex + 1) >= len(history) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -168,8 +178,7 @@ func runGraphicalUi() (err error) {
|
||||||
sendRcon(cmd)
|
sendRcon(cmd)
|
||||||
|
|
||||||
// add to history
|
// add to history
|
||||||
history = append(history, cmd)
|
addToHistory(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