10 /* output troff code; newlines may appear only at the end of s */
11 static void out_out(char *s
, va_list ap
)
13 out_nl
= strchr(s
, '\n') != NULL
;
14 vfprintf(stdout
, s
, ap
);
17 /* output troff code; no preceding newline is necessary */
18 static void outnn(char *s
, ...)
26 /* output troff cmd; should appear after a newline */
27 void out(char *s
, ...)
41 static void out_ps(int n
)
49 static void out_ft(int n
)
51 if (n
>= 0 && o_f
!= n
) {
57 static void out_clr(int n
)
59 if (n
>= 0 && o_m
!= n
) {
61 out("m%s\n", clr_str(o_m
));
65 static int tok_num(char **s
, int scale
)
71 while (**s
&& !isspace(**s
))
74 return eval(tok
, scale
);
77 static void out_draw(char *s
)
83 outnn(" %d", tok_num(&s
, 'm'));
84 outnn(" %d", tok_num(&s
, 'v'));
85 outnn(" ."); /* dpost requires this */
88 outnn(" %d", tok_num(&s
, 'm'));
91 outnn(" %d", tok_num(&s
, 'm'));
92 outnn(" %d", tok_num(&s
, 'v'));
95 outnn(" %d", tok_num(&s
, 'm'));
96 outnn(" %d", tok_num(&s
, 'v'));
97 outnn(" %d", tok_num(&s
, 'm'));
98 outnn(" %d", tok_num(&s
, 'v'));
102 outnn(" %d", tok_num(&s
, 'm'));
103 outnn(" %d", tok_num(&s
, 'v'));
105 outnn(" %d", tok_num(&s
, 'm'));
106 outnn(" %d", tok_num(&s
, 'v'));
113 static void outg(char *c
)
115 if (utf8len((unsigned char) c
[0]) == strlen(c
))
116 outnn("c%s%s", c
, c
[1] ? "\n" : "");
118 out("C%s\n", c
[0] == c_ec
&& c
[1] == '(' ? c
+ 2 : c
);
121 static void outc(char *c
)
123 struct glyph
*g
= dev_glyph(c
, o_f
);
124 int cwid
= charwid(o_f
, o_s
, g
? g
->wid
: SC_DW
);
125 int bwid
= charwid_base(o_f
, o_s
, g
? g
->wid
: SC_DW
);
127 outnn("h%d", (cwid
- bwid
) / 2);
129 if (dev_getbd(o_f
)) {
130 outnn("h%d", dev_getbd(o_f
) - 1);
132 outnn("h%d", -dev_getbd(o_f
) + 1);
135 outnn("h%d", -(cwid
- bwid
) / 2);
139 void out_line(char *s
)
141 char c
[ILNLEN
+ GNLEN
* 4];
143 while ((t
= escread(&s
, c
)) >= 0) {
145 if (c
[0] == c_ni
|| (c
[0] == '\\' && c
[1] == '\\')) {
149 if (c
[0] == '\t' || c
[0] == '\x01' || !strcmp(c_hc
, c
))
162 outnn("h%d", eval(c
, 'm'));
169 out_ps(eval_re(c
, o_s
, '\0'));
172 outnn("v%d", eval(c
, 'v'));