From a2432d031fcd8aedd104ce411dbbf0389128a2d0 Mon Sep 17 00:00:00 2001 From: FIGBERT Date: Fri, 24 Feb 2023 19:08:11 -0800 Subject: [PATCH] Add DisplayMode to UserPreferences --- config/config.go | 2 ++ config/display-mode.go | 24 ++++++++++++++++++++++++ ui/commands.go | 11 +++++++++++ 3 files changed, 37 insertions(+) create mode 100644 config/display-mode.go diff --git a/config/config.go b/config/config.go index 711db1b..5b6e514 100644 --- a/config/config.go +++ b/config/config.go @@ -62,6 +62,8 @@ type UserPreferences struct { AltEnterToSend bool `yaml:"alt_enter_to_send"` InlineURLMode string `yaml:"inline_url_mode"` + + DisplayMode DisplayMode `yaml:"display_mode"` } var InlineURLsProbablySupported bool diff --git a/config/display-mode.go b/config/display-mode.go new file mode 100644 index 0000000..e124241 --- /dev/null +++ b/config/display-mode.go @@ -0,0 +1,24 @@ +// gomuks - A terminal Matrix client written in Go. +// Copyright (C) 2020 Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package config + +type DisplayMode string + +const ( + DisplayModeIRC DisplayMode = "irc" + DisplayModeModern DisplayMode = "modern" +) diff --git a/ui/commands.go b/ui/commands.go index d1d8d8f..ad48d4f 100644 --- a/ui/commands.go +++ b/ui/commands.go @@ -44,6 +44,7 @@ import ( "maunium.net/go/mautrix/format" "maunium.net/go/mautrix/id" + "maunium.net/go/gomuks/config" "maunium.net/go/gomuks/debug" "maunium.net/go/gomuks/lib/filepicker" ) @@ -1040,6 +1041,16 @@ func cmdToggle(cmd *Command) { cmd.Reply("Force-enabled using fancy terminal features to render URLs inside text. Restart gomuks to apply changes.") } continue + case "displaymode": + switch cmd.Config.Preferences.DisplayMode { + case "modern": + cmd.Config.Preferences.DisplayMode = config.DisplayModeIRC + cmd.Reply("Enabled IRC display mode. Restart gomuks to apply changes.") + default: + cmd.Config.Preferences.DisplayMode = config.DisplayModeModern + cmd.Reply("Enabled modern display mode. Restart gomuks to apply changes.") + } + continue case "newline": val = &cmd.Config.Preferences.AltEnterToSend default: