vty 5.29 → 5.30
raw patch · 3 files changed
+35/−1 lines, 3 files
Files
- CHANGELOG.md +9/−0
- src/Graphics/Vty.hs +25/−0
- vty.cabal +1/−1
CHANGELOG.md view
@@ -1,4 +1,13 @@ +5.30+----++New features:+ * Added `Graphics.Vty.setWindowTitle` to emit an escape+ sequence to set the window title, provide the terminal emulator+ accepts Xterm-style title sequences. For details, see:+ https://tldp.org/HOWTO/Xterm-Title-3.html+ 5.29 ----
src/Graphics/Vty.hs view
@@ -33,6 +33,7 @@ module Graphics.Vty ( Vty(..) , mkVty+ , setWindowTitle , Mode(..) , module Graphics.Vty.Config , module Graphics.Vty.Input@@ -54,6 +55,9 @@ import Graphics.Vty.UnicodeWidthTable.IO import Graphics.Vty.UnicodeWidthTable.Install +import Data.Char (isPrint, showLitChar)+import qualified Data.ByteString.Char8 as BS8+ import qualified Control.Exception as E import Control.Monad (when) import Control.Concurrent.STM@@ -224,3 +228,24 @@ , shutdown = shutdownIo , isShutdown = shutdownStatus }++-- | Set the terminal window title string.+--+-- This function emits an Xterm-compatible escape sequence that we+-- anticipate will work for essentially all modern terminal emulators.+-- Ideally we'd use a terminal capability for this, but there does not+-- seem to exist a termcap for setting window titles. If you find that+-- this function does not work for a given terminal emulator, please+-- report the issue.+--+-- For details, see:+--+-- https://tldp.org/HOWTO/Xterm-Title-3.html+setWindowTitle :: Vty -> String -> IO ()+setWindowTitle vty title = do+ let sanitize :: String -> String+ sanitize = concatMap sanitizeChar+ sanitizeChar c | not (isPrint c) = showLitChar c ""+ | otherwise = [c]+ let buf = BS8.pack $ "\ESC]2;" <> sanitize title <> "\007"+ outputByteBuffer (outputIface vty) buf
vty.cabal view
@@ -1,5 +1,5 @@ name: vty-version: 5.29+version: 5.30 license: BSD3 license-file: LICENSE author: AUTHORS