12 uchar **name; /* first byte is ' ' or '\'': modified state */
13 Text **text; /* pointer to Text associated with file */
14 ushort *tag; /* text[i].tag, even if text[i] not defined */
54 0, /* storage for last pattern */
65 Menu menu2 = {0, genmenu2};
66 Menu menu2c ={0, genmenu2c};
67 Menu menu3 = {0, genmenu3};
72 Text *t=(Text *)which->user1;
76 if(hversion==0 || plumbfd<0)
77 menu2str[Plumb] = "(plumb)";
78 m = menuhit(2, mousectl, t==&cmd? &menu2c : &menu2, nil);
79 if(hostlock || t->lock)
97 outTsll(Tplumb, t->tag, which->p0, which->p1);
107 outTsll(Tlook, t->tag, which->p0, which->p1);
114 outTsll(Tsend, 0 /*ignored*/, which->p0, which->p1);
131 switch(m = menuhit(3, mousectl, &menu3, nil)){
143 setcursor(mousectl, &bullseye);
145 if((mousep->buttons&4) && (l = flwhich(mousep->xy)) && getr(&r))
146 duplicate(l, r, l->f.font, m==Resize);
148 setcursor(mousectl, cursor);
155 setcursor(mousectl, &bullseye);
157 if((mousep->buttons&4) && (l = flwhich(mousep->xy)) && !hostlock){
162 outTs(Tclose, t->tag);
166 setcursor(mousectl, cursor);
173 setcursor(mousectl, &bullseye);
175 if((mousep->buttons&4) && (l = flwhich(mousep->xy))){
176 outTs(Twrite, ((Text *)l->user1)->tag);
179 setcursor(mousectl, cursor);
185 if(t = text[m-NMENU3]){
187 if(t->nwin==0 || t->l[i].textfn==0)
188 return; /* not ready yet; try again later */
189 if(t->nwin>1 && which==&t->l[i])
193 while(i!=t->front && t->l[i].textfn==0);
196 sweeptext(0, tag[m-NMENU3]);
203 sweeptext(int new, int tag)
208 if(getr(&r) && (t = malloc(sizeof(Text)))){
209 memset((void*)t, 0, sizeof(Text));
210 current((Flayer *)0);
211 flnew(&t->l[0], gettext, 0, (char *)t);
212 flinit(&t->l[0], r, font, maincols); /*bnl*/
216 startnewfile(Tstartnewfile, t);
232 for(i=0; i<nname; i++)
239 menuins(int n, uchar *s, Text *t, int m, int tg)
248 name = realloc(name, sizeof(name[0])*mname);
249 text = realloc(text, sizeof(text[0])*mname);
250 tag = realloc(tag, sizeof(tag[0])*mname);
251 if(name==nil || text==nil || tag==nil)
254 for(i=nname; i>n; --i)
255 name[i]=name[i-1], text[i]=text[i-1], tag[i]=tag[i-1];
258 name[n] = alloc(strlen((char*)s)+2);
260 strcpy((char*)name[n]+1, (char*)s);
262 menu3.lasthit = n+NMENU3;
270 if(nname==0 || n>=nname || text[n])
274 for(i = n; i<nname; i++)
275 name[i]=name[i+1], text[i]=text[i+1], tag[i]=tag[i+1];
284 strncpy(pat+1, s, 15);
285 menu2str[Search] = pat;
289 static uchar buf[NBUF*UTFmax]={' ', ' ', ' ', ' '};
297 do; while(*t++ = *s++);
305 Text *t=(Text *)which->user1;
307 if(n>=NMENU2+(menu2str[Search]!=0))
310 if(!hostlock && !t->lock || n==Search || n==Look)
317 Text *t=(Text *)which->user1;
325 if(!hostlock && !t->lock)
337 if(n >= NMENU3+nname)
346 if(n == 0) /* unless we've been fooled, this is cmd */
347 return (char *)&name[n][1];
349 mw = 7; /* strlen("~~sam~~"); */
350 for(i=1; i<nname; i++){
351 w = utflen((char*)name[i]+1)+4; /* include "'+. " */
368 if(work && t==(Text *)work->user1) {
374 l = utflen((char*)name[n]+1);
379 k += chartorune(&r, (char*)name[n]+k);
384 strcpy((char*)buf+4, (char*)name[n]+1);
386 strcat((char*)buf, "...");
387 while((l-i) >= NBUF/2-4){
388 k += chartorune(&r, (char*)name[n]+k);
391 strcat((char*)buf, (char*)name[n]+k);
393 strcpy((char*)buf+4, (char*)name[n]+1);
394 i = utflen((char*)buf);
395 k = strlen((char*)buf);
396 while(i<mw && k<sizeof buf-1){