diff options
| author | Akshay Nair <phenax5@gmail.com> | 2024-12-28 21:36:39 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2024-12-28 21:36:39 +0530 |
| commit | d000cbb52821dc33c5d2f3d676dc6efa54f3b25f (patch) | |
| tree | 7d4d51082b3b7ddf4f3b94879383efb003a87394 /src/Chelleport/View.hs | |
| parent | b305546950a6742f25023e2ffece423905e1bda8 (diff) | |
| download | chelleport-d000cbb52821dc33c5d2f3d676dc6efa54f3b25f.tar.gz chelleport-d000cbb52821dc33c5d2f3d676dc6efa54f3b25f.zip | |
Move hints mode state inside ModeHints constructor
Diffstat (limited to 'src/Chelleport/View.hs')
| -rw-r--r-- | src/Chelleport/View.hs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/Chelleport/View.hs b/src/Chelleport/View.hs index 03c12d3..8cb6094 100644 --- a/src/Chelleport/View.hs +++ b/src/Chelleport/View.hs @@ -11,7 +11,7 @@ import Foreign.C (CInt) render :: (MonadDraw m) => State -> m () render state = case stateMode state of - ModeHints _ -> renderHintsView state + ModeHints modeHintsData -> renderHintsView state modeHintsData ModeSearch modeSearchData -> renderSearchView state modeSearchData getSearchText :: State -> ModeSearchData -> String @@ -35,19 +35,19 @@ renderSearchView state searchData@(ModeSearchData {searchFilteredWords, searchHi (w, h) <- windowSize void $ drawText (w `div` 2, h `div` 2) colorWhite FontSM (Text.pack $ getSearchText state searchData) -renderHintsView :: (MonadDraw m) => State -> m () -renderHintsView state = do +renderHintsView :: (MonadDraw m) => State -> ModeHintsData -> m () +renderHintsView state (ModeHintsData {stateGrid, stateKeySequence, stateIsMatched}) = do renderGridLines state (wcell, hcell) <- cellSize state - forM_ (zip [0 ..] $ stateGrid state) $ \(rowIndex, row) -> forM_ (zip [0 ..] row) $ \(colIndex, cell) -> do + forM_ (zip [0 ..] stateGrid) $ \(rowIndex, row) -> forM_ (zip [0 ..] row) $ \(colIndex, cell) -> do let py = rowIndex * hcell + 10 let px = colIndex * wcell + wcell `div` 2 - 20 - visible <- renderKeySequence (stateKeySequence state) cell (px, py) + visible <- renderKeySequence stateKeySequence cell (px, py) when visible $ do renderTargetMarker state (rowIndex, colIndex) - when (stateIsMatched state) $ do + when stateIsMatched $ do renderGranularGrid state (rowIndex, colIndex) renderKeySequence :: (MonadDraw m) => KeySequence -> Cell -> (CInt, CInt) -> m Bool @@ -75,11 +75,10 @@ renderKeySequence keySequence cell (px, py) = do renderGridLines :: (MonadDraw m) => State -> m () renderGridLines state = do - let grid = stateGrid state (wcell, hcell) <- cellSize state + let rows = intToCInt $ stateGridRows state + let columns = intToCInt $ stateGridCols state - let rows = intToCInt $ length grid - let columns = intToCInt $ length $ head grid forM_ [0 .. rows] $ \rowIndex -> do setDrawColor colorFocusLines drawHorizontalLine (rowIndex * hcell + hcell `div` 2) |
