vty 5.9 → 5.9.1
raw patch · 3 files changed
+23/−3 lines, 3 files
Files
- CHANGELOG +5/−0
- src/Graphics/Vty/Output/XTermColor.hs +17/−2
- vty.cabal +1/−1
CHANGELOG view
@@ -1,3 +1,8 @@+5.9.1+ - Vty now only emits UTF8 charset sequences in terminals without a+ preexisting UTF8 declaration to avoid emitting garbage sequences+ (fixes #89)+ 5.9 - Added new Output methods supportsBell and ringTerminalBell to find out whether the output device has an audio bell and to ring it (see #102)
src/Graphics/Vty/Output/XTermColor.hs view
@@ -21,12 +21,17 @@ import System.Posix.IO (fdWrite) import System.Posix.Types (Fd)+import System.Posix.Env (getEnv) #if !(MIN_VERSION_base(4,8,0)) import Control.Applicative import Data.Foldable (foldMap) #endif +import Data.List (isInfixOf)+import Data.Maybe (catMaybes)+import Data.Monoid ((<>))+ -- | Initialize the display to UTF-8. reserveTerminal :: ( Applicative m, MonadIO m ) => String -> Fd -> m Output reserveTerminal variant outFd = liftIO $ do@@ -34,7 +39,9 @@ -- If the terminal variant is xterm-color use xterm instead since, more often than not, -- xterm-color is broken. let variant' = if variant == "xterm-color" then "xterm" else variant- flushedPut setUtf8CharSet++ utf8a <- utf8Active+ when (not utf8a) $ flushedPut setUtf8CharSet t <- TerminfoBased.reserveTerminal variant' outFd mouseModeStatus <- newIORef False@@ -61,7 +68,7 @@ let t' = t { terminalID = terminalID t ++ " (xterm-color)" , releaseTerminal = do- liftIO $ flushedPut setDefaultCharSet+ when (not utf8a) $ liftIO $ flushedPut setDefaultCharSet setMode t' BracketedPaste False setMode t' Mouse False releaseTerminal t@@ -73,6 +80,14 @@ , setMode = xtermSetMode t' } return t'++utf8Active :: IO Bool+utf8Active = do+ let vars = ["LC_ALL", "LANG", "LC_CTYPE"]+ results <- catMaybes <$> mapM getEnv vars+ let matches = filter ("UTF8" `isInfixOf`) results <>+ filter ("UTF-8" `isInfixOf`) results+ return $ not $ null matches -- | Enable bracketed paste mode: -- http://cirw.in/blog/bracketed-paste
vty.cabal view
@@ -1,5 +1,5 @@ name: vty-version: 5.9+version: 5.9.1 license: BSD3 license-file: LICENSE author: AUTHORS