switch from ncurses to brick #1
|
@ -37,7 +37,6 @@ module Mtlstats.Menu (
|
||||||
import Brick.Main (halt)
|
import Brick.Main (halt)
|
||||||
import Brick.Types (BrickEvent (VtyEvent), Widget)
|
import Brick.Types (BrickEvent (VtyEvent), Widget)
|
||||||
import Brick.Widgets.Center (hCenter)
|
import Brick.Widgets.Center (hCenter)
|
||||||
import Brick.Widgets.Core (str, vBox)
|
|
||||||
import Control.Monad.State.Class (gets, modify)
|
import Control.Monad.State.Class (gets, modify)
|
||||||
import Data.Char (toUpper)
|
import Data.Char (toUpper)
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
@ -87,7 +86,7 @@ menuStateController menuFunc = Controller
|
||||||
drawMenu :: Menu a -> Widget ()
|
drawMenu :: Menu a -> Widget ()
|
||||||
drawMenu m = let
|
drawMenu m = let
|
||||||
menuLines = lines $ show m
|
menuLines = lines $ show m
|
||||||
in hCenter $ vBox $ map str menuLines
|
in hCenter $ linesToWidget menuLines
|
||||||
|
|
||||||
-- | The event handler for a 'Menu'
|
-- | The event handler for a 'Menu'
|
||||||
menuHandler :: Menu a -> Handler a
|
menuHandler :: Menu a -> Handler a
|
||||||
|
|
|
@ -19,6 +19,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE LambdaCase #-}
|
||||||
|
|
||||||
module Mtlstats.Util
|
module Mtlstats.Util
|
||||||
( nth
|
( nth
|
||||||
, modifyNth
|
, modifyNth
|
||||||
|
@ -123,4 +125,8 @@ capitalizeName ch s = s ++ [ch']
|
||||||
| otherwise = False
|
| otherwise = False
|
||||||
|
|
||||||
linesToWidget :: [String] -> Widget ()
|
linesToWidget :: [String] -> Widget ()
|
||||||
linesToWidget = vBox . map str
|
linesToWidget = vBox . map
|
||||||
|
( str . \case
|
||||||
|
"" -> " "
|
||||||
|
s -> s
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user