vty 5.2.2 → 5.2.3
raw patch · 4 files changed
+20/−15 lines, 4 files
Files
- AUTHORS +3/−0
- CHANGELOG +5/−0
- src/Graphics/Vty/Input/Classify.hs +11/−14
- vty.cabal +1/−1
AUTHORS view
@@ -15,3 +15,6 @@ * Mikolaj Konarski * Eyal Lotem * Yoshikuni Jujo+ * Dmitry Ivanov++Plus others.. Check the git log for a full list.
CHANGELOG view
@@ -1,3 +1,8 @@+5.2.3+ - evaluate/compile the input parsing table once instead of each keystroke.+ - https://github.com/coreyoconnor/vty/pull/59+ - Thanks ethercrow!+ 5.2.2 - When looking at input for an event, don't look too deep. - https://github.com/coreyoconnor/vty/pull/57
src/Graphics/Vty/Input/Classify.hs view
@@ -6,7 +6,10 @@ -- TODO: measure and rewrite if required. -- TODO: The ClassifyMap interface requires this code to always assure later entries override -- earlier.-module Graphics.Vty.Input.Classify where+module Graphics.Vty.Input.Classify+ ( classify+ , KClass(..)+ ) where import Graphics.Vty.Input.Events @@ -53,28 +56,22 @@ -- TODO: debug log [] -> Invalid -classify, classifyTab :: ClassifyMap -> [Char] -> KClass---- As soon as-classify _table s@(c:_) | ord c >= 0xC2- = if utf8Length (ord c) > length s then Prefix else classifyUtf8 s -- beginning of an utf8 sequence-classify table other- = classifyTab table other+classify :: ClassifyMap -> [Char] -> KClass+classify table =+ let standardClassifier = compile table+ in \s -> case s of+ (c:_) | ord c >= 0xC2 && utf8Length (ord c) > length s -> Prefix -- beginning of an utf8 sequence+ (c:_) | ord c >= 0xC2 -> classifyUtf8 s -- As soon as+ _ -> standardClassifier s classifyUtf8 :: [Char] -> KClass classifyUtf8 s = case decode ((map (fromIntegral . ord) s) :: [Word8]) of Just (unicodeChar, _) -> Valid (EvKey (KChar unicodeChar) []) [] _ -> Invalid -- something bad happened; just ignore and continue. -classifyTab table = compile table--first :: (a -> b) -> (a,c) -> (b,c)-first f (x,y) = (f x, y)- utf8Length :: (Num t, Ord a, Num a) => a -> t utf8Length c | c < 0x80 = 1 | c < 0xE0 = 2 | c < 0xF0 = 3 | otherwise = 4-
vty.cabal view
@@ -1,5 +1,5 @@ name: vty-version: 5.2.2+version: 5.2.3 license: BSD3 license-file: LICENSE author: AUTHORS