Skip to content

Commit d02fe5f

Browse files
committed
Add a /write-theme command to write the current theme to an INI file
1 parent 6a28afd commit d02fe5f

File tree

5 files changed

+12
-0
lines changed

5 files changed

+12
-0
lines changed

docs/commands.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,4 @@
5858
| `/topic <topic>` | Set the current channel's topic (header) |
5959
| `/user` | Show users to initiate a private DM chat channel |
6060
| `/username-attribute <@user>` | Display the attribute used to color the specified username |
61+
| `/write-theme <path>` | Write the current theme to a theme settings file |

src/Matterhorn/Command.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import Prelude ()
1212
import Matterhorn.Prelude
1313

1414
import Brick.Main ( invalidateCache )
15+
import Brick.Themes ( saveTheme )
1516
import qualified Control.Exception as Exn
1617
import qualified Data.Char as Char
1718
import qualified Data.Text as T
@@ -133,6 +134,12 @@ commandList =
133134
NoArg $ \ () -> do
134135
withCurrentTeam enterChannelMembersUserList
135136

137+
, Cmd "write-theme" "Write the current theme to a theme settings file"
138+
(TokenArg "path" NoArg) $ \(path, ()) -> do
139+
theme <- use (csResources.crThemeOriginal)
140+
liftIO $ saveTheme (T.unpack path) theme
141+
postInfoMessage $ "Current theme written to " <> path
142+
136143
, Cmd "leave" "Leave a normal channel or hide a DM channel" NoArg $ \ () -> do
137144
withCurrentTeam startLeaveCurrentChannel
138145

src/Matterhorn/State/Setup.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ setupState mkVty mLogLocation config = do
161161
, _crSubprocessLog = slc
162162
, _crWebsocketActionChan = wac
163163
, _crTheme = themeToAttrMap custTheme
164+
, _crThemeOriginal = custTheme
164165
, _crStatusUpdateChan = userStatusChan
165166
, _crConfiguration = config
166167
, _crFlaggedPosts = mempty

src/Matterhorn/State/ThemeListWindow.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,4 @@ setTheme tId name =
8585
Just it -> do
8686
mh invalidateCache
8787
csResources.crTheme .= (themeToAttrMap $ internalTheme it)
88+
csResources.crThemeOriginal .= internalTheme it

src/Matterhorn/Types.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ module Matterhorn.Types
235235
, crUserPreferences
236236
, crEventQueue
237237
, crTheme
238+
, crThemeOriginal
238239
, crStatusUpdateChan
239240
, crSubprocessLog
240241
, crWebsocketActionChan
@@ -1070,6 +1071,7 @@ data ChatResources =
10701071
, _crSubprocessLog :: STM.TChan ProgramOutput
10711072
, _crWebsocketActionChan :: STM.TChan WebsocketAction
10721073
, _crTheme :: AttrMap
1074+
, _crThemeOriginal :: Theme
10731075
, _crStatusUpdateChan :: STM.TChan [UserId]
10741076
, _crConfiguration :: Config
10751077
, _crFlaggedPosts :: Set PostId

0 commit comments

Comments
 (0)