From 0c6b8c83e8673b394914e1f824dfb887b762b0ee Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sat, 14 Dec 2024 20:59:19 +0530 Subject: Add Tab to reset key sequence --- src/Chelleport/View.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/Chelleport/View.hs') diff --git a/src/Chelleport/View.hs b/src/Chelleport/View.hs index f1e941f..cf51390 100644 --- a/src/Chelleport/View.hs +++ b/src/Chelleport/View.hs @@ -11,6 +11,9 @@ import SDL (($=)) import qualified SDL import Unsafe.Coerce (unsafeCoerce) +isEmpty :: [a] -> Bool +isEmpty = null + render :: State -> DrawContext -> IO () render state ctx = do renderGridLines state ctx @@ -33,16 +36,16 @@ renderKeySequence ctx keySequence cell (px, py) = do | otherwise = ("", cell) let textColor - | null keySequence = colorWhite - | not (null matched) = colorAccent + | isEmpty keySequence = colorWhite + | not $ isEmpty matched = colorAccent | otherwise = colorGray widthRef <- newIORef 0 - unless (null matched) $ do + unless (isEmpty matched) $ do (textWidth, _h) <- drawText ctx (SDL.V2 px py) colorLightGray $ Text.pack matched modifyIORef' widthRef (const textWidth) - unless (null remaining) $ do + unless (isEmpty remaining) $ do prevTextWidth <- readIORef widthRef let pos = px + prevTextWidth void $ drawText ctx (SDL.V2 pos py) textColor $ Text.pack remaining -- cgit v1.3.1