From 83f37966cf8d1467f748e15b9d73e2597e307bf9 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 6 Aug 2017 22:41:21 +0200 Subject: Main: add DebugShowVTState --- src/Main.hs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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{..} = + "" + 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) -- cgit v1.2.3