Converting ansi escape to graphics
Hi all, This is probably a dev question but I'll ask here anyway in case one is watching. I use tin to view messages on the bulletin board (BBS) via a usenet interface. A lot of groups have ANSI art or colors using ANSI and wondered if anyone would be able to add translation from ANSI to the graphic or color. For example, if you connect to endofthelinebbs.com and go to DN.DN-ADDS then look at any message with ANSI in the subject, for example [ANSI] Shadowscope You'll see a string of ANSI characters. These are escape codes, of course. ^[[0m^[[1;1H^[[1C^[[35m▄▄▄▄▄▄▄▄ ^[[0m = All attributes off ^[[1;1H = Move the cursor to the specified position (This would be relative to the headers) ^[[1C = Move the cursor forward specified number of columns without changing the line ^[[35m = Change the foreground color to magenta. Followed by whatever graphics are to be displayed. I could "possibly" do the work myself, but I'm not a C coder, I'm more of a perl tinkerer. If someone showed me what I need to do and where then I can probably do the work. If someone wants to have a crack, a good ANSI reference is at http://ascii-table.com/ansi-escape-sequences.php Thanks, Nigel
On Thu, Apr 16, 2020 at 09:11:34PM +0000, Nigel Reed wrote:
Hi all,
This is probably a dev question but I'll ask here anyway in case one is watching.
I use tin to view messages on the bulletin board (BBS) via a usenet interface.
A lot of groups have ANSI art or colors using ANSI and wondered if anyone would be able to add translation from ANSI to the graphic or color.
For example, if you connect to endofthelinebbs.com and go to DN.DN-ADDS then look at any message with ANSI in the subject, for example [ANSI] Shadowscope
You'll see a string of ANSI characters. These are escape codes, of course.
^[[0m^[[1;1H^[[1C^[[35m▄▄▄▄▄▄▄▄
^[[0m = All attributes off ^[[1;1H = Move the cursor to the specified position (This would be relative to the headers) ^[[1C = Move the cursor forward specified number of columns without changing the line ^[[35m = Change the foreground color to magenta. Followed by whatever graphics are to be displayed.
occasionally someone wants this in ncurses, but it's out of scope since it could be implemented without needing ncurses internals. screen and tmux do this, for instance (using low-level calls). It could be done using curses, but would be just as much work. This example doesn't use curses (it produces markup that vile understands) but does the sort of parsing you're talking about: https://github.com/ThomasDickey/vile-snapshots/blob/master/filters/manfilt.c However it doesn't handle movement outside of the current line. Occasionally I want to view a "typescript" which does that (to-do...).
I could "possibly" do the work myself, but I'm not a C coder, I'm more of a perl tinkerer. If someone showed me what I need to do and where then I can probably do the work. If someone wants to have a crack, a good ANSI reference is at http://ascii-table.com/ansi-escape-sequences.php
I wouldn't call that "good": it appears to be MS-DOS ansi.sys, but doesn't make that apparent, nor provide details on how that differs from other implementations. https://www.vfrazee.com/ms-dos/6.22/help/ansi.sys.htm http://www.kegel.com/nansi/ However, the "whatever graphics" in your example rely upon a particular character-set -- which isn't related to "ANSI". Something that translated those bbs outputs to curses (or UTF-8) would have to know about that. -- Thomas E. Dickey <dickey@invisible-island.net> https://invisible-island.net ftp://ftp.invisible-island.net
participants (2)
-
Nigel Reed -
Thomas Dickey