shithub: riscv

Download patch

ref: 01e3e719ed275ee847e121f6a28e478755b15058
parent: a8a71a36f5f0f8262b76cc04b113312f8c87fc23
author: cinap_lenrek <[email protected]>
date: Sun Sep 23 21:08:09 EDT 2012

mothra: various improvements

* disallow snarf on password entries
* remove current title label as it is displayed in the page list (redundant)
* avoid redrawing page list just to update the title
* check if the chan changed for backup bitmap in pl_rtdraw()

--- a/sys/src/cmd/mothra/libpanel/entry.c
+++ b/sys/src/cmd/mothra/libpanel/entry.c
@@ -19,6 +19,8 @@
 	Entry *ep;
 	int n;
 
+	if(p->flags&USERFL)	/* no snarfing from password entry */
+		return nil;
 	ep=p->data;
 	n=ep->entp-ep->entry;
 	if(n<=0) return nil;
--- a/sys/src/cmd/mothra/libpanel/rtext.c
+++ b/sys/src/cmd/mothra/libpanel/rtext.c
@@ -170,7 +170,7 @@
 	Image *bb;
 
 	bb = b;
-	if(backup==0 || rectinrect(r, backup->r)==0){
+	if(backup==0 || backup->chan!=b->chan || rectinrect(r, backup->r)==0){
 		freeimage(backup);
 		backup=allocimage(display, bb->r, bb->chan, 0, DNofill);
 	}
--- a/sys/src/cmd/mothra/mothra.c
+++ b/sys/src/cmd/mothra/mothra.c
@@ -18,7 +18,6 @@
 Panel *alt;	/* the alternate display */
 Panel *alttext;	/* the alternate text window */
 Panel *cmd;	/* command entry */
-Panel *curttl;	/* label giving the title of the visible text */
 Panel *cururl;	/* label giving the url of the visible text */
 Panel *list;	/* list of previously acquired www pages */
 Panel *msg;	/* message display */
@@ -172,10 +171,6 @@
 			list=pllist(p, PACKN|FILLX, genwww, 8, doprev);
 			plscroll(list, 0, bar);
 		p=plgroup(root, PACKN|FILLX);
-			pllabel(p, PACKW, "Title:");
-			curttl=pllabel(p, PACKE|EXPAND, "---");
-			plplacelabel(curttl, PLACEW);
-		p=plgroup(root, PACKN|FILLX);
 			pllabel(p, PACKW, "Url:");
 			cururl=pllabel(p, PACKE|EXPAND, "---");
 			plplacelabel(cururl, PLACEW);
@@ -482,12 +477,16 @@
 
 char *genwww(Panel *, int index){
 	static char buf[1024];
+	Www *w;
 	int i;
 
 	if(index >= nwww())
 		return 0;
 	i = wwwtop-index-1;
-	snprint(buf, sizeof(buf), "%2d %s", i+1, www(i)->title);
+	w = www(i);
+	if(w->title[0]!='\0')
+		w->gottitle=1;
+	snprint(buf, sizeof(buf), "%2d %s", i+1, w->title);
 	return buf;
 }
 
@@ -520,8 +519,6 @@
 	if(current)
 		current->yoffs=plgetpostextview(text);
 	current=new;
-	plinitlabel(curttl, PACKE|EXPAND, current->title);
-	if(defdisplay) pldraw(curttl, screen);
 	plinitlabel(cururl, PACKE|EXPAND, current->url->fullname);
 	if(defdisplay) pldraw(cururl, screen);
 	plinittextview(text, PACKE|EXPAND, Pt(0, 0), current->text, dolink);
@@ -944,6 +941,8 @@
 void updtext(Www *w){
 	Rtext *t;
 	Action *a;
+	if(defdisplay && w->gottitle==0 && w->title[0]!='\0')
+		pldraw(list, screen);
 	for(t=w->text;t;t=t->next){
 		a=t->user;
 		if(a){
@@ -957,7 +956,7 @@
 	w->yoffs=plgetpostextview(text);
 	plinittextview(text, PACKE|EXPAND, Pt(0, 0), w->text, dolink);
 	plsetpostextview(text, w->yoffs);
-	pldraw(root, screen);
+	pldraw(text, screen);
 }
 
 void finish(Www *w){
--- a/sys/src/cmd/mothra/mothra.h
+++ b/sys/src/cmd/mothra/mothra.h
@@ -37,6 +37,7 @@
 	char title[NTITLE];
 	Rtext *text;
 	int yoffs;
+	int gottitle;		/* title got drawn */
 	int changed;		/* reader sets this every time it updates page */
 	int finished;		/* reader sets this when done */
 	int alldone;		/* page will not change further -- used to adjust cursor */