ref: cf5d7677e060b048d908ceb0600157e902f32220
parent: 444dd6894e6631344f65f3df51e89b154f5273e7
author: Ali Gholami Rudi <ali@rudi.ir>
date: Thu Aug 22 15:23:23 EDT 2013
wb: add p, C, E and P \D drawing commands The filling variants use current color (.m) for filling.
--- a/draw.c
+++ b/draw.c
@@ -142,20 +142,20 @@
{
int h1, h2, v1, v2;
int c = *s++;
- switch (c) {
+ switch (tolower(c)) {
case 'l':
h1 = tok_num(&s, 'm');
v1 = tok_num(&s, 'v');
- wb_drawl(wb, h1, v1);
+ wb_drawl(wb, c, h1, v1);
break;
case 'c':
h1 = tok_num(&s, 'm');
- wb_drawc(wb, h1);
+ wb_drawc(wb, c, h1);
break;
case 'e':
h1 = tok_num(&s, 'm');
v1 = tok_num(&s, 'v');
- wb_drawe(wb, h1, v1);
+ wb_drawe(wb, c, h1, v1);
break;
case 'a':
h1 = tok_num(&s, 'm');
@@ -162,9 +162,10 @@
v1 = tok_num(&s, 'v');
h2 = tok_num(&s, 'm');
v2 = tok_num(&s, 'v');
- wb_drawa(wb, h1, v1, h2, v2);
+ wb_drawa(wb, c, h1, v1, h2, v2);
break;
- default:
+ case '~':
+ case 'p':
wb_drawxbeg(wb, c);
while (*s) {
h1 = tok_num(&s, 'm');
@@ -172,6 +173,7 @@
wb_drawxdot(wb, h1, v1);
}
wb_drawxend(wb);
+ break;
}
}
--- a/out.c
+++ b/out.c
@@ -78,7 +78,7 @@
{
int c = *s++;
out("D%c", c);
- switch (c) {
+ switch (tolower(c)) {
case 'l':
outnn(" %d", tok_num(&s, 'm'));
outnn(" %d", tok_num(&s, 'v'));
@@ -97,7 +97,8 @@
outnn(" %d", tok_num(&s, 'm'));
outnn(" %d", tok_num(&s, 'v'));
break;
- default:
+ case '~':
+ case 'p':
outnn(" %d", tok_num(&s, 'm'));
outnn(" %d", tok_num(&s, 'v'));
while (*s) {
--- a/roff.h
+++ b/roff.h
@@ -221,10 +221,10 @@
void wb_put(struct wb *wb, char *c);
int wb_part(struct wb *wb);
void wb_setpart(struct wb *wb);
-void wb_drawl(struct wb *wb, int h, int v);
-void wb_drawc(struct wb *wb, int r);
-void wb_drawe(struct wb *wb, int h, int v);
-void wb_drawa(struct wb *wb, int h1, int v1, int h2, int v2);
+void wb_drawl(struct wb *wb, int c, int h, int v);
+void wb_drawc(struct wb *wb, int c, int r);
+void wb_drawe(struct wb *wb, int c, int h, int v);
+void wb_drawa(struct wb *wb, int c, int h1, int v1, int h2, int v2);
void wb_drawxbeg(struct wb *wb, int c);
void wb_drawxdot(struct wb *wb, int h, int v);
void wb_drawxend(struct wb *wb);
--- a/wb.c
+++ b/wb.c
@@ -210,33 +210,33 @@
wb->part = 1;
}
-void wb_drawl(struct wb *wb, int h, int v)
+void wb_drawl(struct wb *wb, int c, int h, int v)
{
wb_font(wb);
- sbuf_printf(&wb->sbuf, "%cD'l %du %du'", c_ec, h, v);
+ sbuf_printf(&wb->sbuf, "%cD'%c %du %du'", c_ec, c, h, v);
wb->h += h;
wb->v += v;
wb_stsb(wb);
}
-void wb_drawc(struct wb *wb, int r)
+void wb_drawc(struct wb *wb, int c, int r)
{
wb_font(wb);
- sbuf_printf(&wb->sbuf, "%cD'c %du'", c_ec, r);
+ sbuf_printf(&wb->sbuf, "%cD'%c %du'", c_ec, c, r);
wb->h += r;
}
-void wb_drawe(struct wb *wb, int h, int v)
+void wb_drawe(struct wb *wb, int c, int h, int v)
{
wb_font(wb);
- sbuf_printf(&wb->sbuf, "%cD'e %du %du'", c_ec, h, v);
+ sbuf_printf(&wb->sbuf, "%cD'%c %du %du'", c_ec, c, h, v);
wb->h += h;
}
-void wb_drawa(struct wb *wb, int h1, int v1, int h2, int v2)
+void wb_drawa(struct wb *wb, int c, int h1, int v1, int h2, int v2)
{
wb_font(wb);
- sbuf_printf(&wb->sbuf, "%cD'a %du %du %du %du'", c_ec, h1, v1, h2, v2);
+ sbuf_printf(&wb->sbuf, "%cD'%c %du %du %du %du'", c_ec, c, h1, v1, h2, v2);
wb->h += h1 + h2;
wb->v += v1 + v2;
wb_stsb(wb);