From 7a4f697f7bdce5ab0f2d2dd62ace652056cfc1be Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 1 Aug 2014 14:30:15 +0200 Subject: display count in mode-info-box --- src/Main.hs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Main.hs b/src/Main.hs index 061b982..328c641 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -68,7 +68,7 @@ main = do withMVar lockRef $ \ _ -> do clearLine a - renderInputLine (mode q) (buffer q) + renderInputLine (count q) (mode q) (buffer q) hFlush stdout let cf = VTConfig @@ -362,13 +362,25 @@ special colorCode s = "\x1b[1;" ++ show colorCode ++ "m" ++ s ++ "\x1b[m" -- XXX assumes that the cursor is already at the (cleared) input line -renderInputLine :: Mode -> Buffer -> IO () -renderInputLine m (lhs, rhs) = do +-- TODO renderInputLine looks like it wants to be -> VT () +renderInputLine :: Maybe Int -> Mode -> Buffer -> IO () +renderInputLine mb_cnt m (lhs, rhs) = do clearLine -- TODO this is required for drawing the mode on the right side saveCursor moveCursorRight 1024 - moveCursorLeft (length (show m) - 1) - putStr $ "\x1b[1;30m" ++ show m ++ "\x1b[m" + let (infoLen, info) = + case mb_cnt of + Nothing -> + let gaudy = "\x1b[1;30m" ++ show m ++ "\x1b[m" + plain = show m + in (length plain, gaudy) + Just cnt -> + let gaudy = "\x1b[1;30m" ++ show m ++ + "[\x1b[33m" ++ show cnt ++ "\x1b[30m]\x1b[m" + plain = show m ++ "[" ++ show cnt ++ "]" + in (length plain, gaudy) + moveCursorLeft $ infoLen - 1 + putStr info unsaveCursor let promptString = case m of -- cgit v1.2.3