Skip to content

Commit

Permalink
Add disable and enable line wrap ANSI commands
Browse files Browse the repository at this point in the history
  • Loading branch information
edmundnoble committed Nov 13, 2024
1 parent 52f8644 commit 737c42c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
20 changes: 20 additions & 0 deletions ansi-terminal/src/System/Console/ANSI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions ansi-terminal/src/System/Console/ANSI/Codes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -309,6 +312,10 @@ clearFromCursorToLineEndCode = csi [0] "K"
clearFromCursorToLineBeginningCode = csi [1] "K"
clearLineCode = csi [2] "K"

enableLineWrapCode, disableLineWrapCode :: String
enableLineWrapCode = csi [7] "h"
disableLineWrapCode = csi [7] "l"

scrollPageUpCode, scrollPageDownCode ::
Int -- ^ Number of lines to scroll by
-> String
Expand Down

0 comments on commit 737c42c

Please sign in to comment.