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
, int fn
)
118 outnn("c%s%s", c
, c
[1] ? "\n" : "");
120 out("C%s\n", c
[0] == c_ec
&& c
[1] == '(' ? c
+ 2 : c
);
124 static void outc(char *c
)
126 struct glyph
*g
= dev_glyph(c
, o_f
);
127 int cwid
= charwid(o_f
, o_s
, g
? g
->wid
: SC_DW
);
128 int bwid
= charwid_base(o_f
, o_s
, g
? g
->wid
: SC_DW
);
130 outnn("h%d", (cwid
- bwid
) / 2);
131 outg(c
, g
? dev_fontpos(g
->font
) : o_f
);
132 if (dev_getbd(o_f
)) {
133 outnn("h%d", dev_getbd(o_f
) - 1);
134 outg(c
, g
? dev_fontpos(g
->font
) : o_f
);
135 outnn("h%d", -dev_getbd(o_f
) + 1);
138 outnn("h%d", -(cwid
- bwid
) / 2);
142 void out_line(char *s
)
144 char c
[ILNLEN
+ GNLEN
* 4];
146 while ((t
= escread(&s
, c
)) >= 0) {
148 if (c
[0] == c_ni
|| (c
[0] == '\\' && c
[1] == '\\')) {
152 if (c
[0] == '\t' || c
[0] == '\x01' || !strcmp(c_hc
, c
))
165 outnn("h%d", eval(c
, 'm'));
172 out_ps(eval_re(c
, o_s
, '\0'));
175 outnn("v%d", eval(c
, 'v'));