From: pjb@... (Pascal J. Bourguignon) Date: 2009-08-06T18:55:09+09:00 Subject: Re: Terminal escape sequences James Coglan writes: > [Note: parts of this message were removed to make it a legal post.] > > Hi all, > > Looking through the PDoc source to see how it renders the build progress > meter, I see: > > log "\c[[F\c[[K Rendering: #{dest}" > > Is there a good reference for these escape sequences anywhere? They're not > terribly Google-friendly. Each terminal kind has its own escape sequences. There are thousands of different kinds of terminals. A subset of their escape sequences are referenced in the termcap or terminfo files, for use by libraries such as curses, to provide a certain level of terminal independance on the application side. However, nowadays we don't use many physical terminals anymore. We still use virtual terminals (xterm, Terminal.app, etc). So there is still diversity, but much less. There are standardized escape sequences, and most kinds of terminal actually includes at least a basic subset of these standard escape sequences. There's the ISO-6429 standard, but you will need money to get it. There is also the ECMA-048 standard which should be identical to ISO-6429 and can be downloaded from the web. There's also an ANSI standard that should be identical or quite similar, but I don't know the reference. However, these standard escape sequences are often known by the name ANSI escape sequences (probably because on Microsoft systems they're implemented by a module stored in a file named ANSI.SYS). So to have the highest possible level of terminal compatibility, you should rather use a curses library (which will select the escape sequence to send depending on the terminal of the user). If you choose to use these standard escape sequences, you will restrict your program to terminals that implement these standard escape sequences (probably 95% of the (virtual) terminals in use today, so not a big loss). But even in this later case, I would advise you to abstract them away. Instead of writting: log "\c[[F\c[[K Rendering: #{dest}" write: log "#{Ecma048.cpl}${Ecma048.el} Rendering: #{dest}" (Notice that most of these escape sequences may take optional numeric arguments. CPL (Cursor Preceding Line) with an argument would could back several lines.) -- __Pascal Bourguignon__