(Related to a previous question.)
If I can print a character in the terminal via Prelude.putChar
at a position that I've decided via System.Console.ANSI.setCursorPosition
, how can I get the charcter at that position?
The use case is that I want to do something like this
do
setCursorPosition a b
c <- getTheCharacterHere
putChar $ if c == 'x' then 'y' else 'z'
where getTheCharacterHere
is the desired action of retrieving the character currently shown at the position set via setCursorPosition
.
This isn't possible without a framework like ncurses which keeps track of the state of the entire screen. Terminals are write-only by default. See e.g. this question.