on master help sign in
adding a put_string equation for the inline API.
bcda3dbcoreyoconnor
src/Graphics/Vty/Inline.hs+7
@@ -12,6 +12,7 @@ import Control.Monad.State.Strict
12import Control.Monad.Trans
12import Control.Monad.Trans
13
13
14import Data.Bits ( (.&.), complement )
14import Data.Bits ( (.&.), complement )
15+import qualified Data.String.UTF8 as UTF8
15import Data.IORef
16import Data.IORef
16import Data.Monoid ( mappend )
17import Data.Monoid ( mappend )
17
18
@@ -56,3 +57,9 @@ put_attr_change t c = do
56 liftIO $ modifyIORef ( state_ref t ) $ \s -> s { known_fattr = Just fattr' }
57 liftIO $ modifyIORef ( state_ref t ) $ \s -> s { known_fattr = Just fattr' }
57 inline_hack d
58 inline_hack d
58
59
60+put_string :: ( Applicative m, MonadIO m ) => TerminalHandle -> String -> m ()
61+put_string t s = do
62+ let s_utf8 = UTF8.fromString s
63+ liftIO $ marshall_to_terminal t ( utf8_text_required_bytes s_utf8)
64+ ( serialize_utf8_text s_utf8 )
65+
src/Graphics/Vty/Terminal/TerminfoBased.hs+2
@@ -183,6 +183,8 @@ foreign import ccall unsafe "output_buffer.h stdout_output_buffer" c_output_byte
183 :: CInt -> Ptr Word8 -> CSize -> IO ()
183 :: CInt -> Ptr Word8 -> CSize -> IO ()
184foreign import ccall "gwinsz.h c_get_window_size" c_get_window_size
184foreign import ccall "gwinsz.h c_get_window_size" c_get_window_size
185 :: IO CLong
185 :: IO CLong
186+foreign import ccall "fdatasync" c_fdatasync
187+ :: CInt -> IO CInt
186
188
187get_window_size :: IO (Int,Int)
189get_window_size :: IO (Int,Int)
188get_window_size = do
190get_window_size = do
test/interactive_terminal_test.hs+19
@@ -168,6 +168,7 @@ all_tests
168 , attributes_test_5
168 , attributes_test_5
169 , inline_test_0
169 , inline_test_0
170 , inline_test_1
170 , inline_test_1
171+ , inline_test_2
171 ]
172 ]
172
173
173reserve_output_test = Test
174reserve_output_test = Test
@@ -901,3 +902,21 @@ inline_test_1 = Test
901
902
902 , confirm_results = generic_output_match_confirm
903 , confirm_results = generic_output_match_confirm
903 }
904 }
905+
906+inline_test_2 = Test
907+ { test_name = "Verify styled output can be performed without clearing the screen."
908+ , test_ID = "inline_test_1"
909+ , test_action = do
910+ t <- terminal_handle
911+ put_string t "Not styled. "
912+ put_attr_change t $ back_color red >> apply_style underline
913+ put_string t " Styled! "
914+ put_attr_change t $ default_all
915+ put_string t "Not styled.\n"
916+ release_terminal t
917+ return ()
918+ , print_summary = putStr $ [$heredoc|
919+|]
920+
921+ , confirm_results = generic_output_match_confirm
922+ }