Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!cs.utexas.edu!uunet!visdc!jiii From: jiii@visdc.UUCP (John E Van Deusen III) Newsgroups: comp.unix.wizards Subject: Re: Help with man macros Keywords: text processing nroff man macros Message-ID: <618@visdc.UUCP> Date: 13 Aug 89 23:08:10 GMT References: <434@osc.COM> <613@visdc.UUCP> <16001@vail.ICO.ISC.COM> Reply-To: jiii@visdc.UUCP (John E Van Deusen III) Organization: VI Software Development, Boise, Idaho Lines: 49 In article <16001@vail.ICO.ISC.COM> rcd@ico.ISC.COM (Dick Dunn) writes: > > ...it's probably easier to develop the filter if you use a different > terminal type--create one of your own which is adapted to produce > easily-parsed data for the things the filter has to re-hack and which > minimizes the number of sequences the filter has to handle. >-- >Dick Dunn rcd@ico.isc.com uucp: {ncar,nbires}!ico!rcd (303)449-2870 > ...Simpler is better. As was discussed earlier, there really isn't that much that modifying the nroff driving tables enables you to do. Although you can accomplish quite a bit toward making perfect, terminal-specific \(dg and \(bu special fonts, the italic font is always produced by the sequence _^Hx, (where x is the underlined character). Likewise, the bold font is always produced by repetitions of x^Hx. From my experience it is both possible and desirable to create a filter that can intercept the specific escape sequences for ALL of the terminal types in use on the machine. It is desirable to be able to do this, because nroff does produce other escape codes that are incompatible with certain printers. For instance, the half-line up sequence for the default Teletype 37 is Esc 9. If that sequence is sent to a Diablo 630, it will reset the left margin to the current print position. Thus, a user forgetting to specify -Tlp when invoking the man(1) command, with the output directed to lp(1), could screw up not only his own output, but also everything printed thereafter. The trick is for the filter to try to determine the terminal type for which the nroff output was generated by examining the data stream. For example, the Teletype 37 output, as supplied with my system, does not output anything at the start of the data set. In contrast, the -T450 data stream begins with an Esc 4. Thus, a filter can know to convert Esc 9 to Esc D if there is not an Esc 4 at the beginning of the data. Since the filter is device specific, it should be invoked by the /usr/spool/lp/interface/xxx program, (where xxx is the name of the printer), because these programs are also bound to a particular device. A more important function than correctly interpreting nroff escape sequences is for the filter to protect the printer from random data. It should definately recognize the escape sequences that do system resets or change the number of lines per page and exit if those sequences are encountered in a "normal" data stream. -- John E Van Deusen III, PO Box 9283, Boise, ID 83707, (208) 343-1865 uunet!visdc!jiii