1
0
Fork 0
forked from Mirrors/gomuks

Add an escape command for modern display mode

This commit is contained in:
FIGBERT 2023-04-25 00:25:04 -07:00
parent 27160c1fc6
commit 73b0d3f1a2
No known key found for this signature in database
GPG key ID: 67F1598D607A844B
2 changed files with 16 additions and 0 deletions

View file

@ -113,6 +113,7 @@ func NewCommandProcessor(parent *MainView) *CommandProcessor {
"cs": {"cross-signing"},
"power": {"powerlevel"},
"pl": {"powerlevel"},
"esc": {"escape"},
},
autocompleters: map[string]CommandAutocompleter{
"devices": autocompleteUser,
@ -181,6 +182,8 @@ func NewCommandProcessor(parent *MainView) *CommandProcessor {
"rainbownotice": cmdRainbowNotice,
"escape": cmdEscape,
"fingerprint": cmdFingerprint,
"devices": cmdDevices,
"verify-device": cmdVerifyDevice,

View file

@ -908,6 +908,19 @@ func cmdSetState(cmd *Command) {
}
}
func cmdEscape(cmd *Command) {
if cmd.Config.Preferences.DisplayMode != config.DisplayModeModern {
cmd.Reply("/escape can only be used in the modern display mode")
return
}
if cmd.MainView.rosterView.selected == nil || !cmd.MainView.rosterView.focused {
cmd.Reply("/escape is used to exit from an open room (no room opened)")
return
}
cmd.MainView.rosterView.focused = false
cmd.MainView.rosterView.selected = nil
}
type ToggleMessage interface {
Name() string
Format(state bool) string