{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE TupleSections #-}
module Brick.Widgets.TabularList.Grid (
GridContents(..)
, GridContext(..)
, GridRenderers(..)
, GridSizes(..)
, GridTabularList(..)
, gridTabularList
, renderGridTabularList
, gridMoveLeft
, gridMoveRight
, gridMoveTo
, gridMoveToBeginning
, gridMoveToEnd
, gridMovePageUp
, gridMovePageDown
, handleGridListEvent
, handleGridListEventVi
, module Brick.Widgets.TabularList.Types
) where
import Brick.Widgets.TabularList.Types
import Brick.Widgets.TabularList.Internal.Common
import Brick.Widgets.TabularList.Internal.Lens
import GHC.Generics (Generic)
import Data.Foldable (toList)
import Control.Monad (unless)
import Optics.Core hiding (Empty)
import qualified Data.Sequence as S
import Data.Sequence (Seq(..))
import Data.Generics.Labels
import qualified Brick.Widgets.List as L
import Brick.Types
import Brick.Widgets.Core
import Brick.Widgets.Center
import Graphics.Vty (Event(..), Key(..), Modifier(..))
import Brick.Main (lookupViewport)
data GridContents n row cell rowH colH = GridContents {
forall n row cell rowH colH.
GridContents n row cell rowH colH
-> row -> ColumnIndex -> Maybe cell
cell :: row -> ColumnIndex -> Maybe cell
, forall n row cell rowH colH.
GridContents n row cell rowH colH
-> Maybe (row -> ColumnIndex -> Maybe rowH)
rowHdr :: Maybe (row -> RowIndex -> Maybe rowH)
, forall n row cell rowH colH.
GridContents n row cell rowH colH
-> Maybe (ColumnIndex -> Maybe colH)
colHdr :: Maybe (ColumnIndex -> Maybe colH)
} deriving forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall n row cell rowH colH x.
Rep (GridContents n row cell rowH colH) x
-> GridContents n row cell rowH colH
forall n row cell rowH colH x.
GridContents n row cell rowH colH
-> Rep (GridContents n row cell rowH colH) x
$cto :: forall n row cell rowH colH x.
Rep (GridContents n row cell rowH colH) x
-> GridContents n row cell rowH colH
$cfrom :: forall n row cell rowH colH x.
GridContents n row cell rowH colH
-> Rep (GridContents n row cell rowH colH) x
Generic
data GridContext = GridContext {
GridContext -> Position
row :: Position
, GridContext -> Position
col :: Position
} deriving (ColumnIndex -> GridContext -> ShowS
[GridContext] -> ShowS
GridContext -> String
forall a.
(ColumnIndex -> a -> ShowS)
-> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GridContext] -> ShowS
$cshowList :: [GridContext] -> ShowS
show :: GridContext -> String
$cshow :: GridContext -> String
showsPrec :: ColumnIndex -> GridContext -> ShowS
$cshowsPrec :: ColumnIndex -> GridContext -> ShowS
Show, forall x. Rep GridContext x -> GridContext
forall x. GridContext -> Rep GridContext x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GridContext x -> GridContext
$cfrom :: forall x. GridContext -> Rep GridContext x
Generic)
data GridRenderers n row cell rowH colH = GridRenderers {
forall n row cell rowH colH.
GridRenderers n row cell rowH colH
-> ListFocused
-> ColumnIndex
-> GridContext
-> row
-> Maybe cell
-> Widget n
drawCell :: ListFocused -> WidthDeficit -> GridContext -> row -> Maybe cell -> Widget n
, forall n row cell rowH colH.
GridRenderers n row cell rowH colH
-> Maybe
(ListFocused
-> ColumnIndex -> Position -> row -> Maybe rowH -> Widget n)
drawRowHdr :: Maybe (ListFocused -> WidthDeficit -> Position -> row -> Maybe rowH -> Widget n)
, forall n row cell rowH colH.
GridRenderers n row cell rowH colH
-> Maybe
(ListFocused -> ColumnIndex -> Position -> Maybe colH -> Widget n)
drawColHdr :: Maybe (ListFocused -> WidthDeficit -> Position -> Maybe colH -> Widget n)
, forall n row cell rowH colH.
GridRenderers n row cell rowH colH
-> Maybe (ListFocused -> ColumnIndex -> Widget n)
drawColHdrRowHdr :: Maybe (ListFocused -> WidthDeficit -> Widget n)
} deriving forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall n row cell rowH colH x.
Rep (GridRenderers n row cell rowH colH) x
-> GridRenderers n row cell rowH colH
forall n row cell rowH colH x.
GridRenderers n row cell rowH colH
-> Rep (GridRenderers n row cell rowH colH) x
$cto :: forall n row cell rowH colH x.
Rep (GridRenderers n row cell rowH colH) x
-> GridRenderers n row cell rowH colH
$cfrom :: forall n row cell rowH colH x.
GridRenderers n row cell rowH colH
-> Rep (GridRenderers n row cell rowH colH) x
Generic
data GridSizes rowH = GridSizes {
forall rowH. GridSizes rowH -> Seq ColumnIndex
row :: Seq Width
, forall rowH. GridSizes rowH -> Maybe (RowHeaderWidth rowH)
rowHdr :: Maybe (RowHeaderWidth rowH)
, forall rowH. GridSizes rowH -> Maybe ColumnIndex
colHdr :: Maybe Height
} deriving forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall rowH x. Rep (GridSizes rowH) x -> GridSizes rowH
forall rowH x. GridSizes rowH -> Rep (GridSizes rowH) x
$cto :: forall rowH x. Rep (GridSizes rowH) x -> GridSizes rowH
$cfrom :: forall rowH x. GridSizes rowH -> Rep (GridSizes rowH) x
Generic
data GridTabularList n row cell rowH colH = GridTabularList {
forall n row cell rowH colH.
GridTabularList n row cell rowH colH -> GenericList n Seq row
list :: L.GenericList n Seq row
, forall n row cell rowH colH.
GridTabularList n row cell rowH colH -> GridSizes rowH
sizes :: GridSizes rowH
, forall n row cell rowH colH.
GridTabularList n row cell rowH colH
-> GridContents n row cell rowH colH
contents :: GridContents n row cell rowH colH
, forall n row cell rowH colH.
GridTabularList n row cell rowH colH -> ColumnIndex
currentColumn :: ColumnIndex
} deriving forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall n row cell rowH colH x.
Rep (GridTabularList n row cell rowH colH) x
-> GridTabularList n row cell rowH colH
forall n row cell rowH colH x.
GridTabularList n row cell rowH colH
-> Rep (GridTabularList n row cell rowH colH) x
$cto :: forall n row cell rowH colH x.
Rep (GridTabularList n row cell rowH colH) x
-> GridTabularList n row cell rowH colH
$cfrom :: forall n row cell rowH colH x.
GridTabularList n row cell rowH colH
-> Rep (GridTabularList n row cell rowH colH) x
Generic
gridTabularList :: n
-> Seq row
-> ListItemHeight
-> GridSizes rowH
-> GridContents n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridTabularList :: forall n row rowH cell colH.
n
-> Seq row
-> ColumnIndex
-> GridSizes rowH
-> GridContents n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridTabularList n
n Seq row
rows ColumnIndex
h GridSizes rowH
sizes GridContents n row cell rowH colH
contents = GridTabularList {
$sel:list:GridTabularList :: GenericList n Seq row
list = forall (t :: * -> *) n e.
Foldable t =>
n -> t e -> ColumnIndex -> GenericList n t e
L.list n
n Seq row
rows ColumnIndex
h
, $sel:sizes:GridTabularList :: GridSizes rowH
sizes = GridSizes rowH
sizes
, $sel:contents:GridTabularList :: GridContents n row cell rowH colH
contents = GridContents n row cell rowH colH
contents
, $sel:currentColumn:GridTabularList :: ColumnIndex
currentColumn = ColumnIndex
0
}
data VisibleColumns =
NoColumn
| CurrentColumn
| AnchoredLeft {
VisibleColumns -> ColumnIndex
right :: Int
}
| MiddleColumns {
VisibleColumns -> ColumnIndex
left :: Int,
right :: Int,
VisibleColumns -> ColumnIndex
offset :: Int,
VisibleColumns -> ColumnIndex
totalWidth :: Int
}
| AnchoredRight {
left :: Int,
offset :: Int,
totalWidth :: Int
}
deriving ColumnIndex -> VisibleColumns -> ShowS
[VisibleColumns] -> ShowS
VisibleColumns -> String
forall a.
(ColumnIndex -> a -> ShowS)
-> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VisibleColumns] -> ShowS
$cshowList :: [VisibleColumns] -> ShowS
show :: VisibleColumns -> String
$cshow :: VisibleColumns -> String
showsPrec :: ColumnIndex -> VisibleColumns -> ShowS
$cshowsPrec :: ColumnIndex -> VisibleColumns -> ShowS
Show
visibleColumns :: GridTabularList n row cell rowH colH -> AvailWidth -> VisibleColumns
visibleColumns :: forall n row cell rowH colH.
GridTabularList n row cell rowH colH
-> ColumnIndex -> VisibleColumns
visibleColumns GridTabularList n row cell rowH colH
l ColumnIndex
aW = let curCol :: ColumnIndex
curCol = GridTabularList n row cell rowH colH
l forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "currentColumn" a => a
#currentColumn in
case forall a. ColumnIndex -> Seq a -> (Seq a, Seq a)
S.splitAt ColumnIndex
curCol (GridTabularList n row cell rowH colH
l forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "sizes" a => a
#sizes forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a
b.
(JoinKinds k l m, AppendIndices is js ks) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% forall a. IsLabel "row" a => a
#row) of
(Seq ColumnIndex
_, Seq ColumnIndex
Empty) -> VisibleColumns
NoColumn
(Seq ColumnIndex
left, ColumnIndex
cW :<| Seq ColumnIndex
right) -> if ColumnIndex
aW forall a. Ord a => a -> a -> ListFocused
<= ColumnIndex
0
then VisibleColumns
NoColumn
else if ColumnIndex
cW forall a. Ord a => a -> a -> ListFocused
>= ColumnIndex
aW
then VisibleColumns
CurrentColumn
else let
lW :: ColumnIndex
lW = (ColumnIndex
aW forall a. Num a => a -> a -> a
- ColumnIndex
cW) forall a. Integral a => a -> a -> a
`div` ColumnIndex
2
rW :: ColumnIndex
rW = ColumnIndex
aW forall a. Num a => a -> a -> a
- ColumnIndex
lW forall a. Num a => a -> a -> a
- ColumnIndex
cW
leftForMiddle :: Seq ColumnIndex -> ColumnIndex -> ColumnIndex -> VisibleColumns
leftForMiddle (Seq ColumnIndex
l :|> ColumnIndex
w) ColumnIndex
idx ColumnIndex
accW = if ColumnIndex
accWforall a. Num a => a -> a -> a
+ColumnIndex
w forall a. Ord a => a -> a -> ListFocused
< ColumnIndex
lW
then Seq ColumnIndex -> ColumnIndex -> ColumnIndex -> VisibleColumns
leftForMiddle Seq ColumnIndex
l (ColumnIndex
idxforall a. Num a => a -> a -> a
-ColumnIndex
1) (ColumnIndex
accWforall a. Num a => a -> a -> a
+ColumnIndex
w)
else ColumnIndex
-> ColumnIndex
-> Seq ColumnIndex
-> ColumnIndex
-> ColumnIndex
-> VisibleColumns
rightForMiddle ColumnIndex
idx (ColumnIndex
accWforall a. Num a => a -> a -> a
+ColumnIndex
w) Seq ColumnIndex
right (ColumnIndex
curColforall a. Num a => a -> a -> a
+ColumnIndex
1) ColumnIndex
0
leftForMiddle Seq ColumnIndex
Empty ColumnIndex
_ ColumnIndex
accW = Seq ColumnIndex -> ColumnIndex -> ColumnIndex -> VisibleColumns
rightForLeft Seq ColumnIndex
right (ColumnIndex
curColforall a. Num a => a -> a -> a
+ColumnIndex
1) (ColumnIndex
accWforall a. Num a => a -> a -> a
+ColumnIndex
cW)
rightForMiddle :: ColumnIndex
-> ColumnIndex
-> Seq ColumnIndex
-> ColumnIndex
-> ColumnIndex
-> VisibleColumns
rightForMiddle ColumnIndex
li ColumnIndex
lAccW (ColumnIndex
w :<| Seq ColumnIndex
r) ColumnIndex
ri ColumnIndex
accW = if ColumnIndex
accWforall a. Num a => a -> a -> a
+ColumnIndex
w forall a. Ord a => a -> a -> ListFocused
< ColumnIndex
rW
then ColumnIndex
-> ColumnIndex
-> Seq ColumnIndex
-> ColumnIndex
-> ColumnIndex
-> VisibleColumns
rightForMiddle ColumnIndex
li ColumnIndex
lAccW Seq ColumnIndex
r (ColumnIndex
riforall a. Num a => a -> a -> a
+ColumnIndex
1) (ColumnIndex
accWforall a. Num a => a -> a -> a
+ColumnIndex
w)
else MiddleColumns { $sel:left:NoColumn :: ColumnIndex
left = ColumnIndex
li, $sel:right:NoColumn :: ColumnIndex
right = ColumnIndex
ri, $sel:offset:NoColumn :: ColumnIndex
offset = ColumnIndex
lAccWforall a. Num a => a -> a -> a
-ColumnIndex
lW, $sel:totalWidth:NoColumn :: ColumnIndex
totalWidth = ColumnIndex
lAccWforall a. Num a => a -> a -> a
+ColumnIndex
cWforall a. Num a => a -> a -> a
+ColumnIndex
accWforall a. Num a => a -> a -> a
+ColumnIndex
w }
rightForMiddle ColumnIndex
_ ColumnIndex
_ Seq ColumnIndex
Empty ColumnIndex
_ ColumnIndex
accW = Seq ColumnIndex -> ColumnIndex -> ColumnIndex -> VisibleColumns
leftForRight Seq ColumnIndex
left (ColumnIndex
curColforall a. Num a => a -> a -> a
-ColumnIndex
1) (ColumnIndex
accWforall a. Num a => a -> a -> a
+ColumnIndex
cW)
rightForLeft :: Seq ColumnIndex -> ColumnIndex -> ColumnIndex -> VisibleColumns
rightForLeft (ColumnIndex
w :<| Seq ColumnIndex
r) ColumnIndex
idx ColumnIndex
accW = if ColumnIndex
accWforall a. Num a => a -> a -> a
+ColumnIndex
w forall a. Ord a => a -> a -> ListFocused
< ColumnIndex
aW
then Seq ColumnIndex -> ColumnIndex -> ColumnIndex -> VisibleColumns
rightForLeft Seq ColumnIndex
r (ColumnIndex
idxforall a. Num a => a -> a -> a
+ColumnIndex
1) (ColumnIndex
accWforall a. Num a => a -> a -> a
+ColumnIndex
w)
else ColumnIndex -> VisibleColumns
AnchoredLeft ColumnIndex
idx
rightForLeft Seq ColumnIndex
Empty ColumnIndex
idx ColumnIndex
_ = ColumnIndex -> VisibleColumns
AnchoredLeft (ColumnIndex
idxforall a. Num a => a -> a -> a
-ColumnIndex
1)
leftForRight :: Seq ColumnIndex -> ColumnIndex -> ColumnIndex -> VisibleColumns
leftForRight (Seq ColumnIndex
l :|> ColumnIndex
w) ColumnIndex
idx ColumnIndex
accW = if ColumnIndex
accWforall a. Num a => a -> a -> a
+ColumnIndex
w forall a. Ord a => a -> a -> ListFocused
< ColumnIndex
aW
then Seq ColumnIndex -> ColumnIndex -> ColumnIndex -> VisibleColumns
leftForRight Seq ColumnIndex
l (ColumnIndex
idxforall a. Num a => a -> a -> a
-ColumnIndex
1) (ColumnIndex
accWforall a. Num a => a -> a -> a
+ColumnIndex
w)
else AnchoredRight { $sel:left:NoColumn :: ColumnIndex
left = ColumnIndex
idx, $sel:offset:NoColumn :: ColumnIndex
offset = ColumnIndex
accWforall a. Num a => a -> a -> a
+ColumnIndex
wforall a. Num a => a -> a -> a
-ColumnIndex
aW, $sel:totalWidth:NoColumn :: ColumnIndex
totalWidth = ColumnIndex
accWforall a. Num a => a -> a -> a
+ColumnIndex
w }
leftForRight Seq ColumnIndex
Empty ColumnIndex
_ ColumnIndex
_ = ColumnIndex -> VisibleColumns
AnchoredLeft forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. Foldable t => t a -> ColumnIndex
length (GridTabularList n row cell rowH colH
l forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "sizes" a => a
#sizes forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a
b.
(JoinKinds k l m, AppendIndices is js ks) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% forall a. IsLabel "row" a => a
#row) forall a. Num a => a -> a -> a
- ColumnIndex
1
in Seq ColumnIndex -> ColumnIndex -> ColumnIndex -> VisibleColumns
leftForMiddle Seq ColumnIndex
left (ColumnIndex
curColforall a. Num a => a -> a -> a
-ColumnIndex
1) ColumnIndex
0
renderColumns :: GridTabularList n row cell rowH colH
-> VisibleColumns
-> (WidthDeficit -> ColumnIndex -> Width -> Widget n)
-> Widget n
renderColumns :: forall n row cell rowH colH.
GridTabularList n row cell rowH colH
-> VisibleColumns
-> (ColumnIndex -> ColumnIndex -> ColumnIndex -> Widget n)
-> Widget n
renderColumns GridTabularList n row cell rowH colH
l VisibleColumns
vCs ColumnIndex -> ColumnIndex -> ColumnIndex -> Widget n
dC = forall n. Size -> Size -> RenderM n (Result n) -> Widget n
Widget Size
Greedy Size
Fixed forall a b. (a -> b) -> a -> b
$ do
Context n
c <- forall n. RenderM n (Context n)
getContext
let cWs :: Seq ColumnIndex
cWs = GridTabularList n row cell rowH colH
l forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "sizes" a => a
#sizes forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a
b.
(JoinKinds k l m, AppendIndices is js ks) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% forall a. IsLabel "row" a => a
#row
iH :: ColumnIndex
iH = GridTabularList n row cell rowH colH
l forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "list" a => a
#list forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a
b.
(JoinKinds k l m, AppendIndices is js ks) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% forall a. IsLabel "listItemHeight" a => a
#listItemHeight
curCol :: ColumnIndex
curCol = GridTabularList n row cell rowH colH
l forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "currentColumn" a => a
#currentColumn
aW :: ColumnIndex
aW = Context n
cforall {s} {a}. s -> Getting a s a -> a
^^.forall n. Lens' (Context n) ColumnIndex
availWidthL
forall n. Widget n -> RenderM n (Result n)
render forall a b. (a -> b) -> a -> b
$ case VisibleColumns
vCs of
VisibleColumns
NoColumn -> forall n. Widget n
emptyWidget
VisibleColumns
CurrentColumn -> case forall a. ColumnIndex -> Seq a -> Maybe a
S.lookup ColumnIndex
curCol Seq ColumnIndex
cWs of
Maybe ColumnIndex
Nothing -> forall a. HasCallStack => String -> a
error forall a b. (a -> b) -> a -> b
$ String
"Current column, " forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> String
show ColumnIndex
curCol forall a. Semigroup a => a -> a -> a
<> String
" is outside the boundary of column widths."
Just ColumnIndex
cW -> ColumnIndex -> ColumnIndex -> ColumnIndex -> Widget n
dC (forall a. Ord a => a -> a -> a
max ColumnIndex
0 forall a b. (a -> b) -> a -> b
$ ColumnIndex
cW forall a. Num a => a -> a -> a
- ColumnIndex
aW) ColumnIndex
curCol ColumnIndex
aW
AnchoredLeft ColumnIndex
right -> forall n. [Widget n] -> Widget n
hBox forall a b. (a -> b) -> a -> b
$ forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith (ColumnIndex -> ColumnIndex -> ColumnIndex -> Widget n
dC ColumnIndex
0) [ColumnIndex
0..] forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. Foldable t => t a -> [a]
toList forall a b. (a -> b) -> a -> b
$ forall a. ColumnIndex -> Seq a -> Seq a
S.take (ColumnIndex
rightforall a. Num a => a -> a -> a
+ColumnIndex
1) Seq ColumnIndex
cWs
MiddleColumns {ColumnIndex
totalWidth :: ColumnIndex
offset :: ColumnIndex
right :: ColumnIndex
left :: ColumnIndex
$sel:totalWidth:NoColumn :: VisibleColumns -> ColumnIndex
$sel:offset:NoColumn :: VisibleColumns -> ColumnIndex
$sel:left:NoColumn :: VisibleColumns -> ColumnIndex
$sel:right:NoColumn :: VisibleColumns -> ColumnIndex
..} -> forall n. ColumnIndex -> Widget n -> Widget n
cropLeftBy ColumnIndex
offset forall a b. (a -> b) -> a -> b
$ forall n. (ColumnIndex, ColumnIndex) -> Widget n -> Widget n
setAvailableSize (ColumnIndex
totalWidth, ColumnIndex
iH) forall a b. (a -> b) -> a -> b
$
forall n. [Widget n] -> Widget n
hBox forall a b. (a -> b) -> a -> b
$ forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith (ColumnIndex -> ColumnIndex -> ColumnIndex -> Widget n
dC ColumnIndex
0) [ColumnIndex
left..] forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. Foldable t => t a -> [a]
toList forall a b. (a -> b) -> a -> b
$ forall a. ColumnIndex -> Seq a -> Seq a
S.take (ColumnIndex
rightforall a. Num a => a -> a -> a
-ColumnIndex
leftforall a. Num a => a -> a -> a
+ColumnIndex
1) forall a b. (a -> b) -> a -> b
$ forall a. ColumnIndex -> Seq a -> Seq a
S.drop ColumnIndex
left Seq ColumnIndex
cWs
AnchoredRight {ColumnIndex
totalWidth :: ColumnIndex
offset :: ColumnIndex
left :: ColumnIndex
$sel:totalWidth:NoColumn :: VisibleColumns -> ColumnIndex
$sel:offset:NoColumn :: VisibleColumns -> ColumnIndex
$sel:left:NoColumn :: VisibleColumns -> ColumnIndex
..} -> forall n. ColumnIndex -> Widget n -> Widget n
cropLeftBy ColumnIndex
offset forall a b. (a -> b) -> a -> b
$ forall n. (ColumnIndex, ColumnIndex) -> Widget n -> Widget n
setAvailableSize (ColumnIndex
totalWidth, ColumnIndex
iH) forall a b. (a -> b) -> a -> b
$
forall n. [Widget n] -> Widget n
hBox forall a b. (a -> b) -> a -> b
$ forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith (ColumnIndex -> ColumnIndex -> ColumnIndex -> Widget n
dC ColumnIndex
0) [ColumnIndex
left..] forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. Foldable t => t a -> [a]
toList forall a b. (a -> b) -> a -> b
$ forall a. ColumnIndex -> Seq a -> Seq a
S.drop ColumnIndex
left Seq ColumnIndex
cWs
renderGridTabularList :: (Ord n, Show n)
=> GridRenderers n row cell rowH colH
-> ListFocused
-> GridTabularList n row cell rowH colH
-> Widget n
renderGridTabularList :: forall n row cell rowH colH.
(Ord n, Show n) =>
GridRenderers n row cell rowH colH
-> ListFocused -> GridTabularList n row cell rowH colH -> Widget n
renderGridTabularList GridRenderers n row cell rowH colH
r ListFocused
lf GridTabularList n row cell rowH colH
l = forall n. Size -> Size -> RenderM n (Result n) -> Widget n
Widget Size
Greedy Size
Greedy forall a b. (a -> b) -> a -> b
$ do
Context n
c <- forall n. RenderM n (Context n)
getContext
let drawCell :: ListFocused
-> ColumnIndex -> GridContext -> row -> Maybe cell -> Widget n
drawCell = GridRenderers n row cell rowH colH
r forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "drawCell" a => a
#drawCell
cell :: row -> ColumnIndex -> Maybe cell
cell = GridTabularList n row cell rowH colH
l forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "contents" a => a
#contents forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a
b.
(JoinKinds k l m, AppendIndices is js ks) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% forall a. IsLabel "cell" a => a
#cell
list :: GenericList n Seq row
list = GridTabularList n row cell rowH colH
l forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "list" a => a
#list
curCol :: ColumnIndex
curCol = GridTabularList n row cell rowH colH
l forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "currentColumn" a => a
#currentColumn
aW :: ColumnIndex
aW = Context n
cforall {s} {a}. s -> Getting a s a -> a
^^.forall n. Lens' (Context n) ColumnIndex
availWidthL
aH :: ColumnIndex
aH = Context n
cforall {s} {a}. s -> Getting a s a -> a
^^.forall n. Lens' (Context n) ColumnIndex
availHeightL
iH :: ColumnIndex
iH = GenericList n Seq row
list forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "listItemHeight" a => a
#listItemHeight
wSet :: ColumnIndex -> Widget n -> Widget n
wSet = forall n. (ColumnIndex, ColumnIndex) -> Widget n -> Widget n
setAvailableSize forall b c a. (b -> c) -> (a -> b) -> a -> c
. (, ColumnIndex
iH)
colHdrRow :: VisibleColumns -> ColumnIndex -> ColumnIndex -> Widget n
colHdrRow VisibleColumns
vCs ColumnIndex
rhw' ColumnIndex
rhwd = case (GridTabularList n row cell rowH colH
l forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "contents" a => a
#contents forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a
b.
(JoinKinds k l m, AppendIndices is js ks) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% forall a. IsLabel "colHdr" a => a
#colHdr, GridTabularList n row cell rowH colH
l forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "sizes" a => a
#sizes forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a
b.
(JoinKinds k l m, AppendIndices is js ks) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% forall a. IsLabel "colHdr" a => a
#colHdr, GridRenderers n row cell rowH colH
r forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "drawColHdr" a => a
#drawColHdr) of
(Maybe (ColumnIndex -> Maybe colH)
Nothing, Maybe ColumnIndex
_, Maybe
(ListFocused -> ColumnIndex -> Position -> Maybe colH -> Widget n)
_) -> forall n. Widget n
emptyWidget
(Maybe (ColumnIndex -> Maybe colH)
_, Maybe ColumnIndex
Nothing, Maybe
(ListFocused -> ColumnIndex -> Position -> Maybe colH -> Widget n)
_) -> forall n. Widget n
emptyWidget
(Maybe (ColumnIndex -> Maybe colH)
_, Maybe ColumnIndex
_, Maybe
(ListFocused -> ColumnIndex -> Position -> Maybe colH -> Widget n)
Nothing) -> forall n. Widget n
emptyWidget
(Just ColumnIndex -> Maybe colH
colH, Just ColumnIndex
colHdrH, Just ListFocused -> ColumnIndex -> Position -> Maybe colH -> Widget n
dch) -> let
drawCol :: ColumnIndex -> ColumnIndex -> ColumnIndex -> Widget n
drawCol ColumnIndex
wd ColumnIndex
c ColumnIndex
w = forall n. (ColumnIndex, ColumnIndex) -> Widget n -> Widget n
setAvailableSize (ColumnIndex
w, ColumnIndex
colHdrH) forall a b. (a -> b) -> a -> b
$ ListFocused -> ColumnIndex -> Position -> Maybe colH -> Widget n
dch ListFocused
lf ColumnIndex
wd (ColumnIndex -> ListFocused -> Position
Position ColumnIndex
c (ColumnIndex
c forall a. Eq a => a -> a -> ListFocused
== ColumnIndex
curCol)) forall a b. (a -> b) -> a -> b
$ ColumnIndex -> Maybe colH
colH ColumnIndex
c
chrw :: Widget n
chrw = case GridRenderers n row cell rowH colH
r forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "drawColHdrRowHdr" a => a
#drawColHdrRowHdr of
Maybe (ListFocused -> ColumnIndex -> Widget n)
Nothing -> forall n. Char -> Widget n
fill Char
' '
Just ListFocused -> ColumnIndex -> Widget n
dchrw -> ListFocused -> ColumnIndex -> Widget n
dchrw ListFocused
lf ColumnIndex
rhwd
in forall n. (ColumnIndex, ColumnIndex) -> Widget n -> Widget n
setAvailableSize (ColumnIndex
rhw', ColumnIndex
colHdrH) Widget n
chrw forall n. Widget n -> Widget n -> Widget n
<+> forall n row cell rowH colH.
GridTabularList n row cell rowH colH
-> VisibleColumns
-> (ColumnIndex -> ColumnIndex -> ColumnIndex -> Widget n)
-> Widget n
renderColumns GridTabularList n row cell rowH colH
l VisibleColumns
vCs ColumnIndex -> ColumnIndex -> ColumnIndex -> Widget n
drawCol
renderRow :: VisibleColumns -> ColumnIndex -> ListFocused -> row -> Widget n
renderRow VisibleColumns
vCs ColumnIndex
i ListFocused
f row
r = let
drawCol :: ColumnIndex -> ColumnIndex -> ColumnIndex -> Widget n
drawCol ColumnIndex
wd ColumnIndex
c ColumnIndex
w = let gc :: GridContext
gc = Position -> Position -> GridContext
GridContext (ColumnIndex -> ListFocused -> Position
Position ColumnIndex
i ListFocused
f) (ColumnIndex -> ListFocused -> Position
Position ColumnIndex
c forall a b. (a -> b) -> a -> b
$ ColumnIndex
c forall a. Eq a => a -> a -> ListFocused
== ColumnIndex
curCol)
in forall n. ColumnIndex -> Widget n -> Widget n
wSet ColumnIndex
w forall a b. (a -> b) -> a -> b
$ ListFocused
-> ColumnIndex -> GridContext -> row -> Maybe cell -> Widget n
drawCell ListFocused
lf ColumnIndex
wd GridContext
gc row
r forall a b. (a -> b) -> a -> b
$ row -> ColumnIndex -> Maybe cell
cell row
r ColumnIndex
c
in forall n row cell rowH colH.
GridTabularList n row cell rowH colH
-> VisibleColumns
-> (ColumnIndex -> ColumnIndex -> ColumnIndex -> Widget n)
-> Widget n
renderColumns GridTabularList n row cell rowH colH
l VisibleColumns
vCs ColumnIndex -> ColumnIndex -> ColumnIndex -> Widget n
drawCol
renderList :: RenderM n (Result n)
renderList = let vCs :: VisibleColumns
vCs = forall n row cell rowH colH.
GridTabularList n row cell rowH colH
-> ColumnIndex -> VisibleColumns
visibleColumns GridTabularList n row cell rowH colH
l ColumnIndex
aW in
forall n. Widget n -> RenderM n (Result n)
render forall a b. (a -> b) -> a -> b
$ VisibleColumns -> ColumnIndex -> ColumnIndex -> Widget n
colHdrRow VisibleColumns
vCs ColumnIndex
0 ColumnIndex
0 forall n. Widget n -> Widget n -> Widget n
<=> forall (t :: * -> *) n e.
(Traversable t, Splittable t, Ord n, Show n) =>
(ColumnIndex -> ListFocused -> e -> Widget n)
-> ListFocused -> GenericList n t e -> Widget n
L.renderListWithIndex (VisibleColumns -> ColumnIndex -> ListFocused -> row -> Widget n
renderRow VisibleColumns
vCs) ListFocused
lf GenericList n Seq row
list
renderHdrList :: (row -> ColumnIndex -> a)
-> ColumnIndex
-> (ListFocused -> ColumnIndex -> Position -> row -> a -> Widget n)
-> RenderM n (Result n)
renderHdrList row -> ColumnIndex -> a
rh ColumnIndex
rhw ListFocused -> ColumnIndex -> Position -> row -> a -> Widget n
drh = let
rhw' :: ColumnIndex
rhw' = forall a. Ord a => a -> a -> a
min ColumnIndex
rhw ColumnIndex
aW
rhwd :: ColumnIndex
rhwd = forall a. Ord a => a -> a -> a
max ColumnIndex
0 forall a b. (a -> b) -> a -> b
$ ColumnIndex
rhw forall a. Num a => a -> a -> a
- ColumnIndex
aW
vCs :: VisibleColumns
vCs = forall n row cell rowH colH.
GridTabularList n row cell rowH colH
-> ColumnIndex -> VisibleColumns
visibleColumns GridTabularList n row cell rowH colH
l forall a b. (a -> b) -> a -> b
$ ColumnIndex
aW forall a. Num a => a -> a -> a
- ColumnIndex
rhw'
renderHdrRow :: ColumnIndex -> ListFocused -> row -> Widget n
renderHdrRow ColumnIndex
i ListFocused
f row
row = forall n. ColumnIndex -> Widget n -> Widget n
wSet ColumnIndex
rhw' (ListFocused -> ColumnIndex -> Position -> row -> a -> Widget n
drh ListFocused
lf ColumnIndex
rhwd (ColumnIndex -> ListFocused -> Position
Position ColumnIndex
i ListFocused
f) row
row forall a b. (a -> b) -> a -> b
$ row -> ColumnIndex -> a
rh row
row ColumnIndex
i) forall n. Widget n -> Widget n -> Widget n
<+> VisibleColumns -> ColumnIndex -> ListFocused -> row -> Widget n
renderRow VisibleColumns
vCs ColumnIndex
i ListFocused
f row
row
in forall n. Widget n -> RenderM n (Result n)
render forall a b. (a -> b) -> a -> b
$ VisibleColumns -> ColumnIndex -> ColumnIndex -> Widget n
colHdrRow VisibleColumns
vCs ColumnIndex
rhw' ColumnIndex
rhwd forall n. Widget n -> Widget n -> Widget n
<=> forall (t :: * -> *) n e.
(Traversable t, Splittable t, Ord n, Show n) =>
(ColumnIndex -> ListFocused -> e -> Widget n)
-> ListFocused -> GenericList n t e -> Widget n
L.renderListWithIndex ColumnIndex -> ListFocused -> row -> Widget n
renderHdrRow ListFocused
lf GenericList n Seq row
list
case (GridTabularList n row cell rowH colH
l forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "contents" a => a
#contents forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a
b.
(JoinKinds k l m, AppendIndices is js ks) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% forall a. IsLabel "rowHdr" a => a
#rowHdr, GridTabularList n row cell rowH colH
l forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "sizes" a => a
#sizes forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a
b.
(JoinKinds k l m, AppendIndices is js ks) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% forall a. IsLabel "rowHdr" a => a
#rowHdr, GridRenderers n row cell rowH colH
r forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "drawRowHdr" a => a
#drawRowHdr) of
(Maybe (row -> ColumnIndex -> Maybe rowH)
Nothing, Maybe (RowHeaderWidth rowH)
_, Maybe
(ListFocused
-> ColumnIndex -> Position -> row -> Maybe rowH -> Widget n)
_) -> RenderM n (Result n)
renderList
(Maybe (row -> ColumnIndex -> Maybe rowH)
_, Maybe (RowHeaderWidth rowH)
Nothing, Maybe
(ListFocused
-> ColumnIndex -> Position -> row -> Maybe rowH -> Widget n)
_) -> RenderM n (Result n)
renderList
(Maybe (row -> ColumnIndex -> Maybe rowH)
_, Maybe (RowHeaderWidth rowH)
_, Maybe
(ListFocused
-> ColumnIndex -> Position -> row -> Maybe rowH -> Widget n)
Nothing) -> RenderM n (Result n)
renderList
(Just row -> ColumnIndex -> Maybe rowH
rh, Just (FixedRowHeader ColumnIndex
w), Just ListFocused
-> ColumnIndex -> Position -> row -> Maybe rowH -> Widget n
drh) -> forall {a}.
(row -> ColumnIndex -> a)
-> ColumnIndex
-> (ListFocused -> ColumnIndex -> Position -> row -> a -> Widget n)
-> RenderM n (Result n)
renderHdrList row -> ColumnIndex -> Maybe rowH
rh ColumnIndex
w ListFocused
-> ColumnIndex -> Position -> row -> Maybe rowH -> Widget n
drh
(Just row -> ColumnIndex -> Maybe rowH
rh, Just (AvailRowHeader ColumnIndex -> ColumnIndex
w), Just ListFocused
-> ColumnIndex -> Position -> row -> Maybe rowH -> Widget n
drh) -> forall {a}.
(row -> ColumnIndex -> a)
-> ColumnIndex
-> (ListFocused -> ColumnIndex -> Position -> row -> a -> Widget n)
-> RenderM n (Result n)
renderHdrList row -> ColumnIndex -> Maybe rowH
rh (ColumnIndex -> ColumnIndex
w ColumnIndex
aW) ListFocused
-> ColumnIndex -> Position -> row -> Maybe rowH -> Widget n
drh
(Just row -> ColumnIndex -> Maybe rowH
rh, Just (VisibleRowHeaders ColumnIndex -> [rowH] -> ColumnIndex
w), Just ListFocused
-> ColumnIndex -> Position -> row -> Maybe rowH -> Widget n
drh) -> forall {a}.
(row -> ColumnIndex -> a)
-> ColumnIndex
-> (ListFocused -> ColumnIndex -> Position -> row -> a -> Widget n)
-> RenderM n (Result n)
renderHdrList row -> ColumnIndex -> Maybe rowH
rh (ColumnIndex -> [rowH] -> ColumnIndex
w ColumnIndex
aW forall a b. (a -> b) -> a -> b
$ forall n row rowH.
GenericList n Seq row
-> ColumnIndex -> (row -> ColumnIndex -> Maybe rowH) -> [rowH]
visibleRowHdrs GenericList n Seq row
list ColumnIndex
aH row -> ColumnIndex -> Maybe rowH
rh) ListFocused
-> ColumnIndex -> Position -> row -> Maybe rowH -> Widget n
drh
gridMoveLeft :: GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveLeft :: forall n row cell rowH colH.
GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveLeft GridTabularList n row cell rowH colH
gl = if forall (t :: * -> *) a. Foldable t => t a -> ListFocused
null forall a b. (a -> b) -> a -> b
$ GridTabularList n row cell rowH colH
gl forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "list" a => a
#list forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a
b.
(JoinKinds k l m, AppendIndices is js ks) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% forall a. IsLabel "listSelected" a => a
#listSelected
then GridTabularList n row cell rowH colH
gl
else GridTabularList n row cell rowH colH
gl forall a b. a -> (a -> b) -> b
& forall a. IsLabel "currentColumn" a => a
#currentColumn forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> (a -> b) -> s -> t
%~ forall a. Ord a => a -> a -> a
max ColumnIndex
0 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Num a => a -> a -> a
subtract ColumnIndex
1
gridMoveRight :: GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveRight :: forall n row cell rowH colH.
GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveRight GridTabularList n row cell rowH colH
gl = if forall (t :: * -> *) a. Foldable t => t a -> ListFocused
null forall a b. (a -> b) -> a -> b
$ GridTabularList n row cell rowH colH
gl forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "list" a => a
#list forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a
b.
(JoinKinds k l m, AppendIndices is js ks) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% forall a. IsLabel "listSelected" a => a
#listSelected
then GridTabularList n row cell rowH colH
gl
else GridTabularList n row cell rowH colH
gl forall a b. a -> (a -> b) -> b
& forall a. IsLabel "currentColumn" a => a
#currentColumn forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> (a -> b) -> s -> t
%~ forall a. Ord a => a -> a -> a
min (forall (t :: * -> *) a. Foldable t => t a -> ColumnIndex
length (GridTabularList n row cell rowH colH
gl forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "sizes" a => a
#sizes forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a
b.
(JoinKinds k l m, AppendIndices is js ks) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% forall a. IsLabel "row" a => a
#row) forall a. Num a => a -> a -> a
- ColumnIndex
1) forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. Num a => a -> a -> a
+ColumnIndex
1)
gridMoveTo :: ColumnIndex
-> GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveTo :: forall n row cell rowH colH.
ColumnIndex
-> GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveTo ColumnIndex
n GridTabularList n row cell rowH colH
gl = if forall (t :: * -> *) a. Foldable t => t a -> ListFocused
null forall a b. (a -> b) -> a -> b
$ GridTabularList n row cell rowH colH
gl forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "list" a => a
#list forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a
b.
(JoinKinds k l m, AppendIndices is js ks) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% forall a. IsLabel "listSelected" a => a
#listSelected
then GridTabularList n row cell rowH colH
gl
else GridTabularList n row cell rowH colH
gl forall a b. a -> (a -> b) -> b
& forall a. IsLabel "currentColumn" a => a
#currentColumn forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> b -> s -> t
.~ (forall a. Ord a => a -> a -> a
max ColumnIndex
0 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Ord a => a -> a -> a
min (forall (t :: * -> *) a. Foldable t => t a -> ColumnIndex
length (GridTabularList n row cell rowH colH
gl forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "sizes" a => a
#sizes forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a
b.
(JoinKinds k l m, AppendIndices is js ks) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% forall a. IsLabel "row" a => a
#row) forall a. Num a => a -> a -> a
- ColumnIndex
1)) ColumnIndex
n
gridMoveToBeginning :: GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveToBeginning :: forall n row cell rowH colH.
GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveToBeginning GridTabularList n row cell rowH colH
gl = if forall (t :: * -> *) a. Foldable t => t a -> ListFocused
null forall a b. (a -> b) -> a -> b
$ GridTabularList n row cell rowH colH
gl forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "list" a => a
#list forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a
b.
(JoinKinds k l m, AppendIndices is js ks) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% forall a. IsLabel "listSelected" a => a
#listSelected
then GridTabularList n row cell rowH colH
gl
else GridTabularList n row cell rowH colH
gl forall a b. a -> (a -> b) -> b
& forall a. IsLabel "currentColumn" a => a
#currentColumn forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> b -> s -> t
.~ ColumnIndex
0
gridMoveToEnd :: GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveToEnd :: forall n row cell rowH colH.
GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveToEnd GridTabularList n row cell rowH colH
gl = if forall (t :: * -> *) a. Foldable t => t a -> ListFocused
null forall a b. (a -> b) -> a -> b
$ GridTabularList n row cell rowH colH
gl forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "list" a => a
#list forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a
b.
(JoinKinds k l m, AppendIndices is js ks) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% forall a. IsLabel "listSelected" a => a
#listSelected
then GridTabularList n row cell rowH colH
gl
else GridTabularList n row cell rowH colH
gl forall a b. a -> (a -> b) -> b
& forall a. IsLabel "currentColumn" a => a
#currentColumn forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> b -> s -> t
.~ forall (t :: * -> *) a. Foldable t => t a -> ColumnIndex
length (GridTabularList n row cell rowH colH
gl forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "sizes" a => a
#sizes forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a
b.
(JoinKinds k l m, AppendIndices is js ks) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% forall a. IsLabel "row" a => a
#row) forall a. Num a => a -> a -> a
- ColumnIndex
1
gridMovePage :: Ord n
=> GridRenderers n row cell rowH colH
-> (VisibleColumns -> EventM n (GridTabularList n row cell rowH colH) ())
-> EventM n (GridTabularList n row cell rowH colH) ()
gridMovePage :: forall n row cell rowH colH.
Ord n =>
GridRenderers n row cell rowH colH
-> (VisibleColumns
-> EventM n (GridTabularList n row cell rowH colH) ())
-> EventM n (GridTabularList n row cell rowH colH) ()
gridMovePage GridRenderers n row cell rowH colH
r VisibleColumns
-> EventM n (GridTabularList n row cell rowH colH) ()
f = do
GridTabularList n row cell rowH colH
l <- forall s (m :: * -> *). MonadState s m => m s
get
forall (f :: * -> *). Applicative f => ListFocused -> f () -> f ()
unless (forall (t :: * -> *) a. Foldable t => t a -> ListFocused
null forall a b. (a -> b) -> a -> b
$ GridTabularList n row cell rowH colH
l forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "list" a => a
#list forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a
b.
(JoinKinds k l m, AppendIndices is js ks) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% forall a. IsLabel "listSelected" a => a
#listSelected) forall a b. (a -> b) -> a -> b
$ do
Maybe Viewport
v <- forall n s. Ord n => n -> EventM n s (Maybe Viewport)
lookupViewport forall a b. (a -> b) -> a -> b
$ GridTabularList n row cell rowH colH
l forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "list" a => a
#list forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a
b.
(JoinKinds k l m, AppendIndices is js ks) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% forall a. IsLabel "listName" a => a
#listName
case Maybe Viewport
v of
Maybe Viewport
Nothing -> forall (m :: * -> *) a. Monad m => a -> m a
return ()
Just Viewport
vp -> let
(ColumnIndex
aW, ColumnIndex
aH) = Viewport
vp forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "_vpSize" a => a
#_vpSize
rhw :: ColumnIndex
rhw = case (GridTabularList n row cell rowH colH
l forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "contents" a => a
#contents forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a
b.
(JoinKinds k l m, AppendIndices is js ks) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% forall a. IsLabel "rowHdr" a => a
#rowHdr, GridTabularList n row cell rowH colH
l forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "sizes" a => a
#sizes forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a
b.
(JoinKinds k l m, AppendIndices is js ks) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% forall a. IsLabel "rowHdr" a => a
#rowHdr, GridRenderers n row cell rowH colH
r forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "drawRowHdr" a => a
#drawRowHdr) of
(Maybe (row -> ColumnIndex -> Maybe rowH)
Nothing, Maybe (RowHeaderWidth rowH)
_, Maybe
(ListFocused
-> ColumnIndex -> Position -> row -> Maybe rowH -> Widget n)
_) -> ColumnIndex
0
(Maybe (row -> ColumnIndex -> Maybe rowH)
_, Maybe (RowHeaderWidth rowH)
Nothing, Maybe
(ListFocused
-> ColumnIndex -> Position -> row -> Maybe rowH -> Widget n)
_) -> ColumnIndex
0
(Maybe (row -> ColumnIndex -> Maybe rowH)
_, Maybe (RowHeaderWidth rowH)
_, Maybe
(ListFocused
-> ColumnIndex -> Position -> row -> Maybe rowH -> Widget n)
Nothing) -> ColumnIndex
0
(Maybe (row -> ColumnIndex -> Maybe rowH)
_, Just (FixedRowHeader ColumnIndex
w), Maybe
(ListFocused
-> ColumnIndex -> Position -> row -> Maybe rowH -> Widget n)
_) -> ColumnIndex
w
(Maybe (row -> ColumnIndex -> Maybe rowH)
_, Just (AvailRowHeader ColumnIndex -> ColumnIndex
w), Maybe
(ListFocused
-> ColumnIndex -> Position -> row -> Maybe rowH -> Widget n)
_) -> ColumnIndex -> ColumnIndex
w ColumnIndex
aW
(Just row -> ColumnIndex -> Maybe rowH
rowH, Just (VisibleRowHeaders ColumnIndex -> [rowH] -> ColumnIndex
w), Maybe
(ListFocused
-> ColumnIndex -> Position -> row -> Maybe rowH -> Widget n)
_) -> ColumnIndex -> [rowH] -> ColumnIndex
w ColumnIndex
aW forall a b. (a -> b) -> a -> b
$ forall n row rowH.
GenericList n Seq row
-> ColumnIndex -> (row -> ColumnIndex -> Maybe rowH) -> [rowH]
visibleRowHdrs (GridTabularList n row cell rowH colH
l forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall a. IsLabel "list" a => a
#list) ColumnIndex
aH row -> ColumnIndex -> Maybe rowH
rowH
in VisibleColumns
-> EventM n (GridTabularList n row cell rowH colH) ()
f forall a b. (a -> b) -> a -> b
$ forall n row cell rowH colH.
GridTabularList n row cell rowH colH
-> ColumnIndex -> VisibleColumns
visibleColumns GridTabularList n row cell rowH colH
l forall a b. (a -> b) -> a -> b
$ ColumnIndex
aW forall a. Num a => a -> a -> a
- ColumnIndex
rhw
gridMovePageUp :: Ord n
=> GridRenderers n row cell rowH colH
-> EventM n (GridTabularList n row cell rowH colH) ()
gridMovePageUp :: forall n row cell rowH colH.
Ord n =>
GridRenderers n row cell rowH colH
-> EventM n (GridTabularList n row cell rowH colH) ()
gridMovePageUp GridRenderers n row cell rowH colH
r = forall n row cell rowH colH.
Ord n =>
GridRenderers n row cell rowH colH
-> (VisibleColumns
-> EventM n (GridTabularList n row cell rowH colH) ())
-> EventM n (GridTabularList n row cell rowH colH) ()
gridMovePage GridRenderers n row cell rowH colH
r forall a b. (a -> b) -> a -> b
$ \case
VisibleColumns
NoColumn -> forall (m :: * -> *) a. Monad m => a -> m a
return ()
VisibleColumns
CurrentColumn -> forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify forall n row cell rowH colH.
GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveLeft
AnchoredLeft {} -> forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify forall n row cell rowH colH.
GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveToBeginning
MiddleColumns {ColumnIndex
totalWidth :: ColumnIndex
offset :: ColumnIndex
right :: ColumnIndex
left :: ColumnIndex
$sel:totalWidth:NoColumn :: VisibleColumns -> ColumnIndex
$sel:offset:NoColumn :: VisibleColumns -> ColumnIndex
$sel:left:NoColumn :: VisibleColumns -> ColumnIndex
$sel:right:NoColumn :: VisibleColumns -> ColumnIndex
..} -> forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify forall a b. (a -> b) -> a -> b
$ forall n row cell rowH colH.
ColumnIndex
-> GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveTo ColumnIndex
left
AnchoredRight {ColumnIndex
totalWidth :: ColumnIndex
offset :: ColumnIndex
left :: ColumnIndex
$sel:totalWidth:NoColumn :: VisibleColumns -> ColumnIndex
$sel:offset:NoColumn :: VisibleColumns -> ColumnIndex
$sel:left:NoColumn :: VisibleColumns -> ColumnIndex
..} -> forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify forall a b. (a -> b) -> a -> b
$ forall n row cell rowH colH.
ColumnIndex
-> GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveTo ColumnIndex
left
gridMovePageDown :: Ord n
=> GridRenderers n row cell rowH colH
-> EventM n (GridTabularList n row cell rowH colH) ()
gridMovePageDown :: forall n row cell rowH colH.
Ord n =>
GridRenderers n row cell rowH colH
-> EventM n (GridTabularList n row cell rowH colH) ()
gridMovePageDown GridRenderers n row cell rowH colH
r = forall n row cell rowH colH.
Ord n =>
GridRenderers n row cell rowH colH
-> (VisibleColumns
-> EventM n (GridTabularList n row cell rowH colH) ())
-> EventM n (GridTabularList n row cell rowH colH) ()
gridMovePage GridRenderers n row cell rowH colH
r forall a b. (a -> b) -> a -> b
$ \case
VisibleColumns
NoColumn -> forall (m :: * -> *) a. Monad m => a -> m a
return ()
VisibleColumns
CurrentColumn -> forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify forall n row cell rowH colH.
GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveRight
AnchoredLeft {ColumnIndex
right :: ColumnIndex
$sel:right:NoColumn :: VisibleColumns -> ColumnIndex
..} -> forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify forall a b. (a -> b) -> a -> b
$ forall n row cell rowH colH.
ColumnIndex
-> GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveTo ColumnIndex
right
MiddleColumns {ColumnIndex
totalWidth :: ColumnIndex
offset :: ColumnIndex
right :: ColumnIndex
left :: ColumnIndex
$sel:totalWidth:NoColumn :: VisibleColumns -> ColumnIndex
$sel:offset:NoColumn :: VisibleColumns -> ColumnIndex
$sel:left:NoColumn :: VisibleColumns -> ColumnIndex
$sel:right:NoColumn :: VisibleColumns -> ColumnIndex
..} -> forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify forall a b. (a -> b) -> a -> b
$ forall n row cell rowH colH.
ColumnIndex
-> GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveTo ColumnIndex
right
AnchoredRight {} -> forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify forall n row cell rowH colH.
GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveToEnd
handleGridListEvent :: Ord n
=> GridRenderers n row cell rowH colH
-> Event -> EventM n (GridTabularList n row cell rowH colH) ()
handleGridListEvent :: forall n row cell rowH colH.
Ord n =>
GridRenderers n row cell rowH colH
-> Event -> EventM n (GridTabularList n row cell rowH colH) ()
handleGridListEvent GridRenderers n row cell rowH colH
r Event
e = case Event
e of
EvKey Key
KLeft [] -> forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify forall n row cell rowH colH.
GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveLeft
EvKey Key
KRight [] -> forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify forall n row cell rowH colH.
GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveRight
EvKey Key
KHome [Modifier
MCtrl] -> forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify forall n row cell rowH colH.
GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveToBeginning
EvKey Key
KEnd [Modifier
MCtrl] -> forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify forall n row cell rowH colH.
GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveToEnd
EvKey Key
KPageUp [Modifier
MCtrl] -> forall n row cell rowH colH.
Ord n =>
GridRenderers n row cell rowH colH
-> EventM n (GridTabularList n row cell rowH colH) ()
gridMovePageUp GridRenderers n row cell rowH colH
r
EvKey Key
KPageDown [Modifier
MCtrl] -> forall n row cell rowH colH.
Ord n =>
GridRenderers n row cell rowH colH
-> EventM n (GridTabularList n row cell rowH colH) ()
gridMovePageDown GridRenderers n row cell rowH colH
r
Event
_ -> forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom forall a. IsLabel "list" a => a
#list (forall (t :: * -> *) n e.
(Foldable t, Splittable t, Ord n) =>
Event -> EventM n (GenericList n t e) ()
L.handleListEvent Event
e)
handleGridListEventVi :: Ord n
=> GridRenderers n row cell rowH colH
-> Event -> EventM n (GridTabularList n row cell rowH colH) ()
handleGridListEventVi :: forall n row cell rowH colH.
Ord n =>
GridRenderers n row cell rowH colH
-> Event -> EventM n (GridTabularList n row cell rowH colH) ()
handleGridListEventVi GridRenderers n row cell rowH colH
r Event
e = case Event
e of
EvKey (KChar Char
'h') [] -> forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify forall n row cell rowH colH.
GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveLeft
EvKey (KChar Char
'l') [] -> forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify forall n row cell rowH colH.
GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveRight
EvKey (KChar Char
'H') [] -> forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify forall n row cell rowH colH.
GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveToBeginning
EvKey (KChar Char
'L') [] -> forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify forall n row cell rowH colH.
GridTabularList n row cell rowH colH
-> GridTabularList n row cell rowH colH
gridMoveToEnd
EvKey (KChar Char
'h') [Modifier
MMeta] -> forall n row cell rowH colH.
Ord n =>
GridRenderers n row cell rowH colH
-> EventM n (GridTabularList n row cell rowH colH) ()
gridMovePageUp GridRenderers n row cell rowH colH
r
EvKey (KChar Char
'l') [Modifier
MMeta] -> forall n row cell rowH colH.
Ord n =>
GridRenderers n row cell rowH colH
-> EventM n (GridTabularList n row cell rowH colH) ()
gridMovePageDown GridRenderers n row cell rowH colH
r
EvKey (KChar Char
'h') [Modifier
MAlt] -> forall n row cell rowH colH.
Ord n =>
GridRenderers n row cell rowH colH
-> EventM n (GridTabularList n row cell rowH colH) ()
gridMovePageUp GridRenderers n row cell rowH colH
r
EvKey (KChar Char
'l') [Modifier
MAlt] -> forall n row cell rowH colH.
Ord n =>
GridRenderers n row cell rowH colH
-> EventM n (GridTabularList n row cell rowH colH) ()
gridMovePageDown GridRenderers n row cell rowH colH
r
Event
_ -> forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom forall a. IsLabel "list" a => a
#list (forall (t :: * -> *) n e.
(Foldable t, Splittable t, Ord n) =>
(Event -> EventM n (GenericList n t e) ())
-> Event -> EventM n (GenericList n t e) ()
L.handleListEventVi (\Event
_ -> forall (m :: * -> *) a. Monad m => a -> m a
return ()) Event
e)