|
|
1.1 root 1: .\" @(#)termdesc.me 6.2 (Berkeley) 5/20/86
2: .\"
3: .+c
4: .(l C
5: .sz 14
6: .b "Writing \s-2NROFF\s0 Terminal Descriptions"
7: .sp
8: .sz 10
9: Eric Allman
10: .i "Britton-Lee, Inc."
11: .)l
12: .sp 2
13: .sh 1 "INTRODUCTION"
14: .eh 'SMM:20-%''Writing NROFF Terminal Descriptions'
15: .oh 'Writing NROFF Terminal Descriptions''SMM:20-%'
16: .pp
17: As of the Version 7 Phototypesetter release of \s-2UNIX\s0,*
18: .(f
19: *\s-2UNIX\s0 is a trademark of Bell Laboratories.
20: .)f
21: \s-2NROFF\s0 has supported terminal description files.
22: These files describe the characteristics of available hard-copy printers.
23: This document describes some of the details of how to write
24: terminal description files.
25: .pp
26: .ul
27: Disclaimer.
28: This document describes the results of my personal experience.
29: The effects of changing some of the fields from the norms
30: may not be well defined,
31: even if it seems like it
32: .q ought
33: to work given the descriptions herein.
34: These tables are known to vary slightly
35: for different versions of \s-2UNIX\s0.
36: I have not seen \s-2UNIX\s0 3.0 at this time,
37: so this may be irrelevant in that context.
38: .sh 1 "GENERAL"
39: .pp
40: When \s-2NROFF\s0 starts up,
41: it looks for a
42: .b \-T
43: flag describing the terminal type.
44: For example,
45: if the command line is given as
46: .(b
47: nroff \-T300s
48: .)b
49: \s-2NROFF\s0 prepares output for a
50: .i DTC300S
51: terminal.
52: This terminal is described in the file
53: /usr/lib/term/tab300s
54: on most systems.
55: .pp
56: If no
57: .b \-T
58: flag is given,
59: the terminal type
60: .b 37
61: (ASR 37 \*- a relic assumed for historical humor only)
62: is assumed.
63: .pp
64: The terminal description table is a stripped
65: .q \&.o
66: file generated from a data structure,
67: shown in figure one.
68: .(z
69: .hl
70: .ta 8n 24n
71: #define INCH 240 /* one inch in units */
72: struct
73: {
74: int bset; /* stty bits to set */
75: int breset; /* stty bits to reset */
76: int Hor; /* horizontal resolution in units */
77: int Vert; /* vertical resolution in units */
78: int Newline; /* the distance a newline moves */
79: int Char; /* the distance one char moves */
80: int Em; /* size of an Em */
81: int Halfline; /* the distance a halfline up/down moves */
82: int Adj; /* default adjustment width */
83: char *twinit; /* string to init the terminal */
84: char *twrest; /* string to reset the terminal */
85: char *twnl; /* string to send a newline (CR-LF) */
86: char *hlr; /* half line reverse string */
87: char *hlf; /* half line forward string */
88: char *flr; /* full line reverse string */
89: char *bdon; /* string to turn boldface on */
90: char *bdoff; /* string to turn boldface off */
91: char *ploton; /* string to turn plot on */
92: char *plotoff; /* string to turn plot off */
93: char *up; /* move up in plot mode */
94: char *down; /* move down in plot mode */
95: char *right; /* move right in plot mode */
96: char *left; /* move left in plot mode */
97: char *codetab[256-32]; /* the codes to send for characters */
98: int zzz; /* padding */
99: };
100: .sp
101: .ce
102: Figure 1 \*- the terminal descriptor data structure
103: .hl
104: .)z
105: This structure can be dealt with in two sections:
106: the terminal capability descriptor (everything to codetab),
107: and the output descriptor.
108: .sh 1 "TERMINAL CAPABILITIES"
109: .pp
110: The section of the data structure up to but excluding
111: .i codetab
112: describes the basic functions and setup requirements of the terminal.
113: Distances are measured in
114: .q units,
115: which are 1/240 of an inch in \s-2NROFF\s0.
116: In general, \s-2NROFF\s0 assumes that there is a
117: .q "plot mode"
118: on the terminal that allows you to move in small increments.
119: A terminal has a resolution when in plot mode
120: that is measured in units.
121: This limits how well the terminal can simulate
122: printing Greek and special characters.
123: .sh 2 "bset, breset"
124: .pp
125: These fields define bits in a vanilla stty(2) word
126: (sg_flags) to
127: set and clear respectively when
128: \s-2NROFF\s0 starts.
129: They are normally represented in octal,
130: although you could include <sgtty.h>.
131: [Note:
132: these fields are presumably different
133: in \s-2UNIX\s0 3.0.]
134: .sh 2 "Hor, Vert"
135: .pp
136: These represent the horizontal and vertical resolution respectively
137: of the terminal when it is in plot mode.
138: They are given in units.
139: .sh 2 "Newline"
140: .pp
141: This field describes the distance that the
142: .i twnl
143: field (below) will move the paper;
144: it is literally the size of a newline.
145: .sh 2 "Char"
146: .pp
147: This is the distance that a regular character
148: will move the print head to the right.
149: .sh 2 "Em"
150: .pp
151: The
152: .q em
153: is a typesetting unit,
154: approximately equal to the width of the letter
155: .q m .
156: In \s-2NROFF\s0 driver tables,
157: this must be the distance a space or backspace character will move
158: the carriage.
159: .sh 2 "Halfline"
160: .pp
161: This is the distance that the
162: .i hlr
163: or
164: .i hlf
165: strings move the print head
166: (reverse or forward respectively).
167: .sh 2 "Adj"
168: .pp
169: This is the resolution that \s-2NROFF\s0 will normally adjust
170: your lines to horizontally.
171: Typically this is the same as Char.
172: If the
173: .b \-e
174: flag is given to \s-2NROFF\s0,
175: output resolution will be to the full device resolution.
176: .sh 2 "twinit, twrest"
177: .pp
178: These strings are output when \s-2NROFF\s0 starts and finishes
179: respectively.
180: .sh 2 "twnl"
181: .pp
182: This string is output when \s-2NROFF\s0 wants to do a carriage return.
183: Typically it will be
184: .q "\er\en" .
185: Remember,
186: the terminal will normally have CRMOD turned off
187: when this is set.
188: .sh 2 "hlr, hlf"
189: .pp
190: These strings are sent to move the carriage back or forward
191: one half line respectively.
192: The actual amount that they moved is defined by
193: Halfline.
194: The carriage should be left in the same column.
195: .sh 2 "flr"
196: .pp
197: The string to send to move a full line backwards.
198: This should leave the carriage in the same column.
199: .sh 2 "bdon, bdoff"
200: .pp
201: These strings are sent to turn boldface mode on and off
202: respectively.
203: Normally this will set the terminal into overstrike mode.
204: If they are not given,
205: some newer versions of \s-2NROFF\s0 will output the characters
206: four times to force overstriking.
207: .sh 2 "ploton, plotoff"
208: .pp
209: These strings turn plot mode on and off respectively.
210: In plot mode,
211: the carriage moves a very small amount,
212: and only under specific control;
213: i.e., characters do not automatically cause any carriage motion.
214: .sh 2 "up, down, right, left"
215: .pp
216: These strings are only output in plot mode.
217: They should move the carriage up, down, left, and right
218: respectively;
219: they will move the carriage a distance of Hor or Vert
220: as appropriate.
221: .sh 2 "An Example"
222: .pp
223: Consider the following table describing a
224: DTC300S:
225: .(b
226: .ta 1.5i
227: /*bset*/ 0,
228: /*breset*/ 0177420,
229: /*Hor*/ INCH/60,
230: /*Vert*/ INCH/48,
231: /*Newline*/ INCH/6,
232: /*Char*/ INCH/10,
233: /*Em*/ INCH/10,
234: /*Halfline*/ INCH/12,
235: /*Adj*/ INCH/10,
236: /*twinit*/ "\e033\e006",
237: /*twrest*/ "\e033\e006",
238: /*twnl*/ "\e015\en",
239: /*hlr*/ "\e033H",
240: /*hlf*/ "\e033h",
241: /*flr*/ "\e032",
242: /*bdon*/ "",
243: /*bdoff*/ "",
244: /*ploton*/ "\e006",
245: /*plotoff*/ "\e033\e006",
246: /*up*/ "\e032",
247: /*down*/ "\en",
248: /*right*/ " ",
249: /*left*/ "\eb",
250: .)b
251: This describes a terminal that should have the
252: ALLDELAY and CRMOD bits turned off,
253: 1/60" horizontal and 1/48" vertical resolution,
254: six lines per inch and ten characters per inch, including space,
255: halfline takes 1/12" (one half of a full line),
256: should send ESC-control-F to initialize and reset the terminal
257: (to insure that it is in a normal state),
258: takes <CR><LF> to give a newline,
259: <ESC>H to move back one half line,
260: <ESC>h to move forward one half line,
261: control-Z to move back one full line,
262: has no bold mode,
263: takes control-F to enter plot mode
264: and escape-control-F to exit plot mode,
265: and uses control-Z, linefeed, space, and backspace
266: to move up, down, right, and left respectively
267: when in plot mode.
268: .sh 1 "CHARACTER DESCRIPTIONS"
269: .pp
270: There is one character description
271: for each possible character to be output.
272: The easiest way to find what character corresponds to what position
273: is to edit an existing character table;
274: one is given in the appendix as an example.
275: Character representations are represented as a string per
276: character.
277: .pp
278: The first character of the string
279: is interpreted as a binary number
280: giving the number of character spaces taken up
281: by this character.
282: For regular characters
283: this will always be
284: .q "\e001" ,
285: but Greek and special characters can take more.
286: If the 0200 bit is set in this character,
287: it indicates that the character should be underlined
288: if we are in italic (underline) mode.
289: Thus,
290: alphabetic and numeric descriptions
291: will begin
292: .q "\e201" .
293: .pp
294: The remainder of the string is output to represent the character.
295: If the first output character
296: (i.e.,
297: the second character in the total string)
298: has the 0200 bit set,
299: the character will be output in plot mode
300: so that fancy characters can be built up from existing characters.
301: If necessary,
302: the
303: .q "\e200"
304: character can be used as a null character
305: to force \s-2NROFF\s0 to set the terminal into plot mode.
306: All characters without the 0200 bit are output literally;
307: characters with the 0200 bit are not output,
308: but are used to indicate local carriage movement.
309: The next two bits (0140 bits) represent direction:
310: .(b
311: .ta \w'0200 'u
312: 0200 right
313: 0240 left
314: 0300 down
315: 0340 up
316: .)b
317: The bottom five bits represent a distance in terminal resolution units.
318: This is rather confusing,
319: but the examples should make this much more clear.
320: .sh 2 "Some Examples"
321: .pp
322: The following examples are from the DTC300S table:
323: .(b
324: .ta 2i
325: "\e001 ", /*space*/
326: "\e001=", /*=*/
327: "\e201A", /*A*/
328: .)b
329: These entries show that all of these characters
330: take one character width when output.
331: The letter A is underlined in italic mode,
332: but neither space nor equal sign is.
333: .(b
334: .ta 2i
335: "\e001o\eb+", /*bullet*/
336: "\e002[]", /*square*/
337: "\e202f\^i", /*f\^i*/
338: .)b
339: The bullet character takes only one character position,
340: but is created by outputing the letter
341: .q o
342: and overstriking it with a plus sign.
343: The square character is approximated
344: with two brackets;
345: it takes two full character positions
346: when output.
347: The
348: .q fi
349: ligature
350: is produced using the letters
351: .q f
352: and
353: .q i
354: (surprise!);
355: it is underlined in italic mode.
356: .(b
357: "\e001\e241c\e202(\e241", /*alpha*/
358: "\e001\e200B\e242\e302|\e202\e342", /*beta*/
359: .)b
360: The letters alpha and beta both take a single character position.
361: The alpha is output by entering plot mode,
362: moving left 1 terminal unit (1/60" if you recall),
363: outputing the letter
364: .q c ,
365: moving right 2/60",
366: outputing a left parenthesis,
367: and finally moving left 1/60";
368: it is critical that the net space moved
369: be zero both horizontally and vertically.
370: The beta first has a dummy 0200 character
371: to enter plot mode but not output anything.
372: It then outputs a
373: .q B ,
374: moves left 2/60",
375: moves down 2/48",
376: outputs a vertical bar
377: (which is designed to partically overstrike the left edge of the
378: .q B ,
379: and finally move right 2/60" and up 2/48"
380: to set us back to the right place.
381: .sh 1 "INSTALLATION"
382: .pp
383: To install a terminal descriptor,
384: make it up by editing an existing terminal descriptor.
385: Assuming your terminal name is
386: .i term ,
387: call your new descriptor
388: .b tab \c
389: .i term \c
390: .b .c .
391: Then, execute the following commands:
392: .(b
393: cc -c tabterm.c
394: strip tabterm.c
395: cp tabterm.o /usr/lib/term/tabterm
396: .)b
397: The directory /usr/src/cmd/troff/term
398: typically has a shell file to do this.
399: .+c
400: .ce 2
401: APPENDIX
402: .sp
403: A Sample Table
404: .sp 3
405: This table describes the DTC 300S.
406: .(l
407: .re
408: #define INCH 240
409: /*
410: DASI300S
411: nroff driving tables
412: width and code tables
413: */
414:
415: struct {
416: int bset;
417: int breset;
418: int Hor;
419: int Vert;
420: int Newline;
421: int Char;
422: int Em;
423: int Halfline;
424: int Adj;
425: char *twinit;
426: char *twrest;
427: char *twnl;
428: char *hlr;
429: char *hlf;
430: char *flr;
431: char *bdon;
432: char *bdoff;
433: char *ploton;
434: char *plotoff;
435: char *up;
436: char *down;
437: char *right;
438: char *left;
439: char *codetab[256-32];
440: int zzz;
441: } t = {
442: /*bset*/ 0,
443: /*breset*/ 0177420,
444: /*Hor*/ INCH/60,
445: /*Vert*/ INCH/48,
446: /*Newline*/ INCH/6,
447: /*Char*/ INCH/10,
448: /*Em*/ INCH/10,
449: /*Halfline*/ INCH/12,
450: /*Adj*/ INCH/10,
451: /*twinit*/ "\e033\e006",
452: /*twrest*/ "\e033\e006",
453: /*twnl*/ "\e015\en",
454: /*hlr*/ "\e033H",
455: /*hlf*/ "\e033h",
456: /*flr*/ "\e032",
457: /*bdon*/ "",
458: /*bdoff*/ "",
459: /*ploton*/ "\e006",
460: /*plotoff*/ "\e033\e006",
461: /*up*/ "\e032",
462: /*down*/ "\en",
463: /*right*/ " ",
464: /*left*/ "\eb",
465: /*codetab*/
466: "\e001 ", /*space*/
467: "\e001!", /*!*/
468: "\e001\e"", /*"*/
469: "\e001#", /*#*/
470: "\e001$", /*$*/
471: "\e001%", /*%*/
472: "\e001&", /*&*/
473: "\e001'", /*' close*/
474: "\e001(", /*(*/
475: "\e001)", /*)*/
476: "\e001*", /***/
477: "\e001+", /*+*/
478: "\e001,", /*,*/
479: "\e001-", /*- hyphen*/
480: "\e001.", /*.*/
481: "\e001/", /*/*/
482: "\e2010", /*0*/
483: "\e2011", /*1*/
484: "\e2012", /*2*/
485: "\e2013", /*3*/
486: "\e2014", /*4*/
487: "\e2015", /*5*/
488: "\e2016", /*6*/
489: "\e2017", /*7*/
490: "\e2018", /*8*/
491: "\e2019", /*9*/
492: "\e001:", /*:*/
493: "\e001;", /*;*/
494: "\e001<", /*<*/
495: "\e001=", /*=*/
496: "\e001>", /*>*/
497: "\e001?", /*?*/
498: "\e001@", /*@*/
499: "\e201A", /*A*/
500: "\e201B", /*B*/
501: "\e201C", /*C*/
502: "\e201D", /*D*/
503: "\e201E", /*E*/
504: "\e201F", /*F*/
505: "\e201G", /*G*/
506: "\e201H", /*H*/
507: "\e201I", /*I*/
508: "\e201J", /*J*/
509: "\e201K", /*K*/
510: "\e201L", /*L*/
511: "\e201M", /*M*/
512: "\e201N", /*N*/
513: "\e201O", /*O*/
514: "\e201P", /*P*/
515: "\e201Q", /*Q*/
516: "\e201R", /*R*/
517: "\e201S", /*S*/
518: "\e201T", /*T*/
519: "\e201U", /*U*/
520: "\e201V", /*V*/
521: "\e201W", /*W*/
522: "\e201X", /*X*/
523: "\e201Y", /*Y*/
524: "\e201Z", /*Z*/
525: "\e001[", /*[*/
526: "\e001\e\e", /*\e*/
527: "\e001]", /*]*/
528: "\e001^", /*^*/
529: "\e001_", /*_ dash*/
530: "\e001`", /*` open*/
531: "\e201a", /*a*/
532: "\e201b", /*b*/
533: "\e201c", /*c*/
534: "\e201d", /*d*/
535: "\e201e", /*e*/
536: "\e201f", /*f*/
537: "\e201g", /*g*/
538: "\e201h", /*h*/
539: "\e201i", /*i*/
540: "\e201j", /*j*/
541: "\e201k", /*k*/
542: "\e201l", /*l*/
543: "\e201m", /*m*/
544: "\e201n", /*n*/
545: "\e201o", /*o*/
546: "\e201p", /*p*/
547: "\e201q", /*q*/
548: "\e201r", /*r*/
549: "\e201s", /*s*/
550: "\e201t", /*t*/
551: "\e201u", /*u*/
552: "\e201v", /*v*/
553: "\e201w", /*w*/
554: "\e201x", /*x*/
555: "\e201y", /*y*/
556: "\e201z", /*z*/
557: "\e001{", /*{*/
558: "\e001|", /*|*/
559: "\e001}", /*}*/
560: "\e001~", /*~*/
561: "\e000\e0", /*narrow sp*/
562: "\e001-", /*hyphen*/
563: "\e001o\eb+", /*bullet*/
564: "\e002[]", /*square*/
565: "\e001-", /*3/4 em*/
566: "\e001_", /*rule*/
567: "\e000\e0", /*1/4*/
568: "\e000\e0", /*1/2*/
569: "\e000\e0", /*3/4*/
570: "\e001-", /*minus*/
571: "\e202f\^i", /*fi*/
572: "\e202f\^l", /*fl*/
573: "\e202f\^f", /*ff*/
574: "\e203f\^f\^i", /*ffi*/
575: "\e203f\^f\^l", /*ffl*/
576: "\e000\e0", /*degree*/
577: "\e000\e0", /*dagger*/
578: "\e000\e0", /*section*/
579: "\e001'", /*foot mark*/
580: "\e001'", /*acute accent*/
581: "\e001`", /*grave accent*/
582: "\e001_", /*underrule*/
583: "\e001/", /*slash (longer)*/
584: "\e000\e0", /*half narrow space*/
585: "\e001 ", /*unpaddable space*/
586: "\e001\e241c\e202(\e241", /*alpha*/
587: "\e001\e200B\e242\e302|\e202\e342", /*beta*/
588: "\e001\e200)\e201/\e241", /*gamma*/
589: "\e001\e200o\e342<\e302", /*delta*/
590: "\e001<\eb-", /*epsilon*/
591: "\e001\e200c\e201\e301,\e241\e343<\e302", /*zeta*/
592: "\e001\e200n\e202\e302|\e242\e342", /*eta*/
593: "\e001O\eb-", /*theta*/
594: "\e001i", /*iota*/
595: "\e001k", /*kappa*/
596: "\e001\e200\e\e\e304\e241'\e301\e241'\e345\e202", /*lambda*/
597: "\e001\e200u\e242,\e202", /*mu*/
598: "\e001\e241(\e203/\e242", /*nu*/
599: "\e001\e200c\e201\e301,\e241\e343c\e241\e301`\e201\e301", /*xi*/
600: "\e001o", /*omicron*/
601: "\e001\e341-\e303\e"\e301\e"\e343", /*pi*/
602: "\e001\e200o\e242\e302|\e342\e202", /*rho*/
603: "\e001\e200o\e301\e202~\e341\e242", /*sigma*/
604: "\e001\e200t\e301\e202~\e243~\e201\e341", /*tau*/
605: "\e001v", /*upsilon*/
606: "\e001o\eb/", /*phi*/
607: "\e001x", /*chi*/
608: "\e001\e200/-\e302\e202'\e244'\e202\e342", /*psi*/
609: "\e001\e241u\e203u\e242", /*omega*/
610: "\e001\e242|\e202\e343-\e303\e202`\e242", /*Gamma*/
611: "\e001\e242/\e303-\e204-\e343\e\e\e242", /*Delta*/
612: "\e001O\eb=", /*Theta*/
613: "\e001\e242/\e204\e\e\e242", /*Lambda*/
614: "\e000\e0", /*Xi*/
615: "\e001\e242[]\e204[]\e242\e343-\e303", /*Pi*/
616: "\e001\e200>\e302-\e345-\e303", /*Sigma*/
617: "\e000\e0", /**/
618: "\e001Y", /*Upsilon*/
619: "\e001o\eb[\eb]", /*Phi*/
620: "\e001\e200[]-\e302\e202'\e244`\e202\e342", /*Psi*/
621: "\e001\e200O\e302\e241-\e202-\e241\e342", /*Omega*/
622: "\e000\e0", /*square root*/
623: "\e000\e0", /*terminal sigma*/
624: "\e000\e0", /*root en*/
625: "\e001>\eb_", /*>=*/
626: "\e001<\eb_", /*<=*/
627: "\e001=\eb_", /*identically equal*/
628: "\e001-", /*equation minus*/
629: "\e001=\eb~", /*approx =*/
630: "\e000\e0", /*approximates*/
631: "\e001=\eb/", /*not equal*/
632: "\e002->", /*right arrow*/
633: "\e002<-", /*left arrow*/
634: "\e001|\eb^", /*up arrow*/
635: "\e000\e0", /*down arrow*/
636: "\e001=", /*equation equal*/
637: "\e001x", /*multiply*/
638: "\e001/", /*divide*/
639: "\e001+\eb_", /*plus-minus*/
640: "\e001U", /*cup (union)*/
641: "\e000\e0", /*cap (intersection)*/
642: "\e000\e0", /*subset of*/
643: "\e000\e0", /*superset of*/
644: "\e000\e0", /*improper subset*/
645: "\e000\e0", /* improper superset*/
646: "\e002oo", /*infinity*/
647: "\e001\e200o\e201\e301`\e241\e341`\e241\e341`\e201\e301", /*partial derivative*/
648: "\e001\e242\e\e\e343-\e204-\e303/\e242", /*gradient*/
649: "\e001\e200-\e202\e341,\e301\e242", /*not*/
650: "\e001\e200|'\e202`\e243\e306'\e241`\e202\e346", /*integral sign*/
651: "\e000\e0", /*proportional to*/
652: "\e000\e0", /*empty set*/
653: "\e000\e0", /*member of*/
654: "\e001+", /*equation plus*/
655: "\e001r\ebO", /*registered*/
656: "\e001c\ebO", /*copyright*/
657: "\e001|", /*box rule */
658: "\e001c\eb/", /*cent sign*/
659: "\e000\e0", /*dbl dagger*/
660: "\e000\e0", /*right hand*/
661: "\e001*", /*left hand*/
662: "\e001*", /*math * */
663: "\e000\e0", /*bell system sign*/
664: "\e001|", /*or (was star)*/
665: "\e001O", /*circle*/
666: "\e001|", /*left top (of big curly)*/
667: "\e001|", /*left bottom*/
668: "\e001|", /*right top*/
669: "\e001|", /*right bot*/
670: "\e001|", /*left center of big curly bracket*/
671: "\e001|", /*right center of big curly bracket*/
672: "\e001|", /*bold vertical*/
673: "\e001|", /*left floor (left bot of big sq bract)*/
674: "\e001|", /*right floor (rb of ")*/
675: "\e001|", /*left ceiling (lt of ")*/
676: "\e001|"}; /*right ceiling (rt of ")*/
677: .)l
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.