forked from Mirrors/gomuks
Add an escape command for modern display mode
This commit is contained in:
parent
27160c1fc6
commit
73b0d3f1a2
2 changed files with 16 additions and 0 deletions
|
@ -113,6 +113,7 @@ func NewCommandProcessor(parent *MainView) *CommandProcessor {
|
||||||
"cs": {"cross-signing"},
|
"cs": {"cross-signing"},
|
||||||
"power": {"powerlevel"},
|
"power": {"powerlevel"},
|
||||||
"pl": {"powerlevel"},
|
"pl": {"powerlevel"},
|
||||||
|
"esc": {"escape"},
|
||||||
},
|
},
|
||||||
autocompleters: map[string]CommandAutocompleter{
|
autocompleters: map[string]CommandAutocompleter{
|
||||||
"devices": autocompleteUser,
|
"devices": autocompleteUser,
|
||||||
|
@ -181,6 +182,8 @@ func NewCommandProcessor(parent *MainView) *CommandProcessor {
|
||||||
|
|
||||||
"rainbownotice": cmdRainbowNotice,
|
"rainbownotice": cmdRainbowNotice,
|
||||||
|
|
||||||
|
"escape": cmdEscape,
|
||||||
|
|
||||||
"fingerprint": cmdFingerprint,
|
"fingerprint": cmdFingerprint,
|
||||||
"devices": cmdDevices,
|
"devices": cmdDevices,
|
||||||
"verify-device": cmdVerifyDevice,
|
"verify-device": cmdVerifyDevice,
|
||||||
|
|
|
@ -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 {
|
type ToggleMessage interface {
|
||||||
Name() string
|
Name() string
|
||||||
Format(state bool) string
|
Format(state bool) string
|
||||||
|
|
Loading…
Add table
Reference in a new issue