diff options
author | rsc <devnull@localhost> | 2005-01-30 16:27:45 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2005-01-30 16:27:45 +0000 |
commit | efe12411090ddcb45f524d6b0624ec4493d65175 (patch) | |
tree | d456ee063f7fe3625c7c5f5fc9a95ec1e931a790 | |
parent | 0b22e9bd85861f6a3c8f0635bd4422daa84343eb (diff) | |
download | plan9port-efe12411090ddcb45f524d6b0624ec4493d65175.tar.gz plan9port-efe12411090ddcb45f524d6b0624ec4493d65175.tar.bz2 plan9port-efe12411090ddcb45f524d6b0624ec4493d65175.zip |
handle sysnames in labels
-rw-r--r-- | man/man1/label.1 | 16 | ||||
-rw-r--r-- | src/cmd/9term/9term.c | 11 | ||||
-rw-r--r-- | src/cmd/9term/win.c | 21 |
3 files changed, 37 insertions, 11 deletions
diff --git a/man/man1/label.1 b/man/man1/label.1 index 20fd9007..5866ddbe 100644 --- a/man/man1/label.1 +++ b/man/man1/label.1 @@ -6,6 +6,9 @@ label, awd \- set window label .I string .br .B awd +[ +.I sysname +] .SH DESCRIPTION .I Label sets the label of the current @@ -25,6 +28,14 @@ and windows assume the label is a directory name. When unrooted file names are plumbed in the window, they are evaluated relative to the directory named in the label. +.PP +The label may have a suffix +BI /- sysname \fR, +which is not interpreted as part of the directory during plumbing. +.I Awd +sets the window name to the current directory with a +.BI /- sysname +suffix, using the name of the current system by default. .SH EXAMPLE One can use the following .IR sh (1) @@ -64,8 +75,3 @@ fn cd { .I Awd is also documented in .IR acme (1). -.PP -.I Awd -does not append the -.BI - label -suffix that it does on Plan 9. diff --git a/src/cmd/9term/9term.c b/src/cmd/9term/9term.c index 31c9f289..f22bebc5 100644 --- a/src/cmd/9term/9term.c +++ b/src/cmd/9term/9term.c @@ -1834,7 +1834,8 @@ int label(Rune *sr, int n) { Rune *sl, *el, *er, *r; - + char *p; + er = sr+n; for(r=er-1; r>=sr; r--) if(*r == '\007') @@ -1854,6 +1855,14 @@ label(Rune *sr, int n) snprint(wdir, sizeof wdir, "%.*S", (el-1)-(sl+3), sl+3); drawsetlabel(wdir); + /* remove trailing /-sysname if present */ + p = strrchr(wdir, '/'); + if(p && *(p+1) == '-'){ + if(p == wdir) + p++; + *p = 0; + } + runemove(sl, el, er-el); n -= (el-sl); return n; diff --git a/src/cmd/9term/win.c b/src/cmd/9term/win.c index a6ef1414..37333fcc 100644 --- a/src/cmd/9term/win.c +++ b/src/cmd/9term/win.c @@ -489,11 +489,11 @@ stdoutproc(void *v) } } -char wdir[256]; +char wdir[512]; int label(char *sr, int n) { - char *sl, *el, *er, *r; + char *sl, *el, *er, *r, *p; er = sr+n; for(r=er-1; r>=sr; r--) @@ -503,8 +503,8 @@ label(char *sr, int n) return n; el = r+1; - if(el-sr > sizeof wdir) - sr = el - sizeof wdir; + if(el-sr > sizeof wdir - strlen(name) - 20) + sr = el - sizeof wdir - strlen(name) - 20; for(sl=el-3; sl>=sr; sl--) if(sl[0]=='\033' && sl[1]==']' && sl[2]==';') break; @@ -512,7 +512,18 @@ label(char *sr, int n) return n; *r = 0; - snprint(wdir, sizeof wdir, "name %s/-%s\n0\n", sl+3, name); + /* + * add /-sysname if not present + */ + snprint(wdir, sizeof wdir, "name %s", sl+3); + p = strrchr(wdir, '/'); + if(p==nil || *(p+1) != '-'){ + p = wdir+strlen(wdir); + if(*(p-1) != '/') + *p++ = '/'; + strcpy(p, name); + } + strcat(wdir, "\n0\n"); fswrite(ctlfd, wdir, strlen(wdir)); memmove(sl, el, er-el); |