ghcup-hs/lib-tui/GHCup/Brick/Widgets/KeyInfo.hs

73 lines
2.3 KiB
Haskell
Raw Normal View History

2024-01-10 06:14:59 +00:00
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# OPTIONS_GHC -Wno-unused-record-wildcards #-}
{-# OPTIONS_GHC -Wno-unused-matches #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-
A very simple information-only widget with no handler.
-}
module GHCup.Brick.Widgets.KeyInfo where
2024-02-27 18:19:00 +00:00
import GHCup.Types ( KeyBindings(..) )
2024-01-10 06:14:59 +00:00
import qualified GHCup.Brick.Common as Common
import Brick
( Padding(Max),
Widget(..),
(<+>),
(<=>))
import qualified Brick
2024-02-27 18:19:00 +00:00
import Brick.Widgets.Center ( center )
2024-01-10 06:14:59 +00:00
import Prelude hiding ( appendFile )
draw :: KeyBindings -> Widget Common.Name
draw KeyBindings {..} =
let
mkTextBox = Brick.hLimitPercent 70 . Brick.vBox . fmap (Brick.padRight Brick.Max)
2024-02-27 18:19:00 +00:00
in Common.frontwardLayer "Key Actions"
2024-01-10 06:14:59 +00:00
$ Brick.vBox [
center $
mkTextBox [
Brick.hBox [
Brick.txt "Press "
2024-02-27 18:19:00 +00:00
, Common.keyToWidget bUp, Brick.txt " and ", Common.keyToWidget bDown
2024-01-10 06:14:59 +00:00
, Brick.txtWrap " to navigate the list of tools"
]
, Brick.hBox [
Brick.txt "Press "
2024-02-27 18:19:00 +00:00
, Common.keyToWidget bInstall
2024-01-10 06:14:59 +00:00
, Brick.txtWrap " to install the selected tool. Notice, you may need to set it as default afterwards"
]
, Brick.hBox [
Brick.txt "Press "
2024-02-27 18:19:00 +00:00
, Common.keyToWidget bSet
2024-01-10 06:14:59 +00:00
, Brick.txtWrap " to set a tool as the one for use"
]
, Brick.hBox [
Brick.txt "Press "
2024-02-27 18:19:00 +00:00
, Common.keyToWidget bUninstall
2024-01-10 06:14:59 +00:00
, Brick.txtWrap " to uninstall a tool"
]
, Brick.hBox [
Brick.txt "Press "
2024-02-27 18:19:00 +00:00
, Common.keyToWidget bChangelog
2024-01-10 06:14:59 +00:00
, Brick.txtWrap " to open the tool's changelog. It will open a web browser"
]
, Brick.hBox [
Brick.txt "Press "
2024-02-27 18:19:00 +00:00
, Common.keyToWidget bShowAllVersions
2024-01-10 06:14:59 +00:00
, Brick.txtWrap " to show older version of each tool"
]
]
]
<=> Brick.hBox [Brick.txt "Press q to return to Navigation" <+> Brick.padRight Brick.Max (Brick.txt " ") <+> Brick.txt "Press Enter to go to the Tutorial"]