diff options
Diffstat (limited to 'src/Main.hs')
-rw-r--r-- | src/Main.hs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Main.hs b/src/Main.hs index 71d5cd7..f14d405 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -1,5 +1,6 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE TemplateHaskell #-} module Main where @@ -52,6 +53,17 @@ data VTState = VTState , _registers :: Map Char String } +instance Show VTState where + show VTState{..} = + "<VTState" + ++ " buffer=" ++ show _buffer + ++ " mode=" ++ show _mode + ++ " processCount=" ++ show _processCount + ++ " count=" ++ show (maybe 0 id _count) + ++ " register=" ++ show _register + ++ " registers=" ++ show _registers + ++ ">" + makeLenses ''VTState @@ -139,6 +151,7 @@ uiThread cf putState getState = forever $ do data Command = AlertBadInput String + | DebugShowVTState | InsertString String | KillLastWord | KillLastChar @@ -217,6 +230,9 @@ insertString s (ls, rs) = (ls ++ s, rs) execCommand :: Command -> VT () +execCommand DebugShowVTState = + get >>= tell . (:[]) . pp . SGR [35] . Plain . show + execCommand (MotionCommand x) = do c <- uses count (maybe 1 id) buffer %= move x c @@ -480,6 +496,7 @@ charToCode c = "\\x" ++ showIntAtBase 16 intToDigit (ord c) "" dmap :: Keymap dmap = [ ("\ESC", ChangeMode NormalMode <> SetCount Nothing) + , ("\ESC[24~", DebugShowVTState) , ("d", DeleteEntireLine <> ChangeMode NormalMode <> SetCount Nothing) , ("h", DeleteLeft <> ChangeMode NormalMode <> SetCount Nothing) , ("l", DeleteRight <> ChangeMode NormalMode <> SetCount Nothing) @@ -511,6 +528,7 @@ nmap = , ("w", MotionCommandWarn WordsForward <> SetCount Nothing) , ("d", ChangeMode DeleteMode) , ("\"", ChangeMode SelectRegisterMode <> SetCount Nothing) + , ("\ESC[24~", DebugShowVTState) , ("\ESC[C", MotionCommandWarn GotoRight <> SetCount Nothing) , ("\ESC[D", MotionCommandWarn GotoLeft <> SetCount Nothing) , ("\x0a", ExecuteInputBuffer <> ChangeMode InsertMode <> SetCount Nothing) @@ -540,6 +558,7 @@ imap = [ ("\ESC", ChangeMode NormalMode <> MotionCommand GotoLeft) , ("\x01", MotionCommandWarn GotoFirstChar) , ("\x05", MotionCommandWarn GotoEndOfLine) + , ("\ESC[24~", DebugShowVTState) , ("\ESC[3~", KillNextChar) , ("\ESC[C", MotionCommandWarn GotoRight) , ("\ESC[D", MotionCommandWarn GotoLeft) |