shithub: patch

Download patch

ref: f71155a4403109118ea14d4219febbe7d970f27a
parent: 139c30d7cf7cf1d18a541ab55fc3b3b3ef14c677
author: qwx <qwx@sciops.net>
date: Thu Jan 20 07:40:43 EST 2022

promote sam/term to full fork

--- a/sam-sharedsnarf
+++ /dev/null
@@ -1,99 +1,0 @@
---- //.git/fs/object/84b77568cda98a21dd4f3403a94c56724fbd5b37/tree/sys/src/cmd/sam/mesg.c
-+++ sys/src/cmd/sam/mesg.c
-@@ -350,6 +350,12 @@
- 		f = whichfile(inshort());
- 		p0 = inlong();
- 		journaln(0, p0);
-+		int fd = open("/dev/snarf", OREAD);
-+		if(fd < 0)
-+			panic("paste: open");
-+		bufreset(&snarfbuf);
-+		bufload(&snarfbuf, 0, fd, &i);
-+		close(fd);
- 		for(l=0; l<snarfbuf.nc; l+=m){
- 			m = snarfbuf.nc-l;
- 			if(m>BLOCKSIZE)
-@@ -578,7 +584,9 @@
- snarf(File *f, Posn p1, Posn p2, Buffer *buf, int emptyok)
- {
- 	Posn l;
--	int i;
-+	int i, fd, n;
-+	String *s;
-+	char *cs;
- 
- 	if(!emptyok && p1==p2)
- 		return;
-@@ -588,11 +596,23 @@
- 		fprint(2, "bad snarf addr p1=%ld p2=%ld f->nc=%d\n", p1, p2, f->nc); /*ZZZ should never happen, can remove */
- 		p2 = f->nc;
- 	}
-+	fd = open("/dev/snarf", OWRITE);
-+	if(fd < 0){
-+		fprint(2, "snarf: %r\n");
-+		return;
-+	}
- 	for(l=p1; l<p2; l+=i){
- 		i = p2-l>BLOCKSIZE? BLOCKSIZE : p2-l;
- 		bufread(f, l, genbuf, i);
--		bufinsert(buf, buf->nc, tmprstr(genbuf, i)->s, i);
-+		s = tmprstr(genbuf, i);
-+		cs = Strtoc(s);
-+		n = strlen(cs);
-+		if(write(fd, cs, n) != n)
-+			fprint(2, "snarf: %r\n");
-+		free(cs);
-+		bufinsert(buf, buf->nc, s->s, i);
- 	}
-+	close(fd);
- }
- 
- int
---- //.git/fs/object/84b77568cda98a21dd4f3403a94c56724fbd5b37/tree/sys/src/cmd/samterm/main.c
-+++ sys/src/cmd/samterm/main.c
-@@ -303,11 +303,9 @@
- void
- paste(Text *t, int w)
- {
--	if(snarflen){
--		cut(t, w, 0, 0);
--		t->lock++;
--		outTsl(Tpaste, t->tag, t->l[w].p0);
--	}
-+	cut(t, w, 0, 0);
-+	t->lock++;
-+	outTsl(Tpaste, t->tag, t->l[w].p0);
- }
- 
- void
---- //.git/fs/object/84b77568cda98a21dd4f3403a94c56724fbd5b37/tree/sys/src/cmd/samterm/menu.c
-+++ sys/src/cmd/samterm/menu.c
-@@ -27,7 +27,6 @@
- 	Snarf,
- 	Plumb,
- 	Look,
--	Exch,
- 	Search,
- 	NMENU2 = Search,
- 	Send = Search,
-@@ -50,7 +49,6 @@
- 	"snarf",
- 	"plumb",
- 	"look",
--	"<rio>",
- 	0,		/* storage for last pattern */
- };
- 
-@@ -95,12 +93,6 @@
- 	case Plumb:
- 		if(hversion > 0)
- 			outTsll(Tplumb, t->tag, which->p0, which->p1);
--		break;
--
--	case Exch:
--		snarf(t, w);
--		outT0(Tstartsnarf);
--		setlock();
- 		break;
- 
- 	case Look:
--- a/samterm-col
+++ /dev/null
@@ -1,70 +1,0 @@
-samterm color patch.
-
-diff -r 0dbb01291c38 sys/src/cmd/samterm/flayer.c
---- a/sys/src/cmd/samterm/flayer.c	Thu Jan 07 15:04:56 2016 -0500
-+++ b/sys/src/cmd/samterm/flayer.c	Sun Jan 10 20:31:20 2016 +0100
-@@ -29,18 +29,18 @@
- 	lDrect = r;
- 
- 	/* Main text is yellowish */
--	maincols[BACK] = allocimagemix(display, DPaleyellow, DWhite);
--	maincols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DDarkyellow);
--	maincols[BORD] = allocimage(display, Rect(0,0,2,2), screen->chan, 1, DYellowgreen);
--	maincols[TEXT] = display->black;
--	maincols[HTEXT] = display->black;
-+	maincols[BACK] = display->black;
-+	maincols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x440000FF);
-+	maincols[BORD] = allocimage(display, Rect(0,0,2,2), screen->chan, 1, 0x222222FF);
-+	maincols[TEXT] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x884400FF);
-+	maincols[HTEXT] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x884400FF);
- 
- 	/* Command text is blueish */
--	cmdcols[BACK] = allocimagemix(display, DPalebluegreen, DWhite);
--	cmdcols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DPalegreygreen);
--	cmdcols[BORD] = allocimage(display, Rect(0,0,2,2), screen->chan, 1, DPurpleblue);
--	cmdcols[TEXT] = display->black;
--	cmdcols[HTEXT] = display->black;
-+	cmdcols[BACK] = display->black;
-+	cmdcols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x111111FF);
-+	cmdcols[BORD] = allocimage(display, Rect(0,0,2,2), screen->chan, 1, 0x440000FF);
-+	cmdcols[TEXT] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x770000FF);
-+	cmdcols[HTEXT] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x770000FF);
- }
- 
- void
-@@ -89,12 +89,12 @@
- flclose(Flayer *l)
- {
- 	if(l->visible == All)
--		draw(screen, l->entire, display->white, nil, ZP);
-+		draw(screen, l->entire, display->black, nil, ZP);
- 	else if(l->visible == Some){
- 		if(l->f.b == 0)
- 			l->f.b = allocimage(display, l->entire, screen->chan, 0, DNofill);
- 		if(l->f.b){
--			draw(l->f.b, l->entire, display->white, nil, ZP);
-+			draw(l->f.b, l->entire, display->black, nil, ZP);
- 			flrefresh(l, l->entire, 0);
- 		}
- 	}
-@@ -353,7 +353,7 @@
- 	if(0 && Dx(dr)==Dx(olDrect) && Dy(dr)==Dy(olDrect))
- 		move = 1;
- 	else
--		draw(screen, lDrect, display->white, nil, ZP);
-+		draw(screen, lDrect, display->black, nil, ZP);
- 	for(i=0; i<nllist; i++){
- 		l = llist[i];
- 		l->lastsr = ZR;
-diff -r 0dbb01291c38 sys/src/cmd/samterm/plan9.c
---- a/sys/src/cmd/samterm/plan9.c	Thu Jan 07 15:04:56 2016 -0500
-+++ b/sys/src/cmd/samterm/plan9.c	Sun Jan 10 20:31:20 2016 +0100
-@@ -46,7 +46,7 @@
- 	if(t != nil)
- 		maxtab = strtoul(t, nil, 0);
- 	free(t);
--	draw(screen, screen->clipr, display->white, nil, ZP);
-+	draw(screen, screen->clipr, display->black, nil, ZP);
- }
- 
- int
--- a/samterm-flayers
+++ /dev/null
@@ -1,12 +1,0 @@
-diff -r 12bbf1a60d48 sys/src/cmd/samterm/samterm.h
---- a/sys/src/cmd/samterm/samterm.h	Thu Jun 01 07:07:55 2017 +0000
-+++ b/sys/src/cmd/samterm/samterm.h	Mon Jun 05 15:36:48 2017 +0200
-@@ -3,7 +3,7 @@
- #define	RUNESIZE	sizeof(Rune)
- #define	MAXFILES	256
- #define	READBUFSIZE 8192
--#define	NL	5
-+#define	NL	10
- 
- enum{
- 	Up,
--- a/samterm-fullfrontalnudity
+++ /dev/null
@@ -1,262 +1,0 @@
-diff 614f1d6268fd986fc628eec3754bd4599363ad13 uncommitted
---- a//sys/src/cmd/samterm/flayer.h
-+++ b//sys/src/cmd/samterm/flayer.h
-@@ -42,9 +42,9 @@
- void	flupfront(Flayer*);
- Flayer	*flwhich(Point);
- 
--#define	FLMARGIN	4
-+#define	FLMARGIN	2
- #define	FLSCROLLWID	12
--#define	FLGAP		4
-+#define	FLGAP		0
- 
- extern	Image	*maincols[NCOL];
- extern	Image	*cmdcols[NCOL];
---- a//sys/src/cmd/samterm/main.c
-+++ b//sys/src/cmd/samterm/main.c
-@@ -44,6 +44,8 @@
- 	nscralloc = 100;
- 	r = screen->r;
- 	r.max.y = r.min.y+Dy(r)/5;
-+	if(Dy(r) < font->height)
-+		r.max.y = r.min.y + font->height + 2*FLMARGIN;
- 	flstart(screen->clipr);
- 	rinit(&cmd.rasp);
- 	flnew(&cmd.l[0], gettext, 1, &cmd);
-@@ -240,30 +242,66 @@
- 		getmouse();
- }
- 
--int
--getr(Rectangle *rp)
-+Rectangle
-+inflatepoint(Point p)
- {
--	Point p;
-+	Rectangle *c;
- 	Rectangle r;
--
--	*rp = getrect(3, mousectl);
--	if(rp->max.x && rp->max.x-rp->min.x<=5 && rp->max.y-rp->min.y<=5){
--		p = rp->min;
--		r = cmd.l[cmd.front].entire;
--		*rp = screen->r;
--		if(cmd.nwin==1){
--			if (p.y <= r.min.y)
--				rp->max.y = r.min.y;
--			else if (p.y >= r.max.y)
--				rp->min.y = r.max.y;
--			if (p.x <= r.min.x)
--				rp->max.x = r.min.x;
--			else if (p.x >= r.max.x)
--				rp->min.x = r.max.x;
--		}
-+	
-+	r = screen->r;
-+	c = &cmd.l[cmd.front].entire;
-+	if(ptinrect(p, *c))
-+		return r;
-+	// L
-+	if(p.x < c->min.x)
-+		r.max.x = c->min.x;
-+	// R
-+	else if(p.x >= c->max.x)
-+		r.min.x = c->max.x;
-+	// M
-+	else{
-+		r.min.x = c->min.x;
-+		//r.max.x = screen->max.x;
-+		// A
-+		if(p.y <= c->min.y)
-+			r.max.y = c->min.y;
-+		// B
-+		else
-+			r.min.y = c->max.y;
- 	}
--	return rectclip(rp, screen->r) &&
--	   rp->max.x-rp->min.x>100 && rp->max.y-rp->min.y>40;
-+	return r;
-+}
-+
-+Rectangle
-+defaultrect(void)
-+{
-+	Rectangle *c;
-+	Rectangle L, M, R;
-+
-+	c = &cmd.l[cmd.front].entire;
-+	L = inflatepoint(Pt(c->min.x - 1, c->min.y));
-+	M = inflatepoint(Pt(c->min.x, c->max.y));
-+	R = inflatepoint(Pt(c->max.x + 1, c->min.y));
-+	if(Dx(L) >= Dx(M) && Dx(L) >= Dx(R))
-+		return L;
-+	else if(Dx(M) > Dx(L) && Dx(M) > Dx(R))
-+		return M;
-+	return R;
-+}
-+
-+int
-+promptrect(Rectangle *r)
-+{
-+	*r = getrect(3, mousectl);
-+	if(eqrect(*r, Rect(0,0,0,0)))
-+		return 0;
-+	if(Dx(*r) < 8*font->width && Dy(*r) < 2*font->height)
-+		*r = inflatepoint(r->min);
-+	if(rectclip(r, screen->r) == 0)
-+		*r = defaultrect();
-+	if(Dx(*r) < 2*FLMARGIN || Dy(*r) < 2*FLMARGIN)
-+		*r = cmd.l[cmd.front].entire;
-+	return 1;
- }
- 
- void
---- a//sys/src/cmd/samterm/menu.c
-+++ b//sys/src/cmd/samterm/menu.c
-@@ -127,6 +127,7 @@
- 	int m, i;
- 	Text *t;
- 
-+	l = which;
- 	mw = -1;
- 	switch(m = menuhit(3, mousectl, &menu3, nil)){
- 	case -1:
-@@ -139,46 +140,29 @@
- 
- 	case Zerox:
- 	case Resize:
--		if(!hostlock){
--			setcursor(mousectl, &bullseye);
--			buttons(Down);
--			if((mousep->buttons&4) && (l = flwhich(mousep->xy)) && getr(&r))
--				duplicate(l, r, l->f.font, m==Resize);
--			else
--				setcursor(mousectl, cursor);
--			buttons(Up);
--		}
-+		if(hostlock || l == nil)
-+			break;
-+		if(promptrect(&r))
-+			duplicate(l, r, l->f.font, m == Resize);
- 		break;
- 
- 	case Close:
--		if(!hostlock){
--			setcursor(mousectl, &bullseye);
--			buttons(Down);
--			if((mousep->buttons&4) && (l = flwhich(mousep->xy)) && !hostlock){
--				t=(Text *)l->user1;
--				if (t->nwin>1)
--					closeup(l);
--				else if(t!=&cmd) {
--					outTs(Tclose, t->tag);
--					setlock();
--				}
--			}
--			setcursor(mousectl, cursor);
--			buttons(Up);
-+		if(hostlock || l == nil)
-+			break;
-+		t=(Text *)l->user1;
-+		if (t->nwin>1)
-+			closeup(l);
-+		else if(t!=&cmd) {
-+			outTs(Tclose, t->tag);
-+			setlock();
- 		}
- 		break;
- 
- 	case Write:
--		if(!hostlock){
--			setcursor(mousectl, &bullseye);
--			buttons(Down);
--			if((mousep->buttons&4) && (l = flwhich(mousep->xy))){
--				outTs(Twrite, ((Text *)l->user1)->tag);
--				setlock();
--			}else
--				setcursor(mousectl, cursor);
--			buttons(Up);
--		}
-+		if(hostlock || l == nil)
-+			break;
-+		outTs(Twrite, ((Text *)l->user1)->tag);
-+		setlock();
- 		break;
- 
- 	default:
-@@ -205,23 +189,27 @@
- 	Rectangle r;
- 	Text *t;
- 
--	if(getr(&r) && (t = malloc(sizeof(Text)))){
--		memset((void*)t, 0, sizeof(Text));
--		current((Flayer *)0);
--		flnew(&t->l[0], gettext, 0, (char *)t);
--		flinit(&t->l[0], r, font, maincols);	/*bnl*/
--		t->nwin = 1;
-+	if((t = mallocz(sizeof(*t), 1)) == nil)
-+		return nil;
-+	if(new)
-+		r = inflatepoint(mousep->xy);
-+	else
-+		r = defaultrect();
-+	if(Dx(r) < 2*FLMARGIN || Dy(r) < 2*FLMARGIN)
-+		r = cmd.l[cmd.front].entire;
-+	current((Flayer *)0);
-+	flnew(&t->l[0], gettext, 0, (char *)t);
-+	flinit(&t->l[0], r, font, maincols);	/*bnl*/
-+	t->nwin = 1;
-+	rinit(&t->rasp);
-+	if(new)
-+		startnewfile(Tstartnewfile, t);
-+	else{
- 		rinit(&t->rasp);
--		if(new)
--			startnewfile(Tstartnewfile, t);
--		else{
--			rinit(&t->rasp);
--			t->tag = tag;
--			startfile(t);
--		}
--		return t;
-+		t->tag = tag;
-+		startfile(t);
- 	}
--	return 0;
-+	return t;
- }
- 
- int
---- a//sys/src/cmd/samterm/samterm.h
-+++ b//sys/src/cmd/samterm/samterm.h
-@@ -118,7 +118,6 @@
- int	center(Flayer*, long);
- int	xmenuhit(int, Menu*);
- void	buttons(int);
--int	getr(Rectangle*);
- void	current(Flayer*);
- void	duplicate(Flayer*, Rectangle, Font*, int);
- void	startfile(Text*);
-@@ -162,6 +161,9 @@
- void	dumperrmsg(int, int, int, int);
- int	screensize(int*,int*);
- void	getmouse(void);
-+Rectangle inflatepoint(Point);
-+Rectangle	defaultrect(void);
-+int	promptrect(Rectangle*);
- 
- #include "mesg.h"
- 
---- a//sys/src/cmd/samterm/scroll.c
-+++ b//sys/src/cmd/samterm/scroll.c
-@@ -111,9 +111,6 @@
- 	int x, y, my, oy, h;
- 	long p0;
- 
--	if(l->visible==None)
--		return;
--
- 	s = l->scroll;
- 	x = s.min.x+FLSCROLLWID/2;
- 	scr = scrpos(l->scroll, l->origin, l->origin+l->f.nchars, tot);
--- a/samterm-mousefocus
+++ /dev/null
@@ -1,17 +1,0 @@
-diff 614f1d6268fd986fc628eec3754bd4599363ad13 uncommitted
---- a/sys/src/cmd/samterm/main.c
-+++ b/sys/src/cmd/samterm/main.c
-@@ -79,6 +79,13 @@
- 				continue;
- 			}
- 			nwhich = flwhich(mousep->xy);
-+			if(nwhich && nwhich!=which){
-+				Point p = mousep->xy;
-+				int b = mousep->buttons;
-+				current(nwhich);
-+				mousep->xy = p;
-+				mousep->buttons = b;
-+			}
- 			scr = which && (ptinrect(mousep->xy, which->scroll) ||
- 				mousep->buttons&(8|16));
- 			if(mousep->buttons)