diff options
| author | Roman Smrž <roman.smrz@seznam.cz> | 2026-03-12 21:03:18 +0100 |
|---|---|---|
| committer | Roman Smrž <roman.smrz@seznam.cz> | 2026-03-12 21:03:18 +0100 |
| commit | db5e3ca2e52a288f29442fe724dd2f9c04195443 (patch) | |
| tree | 9d86d29f49caf4005fdd146cca7258bf6d606fb8 | |
| parent | c1d559d31fdf87bc833c7d4795a88e6fcfeb61c8 (diff) | |
Use context index style in all context selection menus
| -rw-r--r-- | main/Main.hs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/main/Main.hs b/main/Main.hs index da71e6a..f306158 100644 --- a/main/Main.hs +++ b/main/Main.hs @@ -540,6 +540,9 @@ interactiveLoop st opts = withTerminal commandCompletion $ \term -> do contextIndexStyle :: TextStyle contextIndexStyle = setForegroundColor BrightCyan noStyle +printSelectOption :: Int -> FormattedText -> CommandM () +printSelectOption i label = cmdPutStrLn $ "[" <> withStyle contextIndexStyle (plainText $ T.pack $ show i) <> "] " <> label + data CommandInput = CommandInput { ciServer :: Server @@ -714,7 +717,7 @@ cmdPeers = do set <- asks ciSetContextOptions set WatchPeers $ map (SelectedPeer . fst) peers forM_ (zip [1..] peers) $ \(i :: Int, (_, name)) -> do - cmdPutStrLn $ "[" <> withStyle contextIndexStyle (plainText $ T.pack $ show i) <> "] " <> plainText name + printSelectOption i $ plainText name cmdPeerAdd :: Command cmdPeerAdd = void $ do @@ -970,7 +973,7 @@ cmdChatrooms = do set <- asks ciSetContextOptions set WatchChatrooms $ map SelectedChatroom chatroomList forM_ (zip [1..] chatroomList) $ \(i :: Int, rstate) -> do - cmdPutStrLn $ plainText $ "[" <> T.pack (show i) <> "] " <> fromMaybe "<unnamed>" (roomName =<< roomStateRoom rstate) + printSelectOption i $ plainText $ fromMaybe "<unnamed>" (roomName =<< roomStateRoom rstate) cmdChatroomCreatePublic :: Command cmdChatroomCreatePublic = do @@ -998,8 +1001,8 @@ cmdContacts = do set <- asks ciSetContextOptions set WatchContacts $ map SelectedContact contacts forM_ (zip [1..] contacts) $ \(i :: Int, c) -> do - cmdPutStrLn $ plainText $ T.concat - [ "[", T.pack (show i), "] ", contactName c + printSelectOption i $ plainText $ T.concat + [ contactName c , case contactIdentity c of Just idt | cname <- displayIdentity idt , cname /= contactName c @@ -1062,7 +1065,7 @@ cmdConversations = do set <- asks ciSetContextOptions set WatchConversations $ map SelectedConversation conversations forM_ (zip [1..] conversations) $ \(i :: Int, conv) -> do - cmdPutStrLn $ plainText $ "[" <> T.pack (show i) <> "] " <> conversationName conv + printSelectOption i $ plainText $ conversationName conv cmdNew :: Command cmdNew = do @@ -1071,7 +1074,7 @@ cmdNew = do set WatchConversations $ map (SelectedConversation . fst) conversations tzone <- liftIO $ getCurrentTimeZone forM_ (zip [1..] conversations) $ \(i :: Int, ( conv, msg )) -> do - cmdPutStrLn $ plainText ("[" <> T.pack (show i) <> "] " <> conversationName conv <> " ") <> formatMessageFT tzone msg + printSelectOption i $ plainText (conversationName conv <> " ") <> formatMessageFT tzone msg where checkNew conv | (msg : _) <- conversationHistory conv |