iverson@cory.Berkeley.EDU (Tim Iverson) (11/07/86)
In article <193@slovax.UUCP> harryb@slovax.UUCP writes: > [stuff about FANSI-CONSOLE, an ANSI 3.64 console emulator for MS-DOS] > >I implement the ANSI 3.64 controls by defining them all in an >'#include fansi.h' and then calling the ones I want from the program, e.g.: > ... > #include "fansi.h" > ... > CUP(xcoord,ycoord); /* CUrsor Position to x,y */ > ... > >'CUP' was defined in fansi.h as: > #define CUP(x,y) printf("^[[%d;%dH",x,y) > >I find it very easy to implement screen control and display features this way. > >Anybody got any tips on how to exploit all the features? I have one comment about your use of macros in this way: its not very portable. What do you do when you want to move it to UNIX? Force everyone who runs your program to use an ANSI terminal? A much better approach is to use curses or if you do not have a curses package, you could use the low level TERMCAP(3X) routines (tgetent, tgetnum, tgetflag, tgetstr, tgoto, and tputs), most of which are available in public domain versions such as the routines distributed with the MS-DOS version of LARN. All that would be necessary to use these routines effectively on a PC with FANSI would be to set up tgetstr to return the proper control strings for FANSI. There are, of course, some disadvantages to this method. The major one is that an MS-DOS user would have to be using FANSI or some other full 3.64 emulator (such as the public domain NANSI.SYS) to use your program. This is no worse than your method with the include file, but still remains portable to UNIX systems. The second major disadvantage is that the TERMCAP(3X) routines probably do not support some of the more esoteric control sequences that FANSI supports. If you never plan on 'sharing' your efforts with the outside world, portability is not an issue. Either way, if you're interested in using these routines, I have tgetent, tgetstr, tgoto, and tputs set up for minimal use of the ANSI 3.64 standard and I would be willing to send them to anyone interested. Please respond via e-mail and if the volume warrants, I will post to net.sources, otherwise I will mail them. Tim Iverson iverson@cory.Berkeley.EDU ...!ucbvax!cory!iverson