Add NewLineByDefault toggle

This commit is contained in:
roger 2021-03-08 13:33:24 +08:00 committed by Tulir Asokan
parent b7966b5d4e
commit 69bbdd0a1b
3 changed files with 5 additions and 1 deletions

View File

@ -52,6 +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"`
}
// Config contains the main config of gomuks.

View File

@ -699,6 +699,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"),
}
func makeUsage() string {
@ -743,6 +744,8 @@ func cmdToggle(cmd *Command) {
val = &cmd.Config.SendToVerifiedOnly
case "showurls":
val = &cmd.Config.Preferences.DisableShowURLs
case "newline":
val = &cmd.Config.Preferences.NewLineByDefault
default:
cmd.Reply("Unknown toggle %s. Use /toggle without arguments for a list of togglable things.", thing)
return

View File

@ -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 {
if (event.Modifiers()&tcell.ModShift == 0 && event.Modifiers()&tcell.ModCtrl == 0) == (view.config.Preferences.NewLineByDefault) {
view.InputSubmit(view.input.GetText())
return true
}