ref: a7768bd61fc9cddd7648b672a3150dc0fd8d186d
parent: e02b84087e8151cc221127dc04abfc08132d9093
author: cinap_lenrek <cinap_lenrek@centraldogma>
date: Thu Oct 13 14:15:55 EDT 2011
mothra: have to jump to fragment link after page is rendered to get correct yoff
--- a/sys/src/cmd/mothra/mothra.c
+++ b/sys/src/cmd/mothra/mothra.c
@@ -248,6 +248,8 @@
esetcursor(current->alldone ? 0 : &readingcurs);
}
+void scrollto(char *tag);
+
void main(int argc, char *argv[]){
Event e;
enum { Eplumb = 128 };
@@ -333,6 +335,8 @@
if(mouse.buttons==0 && current){
if(current->finished){
updtext(current);
+ if(current->url->tag[0])
+ scrollto(current->url->tag);
current->finished=0;
current->changed=0;
current->alldone=1;
@@ -766,10 +770,6 @@
switch(rfork(RFFDG|RFPROC|RFNOWAIT|RFMEM)){
case -1:
message("Can't fork, please wait");
- if(type==HTML)
- plrdhtml(w->url->fullname, fd, w);
- else
- plrdplain(w->url->fullname, fd, w);
break;
case 0:
if(type==HTML)
@@ -801,27 +801,6 @@
plrtfree(tt);
}
-int readstr(char *buf, int nbuf, char *base, char *name)
-{
- char path[128];
- int n, fd;
-
- snprint(path, sizeof path, "%s/%s", base, name);
- if((fd = open(path, OREAD)) < 0){
- ErrOut:
- memset(buf, 0, nbuf);
- return 0;
- }
- n = read(fd, buf, nbuf-1);
- close(fd);
- if(n <= 0){
- close(fd);
- goto ErrOut;
- }
- buf[n] = 0;
- return n;
-}
-
int fileurlopen(Url *url){
char *rel, *base, *x;
int fd;
@@ -856,6 +835,21 @@
return fd;
}
+int readstr(char *buf, int nbuf, char *base, char *name){
+ char path[128];
+ int n, fd;
+
+ n = 0;
+ snprint(path, sizeof path, "%s/%s", base, name);
+ if((fd = open(path, OREAD)) >= 0){
+ if((n = read(fd, buf, nbuf-1)) < 0)
+ n = 0;
+ close(fd);
+ }
+ buf[n] = 0;
+ return n;
+}
+
int urlopen(Url *url, int method, char *body){
int conn, ctlfd, fd, n;
char buf[1024+1], *p;
@@ -865,7 +859,6 @@
if(method == GET)
if((fd = fileurlopen(url)) >= 0)
return fd;
-
snprint(buf, sizeof buf, "%s/clone", mtpt);
if((ctlfd = open(buf, ORDWR)) < 0)
return -1;
@@ -875,7 +868,6 @@
}
buf[n] = 0;
conn = atoi(buf);
-
if(url->basename[0]){
n = snprint(buf, sizeof buf, "baseurl %s", url->basename);
write(ctlfd, buf, n);
@@ -886,7 +878,6 @@
close(ctlfd);
return -1;
}
-
if(method == POST && body){
snprint(buf, sizeof buf, "%s/%d/postbody", mtpt, conn);
if((fd = open(buf, OWRITE)) < 0)
@@ -898,11 +889,9 @@
}
close(fd);
}
-
snprint(buf, sizeof buf, "%s/%d/body", mtpt, conn);
if((fd = open(buf, OREAD)) < 0)
goto ErrOut;
-
snprint(buf, sizeof buf, "%s/%d/parsed", mtpt, conn);
readstr(url->fullname, sizeof(url->fullname), buf, "url");
readstr(url->tag, sizeof(url->tag), buf, "fragment");