Fix newline keybind toggle
This commit is contained in:
parent
69bbdd0a1b
commit
8e6f89a59a
@ -52,7 +52,7 @@ type UserPreferences struct {
|
||||
DisableDownloads bool `yaml:"disable_downloads"`
|
||||
DisableNotifications bool `yaml:"disable_notifications"`
|
||||
DisableShowURLs bool `yaml:"disable_show_urls"`
|
||||
NewLineByDefault bool `yaml:"new_line_by_default"`
|
||||
AltEnterToSend bool `yaml:"alt_enter_to_send"`
|
||||
}
|
||||
|
||||
// Config contains the main config of gomuks.
|
||||
|
@ -686,6 +686,20 @@ func (stm SimpleToggleMessage) Name() string {
|
||||
return string(unicode.ToUpper(rune(stm[0]))) + string(stm[1:])
|
||||
}
|
||||
|
||||
type NewlineKeybindMessage string
|
||||
|
||||
func (nkm NewlineKeybindMessage) Format(state bool) string {
|
||||
if state {
|
||||
return "Now using <enter> to create new line and <alt+enter> to send"
|
||||
} else {
|
||||
return "Now using <enter> to send and <alt+enter> to create new line"
|
||||
}
|
||||
}
|
||||
|
||||
func (nkm NewlineKeybindMessage) Name() string {
|
||||
return string(nkm)
|
||||
}
|
||||
|
||||
var toggleMsg = map[string]ToggleMessage{
|
||||
"rooms": HideMessage("Room list sidebar"),
|
||||
"users": HideMessage("User list sidebar"),
|
||||
@ -699,7 +713,7 @@ var toggleMsg = map[string]ToggleMessage{
|
||||
"notifications": SimpleToggleMessage("desktop notifications"),
|
||||
"unverified": SimpleToggleMessage("sending messages to unverified devices"),
|
||||
"showurls": SimpleToggleMessage("show URLs in text format"),
|
||||
"newline": SimpleToggleMessage("use <enter> to create new line and <alt+enter> to send"),
|
||||
"newline": NewlineKeybindMessage("should <alt+enter> make a new line or send the message"),
|
||||
}
|
||||
|
||||
func makeUsage() string {
|
||||
@ -745,7 +759,7 @@ func cmdToggle(cmd *Command) {
|
||||
case "showurls":
|
||||
val = &cmd.Config.Preferences.DisableShowURLs
|
||||
case "newline":
|
||||
val = &cmd.Config.Preferences.NewLineByDefault
|
||||
val = &cmd.Config.Preferences.AltEnterToSend
|
||||
default:
|
||||
cmd.Reply("Unknown toggle %s. Use /toggle without arguments for a list of togglable things.", thing)
|
||||
return
|
||||
|
@ -374,7 +374,7 @@ func (view *RoomView) OnKeyEvent(event mauview.KeyEvent) bool {
|
||||
msgView.AddScrollOffset(-msgView.Height() / 2)
|
||||
return true
|
||||
case tcell.KeyEnter:
|
||||
if (event.Modifiers()&tcell.ModShift == 0 && event.Modifiers()&tcell.ModCtrl == 0) == (view.config.Preferences.NewLineByDefault) {
|
||||
if (event.Modifiers()&tcell.ModShift == 0 && event.Modifiers()&tcell.ModCtrl == 0) != (view.config.Preferences.AltEnterToSend) {
|
||||
view.InputSubmit(view.input.GetText())
|
||||
return true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user