pause function visualization and handling enhancements
This commit is contained in:
parent
a9fd652eb7
commit
ac75e7e891
|
@ -98,15 +98,17 @@ func (l *Layout) HandleKeyboardEvent(e string) {
|
||||||
selected := l.getSelection()
|
selected := l.getSelection()
|
||||||
|
|
||||||
switch e {
|
switch e {
|
||||||
case console.KeyPause:
|
case console.KeyPause1, console.KeyPause2:
|
||||||
if l.mode == ModePause {
|
if l.mode == ModePause {
|
||||||
l.changeMode(ModeDefault)
|
l.changeMode(ModeDefault)
|
||||||
|
l.statusbar.TogglePause()
|
||||||
} else {
|
} else {
|
||||||
if selected.Type == config.TypeRunChart {
|
if selected.Type == config.TypeRunChart {
|
||||||
selected.CommandChannel <- &data.Command{Type: runchart.CommandDisableSelection}
|
selected.CommandChannel <- &data.Command{Type: runchart.CommandDisableSelection}
|
||||||
}
|
}
|
||||||
l.menu.Idle()
|
l.menu.Idle()
|
||||||
l.changeMode(ModePause)
|
l.changeMode(ModePause)
|
||||||
|
l.statusbar.TogglePause()
|
||||||
}
|
}
|
||||||
case console.KeyEnter:
|
case console.KeyEnter:
|
||||||
switch l.mode {
|
switch l.mode {
|
||||||
|
|
|
@ -9,13 +9,15 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
bindingsIndent = 4
|
bindingsIndent = 3
|
||||||
|
pauseText = " P A U S E D "
|
||||||
)
|
)
|
||||||
|
|
||||||
type StatusBar struct {
|
type StatusBar struct {
|
||||||
*ui.Block
|
*ui.Block
|
||||||
keyBindings []string
|
keyBindings []string
|
||||||
text string
|
text string
|
||||||
|
pause bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStatusLine(configFileName string, palette console.Palette, license *metadata.License) *StatusBar {
|
func NewStatusLine(configFileName string, palette console.Palette, license *metadata.License) *StatusBar {
|
||||||
|
@ -28,6 +30,9 @@ func NewStatusLine(configFileName string, palette console.Palette, license *meta
|
||||||
text += console.AppLicenseWarning
|
text += console.AppLicenseWarning
|
||||||
} else if license.Username != nil {
|
} else if license.Username != nil {
|
||||||
text += fmt.Sprintf("%s | licensed to %s", configFileName, *license.Username)
|
text += fmt.Sprintf("%s | licensed to %s", configFileName, *license.Username)
|
||||||
|
if license.Company != nil {
|
||||||
|
text += fmt.Sprintf(", %s", *license.Company)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
text += fmt.Sprintf("%s | licensed to %s", configFileName, *license.Company)
|
text += fmt.Sprintf("%s | licensed to %s", configFileName, *license.Company)
|
||||||
}
|
}
|
||||||
|
@ -55,5 +60,13 @@ func (s *StatusBar) Draw(buffer *ui.Buffer) {
|
||||||
indent += bindingsIndent + len(binding)
|
indent += bindingsIndent + len(binding)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.pause {
|
||||||
|
buffer.SetString(pauseText, ui.NewStyle(console.MenuColorBackground, console.MenuColorText), image.Pt(s.Max.X-s.Dx()/2-len(pauseText)/2, s.Min.Y))
|
||||||
|
}
|
||||||
|
|
||||||
s.Block.Draw(buffer)
|
s.Block.Draw(buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *StatusBar) TogglePause() {
|
||||||
|
s.pause = !s.pause
|
||||||
|
}
|
||||||
|
|
|
@ -6,9 +6,11 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
KeyPause = "p"
|
KeyPause1 = "p"
|
||||||
KeyQuit = "q"
|
KeyPause2 = "P"
|
||||||
KeyExit = "<C-c>"
|
KeyQuit1 = "q"
|
||||||
|
KeyQuit2 = "Q"
|
||||||
|
KeyQuit3 = "<C-c>"
|
||||||
KeyLeft = "<Left>"
|
KeyLeft = "<Left>"
|
||||||
KeyRight = "<Right>"
|
KeyRight = "<Right>"
|
||||||
KeyUp = "<Up>"
|
KeyUp = "<Up>"
|
||||||
|
|
|
@ -47,7 +47,7 @@ func (h *Handler) HandleEvents() {
|
||||||
case console.SignalClick:
|
case console.SignalClick:
|
||||||
payload := e.Payload.(ui.Mouse)
|
payload := e.Payload.(ui.Mouse)
|
||||||
h.layout.HandleMouseClick(payload.X, payload.Y)
|
h.layout.HandleMouseClick(payload.X, payload.Y)
|
||||||
case console.KeyQuit, console.KeyExit:
|
case console.KeyQuit1, console.KeyQuit2, console.KeyQuit3:
|
||||||
if h.layout.WerePositionsChanged() {
|
if h.layout.WerePositionsChanged() {
|
||||||
h.updateConfigFile()
|
h.updateConfigFile()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue