on master help sign in
Input: provide paste content as a ByteString rather than a String
b5115c8Jonathan Daugherty
src/Graphics/Vty/Input/Events.hs+6−2
@@ -1,5 +1,7 @@
1module Graphics.Vty.Input.Events where
1module Graphics.Vty.Input.Events where
2
2
3+import Data.ByteString
4+
3-- | Representations of non-modifier keys.
5-- | Representations of non-modifier keys.
4--
6--
5-- * KFun is indexed from 0 to 63. Range of supported FKeys varies by terminal and keyboard.
7-- * KFun is indexed from 0 to 63. Range of supported FKeys varies by terminal and keyboard.
@@ -42,12 +44,14 @@ data Event
42 -- signal. If read from 'nextEvent' this is the size at the time the
44 -- signal. If read from 'nextEvent' this is the size at the time the
43 -- event was processed by Vty. Typically these are the same, but if
45 -- event was processed by Vty. Typically these are the same, but if
44 -- somebody is resizing the terminal quickly they can be different.
46 -- somebody is resizing the terminal quickly they can be different.
45− | EvPaste String
47+ | EvPaste ByteString
46 -- ^ A paste event occurs when a bracketed paste input sequence is
48 -- ^ A paste event occurs when a bracketed paste input sequence is
47 -- received. For terminals that support bracketed paste mode, these
49 -- received. For terminals that support bracketed paste mode, these
48 -- events will be triggered on a paste event. Terminals that do not
50 -- events will be triggered on a paste event. Terminals that do not
49 -- support bracketed pastes will send the paste contents as ordinary
51 -- 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.
51 deriving (Eq,Show,Read,Ord)
55 deriving (Eq,Show,Read,Ord)
52
56
53type ClassifyMap = [(String,Event)]
57type ClassifyMap = [(String,Event)]
src/Graphics/Vty/Input/Paste.hs+3−1
@@ -7,6 +7,8 @@ module Graphics.Vty.Input.Paste
7 , bracketedPasteFinished
7 , bracketedPasteFinished
8 ) where
8 ) where
9
9
10+import qualified Data.ByteString.Char8 as BS8
11+
10import Graphics.Vty.Input.Events
12import Graphics.Vty.Input.Events
11import Graphics.Vty.Input.Classify.Types
13import Graphics.Vty.Input.Classify.Types
12
14
@@ -35,7 +37,7 @@ parseBracketedPaste s =
35 rest' = if bracketedPasteEnd `isPrefixOf` rest
37 rest' = if bracketedPasteEnd `isPrefixOf` rest
36 then drop (length bracketedPasteEnd) rest
38 then drop (length bracketedPasteEnd) rest
37 else rest
39 else rest
38− in Valid (EvPaste p) rest'
40+ in Valid (EvPaste $ BS8.pack p) rest'
39
41
40takeUntil :: (Eq a) => [a] -> [a] -> ([a],[a])
42takeUntil :: (Eq a) => [a] -> [a] -> ([a],[a])
41takeUntil [] _ = ([], [])
43takeUntil [] _ = ([], [])