Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kostmo committed Sep 8, 2024
1 parent 4eaa05e commit 29b4479
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
30 changes: 15 additions & 15 deletions src/swarm-tui/Swarm/TUI/Model/Dialog/Robot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,27 @@ mkRobotDisplay c =
RobotDisplay
{ _robotsDisplayMode = RobotList
, _lastFocusedRobotId = Nothing
, _libList = mixedTabularList RobotsList (mkLibraryEntries c) (LstItmH 1) wprk wpr
, _libList = mixedTabularList RobotsList (mkLibraryEntries c) (LstItmH 1) (wprk uiDebug) wpr
, _libRenderers =
MixedRenderers
{ cell = dc
{ cell = dc uiDebug
, rowHdr = Just rowHdr
, colHdr = Just $ colHdr $ c ^. uiDbg
, colHdr = Just $ colHdr uiDebug
, colHdrRowHdr = Just $ ColHdrRowHdr $ \_ _ -> vLimit 1 (fill ' ') <=> hBorder
}
}
where
uiDebug = c ^. uiDbg

emptyRobotDisplay :: Set DebugOption -> RobotDisplay
emptyRobotDisplay uiDebug =
RobotDisplay
{ _robotsDisplayMode = RobotList
, _lastFocusedRobotId = Nothing
, _libList = mixedTabularList RobotsList mempty (LstItmH 1) wprk wpr
, _libList = mixedTabularList RobotsList mempty (LstItmH 1) (wprk uiDebug) wpr
, _libRenderers =
MixedRenderers
{ cell = dc
{ cell = dc uiDebug
, rowHdr = Just rowHdr
, colHdr = Just $ colHdr uiDebug
, colHdrRowHdr = Just $ ColHdrRowHdr $ \_ _ -> vLimit 1 (fill ' ') <=> hBorder
Expand All @@ -104,7 +106,6 @@ colHdr :: Set DebugOption -> MixedColHdr Name Widths
colHdr uiDbg =

Check warning on line 106 in src/swarm-tui/Swarm/TUI/Model/Dialog/Robot.hs

View workflow job for this annotation

GitHub Actions / Haskell-CI - windows-latest - ghc-9.8.2

This binding for ‘uiDbg’ shadows the existing binding
MixedColHdr
{ draw = \_ (MColC (Ix ci)) -> case hdrs V.!? ci of
-- Just ch -> withAttr columnHdrAttr (padRight Max (str ch) <+> str " ") <=> hBorder
Just ch -> withAttr columnHdrAttr (padRight Max $ str ch) <=> hBorder
Nothing -> emptyWidget
, widths = \(Widths ws) -> zipWith (<>) ws (map (ColW . length) $ V.toList hdrs)
Expand Down Expand Up @@ -170,29 +171,28 @@ accessorList =
, _fLog
]

indexedAccessors :: Vector (LibRobotRow a -> a)
indexedAccessors = V.fromList accessorList

dc :: ListFocused -> MixedCtxt -> RobotWidgetRow -> Widget Name
dc _ (MxdCtxt _ (MColC (Ix ci))) r =
dc :: Set DebugOption -> ListFocused -> MixedCtxt -> RobotWidgetRow -> Widget Name
dc uiDebug _ (MxdCtxt _ (MColC (Ix ci))) r =
maybe emptyWidget (renderPlainCell . wWidget . ($ r)) (indexedAccessors V.!? ci)
where
indexedAccessors = V.fromList accessors
accessors = dropFirstColumn uiDebug accessorList
renderPlainCell = padRight Max

-- | For a single-constructor datatype like 'RobotWidgetRow',
-- this implementation is trivial.
wpr :: WidthsPerRow RobotWidgetRow Widths
wpr = WsPerR $ \(Widths x) _ -> x

wprk :: WidthsPerRowKind RobotWidgetRow Widths
wprk = WsPerRK $ \(AvlW aW) allRows ->
wprk :: Set DebugOption -> WidthsPerRowKind RobotWidgetRow Widths
wprk uiDebug = WsPerRK $ \(AvlW aW) allRows ->

Check warning on line 188 in src/swarm-tui/Swarm/TUI/Model/Dialog/Robot.hs

View workflow job for this annotation

GitHub Actions / Haskell-CI - windows-latest - ghc-9.8.2

Defined but not used: ‘aW’
Widths {robotRowWidths = mkWidths allRows}
where
colHeaderRowLengths = map length headingStringList
colHeaderRowLengths = map length $ dropFirstColumn uiDebug headingStringList
mkWidths = map (ColW . (+ 1) . maximum0) . transpose . (colHeaderRowLengths :) . map getColWidthsForRow
where
getColWidthsForRow :: RobotWidgetRow -> [Int]
getColWidthsForRow r = map (wWidth . ($ r)) accessorList
getColWidthsForRow r = map (wWidth . ($ r)) $ dropFirstColumn uiDebug accessorList

mkLibraryEntries :: RobotRenderingContext -> Seq RobotWidgetRow
mkLibraryEntries c =
Expand Down
4 changes: 3 additions & 1 deletion src/swarm-tui/Swarm/TUI/View.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module Swarm.TUI.View (
drawREPL,
) where

import Brick.Widgets.TabularList.Mixed (list)

Check failure on line 36 in src/swarm-tui/Swarm/TUI/View.hs

View workflow job for this annotation

GitHub Actions / Haskell-CI - windows-latest - ghc-9.8.2

Module ‘Brick.Widgets.TabularList.Mixed’ does not export ‘list’.
import Brick hiding (Direction, Location)
import Brick.Focus
import Brick.Forms
Expand Down Expand Up @@ -627,7 +628,8 @@ drawModal s = \case
}
-- let rd = s ^. uiState . uiGameplay . uiDialogs . uiRobot
-- rd' = rd & libList . list .~
renderTheRobots rd
let rd' = rd & libList . list . BL.listSelectedL .~ Just 1

Check warning on line 631 in src/swarm-tui/Swarm/TUI/View.hs

View workflow job for this annotation

GitHub Actions / HLint

Warning in drawModal in module Swarm.TUI.View: Use ?~ ▫︎ Found: "libList . list . BL.listSelectedL .~ Just 1" ▫︎ Perhaps: "((libList . list . BL.listSelectedL) ?~ 1)"
renderTheRobots rd'
RecipesModal -> availableListWidget (s ^. gameState) RecipeList
CommandsModal -> commandsListWidget (s ^. gameState)
MessagesModal -> availableListWidget (s ^. gameState) MessageList
Expand Down

0 comments on commit 29b4479

Please sign in to comment.