`cambrian@ [neo][fs][esp8266] / gopher client for the neo6502 h:.c w:.c col:.c row:.c area:.c4 p:.s "":info 0:ap ssid:.C passwd:.C 30k!:BUF 4k!:D 2k!:HBUF 256!:H 1k!:FTXT 1k!:LINKS / holds 16-bit index into BUF offset:.s rf:.f lp:.s li:.c dsz:.s doc:.c dhost:.C 70_:dport dsel:.C dtype:.c dparam:.C 32!:PAGES / holds 16-bit file offsets of each page FILE=1 . ftypes:"4569gI:;%:iconmap icon:'c::t iconmap?(x=t),->[iconmap,]#y;195 XXX:'C,pl~~^{in=13^->^.} hcheck:(~HBUF|.<100->1;~H|.=0)->!HBUF!H hsave:(.HBUF[~H,[dtype,dsel'.,dhost'.,dport,doc]''s]+). retain:dtype=`1->hcheck hsave recall:~H<.''X:(dtype dsel dhost dport doc)"":dparam dsel'.:dsel dhost'.:dhost rtrim:'Cc::cc x#.^{=0->"";[[cc#1,]#,cc#2]=->-1^.;[cc#1,]+.} edit:xy,w-1=.` ps;gotoxy^{in,=13->line rtrim.` ;=27->"";out^.} clr:0 gotoxy.1 plain area clear quit:cls reset cutoff:'Cc,[x#.,y]>->[x,[x#.,y]-]>.;x title:[dhost,":",dport n2d,"/",dsel,"/",[dtype]]+[,w]cutoff header:0 gotoxy.0`BLACK color.`LIGHT_GREY title[,#.-.w=.` ]+ps footer:(.FTXT[0,h-1]gotoxy`DARK_GREY color.`BLACK[doc n2d," ",offset n2d,"/",dsz n2d]+::stat[info,[w-1,stat#.]-]cutoff[,[w-1,[#.,stat#.]+]-=.` ,stat]+ps!!). msg:'C,clr;[#.-.w%2,h%2]gotoxy;["[",,"]"]+ps~~ transmit:!BUF 0:dsz:offset{'s:+dsz footer}tcprecv tail:'C::s#.^{=0->s;[s,]#=`/->[s,]-.;-1^.} fcopy:'C[FILE,,`CRW]fopen[FILE,~BUF,~BUF#.]fwrite wait FILE fclose tcpclose tocache:1:+doc["cache/",doc n2d]+fcopy tofile:dsel tail,["downloading ",," ..."]+:info footer;fcopy retrieve:["17",dtype]=.->`1:dtype tocache;tofile response:reply->(transmit->(full->"buffer full";retrieve"");"timeout");"download error." selector:(dparam#.->[dsel,"\t",dparam,"\r\n"];[dsel,"\r\n"])+ request:"downloading ...":info footer(selector,#.tcpsend->uwrite response;"transaction failed."):info footer tcpclose dl:"connecting ...":info footer FILE fclose[dhost,dport]tcpconnect(->request;(timeout=0->"connection timeout";"connection failed."):info~~)footer acolor:'c,=`0->active;=`1->active;[ftypes,]=.->factive;=`7->sactive mark:'c::d p-1,(lp=0->:lp 1:li d acolor~~;=lp->d acolor~~);[~LINKS,]+ atend=[p,~BUF#.]> . char=[p,~BUF]##1 next:char,1:+p;() . skip:'c[char,]=->1:+p cr:col>w^->nl . nextln:cr 1:+row 1:col upto:'c::d[~BUF=.,p,^{next=d->p-2;^.}]+. fwd:'c,=13->nextln 10 skip;=10->nextln;1:+col,col>w->nextln dtext:next,(>31->out);fwd . skiprest:next=10->nextln;^. ddesc:next,=9^->(out;fwd)(row^.);skiprest dicon:'c icon(out;fwd) dmap:next,=`i->plain ddesc;[=`0,=`1]|->(link;mark;dicon)ddesc;=`3->(error;dicon)ddesc;[ftypes,]=.->(flink;mark;dicon)ddesc;=`7->(slink;mark;dicon)ddesc;=`.->skiprest;(ulink;dicon)ddesc lines:atend^->rf row^. render:'f:rf clr 2:row 1:col 1:p lines show:dtype,=`0->{dtext}render;=`1->!LINKS{dmap}render;["unhandled item type ",[dtype]]+msg dsize:FILE fsize(y->0xffff;x):dsz fpath:dtype=`1->["cache/",doc n2d]+;dsel tail open:[FILE,fpath,`RO]fopen dsize 0:offset read:[FILE,[offset,0]]fseek!BUF[FILE,~BUF,4k]fread lparse:lp:p next:dtype 9 upto 9 upto:dsel 9 upto:dhost 13 upto d2n:dport "":dparam header uport:'Cs::(s p)[s,1,p-1]+.:dhost p+1^{[,s#.]>->[s,p]-.d2n:dport;[s,]#=`/->([s,p+1,-1]+.d2n:dport;[s,-1]-.:dsel)~~;+1^.} uparse:'C::s 70:dport "":dsel`1:dtype 1_^{[,s#.]>->s:dhost;[s,]#=`:->[s,]uport~~;[s,]#=`/->([s,1,-1]+.:dhost;[s,]-.:dsel);+1^.} goto:'c:li~LINKS#.->[links,li]#:lp show home:0:offset!PAGES 0:lp read show footer up:li-1,(->;nlinks)goto . down:li+1([,nlinks]>->1;)goto pgup:~PAGES#.->~PAGES[<,<]*.:offset 0:lp read show footer pgdown:offset+p~PAGES+offset p-1:+offset 0:lp read show footer reopen:open read show footer query:'C,clr 0 gotoxy.1;pl nl edit rparam:dtype=`7->"Enter search string:"query:dparam#.;1 enter:lp->retain lparse rparam(->dl reopen;show) back:~H#.->recall header FILE fclose reopen go:"Enter address (HOST[:PORT][/SELECTOR]):"query(#.->(retain;uparse )dl header reopen) purge:(doc>1->"cache/1"fdelete wait[["cache/",doc n2d]+,"cache/1"]frename)"cache"dopen^{dread,#.->(="1"^->["cache/",]+fdelete~~)0^.}dclose stop:FILE fclose purge plain quit key:'c,=23->up;=19->down;=18->pgup;=6->pgdown;=32->pgdown;=13->enter;=20->home~~;=8->back;=`g->go~~;=27->stop loop:(in,->key~~)!!^. work:"":dhost`1:dtype"":dsel 1:doc open read header show footer loop rdpasswd:"Enter password:"pl edit:passwd,#.>0->"connecting..."pl[ssid,passwd](network->getip;"connection failed"fail);quit rdssid:"Enter SSID or ? for list of access points:"pl edit:ssid,="?"->aplist reply^.;=""->quit;rdpasswd checkap:{'C+.6="+CWJAP"->1:ap}:logreply apinfo reply ap^->{'C pl}:logreply rdssid mk1:[1,"cache/1",`CRW]fopen[1,"iPress `g' to enter URL or ESC to exit.\t\t(none)\t0\r\n"]fwrite check1:[1,"cache/1",`RO]fopen(NeoE->(["create:",NeoE n2d]+XXX) mk1)1 fclose init:icons size:(w h)[0,1,w-1,h-2]:area 0:lp 1:li D"cache"mkdir main:init usetup checkap{}:logreply check1~BUF:nbuf noecho^->"modem not responding"fail;work