Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add disable and enable line wrap ANSI commands #171

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 [] "?7h"
disableLineWrapCode = csi [] "?7l"

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