summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2012-09-24 01:08:09 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2012-09-24 01:08:09 +0200
commit01e3e719ed275ee847e121f6a28e478755b15058 (patch)
tree9bdde548f72d3e7467a8eb5ec2fcc4e0baa14431
parenta8a71a36f5f0f8262b76cc04b113312f8c87fc23 (diff)
downloadplan9front-01e3e719ed275ee847e121f6a28e478755b15058.tar.xz
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()
-rw-r--r--sys/src/cmd/mothra/libpanel/entry.c2
-rw-r--r--sys/src/cmd/mothra/libpanel/rtext.c2
-rw-r--r--sys/src/cmd/mothra/mothra.c17
-rw-r--r--sys/src/cmd/mothra/mothra.h1
4 files changed, 12 insertions, 10 deletions
diff --git a/sys/src/cmd/mothra/libpanel/entry.c b/sys/src/cmd/mothra/libpanel/entry.c
index d915e2044..6c0f953d4 100644
--- a/sys/src/cmd/mothra/libpanel/entry.c
+++ b/sys/src/cmd/mothra/libpanel/entry.c
@@ -19,6 +19,8 @@ char *pl_snarfentry(Panel *p){
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;
diff --git a/sys/src/cmd/mothra/libpanel/rtext.c b/sys/src/cmd/mothra/libpanel/rtext.c
index 0fa1bcdc4..00790bb01 100644
--- a/sys/src/cmd/mothra/libpanel/rtext.c
+++ b/sys/src/cmd/mothra/libpanel/rtext.c
@@ -170,7 +170,7 @@ void pl_rtdraw(Image *b, Rectangle r, Rtext *t, int yoffs){
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);
}
diff --git a/sys/src/cmd/mothra/mothra.c b/sys/src/cmd/mothra/mothra.c
index 897cba4eb..17306d550 100644
--- a/sys/src/cmd/mothra/mothra.c
+++ b/sys/src/cmd/mothra/mothra.c
@@ -18,7 +18,6 @@ Panel *root; /* the whole display */
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 @@ void mkpanels(void){
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 @@ void nstrcpy(char *to, char *from, int len){
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 @@ void setcurrent(int index, char *tag){
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 geturl(char *urlname, int post, int plumb, int map){
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 @@ void updtext(Www *w){
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){
diff --git a/sys/src/cmd/mothra/mothra.h b/sys/src/cmd/mothra/mothra.h
index 84d117dbf..2588d99f8 100644
--- a/sys/src/cmd/mothra/mothra.h
+++ b/sys/src/cmd/mothra/mothra.h
@@ -37,6 +37,7 @@ struct Www{
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 */