From 48f054df3763968220f7679d0b069a4a0eee46bc Mon Sep 17 00:00:00 2001 From: Alexander Kobjolke Date: Tue, 29 Aug 2023 00:08:02 +0200 Subject: [PATCH] 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] ""