diff options
| author | cinap_lenrek <cinap_lenrek@centraldogma> | 2011-10-09 23:12:02 +0200 |
|---|---|---|
| committer | cinap_lenrek <cinap_lenrek@centraldogma> | 2011-10-09 23:12:02 +0200 |
| commit | a9e63edad93da6b2af6856e1f8b990c8441164a1 (patch) | |
| tree | f0ba6cc2c129d8bc372aae0795dca12a61310303 | |
| parent | 8e4e1e57303f8eafec8a1ac03670179a39f00b70 (diff) | |
| download | plan9front-a9e63edad93da6b2af6856e1f8b990c8441164a1.tar.xz | |
mothra: insert artificial links to href target for images that are also links in mothmode
| -rw-r--r-- | sys/src/cmd/mothra/mothra.c | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/sys/src/cmd/mothra/mothra.c b/sys/src/cmd/mothra/mothra.c index 039a05aca..5620f3c32 100644 --- a/sys/src/cmd/mothra/mothra.c +++ b/sys/src/cmd/mothra/mothra.c @@ -681,8 +681,11 @@ void dolink(Panel *p, int buttons, Rtext *word){ return; if(mothmode){ seturl(&u, a->image ? a->image : a->link, current->url->fullname); - save(&u, file=urltofile(u.reltext)); - message("saved %s", file); + if(buttons == 1){ + save(&u, file=urltofile(u.reltext)); + message("saved %s", file); + } else if(buttons == 2) + hiturl(buttons, u.reltext, 0); return; } if(a->ismap){ @@ -1035,6 +1038,46 @@ void updtext(Www *w){ plsetpostextview(text, w->yoffs); pldraw(root, screen); } + +void +mothon(Www *w, int on) +{ + Rtext *t, *x; + Action *a, *ap; + + if(current == nil || mothmode == on) + return; + if(mothmode = on) + message("moth mode!"); + else + message(mothra); + /* + * insert or remove artificial links to the href for + * images that are also links + */ + for(t=w->text;t;t=t->next){ + a=t->user; + if(a == nil || a->image == nil || a->link == nil) + continue; + x = t->next; + if(on){ + t->next = nil; + ap=mallocz(sizeof(Action), 1); + ap->link = strdup(a->link); + t->space += 4; + plrtstr(&t->next, 0, 0, t->font, strdup("->"), 1, ap); + t->next->next = x; + } else { + t->space -= 4; + t->next = x->next; + x->next = nil; + freetext(x); + } + } + updtext(w); + donecurs(); +} + Cursor confirmcursor={ 0, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, @@ -1099,11 +1142,7 @@ void hit3(int button, int item){ pldraw(root, screen); break; case 1: - if(mothmode = !mothmode) - message("moth mode!"); - else - message(mothra); - donecurs(); + mothon(current, !mothmode); break; case 2: snarf(cmd); |
