handle sysnames in labels
This commit is contained in:
parent
0b22e9bd85
commit
efe1241109
3 changed files with 37 additions and 11 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -1834,6 +1834,7 @@ int
|
|||
label(Rune *sr, int n)
|
||||
{
|
||||
Rune *sl, *el, *er, *r;
|
||||
char *p;
|
||||
|
||||
er = sr+n;
|
||||
for(r=er-1; r>=sr; r--)
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue