on master help sign in
attributeControl: explicitly enable a required mode flag (see #187)

Prior to this change, Vty would initialize the terminal by clearing the flags it needed to clear. That is good, but it means that some flags that were assumed to be enabled but not *explicitly* enabled by Vty would cause trouble if they were not, in fact, enabled prior to Vty initialization. This comes up in (pathological?) cases where the terminal state prior to Vty initialization is not what Vty assumes it will be, i.e., cases in which some flags which are assumed to be set are not. We found this to be true when an application (in this case vim) was terminated uncleanly, leaving the terminal mode flags in a state that Vty did not anticipate. To resolve this problem, this change explicitly sets one flag which we now know to be required for Vty to function properly (the ICRNL flag).

commitc572ad1ac70a1713aa54af97634df853eb43eeb4 authorJonathan Daugherty <cygnus@foobox.com> dateThu 9 Jul 2020, 13:57 (6 years ago) parentf7eef97
1 file changed+7−3
src/Graphics/Vty/Input/Loop.hs+7−3
src/Graphics/Vty/Input/Loop.hs+7−3
@@ -174,9 +174,13 @@ runInputProcessorLoop classifyTable input = do
174174attributeControl :: Fd -> IO (IO (), IO ())
175175attributeControl fd = do
176176 original <- getTerminalAttributes fd
177− let vtyMode = foldl withoutMode original [ StartStopOutput, KeyboardInterrupts
178− , EnableEcho, ProcessInput, ExtendedFunctions
179− ]
177+ let vtyMode = foldl withMode clearedFlags flagsToSet
178+ clearedFlags = foldl withoutMode original flagsToUnset
179+ flagsToSet = [ MapCRtoLF
180+ ]
181+ flagsToUnset = [ StartStopOutput, KeyboardInterrupts
182+ , EnableEcho, ProcessInput, ExtendedFunctions
183+ ]
180184 let setAttrs = setTerminalAttributes fd vtyMode Immediately
181185 unsetAttrs = setTerminalAttributes fd original Immediately
182186 return (setAttrs,unsetAttrs)