From 11870423ed643e31cd75663bd362c569e3f395ba Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Sat, 7 Sep 2024 15:00:17 -0400 Subject: [PATCH] use `brick` --- app/Main.hs | 7 +++++- package.yaml | 1 + passman.cabal | 6 ++++- src/Password/App.hs | 55 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 src/Password/App.hs diff --git a/app/Main.hs b/app/Main.hs index a86fc29..835bec2 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -22,7 +22,12 @@ License along with this program. If not, see module Main (main) where +import Brick (defaultMain) +import Control.Monad (void) + +import Password.App + main :: IO () -main = return () +main = void $ defaultMain passmanApp () --jl diff --git a/package.yaml b/package.yaml index 7acc371..b45ace8 100644 --- a/package.yaml +++ b/package.yaml @@ -28,6 +28,7 @@ dependencies: - microlens >= 0.4.11.2 && < 0.5 - microlens-th >= 0.4.3.6 && < 0.5 - random >=1.2.1.1 && < 1.3 +- brick >= 2.1.1 && < 2.2 ghc-options: - -Wall diff --git a/passman.cabal b/passman.cabal index 1cb9d9a..368497b 100644 --- a/passman.cabal +++ b/passman.cabal @@ -4,7 +4,7 @@ cabal-version: 2.2 -- -- see: https://github.com/sol/hpack -- --- hash: dc89d8fb08ca638ec275e4cc1d9c22d400b1aeabd2825e4419fdd64d4a5e6334 +-- hash: 235d7c20ee589946f5e0cd199cca106191a300f9f24b023a6ef074c197c9861b name: passman version: 0.3.1.1 @@ -26,6 +26,7 @@ extra-source-files: library exposed-modules: Password + Password.App other-modules: Paths_passman autogen-modules: @@ -39,6 +40,7 @@ library , base >=4.7 && <5 , base16-bytestring >=1.0.2.0 && <1.1 , base64-bytestring >=1.2.1.0 && <1.3 + , brick >=2.1.1 && <2.2 , bytestring >=0.11.4.0 && <0.12 , containers >=0.6.2.1 && <0.7 , microlens >=0.4.11.2 && <0.5 @@ -59,6 +61,7 @@ executable passman build-depends: aeson >=2.1.2.1 && <2.2 , base >=4.7 && <5 + , brick >=2.1.1 && <2.2 , bytestring >=0.11.4.0 && <0.12 , containers >=0.6.2.1 && <0.7 , microlens >=0.4.11.2 && <0.5 @@ -95,6 +98,7 @@ test-suite passman-test HUnit , aeson >=2.1.2.1 && <2.2 , base >=4.7 && <5 + , brick >=2.1.1 && <2.2 , bytestring >=0.11.4.0 && <0.12 , containers >=0.6.2.1 && <0.7 , microlens >=0.4.11.2 && <0.5 diff --git a/src/Password/App.hs b/src/Password/App.hs new file mode 100644 index 0000000..1f10905 --- /dev/null +++ b/src/Password/App.hs @@ -0,0 +1,55 @@ +{-| + +Module: Password.App +Description: the application frontend +Copyright: (C) Jonathan Lamothe +License: LGPLv3 (or later) +Maintainer: jonathan@jlamothe.net + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this program. If not, see +. + +-} + +module Password.App (passmanApp) where + +import Brick + ( App (..) + , BrickEvent + , EventM + , Widget + , attrMap + , emptyWidget + , halt + , neverShowCursor + , style + ) + +-- | The main application +passmanApp :: App () () () +passmanApp = App + { appDraw = drawFunc + , appChooseCursor = neverShowCursor + , appHandleEvent = eventHandler + , appStartEvent = return () + , appAttrMap = const $ attrMap (style 0) [] + } + +drawFunc :: () -> [Widget ()] +drawFunc = const [emptyWidget] + +eventHandler :: BrickEvent () () -> EventM () () () +eventHandler = const halt + +--jl