aboutsummaryrefslogtreecommitdiff
path: root/src/Chelleport/View.hs
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2024-12-14 20:59:19 +0530
committerAkshay Nair <phenax5@gmail.com>2024-12-14 21:32:10 +0530
commit0c6b8c83e8673b394914e1f824dfb887b762b0ee (patch)
treeb7878e594881609bd88b6f2f461cfdff5e9c7ab9 /src/Chelleport/View.hs
parent34907bc25dba055dfbfe91d9a91803cc75283bfa (diff)
downloadchelleport-0c6b8c83e8673b394914e1f824dfb887b762b0ee.tar.gz
chelleport-0c6b8c83e8673b394914e1f824dfb887b762b0ee.zip
Add Tab to reset key sequence
Diffstat (limited to '')
-rw-r--r--src/Chelleport/View.hs11
1 files changed, 7 insertions, 4 deletions
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