?login_element?

Subversion Repositories NedoOS

Rev

Rev 974 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. WORDBUFSIZE=128
  2.  
  3. CBOLD=1
  4. CITALIC=1;0x87;add a,a
  5. CUNDERLINE=1;0x2f;cpl
  6. CSTROKE=1;0xff
  7. CLINK=2
  8. CLINKIMG=4
  9. CMARK=8
  10. ;TODO visited link
  11.  
  12.  
  13.  
  14. loadhtml
  15.         push af ;first char
  16. ;skip spaces and line breaks
  17.         cp 0xef ;hippiman.16mb.com начинается с ef bb bf (UTF-8 BOM)
  18.         jr z,loadhtml_html
  19.         call htmlskipspaces_go
  20.          cp '<'
  21. loadhtml_html
  22.          ld a,1
  23.          jr nz,$+3 ;not html
  24.          xor a ;html
  25.          ld (ispre),a
  26.          ;xor a
  27.          ld (printableflag),a ;header is invisible for html
  28. defaultunicodeflag=$+1
  29.          xor 1 ;ld a,1 ;utf-8 by default for html, windows-1251 for text
  30.          ld (utf8flag),a
  31.         call setdefaultfontweight
  32.  
  33.         xor a
  34.         ld (laststringx),a
  35.         ld h,a
  36.         ld l,a ;0
  37.         ld (laststringy),hl
  38.         ld (curprintvirtualy),hl
  39.  
  40.         dec a
  41.         dec hl
  42.         ld (lastpointer),hl
  43.         ld (lastpointerHSB),a
  44.         ld (last2pointer),hl
  45.         ld (last2pointerHSB),a
  46.         ld (firstpointer),hl
  47.         ld (firstpointerHSB),a
  48.         ld (first2pointer),hl
  49.         ld (first2pointerHSB),a
  50.  
  51.         call initstringbuf1 ;buf2 инициализируется в тэге a/img ;содержит setfontweight
  52.          call rememberhrefyxposition ;иначе ссылки могут записаться с неправильным Y после div
  53.        
  54.         ;ld de,0
  55.         ;call setxymc_stateful
  56.         pop af;ld a,'<' ;already read ;TODO может не там сделали push? по идее надо на '<'?
  57.          ;jr $
  58.         call loadhtml_mainloop_go
  59.          call prcharvirtual_crlf_stateful
  60.          ;ld a,-2
  61.          ;in a,(-2)
  62.          ;rra
  63.          ;jr nc,$
  64.          ;jr $
  65.         call closestream
  66.         jp htmlview ;can exit to browser_go via Enter
  67.        
  68. loadhtml_mainloop_mangledcharq
  69.         call prcharvirtual_stateful
  70. loadhtml_mainloop
  71.         rdbyte
  72. loadhtml_mainloop_go
  73.          ;push af
  74.          ;call prcharvirtual_stateful
  75.          ;pop af
  76.          cp '<'+1
  77.          jp nc,loadhtml_mainloop_mangledcharq ;speedup
  78.         or a
  79.         ret z
  80.         cp '<'
  81.         jr z,loadhtml_mainloop_tag
  82.         cp '&'
  83.         jr z,loadhtml_mainloop_mangledchar
  84.         cp 0x0d
  85.         jr z,loadhtml_checkpremainloop
  86.         cp 0x0a
  87.         jr z,loadhtml_checkpremainloop
  88.         cp ' '
  89.         jr z,loadhtml_checkpremainloop
  90.         cp 0x09
  91.         jr z,loadhtml_checkpremainloop
  92.         jp loadhtml_mainloop_mangledcharq
  93. loadhtml_checkpremainloop
  94. ispre=$+1
  95.         ld b,0        
  96.         djnz loadhtml_spacemainloop
  97.          ;jr $
  98.         jr loadhtml_mainloop_mangledcharq
  99.  
  100. loadhtml_spacemainloop
  101.          ;jr $
  102.         ;call countlinewidth
  103.         ;ld a,h
  104.         ;or l ;а там уже управляющие коды
  105.         ld a,(prcharvirtual_stateful_x)
  106.         or a
  107.         jr z,loadhtml_mainloop
  108.         ld a,' '
  109.         jr loadhtml_mainloop_mangledcharq
  110.  
  111. loadhtml_mainloop_mangledchar
  112. ;read until ;
  113.         ld hl,mangledcharslist
  114.         ld de,wordbuf
  115.         call getword_mangledchar ;hl=terminator/space addr,a=char
  116.         ld hl,mangledcharslist
  117. mangledcharstrcp0
  118.         ld a,(hl) ;decoded char
  119.         inc hl
  120.         or a
  121.         jr z,mangledchar_error
  122.         ld de,wordbuf
  123.         push hl
  124.         call strcp
  125.         pop hl
  126.         jr nz,mangledcharstrcp_fail
  127.         dec hl
  128.         ld a,(hl) ;decoded char
  129.         jp loadhtml_mainloop_mangledcharq
  130. mangledcharstrcp_fail
  131.         ld b,-1 ;чтобы точно найти терминатор
  132.         xor a
  133.         cpir ;найдём обязательно
  134.         jr mangledcharstrcp0
  135. mangledchar_error=loadhtml_mainloop
  136. loadhtml_mainloop_tag
  137.         call RDBYTE;rdbyte
  138.         ld (loadhtml_tagcloser),a
  139.         cp '/'
  140.         jr nz,executetag
  141.         call RDBYTE;rdbyte
  142. executetag
  143.         ld de,wordbuf
  144.         call getword_tag_go ;hl=terminator/space addr,a=char ;first char already read
  145.         ld (executetag_endchar),a
  146.        
  147.         if 1==0
  148.          ld hl,wordbuf
  149. executetag_typetag0
  150.          ld a,(hl)
  151.          or a
  152.          jr z,executetag_typetagq
  153.          inc hl
  154.          push hl
  155.          call prcharvirtual_stateful
  156.          pop hl
  157.          jr executetag_typetag0
  158. executetag_typetagq
  159.         endif
  160.        
  161.         ;cp '>'
  162.         ;call skipspaces
  163.         ;ld (execcmd_pars),hl
  164.         ld hl,tagslist ;list of internal commands
  165. strcpexec0
  166.         ld c,(hl)
  167.         inc hl
  168.         ld b,(hl)
  169.         inc hl
  170.         ld a,b
  171.         cp -1
  172.         jr z,executetag_error ;a!=0: no such internal command
  173.         ld de,wordbuf
  174.         push hl
  175.         call strcp
  176.         pop hl
  177.         jr nz,strcpexec_fail
  178.         ld h,b
  179.         ld l,c
  180. loadhtml_tagcloser=$+1
  181.         ld a,0
  182.         cp '/'
  183.         call jphl ;execute command (Z=closing tag)
  184.  
  185. ;TODO read the rest of the tag?
  186.        
  187.         jp loadhtml_mainloop
  188. jphl
  189.         jp (hl) ;run internal command
  190. strcpexec_fail
  191.         ld b,-1 ;чтобы точно найти терминатор
  192.         xor a
  193.         cpir ;найдём обязательно
  194.         jr strcpexec0
  195.  
  196. executetag_error
  197. ;no such tag
  198.          call skiprestoftag
  199.         jp loadhtml_mainloop
  200.        
  201.        
  202. mangledcharslist
  203.         db "&"
  204.         db "amp",0
  205.         db "<"
  206.         db "lt",0
  207.         db ">"
  208.         db "gt",0
  209.         db " "
  210.         db "nbsp",0
  211.         db 34
  212.         db "quote",0
  213.         db 34
  214.         db "lquote",0
  215.         db 34
  216.         db "rquote",0
  217.  
  218.         db 0 ;end of mangled chars list
  219.  
  220. tagslist
  221.         dw tag_p
  222.         db "p",0
  223.         dw tag_pre
  224.         db "pre",0
  225.         dw tag_code
  226.         db "code",0
  227.         dw tag_div
  228.         db "div",0
  229.         dw tag_ul
  230.         db "ul",0
  231.         dw tag_li
  232.         db "li",0
  233.         dw tag_th
  234.         db "th",0
  235.         dw tag_center
  236.         db "center",0 ;deprecated
  237.         dw tag_h1
  238.         db "h1",0
  239.         dw tag_h2
  240.         db "h2",0
  241.         dw tag_h3
  242.         db "h3",0
  243.         dw tag_h4
  244.         db "h4",0
  245.         dw tag_h5
  246.         db "h5",0
  247.         dw tag_h6
  248.         db "h6",0
  249.         dw tag_ins
  250.         db "ins",0
  251.         dw tag_u
  252.         db "u",0
  253.         dw tag_b
  254.         db "b",0
  255.         dw tag_em
  256.         db "em",0
  257.         dw tag_cite
  258.         db "cite",0
  259.         dw tag_i
  260.         db "i",0
  261.         dw tag_del
  262.         db "del",0
  263.         dw tag_s
  264.         db "s",0
  265.         dw tag_a
  266.         db "a",0
  267.         dw tag_strong
  268.         db "strong",0
  269.         dw tag_img
  270.         db "img",0
  271.         dw tag_html
  272.         db "html",0
  273.         dw tag_head
  274.         db "head",0
  275.         dw tag_meta
  276.         db "meta",0
  277.         dw tag_title
  278.         db "title",0
  279.         dw tag_body
  280.         db "body",0
  281.         dw tag_font
  282.         db "font",0
  283.         dw tag_br
  284.         db "br",0
  285.         dw tag_table
  286.         db "table",0
  287.         dw tag_tbody
  288.         db "tbody",0
  289.         dw tag_tr
  290.         db "tr",0
  291.         dw tag_td
  292.         db "td",0
  293.         dw tag_mark
  294.         db "mark",0
  295.         dw tag_span
  296.         db "span",0
  297.         dw tag_script
  298.         db "script",0
  299.         dw tag_doctype
  300.         db "!doctype",0
  301.         dw tag_COMMENT
  302.         db "!--",0
  303.         dw tag_link
  304.         db "link",0
  305.         dw tag_style
  306.         db "style",0
  307.         dw tag_frameset
  308.         db "frameset",0
  309.         dw tag_frame
  310.         db "frame",0
  311.         dw tag_iframe
  312.         db "iframe",0
  313.         dw tag_label
  314.         db "label",0
  315.         dw tag_form
  316.         db "form",0
  317.         dw tag_input
  318.         db "input",0
  319.         dw tag_dl ;forum.nedopc.com
  320.         db "dl",0
  321.         dw tag_dd ;forum.nedopc.com
  322.         db "dd",0
  323.         dw tag_dt ;forum.nedopc.com
  324.         db "dt",0
  325.        
  326.         dw -1 ;end of tags list
  327.        
  328. ;Z=closing tag
  329.  
  330. tag_label
  331. ;<label for="searchInput">Поиск</label>
  332. ;TODO
  333.         jp skiprestoftag
  334.  
  335. tag_form
  336. tag_input
  337. ;<form action="http://speccy.info/w/index.php" id="searchform">
  338. ;<input type="hidden" name="title" value="Служебная:Поиск">
  339. ;<input type="search" name="search" placeholder="Поиск" title="Искать в SpeccyWiki [shift-esc-f]" accesskey="f" id="searchInput" autocomplete="off">
  340. ;<input type="submit" name="go" value="Перейти" title="Перейти к странице, имеющей в точности такое название" id="searchGoButton" class="searchButton">&nbsp;
  341. ;<input type="submit" name="fulltext" value="Найти" title="Найти страницы, содержащие указанный текст" id="mw-searchButton" class="searchButton">
  342. ;</form>
  343. ;TODO
  344.         jp skiprestoftag
  345.        
  346. tag_code
  347. tag_pre
  348.         push af ;z/nz
  349.         call prcharvirtual_crlf_stateful ;opening&closing
  350.         call htmlinitbody ;zxdn реклама в plain text
  351.         pop af ;z/nz
  352.         ld hl,ispre
  353.         ld a,1
  354.         jr tag_u_b_i
  355.  
  356. tag_center
  357. ;TODO test
  358.         ld hl,iscentered
  359.         ld a,1
  360.         jr tag_u_b_i
  361.  
  362. tag_h1
  363. tag_h2
  364. tag_h3
  365. tag_h4
  366. tag_h5
  367. tag_h6
  368.         jr z,tag_hclose
  369.         ld a,1
  370.         ld (iscentered),a
  371.         jr tag_b
  372. tag_hclose
  373.         call prcharvirtual_crlf_stateful
  374.         ;xor a
  375.         ;ld (iscentered),a
  376.         jr tag_u_b_iq
  377.  
  378. tag_mark
  379.         ld hl,curmark
  380.         ld a,CMARK
  381.         jr tag_u_b_i
  382.        
  383. tag_del
  384. tag_s
  385.         ld hl,curstroke
  386.         ld a,CSTROKE
  387.         jr tag_u_b_i
  388. tag_ins
  389. tag_u
  390.         ld hl,curunderline
  391.         ld a,CUNDERLINE
  392.         jr tag_u_b_i
  393. tag_th ;table header: TODO also center in cell
  394. tag_b
  395. tag_strong
  396.         ld hl,curbold
  397.         ld a,CBOLD
  398.         jr tag_u_b_i
  399. tag_em
  400. tag_cite
  401. tag_i
  402.         ld hl,curitalic
  403.         ld a,CITALIC
  404. tag_u_b_i
  405.         ld (hl),0
  406.         jr z,$+3 ;Z=closing tag
  407.         ld (hl),a
  408. tag_u_b_iq
  409.         call setfontweight
  410.         jp skiprestoftag
  411.        
  412. tag_ul ;list
  413.        jp nz,skiprestoftag ;opening (li does newline)
  414. tag_dd ;на lib.ru это перевод строки
  415. tag_p
  416. tag_div
  417.         call prcharvirtual_crlf_stateful
  418.         jp skiprestoftag
  419. tag_br
  420.         ld (last_crlf_flag),a
  421.         call prcharvirtual_crlf_stateful
  422.         jp skiprestoftag
  423. tag_tr
  424. ;only closing tr works as crlf
  425.         call z,prcharvirtual_crlf_stateful
  426.         jp skiprestoftag
  427. tag_td
  428. ;only closing td works as tab
  429.         call z,prcharvirtual_tab_stateful
  430.         jp skiprestoftag
  431.  
  432. tag_head
  433. ;TODO read all tags inside (meta, title)
  434.         jp skiprestoftag
  435.  
  436. tag_iframe
  437. tag_frame
  438. ;TODO find src="..." (now we find last param)
  439.         ;jr $
  440.         call htmlskipspaces
  441. tag_frame0
  442.         ;ld a,(prcharvirtual_stateful_x)
  443.         ;jr $
  444.        
  445.         ld a,(executetag_endchar)
  446.         call htmlskipspaces_go
  447.         ld de,wordbuf
  448.         call getword_param_go ;в параметре могут быть закавыченные пробелы!
  449.         ld (executetag_endchar),a
  450.         or a
  451.         ret z
  452.         ld hl,(wordbuf)
  453.         ld de,0x7273 ;check src attribute
  454.         sbc hl,de
  455.         jr nz,.no_src_attr
  456.        
  457.         ld a,CLINKIMG
  458.         ld (curlinkimg),a
  459.         call setfontweight
  460.          call rememberhrefyxposition
  461.         call initstringbuf2
  462.         ld a,'['
  463.         call prcharvirtual_stateful
  464. ;read link to stringbuf2 until doublequote
  465. ;print it
  466.         ld hl,wordbuf+5 ;after src="
  467. .tag_frame_typetag0
  468.          ld a,(hl)
  469.          or a
  470.          jp z,.no_src_attr
  471.          cp 34
  472.          jp z,.no_src_attr
  473.           cp "'"
  474.           jp z,.no_src_attr
  475.          inc hl
  476.          push hl
  477.          push af
  478.          call prcharvirtual_stateful
  479.          pop af
  480.         call printtostringbuf2
  481.          pop hl
  482.          jr .tag_frame_typetag0
  483.        
  484. .no_src_attr
  485.         ld a,(iy+0)
  486.         cp '>'
  487.         jr nz,tag_frame0
  488.         jp tag_frame_typetagq
  489.  
  490. inithref
  491.         display "inithref=",inithref
  492.          ld a,(curlink)
  493.          or a
  494.          call nz,savestringbuf2 ;если img внутри a
  495.         call initstringbuf2
  496.         ;ld a,CLINK
  497.         ;ld (curlink),a
  498.         call setfontweight
  499.          jp rememberhrefyxposition
  500.          
  501. tag_img
  502.         jp z,skiprestoftag ;Z=closing tag (does nothing)
  503.         ;jr $
  504.         call htmlskipspaces
  505. tag_img_readsrc
  506.         call htmlskipspaces_go
  507.         ld hl,tsrc
  508.         call eatgivenword_go
  509.         ;jr nz,tag_img_srcfail
  510.        
  511.         jr z,tag_img_srcq
  512. tag_img_srcfail
  513.         call htmlskipparam
  514.           or a
  515.           ret z
  516.          cp '>'
  517.         jr nz,tag_img_readsrc
  518.         jr tag_img_opening_readaltq
  519. tag_img_srcq
  520.        
  521.         ;ld hl,tsrc
  522.         ;call eatgivenword_go
  523.         ;jr nz,tag_img_opening_fail
  524. ;read link to stringbuf2 until doublequote
  525.         ld a,CLINKIMG
  526.         ld (curlinkimg),a
  527.         call inithref
  528.        
  529.         call RDBYTE;rdbyte
  530.          cp "'"
  531.          jr z,tag_img_opening_read0
  532.         cp 34
  533.         jr nz,tag_img_opening_read_go
  534.  
  535. tag_img_opening_read0
  536.         call RDBYTE;rdbyte
  537. tag_img_opening_read_go
  538.         or a
  539.         ret z
  540.         cp 34
  541.         jr z,tag_img_opening_readq
  542.          cp "'"
  543.          jr z,tag_img_opening_readq
  544.           cp " "
  545.           jr z,tag_img_opening_readq
  546.          ;push af
  547.          ;call prcharvirtual_stateful
  548.          ;pop af
  549.         call printtostringbuf2
  550.         jr tag_img_opening_read0
  551. tag_img_opening_readq
  552. tag_img_opening_fail
  553. ;a=last char read=quote
  554.          ;jr $
  555.         call htmlskipspaces
  556.         push af
  557.         ld a,'['
  558.         call prcharvirtual_stateful
  559.         pop af
  560. tag_img_opening_readalt
  561. ;a=last char read
  562.         call htmlskipspaces_go
  563.         ld hl,talt
  564.         call eatgivenword_go
  565.         jr nz,tag_img_opening_altfail
  566.        
  567.         call RDBYTE;rdbyte
  568.          cp "'"
  569.          jr z,tag_img_opening_readalt0
  570.         cp 34
  571.         jr nz,tag_img_opening_readalt_go
  572.  
  573. tag_img_opening_readalt0
  574.         call RDBYTE;rdbyte
  575. tag_img_opening_readalt_go
  576.         or a
  577.         ret z
  578.         cp 34
  579.         jr z,tag_img_opening_readaltq
  580.          cp "'"
  581.          jr z,tag_img_opening_readaltq
  582. ;TODO mangled symbols
  583.         call prcharvirtual_stateful
  584.         jr tag_img_opening_readalt0
  585. tag_img_opening_altfail
  586. ;find alt in next parameters
  587.         call htmlskipparam
  588.           or a
  589.           ret z
  590.          cp '>'
  591.         jr nz,tag_img_opening_readalt
  592. tag_img_opening_readaltq
  593.          ld (executetag_endchar),a
  594. tag_frame_typetagq ;TODO почему выше съедает первый фрейм atmturbo?
  595.         ld a,']'
  596.         call prcharvirtual_stateful
  597.         xor a
  598.         ld (curlinkimg),a
  599.         jr closehrefq
  600.         ;call prcharvirtual_stateful
  601.         ;call savestringbuf2 ;after printing ']' to count full size
  602.         ;xor a
  603.         ;ld (curlink),a
  604.         ;call setfontweight
  605.         ;jp skiprestoftag
  606.  
  607. tag_a
  608.         jr nz,tag_a_opening
  609.         ld a,'}'
  610.         call prcharvirtual_stateful
  611.         xor a
  612.         ld (curlink),a
  613. closehrefq
  614.         call savestringbuf2 ;after printing '}' to count full size
  615.         ;xor a
  616.         ;ld (curlink),a
  617.         call setfontweight
  618.         jp skiprestoftag
  619. tag_a_opening
  620.          ;jr $
  621.         call htmlskipspaces
  622. tag_a_opening_readhref
  623.         call htmlskipspaces_go
  624.         ld hl,thref
  625.         call eatgivenword_go
  626.         jr nz,tag_a_opening_hreffail
  627.  
  628.         ld a,CLINK
  629.         ld (curlink),a
  630.         call inithref
  631.        
  632.         ;zxdn: no quotes in href
  633.         call RDBYTE;rdbyte
  634.          cp "'"
  635.          jr z,tag_a_opening_read0
  636.         cp 34
  637.         jr nz,tag_a_opening_read_go
  638.  
  639. ;read link to stringbuf2 until doublequote
  640. tag_a_opening_read0
  641.         call RDBYTE;rdbyte
  642. tag_a_opening_read_go
  643.         or a
  644.         ret z
  645.         cp '>'
  646.         jr z,tag_a_opening_readq
  647.         cp 34
  648.         jr z,tag_a_opening_readq
  649.          cp "'"
  650.          jr z,tag_a_opening_readq
  651.         cp 0x0d
  652.         jr z,tag_a_opening_read0 ;lib.ru
  653.         cp 0x0a
  654.         jr z,tag_a_opening_read0 ;lib.ru
  655.          if 1==0
  656.          cp '&'
  657.          jr nz,tag_a_opening_read0ok
  658.         call printtostringbuf2
  659. ;TODO проверить &amp; (forum.nedopc.com)
  660.         call RDBYTE;rdbyte
  661.          cp 'a'
  662.          jr nz,tag_a_opening_read0ok
  663.         call RDBYTE;rdbyte
  664.         call RDBYTE;rdbyte
  665.         call RDBYTE;rdbyte        
  666.         jr tag_a_opening_read0
  667. tag_a_opening_read0ok
  668.          endif
  669.          ;push af
  670.          ;call prcharvirtual_stateful ;debug print
  671.          ;pop af
  672.         call printtostringbuf2
  673.         jr tag_a_opening_read0
  674. tag_a_opening_hreffail
  675. ;find href in next parameters
  676.         call htmlskipparam
  677.           or a
  678.           ret z
  679.          cp '>'
  680.         jr nz,tag_a_opening_readhref
  681. tag_a_opening_readq
  682.          ld (executetag_endchar),a
  683. tag_a_opening_fail
  684.         ld a,'{'
  685.         call prcharvirtual_stateful
  686.         jp skiprestoftag
  687.  
  688.  
  689. ;skip until space/>/"/EOF
  690. ;if ", skip until another ", then skip space/>
  691. ;a=last char read
  692. ;out: a=last char (space/>/")
  693. htmlskipparam0
  694.         call RDBYTE;rdbyte
  695. htmlskipparam
  696.         or a
  697.         ret z
  698.         cp ' '
  699.         ret z
  700.         cp '>'
  701.         ret z
  702.         cp 34
  703.         jr nz,htmlskipparam0
  704. htmlskipparamquote0
  705.         call RDBYTE;rdbyte
  706.         or a
  707.         ret z
  708.         cp 34
  709.         jr nz,htmlskipparamquote0
  710.         jp RDBYTE;rdbyte ;skip space/>        
  711.  
  712. eatgivenword
  713. ;hl=word (asciiz)
  714. ;out: Z=OK (or else a=last char read)
  715. eatgivenword0
  716.         ld a,(hl)
  717.         or a
  718.         ret z
  719.         call RDBYTE;rdbyte
  720.         ;ld (executetag_endchar),a
  721. eatgivenword_go
  722.          or 0x20
  723.         cp (hl)
  724.         inc hl
  725.         jr z,eatgivenword0
  726.         ld (executetag_endchar),a
  727.         ret ;fail
  728.  
  729. getword_tag
  730. ;hl=string
  731. ;de=wordbuf
  732. ;out: hl=terminator/space/> addr, a=terminator/space/> char
  733. ;TODO проверять переполнение WORDBUFSIZE
  734. getword_tag0
  735.         call RDBYTE;rdbyte
  736. getword_tag_go
  737.         or a
  738.         jr z,getword_tagq
  739.         cp ' '
  740.         jr z,getword_tagq
  741.         cp '>'
  742.         jr z,getword_tagq
  743.          or 0x20
  744.         ld (de),a
  745.         inc de
  746.         jr getword_tag0
  747. getword_tagq
  748.         push af
  749.         xor a
  750.         ld (de),a
  751.         pop af
  752.         ret
  753.  
  754.  
  755. getword_mangledchar
  756. ;hl=string
  757. ;de=wordbuf
  758. ;out: hl=terminator/space/; addr, a=terminator/space/; char
  759. ;TODO проверять переполнение WORDBUFSIZE
  760. getword_mangledchar0
  761.         call RDBYTE;rdbyte
  762.         ;or a
  763.         ;jr z,getword_mangledcharq
  764.          cp "A"
  765.          jr c,getword_mangledcharq
  766.         ;cp ';'
  767.         ;jr z,getword_mangledcharq
  768.         ;cp '#'
  769.         ;jr z,getword_mangledcharq ;lib.ru &#97&#102&#114&#97&#110&#105&#117&#115&#64&#110&#101&#119&#109&#97&#105&#108&#46&#114&#117
  770.         ld (de),a
  771.         inc de
  772.         jr getword_mangledchar0
  773. getword_mangledcharq
  774.         push af
  775.         xor a
  776.         ld (de),a
  777.         pop af
  778.         ret
  779.  
  780. ;getword_param
  781. ;hl=string
  782. ;de=wordbuf
  783. ;out: hl=terminator/space/; addr, a=terminator/space/; char
  784. ;TODO проверять переполнение WORDBUFSIZE
  785. getword_param0
  786.         call RDBYTE;rdbyte
  787. getword_param_go ;в параметре могут быть закавыченные пробелы!
  788.         or a
  789.         jr z,getword_paramq
  790.          cp "'"
  791.          jr z,getword_paramquote
  792.          cp 34
  793.          jr z,getword_paramquote
  794.         cp ' '
  795.         jr z,getword_paramspaceq
  796.         ;cp ';'
  797.         ;jr z,getword_paramcharq
  798.         ;cp '#'
  799.         ;jr z,getword_paramcharq ;lib.ru &#97&#102&#114&#97&#110&#105&#117&#115&#64&#110&#101&#119&#109&#97&#105&#108&#46&#114&#117
  800.         cp '>'
  801.         jr z,getword_paramq
  802. getword_param0ok
  803.          or 0x20
  804.         ld (de),a
  805.         inc de
  806.         jr getword_param0
  807. getword_paramquote
  808.         ld c,a
  809. getword_paramquote0
  810.         ld (de),a
  811.         inc de
  812.         call RDBYTE;rdbyte
  813.         cp c
  814.         jr nz,getword_paramquote0 ;TODO а если она никогда не закроетсЯ???
  815.         jr getword_param0ok
  816. getword_paramspaceq
  817. ;или тут проверЯть, в кавычках ли мы?
  818. getword_paramq
  819.         push af
  820.         xor a
  821.         ld (de),a
  822.         pop af
  823.         ret
  824.  
  825.  
  826.        
  827. strcp
  828. ;hl=s1
  829. ;de=s2
  830. ;out: Z (equal, hl=terminator of s1+1, de=terminator of s2+1), NZ (not equal, hl=erroraddr in s1, de=erroraddr in s2)
  831. strcp0.
  832.         ld a,[de] ;s2
  833.         cp [hl] ;s1
  834.         ret nz
  835.         inc hl
  836.         inc de
  837.         or a
  838.         jr nz,strcp0.
  839.         ret ;z
  840.  
  841. strcp_tillde0
  842. ;hl=s1
  843. ;de=s2
  844. ;out: Z (equal, hl=terminator of s1+1, de=terminator of s2+1), NZ (not equal, hl=erroraddr in s1, de=erroraddr in s2)
  845. strcp_tillde0_0.
  846.         ld a,[de] ;s2
  847.         or a
  848.         ret z
  849.         cp [hl] ;s1
  850.         ret nz
  851.         inc hl
  852.         inc de
  853.         jr strcp_tillde0_0.
  854.  
  855.        
  856. thref
  857.         db "href=",0
  858. tsrc
  859.         db "src=",0
  860. talt
  861.         db "alt=",0
  862.        
  863. rememberhrefyxposition
  864.         ld a,(prcharvirtual_stateful_x) ;для центрированных получается неправильно! на этом этапе экранный x ещё не известен!
  865.         ld (hrefxposition),a
  866.         ld hl,(curprintvirtualy)
  867.         ld (hrefyposition),hl
  868.         ret
  869.  
  870. tag_title
  871. ;not used, because header is skipped (TODO)
  872.         ;jp z,tag_titleclose
  873.         jp nz,tag_h1 ;open
  874. ;tag_titleclose
  875.          ;ld a,1
  876.          ;ld (utf8flag),a ;нельзя, т.к. title после charset
  877.         call prcharvirtual_crlf_stateful ;</title> forces newline
  878.         xor a ;z
  879.         jp tag_h1
  880.         display "tag_li ",tag_li
  881. tag_li ;list line (no closing tag)? но на msn.com куча <li ><a...>...</a></li>
  882.         push af
  883.         call prcharvirtual_crlf_stateful
  884.         pop af
  885.         jp z,skiprestoftag ;closing
  886.         ld a,'*';'-';'*' ;TODO с учётом UTF8
  887.         call prcharvirtual_stateful
  888.         ld a,' '
  889.         call prcharvirtual_stateful
  890.         jp skiprestoftag
  891.  
  892. tag_meta
  893. ;TODO find "charset=UTF-8" or "charset=windows-1251"
  894. tag_meta0
  895.         ld b,a
  896.         push bc
  897.         call RDBYTE;rdbyte
  898.         pop bc
  899.         or a
  900.         ret z
  901.         cp '>'
  902.         jp z,skiprestoftag0
  903.         or 0x20
  904.         cp 'w'
  905.         jr nz,tag_meta0
  906.         ld a,b
  907.         cp '='
  908.          ld a,'w'
  909.          jr nz,tag_meta0
  910.          xor a;ld a,0
  911.          ld (utf8flag),a
  912.         jp skiprestoftag_go
  913.  
  914. tag_style
  915. tag_script
  916. ;TODO skip until </script>
  917. tag_script0
  918.         ld b,a
  919.         push bc
  920.         call RDBYTE;rdbyte
  921.         pop bc
  922.         or a
  923.         ret z
  924.         cp '/'
  925.         jr nz,tag_script0
  926.         ld a,b
  927.         cp '<'
  928.          ld a,'/'
  929.         jr nz,tag_script0
  930.         jp skiprestoftag_go
  931.  
  932. htmlskipspaces
  933. htmlskipspaces0
  934.         call RDBYTE;rdbyte
  935. htmlskipspaces_go
  936.         cp ' '
  937.         jr z,htmlskipspaces0
  938.         cp 0x0d
  939.         jr z,htmlskipspaces0
  940.         cp 0x0a
  941.         jr z,htmlskipspaces0
  942.         ld (executetag_endchar),a
  943.         ret
  944.  
  945. tag_COMMENT
  946.         call RDBYTE
  947.         or a
  948.         ret z
  949.         cp '-'
  950.         jr nz,tag_COMMENT
  951.         call RDBYTE
  952.         or a
  953.         ret z
  954.         cp '-'
  955.         jr nz,tag_COMMENT
  956.         call RDBYTE
  957.         or a
  958.         ret z
  959.         cp '>'
  960.         jr nz,tag_COMMENT
  961.         ret
  962.        
  963. tag_font
  964. ;TODO push old font/pop old font
  965.  
  966. tag_link
  967. ;TODO find href
  968.  
  969. tag_dl
  970. tag_dt
  971. tag_doctype
  972. tag_span
  973. tag_html
  974. ;tag_ul      ;перенос не нужен, так как далее li
  975. tag_table   ;перенос не нужен, так как далее tr
  976. tag_tbody
  977.         jp skiprestoftag
  978.  
  979. tag_frameset ;before body
  980. tag_body
  981.         call htmlinitbody
  982.         jp skiprestoftag
  983.  
  984. htmlinitbody
  985.          xor a
  986.          ld (iscentered),a
  987.          inc a ;ld a,1
  988.          ld (printableflag),a
  989. ;эти манипуляции затрут уже напечатанные фреймы:
  990.          ;call prcharvirtual_x0
  991.          call setdefaultfontweight
  992.          jp setfontweight;call initstringbuf1 ;без этого не пишет коды установки цвета
  993.        
  994. skiprestoftag
  995. ;we can be at >/space/EOF (in executetag_endchar)
  996. executetag_endchar=$+1
  997.         ld a,0
  998. skiprestoftag0
  999.         cp '>'
  1000.         ret z
  1001. skiprestoftag_go
  1002.         call RDBYTE;rdbyte
  1003.         or a
  1004.         ret z
  1005.         jr skiprestoftag0
  1006.  
  1007.        
  1008. wordbuf
  1009.         ds WORDBUFSIZE
  1010.