on master help sign in
Input: provide paste content as a ByteString rather than a String
commitb5115c881cb8a0bdcd2940a30d86bdfadc398a88 authorJonathan Daugherty <cygnus@foobox.com> dateThu 11 Aug 2016, 12:12 (10 years ago) parentd0a469b
2 files changed+9−3
src/Graphics/Vty/Input/Events.hs+6−2 src/Graphics/Vty/Input/Paste.hs+3−1
src/Graphics/Vty/Input/Events.hs+6−2
@@ -1,5 +1,7 @@
11module Graphics.Vty.Input.Events where
22
3+import Data.ByteString
4+
35-- | Representations of non-modifier keys.
46--
57-- * KFun is indexed from 0 to 63. Range of supported FKeys varies by terminal and keyboard.
@@ -42,12 +44,14 @@ data Event
4244 -- signal. If read from 'nextEvent' this is the size at the time the
4345 -- event was processed by Vty. Typically these are the same, but if
4446 -- somebody is resizing the terminal quickly they can be different.
45− | EvPaste String
47+ | EvPaste ByteString
4648 -- ^ A paste event occurs when a bracketed paste input sequence is
4749 -- received. For terminals that support bracketed paste mode, these
4850 -- events will be triggered on a paste event. Terminals that do not
4951 -- support bracketed pastes will send the paste contents as ordinary
50− -- input (which is probably bad, so beware!)
52+ -- input (which is probably bad, so beware!) Note that the data is
53+ -- provided in raw form and you'll have to decode (e.g. as UTF-8) if
54+ -- that's what your application expects.
5155 deriving (Eq,Show,Read,Ord)
5256
5357type ClassifyMap = [(String,Event)]
src/Graphics/Vty/Input/Paste.hs+3−1
@@ -7,6 +7,8 @@ module Graphics.Vty.Input.Paste
77 , bracketedPasteFinished
88 ) where
99
10+import qualified Data.ByteString.Char8 as BS8
11+
1012import Graphics.Vty.Input.Events
1113import Graphics.Vty.Input.Classify.Types
1214
@@ -35,7 +37,7 @@ parseBracketedPaste s =
3537 rest' = if bracketedPasteEnd `isPrefixOf` rest
3638 then drop (length bracketedPasteEnd) rest
3739 else rest
38− in Valid (EvPaste p) rest'
40+ in Valid (EvPaste $ BS8.pack p) rest'
3941
4042takeUntil :: (Eq a) => [a] -> [a] -> ([a],[a])
4143takeUntil [] _ = ([], [])