apratt@iuvax.UUCP (05/02/84)
It makes the code look a little worse, but in a C program, the "accepted"
modular-programming method would be:
#define ON 1
#define OFF 0
printf("This is ");
highlight(ON);
underline(ON);
printf("very");
highlight(OFF);
underline(OFF);
printf("important\n");
That way, the functions could take care of sending the apropriate code.
Redefining putc will *not* work if you use printf, unless you redefine printf
as well. This is because the library version of printf would not use your
new and improved putc as a filter/translator/interpreter.
In text files, however, the ANSI standard is as good as any, but a little
verbose; writing an interpreter for it (to include cursor motion, screen
clearing, etc.) is not trivial. Also, you should keep in mind that not a lot
of terminals have such features as double height/double width lines.
Of course, these files would have to be run through a filter which interprets
the embedded ANSI codes and sends the appropriate termcap-supported codes.
This all is assuming, of course, that you want portability from UNIX to UNIX
as well as terminal to terminal.
I suppose there is nothing intrinsically wrong with embedding control
characters in a file, but I would be wary of transmitting it over the net.
After all, *somewhere* there might be a mailer which gags on ASCII 27 (ESC).
For local use with your own package, of course, you can do whatever you want.
----
-- Allan Pratt
...ihnp4!inuxc!iuvax!apratt