on master help sign in
adding a put_string equation for the inline API.

Ignore-this: b1665413f489310eacc0441a8ddb731f darcs-hash:20100806215448-f0a0d-4dea846225c80f0644ba54a544bce278f3c8bde8.gz

commitbcda3db0eb50b14bf7b74e5cd75109c65e5e60bf authorcoreyoconnor <coreyoconnor@gmail.com> dateFri 6 Aug 2010, 14:54 (16 years ago) parent9bad126
3 files changed+28
src/Graphics/Vty/Inline.hs+7 src/Graphics/Vty/Terminal/TerminfoBased.hs+2 test/interactive_terminal_test.hs+19
src/Graphics/Vty/Inline.hs+7
@@ -12,6 +12,7 @@ import Control.Monad.State.Strict
1212import Control.Monad.Trans
1313
1414import Data.Bits ( (.&.), complement )
15+import qualified Data.String.UTF8 as UTF8
1516import Data.IORef
1617import Data.Monoid ( mappend )
1718
@@ -56,3 +57,9 @@ put_attr_change t c = do
5657 liftIO $ modifyIORef ( state_ref t ) $ \s -> s { known_fattr = Just fattr' }
5758 inline_hack d
5859
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
183183 :: CInt -> Ptr Word8 -> CSize -> IO ()
184184foreign import ccall "gwinsz.h c_get_window_size" c_get_window_size
185185 :: IO CLong
186+foreign import ccall "fdatasync" c_fdatasync
187+ :: CInt -> IO CInt
186188
187189get_window_size :: IO (Int,Int)
188190get_window_size = do
test/interactive_terminal_test.hs+19
@@ -168,6 +168,7 @@ all_tests
168168 , attributes_test_5
169169 , inline_test_0
170170 , inline_test_1
171+ , inline_test_2
171172 ]
172173
173174reserve_output_test = Test
@@ -901,3 +902,21 @@ inline_test_1 = Test
901902
902903 , confirm_results = generic_output_match_confirm
903904 }
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+ }