From 2ac232f7e994f7d026c2900090658f5bf4f1d9be Mon Sep 17 00:00:00 2001 From: Edmund Noble Date: Tue, 12 Nov 2024 22:57:23 -0500 Subject: [PATCH] Add disable and enable line wrap ANSI commands --- ansi-terminal/src/System/Console/ANSI.hs | 20 +++++++++++++++++++ .../src/System/Console/ANSI/Codes.hs | 7 +++++++ 2 files changed, 27 insertions(+) diff --git a/ansi-terminal/src/System/Console/ANSI.hs b/ansi-terminal/src/System/Console/ANSI.hs index f2f529c..d82888a 100644 --- a/ansi-terminal/src/System/Console/ANSI.hs +++ b/ansi-terminal/src/System/Console/ANSI.hs @@ -267,6 +267,16 @@ module System.Console.ANSI , clearFromCursorToLineBeginningCode , clearLineCode + -- * Enabling and disabling line wrap + , disableLineWrap + , enableLineWrap + -- ** \'h...\' variants + , hDisableLineWrap + , hEnableLineWrap + -- ** \'...Code\' variants + , disableLineWrapCode + , enableLineWrapCode + -- * Scrolling the screen , scrollPageUp , scrollPageDown @@ -1028,6 +1038,16 @@ clearFromCursorToLineEnd = hClearFromCursorToLineEnd stdout clearFromCursorToLineBeginning = hClearFromCursorToLineBeginning stdout clearLine = hClearLine stdout +hEnableLineWrap, hDisableLineWrap :: + Handle + -> IO () +hEnableLineWrap h = hPutStr h enableLineWrapCode +hDisableLineWrap h = hPutStr h disableLineWrapCode + +enableLineWrap, disableLineWrap :: IO () +enableLineWrap = hEnableLineWrap stdout +disableLineWrap = hDisableLineWrap stdout + hScrollPageUp, hScrollPageDown :: Handle -> Int -- Number of lines to scroll by diff --git a/ansi-terminal/src/System/Console/ANSI/Codes.hs b/ansi-terminal/src/System/Console/ANSI/Codes.hs index d300406..1870d6d 100644 --- a/ansi-terminal/src/System/Console/ANSI/Codes.hs +++ b/ansi-terminal/src/System/Console/ANSI/Codes.hs @@ -35,6 +35,9 @@ module System.Console.ANSI.Codes , clearScreenCode, clearFromCursorToLineEndCode , clearFromCursorToLineBeginningCode, clearLineCode + -- * Enabling and disabling line wrap + , enableLineWrapCode, disableLineWrapCode + -- * Scrolling the screen -- -- | These functions yield @\"\"@ when the number is @0@ as, on some @@ -309,6 +312,10 @@ clearFromCursorToLineEndCode = csi [0] "K" clearFromCursorToLineBeginningCode = csi [1] "K" clearLineCode = csi [2] "K" +enableLineWrapCode, disableLineWrapCode :: String +enableLineWrapCode = csi [] "?7h" +disableLineWrapCode = csi [] "?7l" + scrollPageUpCode, scrollPageDownCode :: Int -- ^ Number of lines to scroll by -> String