diff options
author | rsc <devnull@localhost> | 2004-04-29 17:13:24 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2004-04-29 17:13:24 +0000 |
commit | be36ff68854c86247fdc769c0eaa89eb284b5ca7 (patch) | |
tree | a523e17071eb0e3088f906446b158b3d184b77fe /src/cmd | |
parent | 3d72637f9b4c42b1fc9b7d95d278ea3dd65c748d (diff) | |
download | plan9port-be36ff68854c86247fdc769c0eaa89eb284b5ca7.tar.gz plan9port-be36ff68854c86247fdc769c0eaa89eb284b5ca7.tar.bz2 plan9port-be36ff68854c86247fdc769c0eaa89eb284b5ca7.zip |
add -W to specify window size.
various other little fixes.
Diffstat (limited to 'src/cmd')
-rw-r--r-- | src/cmd/9term/9term.c | 5 | ||||
-rw-r--r-- | src/cmd/acidtypes/type.c | 2 | ||||
-rw-r--r-- | src/cmd/acme/acme.c | 7 | ||||
-rw-r--r-- | src/cmd/auxstats/Linux.c | 15 | ||||
-rw-r--r-- | src/cmd/draw/gview.c | 5 | ||||
-rw-r--r-- | src/cmd/draw/img.c | 7 | ||||
-rw-r--r-- | src/cmd/draw/stats.c | 5 | ||||
-rw-r--r-- | src/cmd/draw/tweak.c | 16 | ||||
-rw-r--r-- | src/cmd/jpg/bmp.c | 13 | ||||
-rw-r--r-- | src/cmd/jpg/gif.c | 14 | ||||
-rw-r--r-- | src/cmd/jpg/ico.c | 5 | ||||
-rw-r--r-- | src/cmd/jpg/jpg.c | 13 | ||||
-rw-r--r-- | src/cmd/jpg/png.c | 13 | ||||
-rw-r--r-- | src/cmd/jpg/ppm.c | 13 | ||||
-rw-r--r-- | src/cmd/jpg/yuv.c | 13 | ||||
-rw-r--r-- | src/cmd/mc.c | 245 | ||||
-rw-r--r-- | src/cmd/plot/plot.c | 3 | ||||
-rw-r--r-- | src/cmd/sam/sam.c | 8 | ||||
-rw-r--r-- | src/cmd/samterm/plan9.c | 9 | ||||
-rw-r--r-- | src/cmd/vac/vtdump.c | 2 |
20 files changed, 136 insertions, 277 deletions
diff --git a/src/cmd/9term/9term.c b/src/cmd/9term/9term.c index feef6b68..3dafb385 100644 --- a/src/cmd/9term/9term.c +++ b/src/cmd/9term/9term.c @@ -186,7 +186,7 @@ Cursor whitearrow = { void usage(void) { - fprint(2, "usage: 9term [-ars] [cmd ...]\n"); + fprint(2, "usage: 9term [-ars] [-W winsize] [cmd ...]\n"); threadexitsall("usage"); } @@ -215,6 +215,9 @@ threadmain(int argc, char *argv[]) case 'w': /* started from "rio" window manager */ use9wm = 1; break; + case 'W': + winsize = EARGF(usage()); + break; }ARGEND if(font) diff --git a/src/cmd/acidtypes/type.c b/src/cmd/acidtypes/type.c index c9e8431e..5449077a 100644 --- a/src/cmd/acidtypes/type.c +++ b/src/cmd/acidtypes/type.c @@ -463,7 +463,7 @@ ttt=ttt->sub; name, nameof(tt, 0)); Bprint(b, "\tindent_%s(addr+%lud, indent+\" \");\n", nameof(tt, 1), t->val[j]); - Bprint(b, "\tprint(indent, \"\t}\\n\");\n"); + Bprint(b, "\tprint(indent, \"}\\n\");\n"); break; } } diff --git a/src/cmd/acme/acme.c b/src/cmd/acme/acme.c index 7c563380..8d0413fa 100644 --- a/src/cmd/acme/acme.c +++ b/src/cmd/acme/acme.c @@ -96,9 +96,14 @@ threadmain(int argc, char *argv[]) if(loadfile == nil) goto Usage; break; + case 'W': + winsize = ARGF(); + if(winsize == nil) + goto Usage; + break; default: Usage: - fprint(2, "usage: acme -a -c ncol -f fontname -F fixedwidthfontname -l loadfile\n"); + fprint(2, "usage: acme -a -c ncol -f fontname -F fixedwidthfontname -l loadfile -W winsize\n"); exits("usage"); }ARGEND diff --git a/src/cmd/auxstats/Linux.c b/src/cmd/auxstats/Linux.c index d4c2a29c..afd88407 100644 --- a/src/cmd/auxstats/Linux.c +++ b/src/cmd/auxstats/Linux.c @@ -109,21 +109,20 @@ xnet(int first) totinb = 0; totoub = 0; for(i=0; i<nline; i++){ + if((q = strchr(line[i], ':')) != nil) + *q = ' '; tokens(i); if(ntok < 8+8) continue; if(strncmp(tok[0], "eth", 3) != 0) continue; - q = strchr(tok[0], ':'); - *q++ = 0; - tok[0] = q; - inb = atoll(tok[0]); - oub = atoll(tok[8]); - in = atoll(tok[1]); - ou = atoll(tok[9]); + inb = atoll(tok[1]); + oub = atoll(tok[9]); + in = atoll(tok[2]); + ou = atoll(tok[10]); b = inb+oub; p = in+ou; - e = atoll(tok[2])+atoll(tok[10]); + e = atoll(tok[3])+atoll(tok[11]); totb += b; totp += p; tote += e; diff --git a/src/cmd/draw/gview.c b/src/cmd/draw/gview.c index 82491558..5e80ee2a 100644 --- a/src/cmd/draw/gview.c +++ b/src/cmd/draw/gview.c @@ -1956,7 +1956,7 @@ void usage(void) int i; fprintf(stderr,"Usage %s [options] [infile]\n", argv0); fprintf(stderr, -"option ::= -l logfile | -m\n" +"option ::= -W winsize | -l logfile | -m\n" "\n" "Read a polygonal line graph in an ASCII format (one x y pair per line, delimited\n" "by spaces with a label after each polyline), and view it interactively. Use\n" @@ -1981,6 +1981,9 @@ void main(int argc, char *argv[]) break; case 'l': logfil = fopen(ARGF(),"w"); break; + case 'W': + winsize = EARGF(usage()); + break; default: usage(); } ARGEND diff --git a/src/cmd/draw/img.c b/src/cmd/draw/img.c index 354e5885..01caa3c4 100644 --- a/src/cmd/draw/img.c +++ b/src/cmd/draw/img.c @@ -6,7 +6,7 @@ void usage(void) { - fprint(2, "usage: img [file]\n"); + fprint(2, "usage: img [-W winsize] [file]\n"); exits("usage"); } @@ -29,6 +29,9 @@ main(int argc, char **argv) Event e; ARGBEGIN{ + case 'W': + winsize = EARGF(usage()); + break; default: usage(); }ARGEND @@ -48,6 +51,8 @@ main(int argc, char **argv) if((image=readimage(display, fd, 0)) == nil) sysfatal("readimage: %r"); + drawresizewindow(Rect(0,0,Dx(image->r),Dy(image->r))); + einit(Emouse|Ekeyboard); eresized(0); for(;;){ diff --git a/src/cmd/draw/stats.c b/src/cmd/draw/stats.c index f49f541c..8a43fb09 100644 --- a/src/cmd/draw/stats.c +++ b/src/cmd/draw/stats.c @@ -332,7 +332,7 @@ update1(Graph *g, long v, ulong vmax) void usage(void) { - fprint(2, "usage: stats [-O] [-S scale] [-LY] [-%s] [machine...]\n", argchars); + fprint(2, "usage: stats [-O] [-S scale] [-LY] [-W winsize] [-%s] [machine...]\n", argchars); exits("usage"); } @@ -710,6 +710,9 @@ threadmain(int argc, char *argv[]) case 'O': oldsystem = 1; break; + case 'W': + winsize = EARGF(usage()); + break; default: if(nargs>=sizeof args || strchr(argchars, ARGC())==nil) usage(); diff --git a/src/cmd/draw/tweak.c b/src/cmd/draw/tweak.c index c7e12878..82a22ee1 100644 --- a/src/cmd/draw/tweak.c +++ b/src/cmd/draw/tweak.c @@ -172,12 +172,26 @@ void drawall(void); void tclose1(Thing*); void +usage(void) +{ + fprint(2, "usage: tweak [-W winsize] file...\n"); + exits("usage"); +} + +void main(int argc, char *argv[]) { int i; Event e; Thing *t; + ARGBEGIN{ + case 'W': + winsize = EARGF(usage()); + break; + default: + usage(); + }ARGEND mag = Mag; if(initdraw(error, 0, "tweak") < 0){ fprint(2, "tweak: initdraw failed: %r\n"); @@ -191,7 +205,7 @@ main(int argc, char *argv[]) } einit(Emouse|Ekeyboard); eresized(0); - i = 1; + i = 0; setjmp(err); for(; i<argc; i++){ file = argv[i]; diff --git a/src/cmd/jpg/bmp.c b/src/cmd/jpg/bmp.c index f7e07a01..ba1b813a 100644 --- a/src/cmd/jpg/bmp.c +++ b/src/cmd/jpg/bmp.c @@ -44,12 +44,22 @@ eresized(int new) } void +usage(void) +{ + fprint(2, "usage: bmp -39cdektv -W winsize [file.bmp ...]\n"); + exits("usage"); +} + +void main(int argc, char *argv[]) { int fd, i; char *err; ARGBEGIN{ + case 'W': + winsize = EARGF(usage()); + break; case '3': /* produce encoded, compressed, three-color bitmap file; no display by default */ threeflag++; /* fall through */ @@ -89,8 +99,7 @@ main(int argc, char *argv[]) outchan = CMAP8; break; default: - fprint(2, "usage: bmp -39cdektv [file.bmp ...]\n"); - exits("usage"); + usage(); }ARGEND; err = nil; diff --git a/src/cmd/jpg/gif.c b/src/cmd/jpg/gif.c index f9927017..f8f89de9 100644 --- a/src/cmd/jpg/gif.c +++ b/src/cmd/jpg/gif.c @@ -57,12 +57,23 @@ eresized(int new) } void +usage(void) +{ + fprint(2, "usage: gif -39cdektv -W winsize [file.gif ...]\n"); + exits("usage"); +} + + +void main(int argc, char *argv[]) { int fd, i; char *err; ARGBEGIN{ + case 'W': + winsize = EARGF(usage()); + break; case '3': /* produce encoded, compressed, three-color bitmap file; no display by default */ threeflag++; /* fall through */ @@ -102,8 +113,7 @@ main(int argc, char *argv[]) outchan = CMAP8; break; default: - fprint(2, "usage: gif -39cdektv [file.gif ...]\n"); - exits("usage"); + usage(); }ARGEND; err = nil; diff --git a/src/cmd/jpg/ico.c b/src/cmd/jpg/ico.c index 3a275e65..1380b18f 100644 --- a/src/cmd/jpg/ico.c +++ b/src/cmd/jpg/ico.c @@ -258,7 +258,7 @@ Bgeticon(Biobuf *b, Icon *icon) void usage(void) { - fprint(2, "usage: %s [file]\n", argv0); + fprint(2, "usage: %s -W winsize [file]\n", argv0); exits("usage"); } @@ -444,6 +444,9 @@ main(int argc, char **argv) Event e; ARGBEGIN{ + case 'W': + winsize = EARGF(usage()); + break; case 'd': debug = 1; break; diff --git a/src/cmd/jpg/jpg.c b/src/cmd/jpg/jpg.c index cf438a93..f61172a5 100644 --- a/src/cmd/jpg/jpg.c +++ b/src/cmd/jpg/jpg.c @@ -46,6 +46,13 @@ eresized(int new) } void +usage(void) +{ + fprint(2, "usage: jpg -39cdefFkJrtv -W winsize [file.jpg ...]\n"); + exits("usage"); +} + +void main(int argc, char *argv[]) { int fd, i, yflag; @@ -54,6 +61,9 @@ main(int argc, char *argv[]) yflag = 0; ARGBEGIN{ + case 'W': + winsize = EARGF(usage()); + break; case 'c': /* produce encoded, compressed, bitmap file; no display by default */ cflag++; dflag++; @@ -110,8 +120,7 @@ main(int argc, char *argv[]) outchan = CMAP8; break; default: - fprint(2, "usage: jpg -39cdefFkJrtv [file.jpg ...]\n"); - exits("usage"); + usage(); }ARGEND; if(yflag==0 && dflag==0 && colorspace==CYCbCr){ /* see if we should convert right to RGB */ diff --git a/src/cmd/jpg/png.c b/src/cmd/jpg/png.c index d653fe6a..a815abfc 100644 --- a/src/cmd/jpg/png.c +++ b/src/cmd/jpg/png.c @@ -44,6 +44,13 @@ eresized(int new) } void +usage(void) +{ + fprint(2, "usage: png -39cdekrtv -W winsize [file.png ...]\n"); + exits("usage"); +} + +void main(int argc, char *argv[]) { int fd, i; @@ -51,6 +58,9 @@ main(int argc, char *argv[]) char buf[12+1]; ARGBEGIN{ + case 'W': + winsize = EARGF(usage()); + break; case 'c': /* produce encoded, compressed, bitmap file; no display by default */ cflag++; dflag++; @@ -96,8 +106,7 @@ main(int argc, char *argv[]) outchan = CMAP8; break; default: - fprint(2, "usage: png -39cdekrtv [file.png ...]\n"); - exits("usage"); + usage(); }ARGEND; if(dflag==0 && colorspace==CYCbCr){ /* see if we should convert right to RGB */ diff --git a/src/cmd/jpg/ppm.c b/src/cmd/jpg/ppm.c index 24019dfa..d90344ed 100644 --- a/src/cmd/jpg/ppm.c +++ b/src/cmd/jpg/ppm.c @@ -42,12 +42,22 @@ eresized(int new) } void +usage(void) +{ + fprint(2, "usage: ppm -39cdektv -W winsize [file.ppm ...]\n"); + exits("usage"); +} + +void main(int argc, char *argv[]) { int fd, i; char *err; ARGBEGIN{ + case 'W': + winsize = EARGF(usage()); + break; case '3': /* produce encoded, compressed, three-color bitmap file; no display by default */ threeflag++; /* fall through */ @@ -87,8 +97,7 @@ main(int argc, char *argv[]) outchan = CMAP8; break; default: - fprint(2, "usage: ppm -39cdektv [file.ppm ...]\n"); - exits("usage"); + usage(); }ARGEND; err = nil; diff --git a/src/cmd/jpg/yuv.c b/src/cmd/jpg/yuv.c index 929ccf39..6027236b 100644 --- a/src/cmd/jpg/yuv.c +++ b/src/cmd/jpg/yuv.c @@ -44,12 +44,22 @@ eresized(int new) } void +usage(void) +{ + fprint(2, "usage: yuv -39cdektv -W winsize [file.yuv ...]\n"); + exits("usage"); +} + +void main(int argc, char *argv[]) { int fd, i; char *err; ARGBEGIN{ + case 'W': + winsize = EARGF(usage()); + break; case '3': /* produce encoded, compressed, three-color bitmap file; no display by default */ threeflag++; /* fall through */ @@ -89,8 +99,7 @@ main(int argc, char *argv[]) outchan = CMAP8; break; default: - fprint(2, "usage: yuv -39cdektv [file.yuv ...]\n"); - exits("usage"); + usage(); }ARGEND; err = nil; diff --git a/src/cmd/mc.c b/src/cmd/mc.c deleted file mode 100644 index 45e7adf4..00000000 --- a/src/cmd/mc.c +++ /dev/null @@ -1,245 +0,0 @@ -/* - * mc - columnate - * - * mc[-][-LINEWIDTH][-t][file...] - * - causes break on colon - * -LINEWIDTH sets width of line in which to columnate(default 80) - * -t suppresses expanding multiple blanks into tabs - * - */ -#include <u.h> -#include <sys/ioctl.h> -#include <sys/termios.h> -#include <libc.h> -#include <draw.h> -#include <bio.h> - -#define WIDTH 80 -#define TAB 4 -#define WORD_ALLOC_QUANTA 1024 -#define ALLOC_QUANTA 4096 - -int linewidth=WIDTH; -int colonflag=0; -int tabflag=0; /* -t flag turned off forever */ -Rune *cbuf, *cbufp; -Rune **word; -int maxwidth=0; -int nalloc=ALLOC_QUANTA; -int nwalloc=WORD_ALLOC_QUANTA; -int nchars=0; -int nwords=0; -Biobuf bin; -Biobuf bout; - -void getwidth(void), readbuf(int), error(char *); -void scanwords(void), columnate(void), morechars(void); - -void -main(int argc, char *argv[]) -{ - int i; - int lineset; - int ifd; - - lineset = 0; - Binit(&bout, 1, OWRITE); - while(argc > 1 && argv[1][0] == '-'){ - --argc; argv++; - switch(argv[0][1]){ - case '\0': - colonflag = 1; - break; - case 't': - tabflag = 0; - break; - default: - linewidth = atoi(&argv[0][1]); - if(linewidth <= 1) - linewidth = WIDTH; - lineset = 1; - break; - } - } - if(lineset == 0) - getwidth(); - cbuf = cbufp = malloc(ALLOC_QUANTA*(sizeof *cbuf)); - word = malloc(WORD_ALLOC_QUANTA*(sizeof *word)); - if(word == 0 || cbuf == 0) - error("out of memory"); - if(argc == 1) - readbuf(0); - else{ - for(i = 1; i < argc; i++){ - if((ifd = open(*++argv, OREAD)) == -1) - fprint(2, "mc: can't open %s (%r)\n", *argv); - else{ - readbuf(ifd); - Bflush(&bin); - close(ifd); - } - } - } - columnate(); - exits(0); -} -void -error(char *s) -{ - fprint(2, "mc: %s\n", s); - exits(s); -} -void -readbuf(int fd) -{ - int lastwascolon = 0; - long c; - int linesiz = 0; - - Binit(&bin, fd, OREAD); - do{ - if(nchars++ >= nalloc) - morechars(); - *cbufp++ = c = Bgetrune(&bin); - linesiz++; - if(c == '\t') { - cbufp[-1] = L' '; - while(linesiz%TAB != 0) { - if(nchars++ >= nalloc) - morechars(); - *cbufp++ = L' '; - linesiz++; - } - } - if(colonflag && c == ':') - lastwascolon++; - else if(lastwascolon){ - if(c == '\n'){ - --nchars; /* skip newline */ - *cbufp = L'\0'; - while(nchars > 0 && cbuf[--nchars] != '\n') - ; - if(nchars) - nchars++; - columnate(); - if (nchars) - Bputc(&bout, '\n'); - Bprint(&bout, "%S", cbuf+nchars); - nchars = 0; - cbufp = cbuf; - } - lastwascolon = 0; - } - if(c == '\n') - linesiz = 0; - }while(c >= 0); -} -void -scanwords(void) -{ - Rune *p, *q; - int i; - - nwords=0; - maxwidth=0; - for(p = q = cbuf, i = 0; i < nchars; i++){ - if(*p++ == L'\n'){ - if(nwords >= nwalloc){ - nwalloc += WORD_ALLOC_QUANTA; - if((word = realloc(word, nwalloc*sizeof(*word)))==0) - error("out of memory"); - } - word[nwords++] = q; - p[-1] = L'\0'; - if(p-q > maxwidth) - maxwidth = p-q; - q = p; - } - } -} - -void -columnate(void) -{ - int i, j; - int words_per_line; - int nlines; - int col; - int endcol; - - - scanwords(); - if(nwords==0) - return; - words_per_line = linewidth/maxwidth; - if(words_per_line <= 0) - words_per_line = 1; - nlines=(nwords+words_per_line-1)/words_per_line; - for(i = 0; i < nlines; i++){ - col = endcol = 0; - for(j = i; j < nwords; j += nlines){ - endcol += maxwidth; - Bprint(&bout, "%S", word[j]); - col += word[j+1]-word[j]-1; - if(j+nlines < nwords){ - if(tabflag) { - int tabcol = (col|(TAB-1))+1; - while(tabcol <= endcol){ - Bputc(&bout, '\t'); - col = tabcol; - tabcol += TAB; - } - } - while(col < endcol){ - Bputc(&bout, ' '); - col++; - } - } - } - Bputc(&bout, '\n'); - } -} - -void -morechars(void) -{ - nalloc += ALLOC_QUANTA; - if((cbuf = realloc(cbuf, nalloc*sizeof(*cbuf))) == 0) - error("out of memory"); - cbufp = cbuf+nchars-1; -} - -/* - * These routines discover the width of the display. - * It takes some work. If we do the easy calls to the - * draw library, the screen flashes due to repainting - * when mc exits. - */ - -int -windowrect(struct winsize *ws) -{ - int tty; - - if((tty = open("/dev/tty", OWRITE)) < 0) - tty = 1; - - if(ioctl(tty, TIOCGWINSZ, ws) < 0){ - if(tty != 1) - close(tty); - return -1; - } - if(tty != 1) - close(tty); - return 0; -} - -void -getwidth(void) -{ - struct winsize ws; - - if(windowrect(&ws) < 0) - return; - linewidth = ws.ws_col; -} diff --git a/src/cmd/plot/plot.c b/src/cmd/plot/plot.c index 04e5cf54..1360f686 100644 --- a/src/cmd/plot/plot.c +++ b/src/cmd/plot/plot.c @@ -149,6 +149,7 @@ main(int arc, char *arv[]){ fd = dup(0, -1); /* because openpl will close 0! */ dflag=0; oflag=""; + winsize = "512x512"; for(i=1;i!=arc;i++) if(arv[i][0]=='-') switch(arv[i][1]){ case 'd': dflag=1; break; case 'o': oflag=arv[i]+2; break; @@ -168,7 +169,6 @@ main(int arc, char *arv[]){ case 'D': break; case 'd': break; case 'o': break; - case 'W': break; case 's': break; case 'e': erase(); break; case 'C': closepl(); break; @@ -177,6 +177,7 @@ main(int arc, char *arv[]){ case 'f': cfill(ap+1); break; case 'p': pen(ap+1); break; case 'g': grade(atof(ap+1)); break; + case 'W': winsize = ap+1; break; } } else if ((bp = Bopen(arv[1], OREAD)) == 0) { diff --git a/src/cmd/sam/sam.c b/src/cmd/sam/sam.c index 078d9439..5a009bb0 100644 --- a/src/cmd/sam/sam.c +++ b/src/cmd/sam/sam.c @@ -29,6 +29,8 @@ File *lastfile; Disk *disk; long seq; +char *winsize; + Rune baddir[] = { '<', 'b', 'a', 'd', 'd', 'i', 'r', '>', '\n'}; void usage(void); @@ -82,6 +84,10 @@ main(int argc, char *argv[]) argc--; break; + case 'W': + --argc, argv++; + break; + default: dprint("sam: unknown flag %c\n", argv[0][1]); exits("usage"); @@ -101,7 +107,7 @@ main(int argc, char *argv[]) if(home == 0) home = "/"; if(!dflag) - startup(machine, Rflag, arg, ap); + startup(machine, Rflag, arg, argv); notify(notifyf); getcurwd(); if(argc>1){ diff --git a/src/cmd/samterm/plan9.c b/src/cmd/samterm/plan9.c index feb89573..4d58c609 100644 --- a/src/cmd/samterm/plan9.c +++ b/src/cmd/samterm/plan9.c @@ -28,10 +28,15 @@ static char *exname; void getscreen(int argc, char **argv) { + int i; char *t; - USED(argc); - USED(argv); + /* not exactly right */ + for(i=0; i<argc-1; i++){ + if(strcmp(argv[i], "-W") == 0) + winsize = argv[i+1]; + } + if(initdraw(panic1, nil, "sam") < 0){ fprint(2, "samterm: initdraw: %r\n"); threadexitsall("init"); diff --git a/src/cmd/vac/vtdump.c b/src/cmd/vac/vtdump.c index daabedc6..ee6a0c62 100644 --- a/src/cmd/vac/vtdump.c +++ b/src/cmd/vac/vtdump.c @@ -87,10 +87,12 @@ threadmain(int argc, char *argv[]) Bprint(bout, "prev: %V\n", root.prev); } +fprint(2, "read...\n"); n = vtread(z, root.score, VtDirType, buf, bsize); if(n < 0) sysfatal("could not read root dir"); +fprint(2, "...\n"); /* fake up top level source */ memset(&source, 0, sizeof(source)); memmove(source.score, root.score, VtScoreSize); |