From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f46.google.com ([209.85.208.46]) by ewsd; Thu Apr 9 03:04:56 EDT 2020 Received: by mail-ed1-f46.google.com with SMTP id w26so12012890edu.7 for <9front@9front.org>; Thu, 09 Apr 2020 00:04:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-transfer-encoding; bh=CvYitVYxKAqXC+NWVdzoM9Ak/Bo+/+00gvp8PEgZkI0=; b=k6OI4BOdty4irMrFwdbwV1o4P7OxbGAON6a00ieNqL+Ystli8PFXF623ZUPXLUTmKd FyHTPbwIlHEXV1QZMu4PoAMLh/6o2DWaPptRxwGTSxzhMiX0dnHsWnD1zk1e6epe2iT5 zh8vVv+1VasL9pTJSbvWt3bLfvpa359hd22b9tRWXKgzcrVs2dTM8nJ3NoEFCBAomq8Z WNJs4M5wD6ptBBghhjwgqsosTFwIpIXeOXMAdjkG/R9Oa2Mby+pvhYVoxHHHvpxldwcg D2KA7nKMteqt39NmySWSTx1fENm3xNRPm0Za+RokXbNNKgf+zidxjV5uktUwl5vhp/VI aiGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-transfer-encoding; bh=CvYitVYxKAqXC+NWVdzoM9Ak/Bo+/+00gvp8PEgZkI0=; b=uimvHjZBCY96bfPlRSxw9L7WZg7h6qvQ000EmfcReyycn0BdsrSJV+HFDV9eOKezgv lnv7H705cWWI/l19nIKk9KUhus4AuJF6QJP5LRJqvcTDs/MdTcH4ULP5S08UTNBajwbR 2aUiq5G4Zpl5v08hCkZbNJx4Lkp7NDhabAAAgRCn1N8K4P+wt1IRlDIKSHKZwivaM0GK LcaU/ymiEQQmd7oo5MXyJg3QI4iOY3kjtYJy0FUwsoVKllaW0I056xnWoYHPgzV6vN1N /X2ubRWHNDfsigOEHpmMV7UQ80hYayDR3ZMv57m/XfyiAkFHj/cnC4wB8Y0JBCjaaZWK D9gA== X-Gm-Message-State: AGi0PuZENhAulORUOqnxMylDFV5vZZS96kqXwK+/+kb9WwbUp2xwO0Sf 1xTMuaX6YkOckKVtrZmHzOVFxpNNEpn6UyHEn7laSw== X-Google-Smtp-Source: APiQypJTlKnzIk2YCGLHsisAVc7TZRLv+nhv/43yUXKQGJSrNGwH1rm6bxj0Kt1gpOA20IF0kkaD7bWXyqTeZpFrWU4= X-Received: by 2002:a2e:804a:: with SMTP id p10mr7680938ljg.289.1586415554213; Wed, 08 Apr 2020 23:59:14 -0700 (PDT) MIME-Version: 1.0 References: <618C497B56559996D5CB5F02EF37BD27@eigenstate.org> In-Reply-To: From: =?UTF-8?Q?Iruat=C3=A3_Souza?= Date: Thu, 9 Apr 2020 08:59:02 +0200 Message-ID: Subject: Re: [9front] vt plumbing: empty selection To: 9front@9front.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: shared lossless session XML over YAML proxy factory hardware-scale solution sorry 1 * UTFmax On Thu, Apr 9, 2020 at 8:58 AM Iruat=C3=A3 Souza wrot= e: > > Ori, > > It seems that in surrounding, if x0 =3D=3D x1 you allocate a one byte > buffer but return nil, effectively leaking that buffer. > > On Thu, Apr 9, 2020 at 6:15 AM wrote: > > > > Plumbing text in vt requires selecting the text that you > > want to plumb precisely. This patch makes plumbing behave > > the same way that it does in rio, though cwd isn't updated > > whenever we change directories. That'll take further thought > > to get right. > > > > There's an escape code (OSC 7) for programs to advertise > > their current working directory to the terminal emulator, > > and I'm willing to implement it -- but nothing on 9front > > generates it, and it's not clear that we want to start. > > The programs that do generate it are likely to be on the > > other end of an ssh connection, which means that their cwd > > is unlikely to make sense to plumb. Is there anything that > > is useful to do here? > > > > diff -r 3bcb5998f222 sys/src/cmd/vt/main.c > > --- a/sys/src/cmd/vt/main.c Wed Apr 08 23:48:09 2020 +0200 > > +++ b/sys/src/cmd/vt/main.c Wed Apr 08 21:07:46 2020 -0700 > > @@ -170,7 +170,7 @@ > > void escapedump(int,uchar *,int); > > void paste(void); > > void snarfsel(void); > > -void plumbsel(void); > > +void plumbsel(Point); > > > > static Channel *pidchan; > > > > @@ -982,13 +982,47 @@ > > free(s); > > } > > > > +/* > > + * Grabs the non-whitespace text around a character > > + * cell, matching the behavior in rio for plumbing. > > + * Does not modify the selection. > > + */ > > +char* > > +surrounding(Point p) > > +{ > > + int c, x0, x1; > > + char *s, *e; > > + > > + for(x0 =3D p.x; x0 > 0; x0--){ > > + c =3D *onscreenr(x0 - 1, p.y); > > + if(c =3D=3D 0 || c =3D=3D ' ' || c =3D=3D '\t' || c =3D= =3D '\n') > > + break; > > + } > > + for(x1 =3D p.x; x1 <=3D xmax; x1++){ > > + c =3D *onscreenr(x1 + 1, p.y); > > + if(c =3D=3D 0 || c =3D=3D ' ' || c =3D=3D '\t' || c =3D= =3D '\n') > > + break; > > + } > > + s =3D malloc((x1 - x0 + 1)*UTFmax); > > + if(s =3D=3D nil || x0 =3D=3D x1) > > + return nil; > > + e =3D selrange(s, x0, p.y, x1, p.y); > > + *e =3D 0; > > + for(e =3D s; *e; e++) > > + print("%c(%d)\n", *e, *e); > > + return s; > > +} > > + > > void > > -plumbsel(void) > > +plumbsel(Point p) > > { > > char *s, wdir[1024]; > > int plumb; > > > > - if((s =3D selection()) =3D=3D nil) > > + s =3D selection(); > > + if(s =3D=3D nil || *s =3D=3D 0) > > + s =3D surrounding(p); > > + if(s =3D=3D nil) > > return; > > if(getwd(wdir, sizeof wdir) =3D=3D nil){ > > free(s); > > @@ -1116,6 +1150,9 @@ > > void > > readmenu(void) > > { > > + Point p; > > + > > + p =3D pos(mc->xy); > > if(button3()) { > > menu3.item[1] =3D ttystate[cs->raw].crnl ? "cr" : "crnl= "; > > menu3.item[2] =3D ttystate[cs->raw].nlcr ? "nl" : "nlcr= "; > > @@ -1173,7 +1210,7 @@ > > return; > > > > case Mplumb: > > - plumbsel(); > > + plumbsel(p); > > return; > > > > case Mpage: /* pause and clear at end of screen */ > >