You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GHC issue #21488 is fixed in GHC 9.2.5, but not in GHC 9.4.3 or GHC 9.4.4. So, on Windows, with GHC 9.2.5 and:
ghc-options:
- -with-rtsopts=--io-manager=native
moduleMain (main) whereimportControl.ExceptionimportqualifiedData.ListasLimportData.MaybeimportSystem.Console.ANSIhiding (getReportedCursorPosition)
importSystem.IOimportSystem.Timeoutmain::IO()
main =do-- set no buffering (if 'no buffering' is not already set, the contents of-- the buffer will be discarded, so this needs to be done before the cursor-- positon is emitted)
hSetBuffering stdin NoBuffering-- ensure that echoing is off
input <- bracket (hGetEcho stdin) (hSetEcho stdin) $\_ ->do
hSetEcho stdin False
reportCursorPosition
hFlush stdout -- ensure the report cursor position code is sent to the-- operating system
getReportedCursorPosition
print input
getReportedCursorPosition = getReport "\ESC[" ["R"]
getReport::String-> [String] ->IOString
getReport _ []=error"getReport requires a list of terminating sequences."
getReport startChars endChars =do
fromMaybe ""<$> timeout 500000 (getStart startChars "")
where
endChars' = mapMaybe L.uncons endChars
getStart::String->String->IOString
getStart "" r = getRest r
getStart (h:hs) r =do
c <-getCharif c == h
then getStart hs (c:r)
elsereturn$reverse (c:r)
getRest::String->IOString
getRest r =do
c <-getCharcaselookup c endChars' ofNothing-> getRest (c:r)
Just es -> getEnd es (c:r)
getEnd::String->String->IOString
getEnd "" r =return$reverse r
getEnd (e:es) r =do
c <-getCharif c /= e
then getRest (c:r)
else getEnd es (c:r)
works as it currently does on Unix-like operating systems.
WinIO has seen https://gitlab.haskell.org/ghc/ghc/-/issues/806 closed, the issue referred to in the documentation for reportCursorPositionCode.
However, to date, I have not been able to get
getChar
on Windows with WinIO to behave as I would expect; see https://gitlab.haskell.org/ghc/ghc/-/issues/21488.The text was updated successfully, but these errors were encountered: