From 5c113326e796ad0e71eb28dc9ff7b241fff5f8f9 Mon Sep 17 00:00:00 2001 From: Alexander Kobjolke Date: Tue, 29 Aug 2023 00:06:45 +0200 Subject: [PATCH 1/2] flake: Add dependency to process --- hcat.cabal | 7 ++++--- package.yaml | 3 +-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hcat.cabal b/hcat.cabal index 0923336..f84a895 100644 --- a/hcat.cabal +++ b/hcat.cabal @@ -27,9 +27,10 @@ library BlockArguments OverloadedStrings ImportQualifiedPost - ghc-options: -Wall -Wunused-packages -fdefer-typed-holes + ghc-options: -Wall -fdefer-typed-holes build-depends: base >=4.13 && <5 + , process , text default-language: GHC2021 @@ -43,7 +44,7 @@ executable hcat BlockArguments OverloadedStrings ImportQualifiedPost - ghc-options: -Wall -Wunused-packages -fdefer-typed-holes + ghc-options: -Wall -fdefer-typed-holes build-depends: base >=4.13 && <5 , hcat @@ -61,7 +62,7 @@ test-suite spec BlockArguments OverloadedStrings ImportQualifiedPost - ghc-options: -Wall -Wunused-packages -fdefer-typed-holes + ghc-options: -Wall -fdefer-typed-holes cpp-options: -DTEST build-tool-depends: hspec-discover:hspec-discover diff --git a/package.yaml b/package.yaml index 40a373f..b2d6beb 100644 --- a/package.yaml +++ b/package.yaml @@ -13,12 +13,10 @@ dependencies: - base >= 4.13 && < 5 # - bytestring # - time -# - process # - directory ghc-options: - -Wall - - -Wunused-packages - -fdefer-typed-holes default-extensions: @@ -30,6 +28,7 @@ library: source-dirs: src dependencies: - text + - process verbatim: default-language: GHC2021 From 48f054df3763968220f7679d0b069a4a0eee46bc Mon Sep 17 00:00:00 2001 From: Alexander Kobjolke Date: Tue, 29 Aug 2023 00:08:02 +0200 Subject: [PATCH 2/2] Implement getScreenDimensions --- src/HCat/Internal.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/HCat/Internal.hs b/src/HCat/Internal.hs index d28a0ff..467a446 100644 --- a/src/HCat/Internal.hs +++ b/src/HCat/Internal.hs @@ -4,6 +4,8 @@ module HCat.Internal where import Data.Text (Text) import Data.Text qualified as T +import System.Process qualified as P + -- | @parseArgs@ takes a list of strings and returns a single FilePath if there was exactly one element. -- -- >>> parseArgs ["foo"] @@ -67,3 +69,8 @@ paginate (ScreenDimensions rows cols) = type Pages = [Page] type Page = Text + +getScreenDimensions :: IO ScreenDimensions +getScreenDimensions = ScreenDimensions <$> tput "lines" <*> tput "cols" + where + tput cmd = read <$> P.readProcess "tput" [cmd] ""