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"`
|
DisableDownloads bool `yaml:"disable_downloads"`
|
||||||
DisableNotifications bool `yaml:"disable_notifications"`
|
DisableNotifications bool `yaml:"disable_notifications"`
|
||||||
DisableShowURLs bool `yaml:"disable_show_urls"`
|
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.
|
// Config contains the main config of gomuks.
|
||||||
|
@ -550,8 +550,8 @@ func cmdPrivateMessage(cmd *Command) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
req := &mautrix.ReqCreateRoom{
|
req := &mautrix.ReqCreateRoom{
|
||||||
Preset: "trusted_private_chat",
|
Preset: "trusted_private_chat",
|
||||||
Invite: invites,
|
Invite: invites,
|
||||||
IsDirect: true,
|
IsDirect: true,
|
||||||
}
|
}
|
||||||
room, err := cmd.Matrix.CreateRoom(req)
|
room, err := cmd.Matrix.CreateRoom(req)
|
||||||
@ -686,6 +686,20 @@ func (stm SimpleToggleMessage) Name() string {
|
|||||||
return string(unicode.ToUpper(rune(stm[0]))) + string(stm[1:])
|
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{
|
var toggleMsg = map[string]ToggleMessage{
|
||||||
"rooms": HideMessage("Room list sidebar"),
|
"rooms": HideMessage("Room list sidebar"),
|
||||||
"users": HideMessage("User list sidebar"),
|
"users": HideMessage("User list sidebar"),
|
||||||
@ -699,7 +713,7 @@ var toggleMsg = map[string]ToggleMessage{
|
|||||||
"notifications": SimpleToggleMessage("desktop notifications"),
|
"notifications": SimpleToggleMessage("desktop notifications"),
|
||||||
"unverified": SimpleToggleMessage("sending messages to unverified devices"),
|
"unverified": SimpleToggleMessage("sending messages to unverified devices"),
|
||||||
"showurls": SimpleToggleMessage("show URLs in text format"),
|
"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 {
|
func makeUsage() string {
|
||||||
@ -745,7 +759,7 @@ func cmdToggle(cmd *Command) {
|
|||||||
case "showurls":
|
case "showurls":
|
||||||
val = &cmd.Config.Preferences.DisableShowURLs
|
val = &cmd.Config.Preferences.DisableShowURLs
|
||||||
case "newline":
|
case "newline":
|
||||||
val = &cmd.Config.Preferences.NewLineByDefault
|
val = &cmd.Config.Preferences.AltEnterToSend
|
||||||
default:
|
default:
|
||||||
cmd.Reply("Unknown toggle %s. Use /toggle without arguments for a list of togglable things.", thing)
|
cmd.Reply("Unknown toggle %s. Use /toggle without arguments for a list of togglable things.", thing)
|
||||||
return
|
return
|
||||||
|
@ -374,7 +374,7 @@ func (view *RoomView) OnKeyEvent(event mauview.KeyEvent) bool {
|
|||||||
msgView.AddScrollOffset(-msgView.Height() / 2)
|
msgView.AddScrollOffset(-msgView.Height() / 2)
|
||||||
return true
|
return true
|
||||||
case tcell.KeyEnter:
|
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())
|
view.InputSubmit(view.input.GetText())
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user