Christopher King
Christopher King

Reputation: 10941

`ansi-terminal` how to get cursor position in Haskell

The ansi-terminal library is a wonderful little library that allows you to move the cursor around and stuff (without all the extra stuff ncurses based stuff imposes.) The only problem is it doesn't provide a way to get the position of the cursor. Anyway, that uses or is compatible with the rest of the library, that I could do that. I know one way would be to track the cursor everywhere it goes, but I want to allow outside putStrs and such.

Upvotes: 3

Views: 946

Answers (1)

dfeuer
dfeuer

Reputation: 48591

According to Wikipedia, the DSR terminal command should get you the position, and there are also commands to save and restore the position. I don't know why ansi-terminal does not support these; perhaps you should file a bug report.

UPDATE: Support for saving and restoring cursor position has now been added to ansi-terminal!

Upvotes: 4

Related Questions