Image *cols[Ncolor][3];
Graph *graph;
Machine mach[NMACH];
-Font *mediumfont;
int pids[NPROC];
int npid;
int parity; /* toggled to avoid patterns in textured background */
void
colinit(void)
{
- mediumfont = openfont(display, "/lib/font/bit/pelm/latin1.8.font");
- if(mediumfont == nil)
- mediumfont = font;
-
/* Peach */
mkcol(0, 0xFFAAAAFF, 0xFFAAAAFF, 0xBB5D5DFF);
/* Aqua */
maxw = 0;
r[1] = '\0';
for(s=text; *s; ){
- if(p.y+mediumfont->height-Ysqueeze > maxy)
+ if(p.y+font->height-Ysqueeze > maxy)
break;
w = chartorune(r, s);
s += w;
- w = runestringwidth(mediumfont, r);
+ w = runestringwidth(font, r);
if(w > maxw)
maxw = w;
- runestring(screen, p, display->black, ZP, mediumfont, r);
- p.y += mediumfont->height-Ysqueeze;
+ runestring(screen, p, display->black, ZP, font, r);
+ p.y += font->height-Ysqueeze;
}
}
x = p.x + Labspace;
y = p.y + (dy*(vmax-v))/vmax;
draw(screen, Rect(p.x, y-1, p.x+Labspace, y+1), display->black, nil, ZP);
- if(dy > 5*mediumfont->height)
- string(screen, Pt(x, y-mediumfont->height/2),
- display->black, ZP, mediumfont, label);
+ if(dy > 5*font->height)
+ string(screen, Pt(x, y-font->height/2),
+ display->black, ZP, font, label);
}
void
/* draw message */
if(strlen(msg) > g->overtmplen)
msg[g->overtmplen] = 0;
- string(screen, g->overtmp->r.min, display->black, ZP, mediumfont, msg);
+ string(screen, g->overtmp->r.min, display->black, ZP, font, msg);
}
void
/* label left edge */
x = screen->r.min.x;
- y = screen->r.min.y + Labspace+mediumfont->height+Labspace;
+ y = screen->r.min.y + Labspace+font->height+Labspace;
dy = (screen->r.max.y - y)/ngraph;
- dx = Labspace+stringwidth(mediumfont, "0")+Labspace;
+ dx = Labspace+stringwidth(font, "0")+Labspace;
startx = x+dx+1;
starty = y;
for(i=0; i<ngraph; i++,y+=dy){
}
/* label right edge */
- dx = Labspace+stringwidth(mediumfont, "0.001")+Labspace;
+ dx = Labspace+stringwidth(font, "0.001")+Labspace;
hashdx = dx;
x = screen->r.max.x - dx;
- y = screen->r.min.y + Labspace+mediumfont->height+Labspace;
+ y = screen->r.min.y + Labspace+font->height+Labspace;
for(i=0; i<ngraph; i++,y+=dy){
draw(screen, Rect(x, y-1, screen->r.max.x, y), display->black, nil, ZP);
draw(screen, Rect(x, y, x+dx, screen->r.max.y), cols[graph[i].colindex][0], nil, paritypt(x));
dx = (screen->r.max.x - dx - startx)/nmach;
for(x=startx, i=0; i<nmach; i++,x+=dx){
draw(screen, Rect(x-1, starty-1, x, screen->r.max.y), display->black, nil, ZP);
- j = dx/stringwidth(mediumfont, "0");
+ j = dx/stringwidth(font, "0");
n = mach[i].nproc;
if(n>1 && j>=1+3+(n>10)+(n>100)){ /* first char of name + (n) */
j -= 3+(n>10)+(n>100);
}else
snprint(buf, sizeof buf, "%.*s", j, mach[i].name);
string(screen, Pt(x+Labspace, screen->r.min.y + Labspace), display->black, ZP,
- mediumfont, buf);
+ font, buf);
}
/* draw last vertical line */
draw(screen,
g->overtmp = nil;
g->overtmplen = 0;
r = g->r;
- r.max.y = r.min.y+mediumfont->height;
- n = (g->r.max.x - r.min.x)/stringwidth(mediumfont, "9");
+ r.max.y = r.min.y+font->height;
+ n = (g->r.max.x - r.min.x)/stringwidth(font, "9");
if(n > 4){
if(n > Gmsglen)
n = Gmsglen;
- r.max.x = r.min.x+stringwidth(mediumfont, "9")*n;
+ r.max.x = r.min.x+stringwidth(font, "9")*n;
g->overtmplen = n;
g->overtmp = allocimage(display, r, screen->chan, 0, -1);
}