ip/gping: honor $font instead of hardcoding
This commit is contained in:
parent
7f76e8dbf7
commit
fa4dd2f2fe
1 changed files with 17 additions and 22 deletions
|
@ -115,7 +115,6 @@ void (*newvaluefn[Nmenu2])(Machine*, long*, long*, long*) = {
|
||||||
Image *cols[Ncolor][3];
|
Image *cols[Ncolor][3];
|
||||||
Graph *graph;
|
Graph *graph;
|
||||||
Machine mach[NMACH];
|
Machine mach[NMACH];
|
||||||
Font *mediumfont;
|
|
||||||
int pids[NPROC];
|
int pids[NPROC];
|
||||||
int npid;
|
int npid;
|
||||||
int parity; /* toggled to avoid patterns in textured background */
|
int parity; /* toggled to avoid patterns in textured background */
|
||||||
|
@ -190,10 +189,6 @@ mkcol(int i, int c0, int c1, int c2)
|
||||||
void
|
void
|
||||||
colinit(void)
|
colinit(void)
|
||||||
{
|
{
|
||||||
mediumfont = openfont(display, "/lib/font/bit/pelm/latin1.8.font");
|
|
||||||
if(mediumfont == nil)
|
|
||||||
mediumfont = font;
|
|
||||||
|
|
||||||
/* Peach */
|
/* Peach */
|
||||||
mkcol(0, 0xFFAAAAFF, 0xFFAAAAFF, 0xBB5D5DFF);
|
mkcol(0, 0xFFAAAAFF, 0xFFAAAAFF, 0xBB5D5DFF);
|
||||||
/* Aqua */
|
/* Aqua */
|
||||||
|
@ -242,15 +237,15 @@ label(Point p, int dy, char *text)
|
||||||
maxw = 0;
|
maxw = 0;
|
||||||
r[1] = '\0';
|
r[1] = '\0';
|
||||||
for(s=text; *s; ){
|
for(s=text; *s; ){
|
||||||
if(p.y+mediumfont->height-Ysqueeze > maxy)
|
if(p.y+font->height-Ysqueeze > maxy)
|
||||||
break;
|
break;
|
||||||
w = chartorune(r, s);
|
w = chartorune(r, s);
|
||||||
s += w;
|
s += w;
|
||||||
w = runestringwidth(mediumfont, r);
|
w = runestringwidth(font, r);
|
||||||
if(w > maxw)
|
if(w > maxw)
|
||||||
maxw = w;
|
maxw = w;
|
||||||
runestring(screen, p, display->black, ZP, mediumfont, r);
|
runestring(screen, p, display->black, ZP, font, r);
|
||||||
p.y += mediumfont->height-Ysqueeze;
|
p.y += font->height-Ysqueeze;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,9 +258,9 @@ hashmark(Point p, int dy, long v, long vmax, char *label)
|
||||||
x = p.x + Labspace;
|
x = p.x + Labspace;
|
||||||
y = p.y + (dy*(vmax-v))/vmax;
|
y = p.y + (dy*(vmax-v))/vmax;
|
||||||
draw(screen, Rect(p.x, y-1, p.x+Labspace, y+1), display->black, nil, ZP);
|
draw(screen, Rect(p.x, y-1, p.x+Labspace, y+1), display->black, nil, ZP);
|
||||||
if(dy > 5*mediumfont->height)
|
if(dy > 5*font->height)
|
||||||
string(screen, Pt(x, y-mediumfont->height/2),
|
string(screen, Pt(x, y-font->height/2),
|
||||||
display->black, ZP, mediumfont, label);
|
display->black, ZP, font, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -368,7 +363,7 @@ drawmsg(Graph *g, char *msg)
|
||||||
/* draw message */
|
/* draw message */
|
||||||
if(strlen(msg) > g->overtmplen)
|
if(strlen(msg) > g->overtmplen)
|
||||||
msg[g->overtmplen] = 0;
|
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
|
void
|
||||||
|
@ -773,9 +768,9 @@ resize(void)
|
||||||
|
|
||||||
/* label left edge */
|
/* label left edge */
|
||||||
x = screen->r.min.x;
|
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;
|
dy = (screen->r.max.y - y)/ngraph;
|
||||||
dx = Labspace+stringwidth(mediumfont, "0")+Labspace;
|
dx = Labspace+stringwidth(font, "0")+Labspace;
|
||||||
startx = x+dx+1;
|
startx = x+dx+1;
|
||||||
starty = y;
|
starty = y;
|
||||||
for(i=0; i<ngraph; i++,y+=dy){
|
for(i=0; i<ngraph; i++,y+=dy){
|
||||||
|
@ -786,10 +781,10 @@ resize(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* label right edge */
|
/* label right edge */
|
||||||
dx = Labspace+stringwidth(mediumfont, "0.001")+Labspace;
|
dx = Labspace+stringwidth(font, "0.001")+Labspace;
|
||||||
hashdx = dx;
|
hashdx = dx;
|
||||||
x = screen->r.max.x - 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){
|
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-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));
|
draw(screen, Rect(x, y, x+dx, screen->r.max.y), cols[graph[i].colindex][0], nil, paritypt(x));
|
||||||
|
@ -801,7 +796,7 @@ resize(void)
|
||||||
dx = (screen->r.max.x - dx - startx)/nmach;
|
dx = (screen->r.max.x - dx - startx)/nmach;
|
||||||
for(x=startx, i=0; i<nmach; i++,x+=dx){
|
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);
|
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;
|
n = mach[i].nproc;
|
||||||
if(n>1 && j>=1+3+(n>10)+(n>100)){ /* first char of name + (n) */
|
if(n>1 && j>=1+3+(n>10)+(n>100)){ /* first char of name + (n) */
|
||||||
j -= 3+(n>10)+(n>100);
|
j -= 3+(n>10)+(n>100);
|
||||||
|
@ -811,7 +806,7 @@ resize(void)
|
||||||
}else
|
}else
|
||||||
snprint(buf, sizeof buf, "%.*s", j, mach[i].name);
|
snprint(buf, sizeof buf, "%.*s", j, mach[i].name);
|
||||||
string(screen, Pt(x+Labspace, screen->r.min.y + Labspace), display->black, ZP,
|
string(screen, Pt(x+Labspace, screen->r.min.y + Labspace), display->black, ZP,
|
||||||
mediumfont, buf);
|
font, buf);
|
||||||
}
|
}
|
||||||
/* draw last vertical line */
|
/* draw last vertical line */
|
||||||
draw(screen,
|
draw(screen,
|
||||||
|
@ -847,12 +842,12 @@ resize(void)
|
||||||
g->overtmp = nil;
|
g->overtmp = nil;
|
||||||
g->overtmplen = 0;
|
g->overtmplen = 0;
|
||||||
r = g->r;
|
r = g->r;
|
||||||
r.max.y = r.min.y+mediumfont->height;
|
r.max.y = r.min.y+font->height;
|
||||||
n = (g->r.max.x - r.min.x)/stringwidth(mediumfont, "9");
|
n = (g->r.max.x - r.min.x)/stringwidth(font, "9");
|
||||||
if(n > 4){
|
if(n > 4){
|
||||||
if(n > Gmsglen)
|
if(n > Gmsglen)
|
||||||
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->overtmplen = n;
|
||||||
g->overtmp = allocimage(display, r, screen->chan, 0, -1);
|
g->overtmp = allocimage(display, r, screen->chan, 0, -1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue