Parsing curses output
-
Let's say I have a program that outputs some data in a scrollable curses interface. I want to convert that data into HTML. I've done pretty well so far just emulating the down arrow key and then stripping ANSI escape sequences from the program's output, but occasionally I get lines that contain parts of other lines, or a line followed by the only two words in the next line that change.
Is there a library that works like a terminal emulator, so that I could query "what's the last line currently on the screen" instead of some naive "drop all the things that look vaguely like formatting" approach?
-
You mean convert dwarf fortress to a grid of html elements? Why don't you say so!
I don't know.
-
Not sure if this is any use for what you're after, but I've had some success with output of builds that have been colorized and saving them as HTML with <a href="https://pypi.python.org/pypi/ansi2html/>ansi2html. (Basically I just tee/pipe the colorized output to a file then run it through ansi2html with output to *.html.)
-
@PJH said:
Not sure if this is any use for what you're after, but I've had some success with output of builds that have been colorized and saving them as HTML with ansi2html. (Basically I just tee/pipe the colorized output to a file then run it through ansi2html with output to *.html.)
That's just color codes. I'm stripping those out anyway. The program looks like this:And I want to convert the 72955 entries into static HTML pages with links between them (which is trivial with regular expressions).
-
You want to use a VT100 (or VT102 or VT220) parsing library. Last time this problem came up for me, I was using Perl, so I used Term::VT102 from CPAN. The previous time, I was using Java, and used the VT100 parser in the source code of jta (a terminal implemented in Java), because it had a compatible license (GPL, the same I was using), with some modifications.
-
Ben - why don't you just reverse-engineer the save files?
-
@too_many_usernames said:
Ben - why don't you just reverse-engineer the save files?
I've been trying to do that. Maybe getting another set of eyes on the stuff I'm trying to figure out will help.
-
@Ben L. said:
Let's say I have a program that outputs some data in a scrollable curses interface. I want to convert that data into HTML.
Doesn't that belong in the Bad Ideas thread?
-
ok so I have the book parsing pretty much down, at least for now.
This data is apparently the same set of fields for both records. I linked to the shorter record because otherwise you'd miss it. I have no clue how to start to begin to prepare to try to unravel this mess.