Improve action menu escape handling
Make the F11 action menu close through a shared close action so Escape and the explicit Close actions menu item follow the same path. Treat Escape-prefixed Up and Down events as close inputs while the action menu is active, which handles termbox InputAlt behavior after pressing Escape. Preserve and restore the user/channel tree selection across action menu open and close, and preserve selection across live tree rebuilds. Tested with: GOCACHE=/tmp/barnard-go-cache go test ./...
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"git.stormux.org/storm/barnard/gumble/gumble"
|
||||
"git.stormux.org/storm/barnard/uiterm"
|
||||
)
|
||||
|
||||
func TestParseToggleState(t *testing.T) {
|
||||
@@ -63,3 +64,27 @@ func TestPermissionList(t *testing.T) {
|
||||
t.Fatalf("expected write,ban, got %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdminEscapeInputs(t *testing.T) {
|
||||
if !isAdminEscapeKey(uiterm.KeyEsc) {
|
||||
t.Fatal("expected escape key to close admin menu")
|
||||
}
|
||||
if !isAdminEscapeKey(uiterm.KeyAltEsc) {
|
||||
t.Fatal("expected alt escape key to close admin menu")
|
||||
}
|
||||
if !isAdminEscapeKey(uiterm.KeyAltArrowUp) {
|
||||
t.Fatal("expected escape-prefixed up arrow to close admin menu")
|
||||
}
|
||||
if !isAdminEscapeKey(uiterm.KeyAltArrowDown) {
|
||||
t.Fatal("expected escape-prefixed down arrow to close admin menu")
|
||||
}
|
||||
if isAdminEscapeKey(uiterm.KeyEnter) {
|
||||
t.Fatal("expected enter key not to close admin menu")
|
||||
}
|
||||
if !isAdminEscapeCharacter(rune(uiterm.KeyEsc)) {
|
||||
t.Fatal("expected escape character to close admin menu")
|
||||
}
|
||||
if isAdminEscapeCharacter('x') {
|
||||
t.Fatal("expected non-escape character not to close admin menu")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user