6 static int cwid(char *c
)
8 struct glyph
*g
= dev_glyph(c
, n_f
);
9 return charwid(n_f
, n_s
, g
? g
->wid
: SC_DW
);
12 static int hchar(char *c
)
15 return c
[1] == '_' || c
[1] == '-';
18 return (c
[0] == 'r' && c
[1] == 'u') || (c
[0] == 'u' && c
[1] == 'l') ||
19 (c
[0] == 'r' && c
[1] == 'n');
22 static int vchar(char *c
)
26 return (c
[0] == 'b' && c
[1] == 'v') || (c
[0] == 'b' && c
[1] == 'r');
29 void ren_hline(struct wb
*wb
, int l
, char *c
)
33 /* negative length; moving backwards */
40 /* length less than character width */
44 wb_hmov(wb
, -(w
- l
) / 2);
55 for (i
= 0; i
< n
; i
++)
59 wb_hmov(wb
, -(w
- l
+ 1) / 2);
62 static void ren_vline(struct wb
*wb
, int l
, char *c
)
64 int w
, n
, i
, rem
, hw
, neg
;
66 w
= SC_HT
; /* character height */
67 hw
= cwid(c
); /* character width */
68 /* negative length; moving backwards */
75 /* length less than character width */
79 wb_vmov(wb
, -w
+ l
/ 2);
92 for (i
= 0; i
< n
; i
++) {
105 void ren_hlcmd(struct wb
*wb
, char *arg
)
108 int l
= eval_up(&arg
, 'm');
109 if (arg
[0] == c_ec
&& arg
[1] == '&') /* \& can be used as a separator */
111 if (!*arg
|| charread(&arg
, lc
) < 0)
114 ren_hline(wb
, l
, lc
);
117 void ren_vlcmd(struct wb
*wb
, char *arg
)
120 int l
= eval_up(&arg
, 'v');
121 if (arg
[0] == c_ec
&& arg
[1] == '&') /* \& can be used as a separator */
123 if (!*arg
|| charread(&arg
, lc
) < 0)
126 ren_vline(wb
, l
, lc
);
129 static int tok_num(char **s
, int scale
)
135 while (**s
&& !isspace(**s
))
138 return eval(tok
, scale
);
141 void ren_dcmd(struct wb
*wb
, char *s
)
145 switch (tolower(c
)) {
147 h1
= tok_num(&s
, 'm');
148 v1
= tok_num(&s
, 'v');
149 wb_drawl(wb
, c
, h1
, v1
);
152 h1
= tok_num(&s
, 'm');
156 h1
= tok_num(&s
, 'm');
157 v1
= tok_num(&s
, 'v');
158 wb_drawe(wb
, c
, h1
, v1
);
161 h1
= tok_num(&s
, 'm');
162 v1
= tok_num(&s
, 'v');
163 h2
= tok_num(&s
, 'm');
164 v2
= tok_num(&s
, 'v');
165 wb_drawa(wb
, c
, h1
, v1
, h2
, v2
);
171 h1
= tok_num(&s
, 'm');
172 v1
= tok_num(&s
, 'v');
173 wb_drawxdot(wb
, h1
, v1
);
180 void ren_bcmd(struct wb
*wb
, char *arg
)
185 sstr_push(arg
); /* using ren_char()'s interface */
190 ren_char(&wb2
, sstr_next
, sstr_back
);
191 if (wb_wid(&wb2
) > w
)
193 wb_hmov(&wb2
, -wb_wid(&wb2
));
194 wb_vmov(&wb2
, SC_HT
);
199 center
= -(n
* SC_HT
+ SC_EM
) / 2;
200 wb_vmov(wb
, center
+ SC_HT
);
207 void ren_ocmd(struct wb
*wb
, char *arg
)
212 sstr_push(arg
); /* using ren_char()'s interface */
218 ren_char(&wb3
, sstr_next
, sstr_back
);
222 wb_hmov(&wb2
, -wc
/ 2);
224 wb_hmov(&wb2
, -wc
/ 2);