Reading ANSI escape sequences is nitty gritty and very easy to get wrong. I am after a library that includes an abstraction for reading escaped sequences preferrably as inst
You may want to take a look at Jansi. Here is the homepage and github repo
I hope that helps.