diff options
author | Petter Rodhelind <petter.rodhelind@gmail.com> | 2020-12-18 09:13:34 +0100 |
---|---|---|
committer | Petter Rodhelind <petter.rodhelind@gmail.com> | 2020-12-18 09:13:34 +0100 |
commit | 94c521bf102a74aec7e1a5c3a9ef5eaa968d4e14 (patch) | |
tree | ad1ad80ee9a4e0ae97451c94a7cf455d3068951b /src/cmd | |
parent | 7cda34cf34f3afbd3f2000aa5e2b59ddc319f0f2 (diff) | |
parent | 2991442aef1cf020ffde43673433ee97ef322a53 (diff) | |
download | plan9port-94c521bf102a74aec7e1a5c3a9ef5eaa968d4e14.tar.gz plan9port-94c521bf102a74aec7e1a5c3a9ef5eaa968d4e14.tar.bz2 plan9port-94c521bf102a74aec7e1a5c3a9ef5eaa968d4e14.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/cmd')
-rw-r--r-- | src/cmd/acme/xfid.c | 18 | ||||
-rw-r--r-- | src/cmd/devdraw/srv.c | 8 | ||||
-rwxr-xr-x | src/cmd/dformat | 108 | ||||
-rw-r--r-- | src/cmd/fontsrv/mac.c | 22 | ||||
-rw-r--r-- | src/cmd/sam/sam.h | 3 | ||||
-rw-r--r-- | src/cmd/time.c | 6 | ||||
-rw-r--r-- | src/cmd/touch.c | 2 |
7 files changed, 48 insertions, 119 deletions
diff --git a/src/cmd/acme/xfid.c b/src/cmd/acme/xfid.c index 9c7be2c0..e7d9f4cb 100644 --- a/src/cmd/acme/xfid.c +++ b/src/cmd/acme/xfid.c @@ -701,6 +701,24 @@ out: winsetname(w, r, nr); m += (q+1) - pp; }else + if(strncmp(p, "font ", 5) == 0){ /* execute font command */ + pp = p+5; + m = 5; + q = memchr(pp, '\n', e-pp); + if(q==nil || q==pp){ + err = Ebadctl; + break; + } + *q = 0; + nulls = FALSE; + cvttorunes(pp, q-pp, r, &nb, &nr, &nulls); + if(nulls){ + err = "nulls in font string"; + break; + } + fontx(&w->body, nil, nil, FALSE, XXX, r, nr); + m += (q+1) - pp; + }else if(strncmp(p, "dump ", 5) == 0){ /* set dump string */ pp = p+5; m = 5; diff --git a/src/cmd/devdraw/srv.c b/src/cmd/devdraw/srv.c index 05a08fda..479e41e0 100644 --- a/src/cmd/devdraw/srv.c +++ b/src/cmd/devdraw/srv.c @@ -88,7 +88,7 @@ threadmain(int argc, char **argv) void gfx_started(void) { - char *addr; + char *ns, *addr; if(srvname == nil) { // Legacy mode: serving single client on pipes. @@ -97,7 +97,11 @@ gfx_started(void) } // Server mode. - addr = smprint("unix!%s/%s", getns(), srvname); + if((ns = getns()) == nil) + sysfatal("out of memory"); + + addr = smprint("unix!%s/%s", ns, srvname); + free(ns); if(addr == nil) sysfatal("out of memory"); diff --git a/src/cmd/dformat b/src/cmd/dformat deleted file mode 100755 index f14b5841..00000000 --- a/src/cmd/dformat +++ /dev/null @@ -1,108 +0,0 @@ -awk ' -function error(s) { print "dformat error: " s " near input line " NR | "cat 1>&2" } - -BEGIN { s = "recht 0.3 addrht 0.055 recspread 0.15 " - s = s "charwid 0.07 textht 0.167 addrdelta 4 " - s = s "bitwid 0.125 linedisp 0.04 addr both " - s = s "fill off linethrutext 1" - n = split(s, x) - for (i = 1; i <= n-1; i += 2) oparm[x[i]] = parm[x[i]] = x[i+1] -} - -inlang == 0 { if ($0 !~ /^\.begin[ \t]/ || $2 != "dformat") print - else { - inlang = 1; print ".PS"; boxacnt = 0 - if (firstpic != 1) { firstpic = 1; print "fillval = 0.9" } - } - next - } -/^\.end/ { inlang = 0; print ".PE"; next } - -$1 == "style" { if (!($2 in parm)) error("unrecognized name: " $2) - else if ($3 == "reset") { - t = oparm[$2]; oparm[$2] = parm[$2]; parm[$2] = t - } else { - oparm[$2] = parm[$2]; parm[$2] = $3 - } - next - } - -$1 == "pic" { $1 = ""; print $0; next } - -/^[^ \t]/ { printf "BoxA: box invis ht %g wid 0", parm["recht"] - if (boxacnt++) printf " with .n at BoxA.s - (0,%g)", - parm["recspread"] + maxdy*parm["textht"] - printf "\n" - maxdy = sumboxlen = 0 - gsub(/[ \t]+$/, "") - if ($0 != "noname") { - printf " \"%s \" rjust at BoxA.w\n", $0 - printf " box invis with .e at BoxA.w ht 0 wid %g\n", - parm["charwid"] * (length($0) + 3) - } - printf " BoxB: box invis ht %g wid 0 at BoxA\n", parm["recht"] - next - } -/./ { boxname = "" - if ($1 ~ /:$/) { - boxname = substr($1, 1, length($1)-1) - $1 = ""; $0 = " " $0 - } - range = $1; $1 = "" - gsub(/^[ \t]+/, ""); gsub(/[ \t]+$/, ""); text = $0 - n = split(range, x, "-") - rlo = x[1] - rhi = (n >= 2) ? x[2] : rlo - cwid = (rhi >= rlo) ? rhi - rlo + 1 : rlo - rhi + 1 - rwid = (n >= 3) ? (0 + x[3]) : cwid - btype = x[4] - if (btype !~ /^(dot|dash|invis)/) btype = "solid" - textlen = parm["charwid"] * length(text) - boxlen = parm["bitwid"] * rwid - dy = 0 - if (textlen > boxlen) { # set dy, the channel for this text - chan[maxdy+1] = -999 - for (dy = 1; chan[dy]+textlen > sumboxlen; dy++) ; - if (dy > maxdy) maxdy = dy - if (parm["linethrutext"] == 0) - for (k = 1; k <= dy; k++) - chan[k] = sumboxlen+boxlen - else - chan[dy] = sumboxlen - } - sumboxlen += boxlen - fill = "" - if (parm["fill"] == "on") fill = " fill " - if (boxname != "") printf " %s:", boxname - printf " BoxB: box %s %s ht %g wid %g with .w at BoxB.e\n", - fill, btype, parm["recht"], boxlen - if (dy == 0) printf " \"%s\" at BoxB.c\n", text - else { if (rwid < 2) start = "BoxB.s" - else start = "BoxB.se - (" parm["linedisp"] ",0)" - printf " line from %s down %g\n", - start, dy*parm["textht"] - printf " \"%s\\|\" at last line .s rjust\n", text - printf " box invis with .e at last line .s ht 0 wid %g\n", - textlen - } - - if (parm["addr"] ~ /^(left|right|both)$/) { - dp = int(parm["addrdelta"]) # Delta Point size - if (dp < 0 || dp > 9) error("bad addrdelta value: " dp) - dah = parm["addrht"] # Delta Addr Height - pb = parm["addr"] # Parameter for Bits - if (rlo == rhi) { - printf " \"\\s-%d%s\\s+%d\" at BoxB.s + (0,%g)\n", - dp, rlo, dp, dah - } else { - if (pb == "left" || pb == "both") - printf "\t\"\\|\\s-%d%s\\s+%d\" ljust at BoxB.sw + (0,%g)\n", - dp, rlo, dp, dah - if (pb == "right" || pb == "both") - printf "\t\"\\s-%d%s\\s+%d\\|\" rjust at BoxB.se + (0,%g)\n", - dp, rhi, dp, dah - } - } - } -END { if (inlang) error("eof inside begin/end") } -' $* diff --git a/src/cmd/fontsrv/mac.c b/src/cmd/fontsrv/mac.c index 9829b5a8..c5a2e0f1 100644 --- a/src/cmd/fontsrv/mac.c +++ b/src/cmd/fontsrv/mac.c @@ -76,6 +76,17 @@ mac2r(CGRect r, int size, int unit) } void +meminvert(Memimage *m) +{ + uchar *p, *ep; + + p = byteaddr(m, m->r.min); + ep = p + 4*m->width*Dy(m->r); + for(; p < ep; p++) + *p ^= 0xff; +} + +void loadfonts(void) { int i, n; @@ -223,8 +234,8 @@ mksubfont(XFont *f, char *name, int lo, int hi, int size, int antialias) int i, height, ascent; Fontchar *fc, *fc0; Memsubfont *sf; - CGFloat whitef[] = { 1.0, 1.0 }; - CGColorRef white; + CGFloat blackf[] = { 0.0, 1.0 }; + CGColorRef black; s = c2mac(name); desc = CTFontDescriptorCreateWithNameAndSize(s, size); @@ -267,7 +278,7 @@ mksubfont(XFont *f, char *name, int lo, int hi, int size, int antialias) color = CGColorSpaceCreateWithName(kCGColorSpaceGenericGray); ctxt = CGBitmapContextCreate(byteaddr(mc, mc->r.min), Dx(mc->r), Dy(mc->r), 8, mc->width*sizeof(u32int), color, kCGImageAlphaNone); - white = CGColorCreate(color, whitef); + black = CGColorCreate(color, blackf); CGColorSpaceRelease(color); if(ctxt == nil) { freememimage(m); @@ -293,7 +304,7 @@ mksubfont(XFont *f, char *name, int lo, int hi, int size, int antialias) CGRect r; CGPoint p1; CFStringRef keys[] = { kCTFontAttributeName, kCTForegroundColorAttributeName }; - CFTypeRef values[] = { font, white }; + CFTypeRef values[] = { font, black }; sprint(buf, "%C", (Rune)mapUnicode(name, i)); str = c2mac(buf); @@ -310,7 +321,7 @@ mksubfont(XFont *f, char *name, int lo, int hi, int size, int antialias) line = CTLineCreateWithAttributedString(attrString); CGContextSetTextPosition(ctxt, 0, y0); r = CTLineGetImageBounds(line, ctxt); - memfillcolor(mc, DBlack); + memfillcolor(mc, DWhite); CTLineDraw(line, ctxt); CFRelease(line); @@ -330,6 +341,7 @@ mksubfont(XFont *f, char *name, int lo, int hi, int size, int antialias) continue; } + meminvert(mc); memimagedraw(m, Rect(x, 0, x + p1.x, y), mc, ZP, memopaque, ZP, S); fc->width = p1.x; fc->left = 0; diff --git a/src/cmd/sam/sam.h b/src/cmd/sam/sam.h index c11163ef..aae39b4a 100644 --- a/src/cmd/sam/sam.h +++ b/src/cmd/sam/sam.h @@ -9,6 +9,9 @@ #undef warn #define warn samwarn +#undef class +#define class samclass + /* * BLOCKSIZE is relatively small to keep memory consumption down. */ diff --git a/src/cmd/time.c b/src/cmd/time.c index 3b52216b..16379a89 100644 --- a/src/cmd/time.c +++ b/src/cmd/time.c @@ -47,11 +47,11 @@ main(int argc, char *argv[]) error("wait"); } l = w->time[0]; - add("%ld.%.2ldu", l/1000, (l%1000)/10); + add("%ld.%.3ldu", l/1000, l%1000); l = w->time[1]; - add("%ld.%.2lds", l/1000, (l%1000)/10); + add("%ld.%.3lds", l/1000, l%1000); l = (t1-t0)/1000000; - add("%ld.%.2ldr", l/1000, (l%1000)/10); + add("%ld.%.3ldr", l/1000, l%1000); add("\t"); for(i=1; i<argc; i++){ add("%s", argv[i], 0); diff --git a/src/cmd/touch.c b/src/cmd/touch.c index 471e2b17..26141815 100644 --- a/src/cmd/touch.c +++ b/src/cmd/touch.c @@ -54,7 +54,7 @@ touch(int nocreate, char *name) fprint(2, "touch: %s: cannot wstat: %r\n", name); return 1; } - if((fd = create(name, OREAD, 0666)) < 0) { + if((fd = create(name, OWRITE, 0666)) < 0) { fprint(2, "touch: %s: cannot create: %r\n", name); return 1; } |