From 8dfb26e8e115cf04350c5333ce293c3026361adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Mon, 22 Jun 2026 21:47:58 +0200 Subject: Convert to generic Message type for formatting --- main/Main.hs | 4 +--- src/Erebos/Conversation.hs | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/main/Main.hs b/main/Main.hs index 2737915..def3b8c 100644 --- a/main/Main.hs +++ b/main/Main.hs @@ -444,9 +444,7 @@ interactiveLoop st opts = withTerminal commandCompletion $ \term -> do SelectedConversation conv -> return $ conversationPeer conv _ -> return Nothing when (not tui || maybe False (msgPeer cur `sameIdentity`) mbpid) $ do - line <- printLine term $ - (if new then withStyle (setForegroundColor BrightYellow noStyle) else id) $ - plainText $ T.pack $ formatDirectMessage tzone msg + line <- printLine term $ formatMessageFT tzone $ makeMessage new msg modifyMVar_ currentLinesVar $ return . (line :) case optDmBotEcho opts of diff --git a/src/Erebos/Conversation.hs b/src/Erebos/Conversation.hs index 365f8de..1c2b340 100644 --- a/src/Erebos/Conversation.hs +++ b/src/Erebos/Conversation.hs @@ -2,6 +2,7 @@ module Erebos.Conversation ( Message, + makeMessage, messageFrom, messageTime, messageText, @@ -51,6 +52,9 @@ import Erebos.TextFormat.Types data Message = forall conv msg. ConversationType conv msg => Message msg Bool +makeMessage :: ConversationType conv msg => Bool -> msg -> Message +makeMessage = flip Message + withMessage :: (forall conv msg. ConversationType conv msg => msg -> a) -> Message -> a withMessage f (Message msg _) = f msg -- cgit v1.2.3