joeyh

I can parse ansi escapes in my head now (finally)

joeyh at

Currently writing a function from oldval and newval to an optimal screen output sequence. Ie, currently writing curses.

Except, in curses, the user provided values don't themselves include ansi escape sequences to set colors. They do in my function, which is where a lot of the "fun" will be.

old: foofoofooREDbarbarbarNORMALbaz
new: foofoofooREDxarbarbayNORMALbaz
out: e[9C---->REDxe[7C-->yNORMAL

*System.Console.Regions T> genLineUpdate  $ calcLineUpdate (T.pack "\ESC[92mfoofoofoo\ESC[91mbarbarbar\ESC[0mbaz") (T.pack "\ESC[92mfoofoofoo\ESC[91mxarbarbax\ESC[0mbaz")
"\ESC[92m\ESC[91m\ESC[9Cx\ESC[7Cx"

\o/ worked first try!

joeyh at 2015-11-02T21:30:00Z

Or, pretty-printing the internal data structure representing the line update:

[SGR "\ESC[92m",SGR "\ESC[91m",Skip "foofoofoo",Display "x",Skip "arbarba",Display "x"]

Ok, so it's not 100% optimal since it doesn't combine SGR codes..

joeyh at 2015-11-02T21:33:46Z