packages feed

vty 5.26 → 5.27

raw patch · 5 files changed

+51/−1 lines, 5 files

Files

CHANGELOG.md view
@@ -1,4 +1,10 @@ +5.27+ - Added Graphics.Vty.Config.getTtyEraseChar to support querying the+   kernel for the current terminal's settings to obtain the character+   assigned by the "stty erase" command. That can then be added to the+   Vty configuration's input map to map to KBS (backspace) if desired.+ 5.26  - Resolved various import warnings (thanks @glguy)  - Removed the MonadIO constraint from the Output type's fields and
+ cbits/get_tty_erase.c view
@@ -0,0 +1,18 @@+#include <termios.h>+#include <stdio.h>+#include <unistd.h>+#include <stdlib.h>++// Given a file descriptor for a terminal, get the ERASE character for+// the terminal. If the terminal info cannot be obtained, this returns+// zero.+char vty_get_tty_erase(int fd)+{+    struct termios trm;++    if (0 == tcgetattr(fd, &trm)) {+        return (char) trm.c_cc[VERASE];+    } else {+        return (char) 0;+    }+}
demos/ModeDemo.hs view
@@ -2,6 +2,8 @@  import Control.Applicative import Data.Monoid+import Foreign.C.Types (CInt(..), CChar(..))+import System.Posix.Types (Fd(..))  import Graphics.Vty 
src/Graphics/Vty/Config.hs view
@@ -65,6 +65,7 @@   , runParseConfig   , parseConfigFile   , defaultConfig+  , getTtyEraseChar   ) where @@ -92,6 +93,7 @@ import System.Environment (lookupEnv) import System.Posix.IO (stdInput, stdOutput) import System.Posix.Types (Fd(..))+import Foreign.C.Types (CInt(..), CChar(..))  import Text.Parsec hiding ((<|>)) import Text.Parsec.Token ( GenLanguageDef(..) )@@ -306,3 +308,24 @@   gparseAlts con = L1 <$> gparseAlts con <|> R1 <$> gparseAlts con  instance GParseAlts V1 where gparseAlts _ = fail "GParse: V1"++foreign import ccall "vty_get_tty_erase" cGetTtyErase :: Fd -> IO CChar++-- | Get the "erase" character for the terminal attached to the+-- specified file descriptor. This is the character configured by 'stty+-- erase'. If the call to 'tcgetattr' fails, this will return 'Nothing'.+-- Otherwise it will return the character that has been configured to+-- indicate the canonical mode ERASE behavior. That character can then+-- be added to the table of strings that we interpret to mean Backspace.+--+-- For more details, see:+--+-- * https://www.gnu.org/software/libc/manual/html_node/Canonical-or-Not.html+-- * https://www.gsp.com/cgi-bin/man.cgi?section=1&topic=stty+-- * https://github.com/matterhorn-chat/matterhorn/issues/565+getTtyEraseChar :: Fd -> IO (Maybe Char)+getTtyEraseChar fd = do+    c <- cGetTtyErase fd+    if c /= 0+       then return $ Just $ toEnum $ fromEnum c+       else return Nothing
vty.cabal view
@@ -1,5 +1,5 @@ name:                vty-version:             5.26+version:             5.27 license:             BSD3 license-file:        LICENSE author:              AUTHORS@@ -106,6 +106,7 @@    c-sources:           cbits/gwinsz.c                        cbits/set_term_timing.c+                       cbits/get_tty_erase.c                        cbits/mk_wcwidth.c    include-dirs:        cbits