?login_element?

Subversion Repositories NedoOS

Rev

Rev 975 | 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.          ld a,(curlink)
  492.          or a
  493.          call nz,savestringbuf2 ;если img внутри a
  494.         call initstringbuf2
  495.         ;ld a,CLINK
  496.         ;ld (curlink),a
  497.         call setfontweight
  498.          jp rememberhrefyxposition
  499.          
  500. tag_img
  501.         jp z,skiprestoftag ;Z=closing tag (does nothing)
  502.         ;jr $
  503.         call htmlskipspaces
  504. tag_img_readsrc
  505.         call htmlskipspaces_go
  506.         ld hl,tsrc
  507.         call eatgivenword_go
  508.         ;jr nz,tag_img_srcfail
  509.        
  510.         jr z,tag_img_srcq
  511. tag_img_srcfail
  512.         call htmlskipparam
  513.           or a
  514.           ret z
  515.          cp '>'
  516.         jr nz,tag_img_readsrc
  517.         jr tag_img_opening_readaltq
  518. tag_img_srcq
  519.        
  520.         ;ld hl,tsrc
  521.         ;call eatgivenword_go
  522.         ;jr nz,tag_img_opening_fail
  523. ;read link to stringbuf2 until doublequote
  524.         ld a,CLINKIMG
  525.         ld (curlinkimg),a
  526.         call inithref
  527.        
  528.         call RDBYTE;rdbyte
  529.          cp "'"
  530.          jr z,tag_img_opening_read0
  531.         cp 34
  532.         jr nz,tag_img_opening_read_go
  533.  
  534. tag_img_opening_read0
  535.         call RDBYTE;rdbyte
  536. tag_img_opening_read_go
  537.         or a
  538.         ret z
  539.         cp 34
  540.         jr z,tag_img_opening_readq
  541.          cp "'"
  542.          jr z,tag_img_opening_readq
  543.           cp " "
  544.           jr z,tag_img_opening_readq
  545.          ;push af
  546.          ;call prcharvirtual_stateful
  547.          ;pop af
  548.         call printtostringbuf2
  549.         jr tag_img_opening_read0
  550. tag_img_opening_readq
  551. tag_img_opening_fail
  552. ;a=last char read=quote
  553.          ;jr $
  554.         call htmlskipspaces
  555.         push af
  556.         ld a,'['
  557.         call prcharvirtual_stateful
  558.         pop af
  559. tag_img_opening_readalt
  560. ;a=last char read
  561.         call htmlskipspaces_go
  562.         ld hl,talt
  563.         call eatgivenword_go
  564.         jr nz,tag_img_opening_altfail
  565.        
  566.         call RDBYTE;rdbyte
  567.          cp "'"
  568.          jr z,tag_img_opening_readalt0
  569.         cp 34
  570.         jr nz,tag_img_opening_readalt_go
  571.  
  572. tag_img_opening_readalt0
  573.         call RDBYTE;rdbyte
  574. tag_img_opening_readalt_go
  575.         or a
  576.         ret z
  577.         cp 34
  578.         jr z,tag_img_opening_readaltq
  579.          cp "'"
  580.          jr z,tag_img_opening_readaltq
  581. ;TODO mangled symbols
  582.         call prcharvirtual_stateful
  583.         jr tag_img_opening_readalt0
  584. tag_img_opening_altfail
  585. ;find alt in next parameters
  586.         call htmlskipparam
  587.           or a
  588.           ret z
  589.          cp '>'
  590.         jr nz,tag_img_opening_readalt
  591. tag_img_opening_readaltq
  592.          ld (executetag_endchar),a
  593. tag_frame_typetagq ;TODO почему выше съедает первый фрейм atmturbo?
  594.         ld a,']'
  595.         call prcharvirtual_stateful
  596.         xor a
  597.         ld (curlinkimg),a
  598.         jr closehrefq
  599.         ;call prcharvirtual_stateful
  600.         ;call savestringbuf2 ;after printing ']' to count full size
  601.         ;xor a
  602.         ;ld (curlink),a
  603.         ;call setfontweight
  604.         ;jp skiprestoftag
  605.  
  606. tag_a
  607.         jr nz,tag_a_opening
  608.         ld a,'}'
  609.         call prcharvirtual_stateful
  610.         xor a
  611.         ld (curlink),a
  612. closehrefq
  613.         call savestringbuf2 ;after printing '}' to count full size
  614.         ;xor a
  615.         ;ld (curlink),a
  616.         call setfontweight
  617.         jp skiprestoftag
  618. tag_a_opening
  619.          ;jr $
  620.         call htmlskipspaces
  621. tag_a_opening_readhref
  622.         call htmlskipspaces_go
  623.         ld hl,thref
  624.         call eatgivenword_go
  625.         jr nz,tag_a_opening_hreffail
  626.  
  627.         ld a,CLINK
  628.         ld (curlink),a
  629.         call inithref
  630.        
  631.         ;zxdn: no quotes in href
  632.         call RDBYTE;rdbyte
  633.          cp "'"
  634.          jr z,tag_a_opening_read0
  635.         cp 34
  636.         jr nz,tag_a_opening_read_go
  637.  
  638. ;read link to stringbuf2 until doublequote
  639. tag_a_opening_read0
  640.         call RDBYTE;rdbyte
  641. tag_a_opening_read_go
  642.         or a
  643.         ret z
  644.         cp '>'
  645.         jr z,tag_a_opening_readq
  646.         cp 34
  647.         jr z,tag_a_opening_readq
  648.          cp "'"
  649.          jr z,tag_a_opening_readq
  650.         cp 0x0d
  651.         jr z,tag_a_opening_read0 ;lib.ru
  652.         cp 0x0a
  653.         jr z,tag_a_opening_read0 ;lib.ru
  654.          if 1==0
  655.          cp '&'
  656.          jr nz,tag_a_opening_read0ok
  657.         call printtostringbuf2
  658. ;TODO проверить &amp; (forum.nedopc.com)
  659.         call RDBYTE;rdbyte
  660.          cp 'a'
  661.          jr nz,tag_a_opening_read0ok
  662.         call RDBYTE;rdbyte
  663.         call RDBYTE;rdbyte
  664.         call RDBYTE;rdbyte        
  665.         jr tag_a_opening_read0
  666. tag_a_opening_read0ok
  667.          endif
  668.          ;push af
  669.          ;call prcharvirtual_stateful ;debug print
  670.          ;pop af
  671.         call printtostringbuf2
  672.         jr tag_a_opening_read0
  673. tag_a_opening_hreffail
  674. ;find href in next parameters
  675.         call htmlskipparam
  676.           or a
  677.           ret z
  678.          cp '>'
  679.         jr nz,tag_a_opening_readhref
  680. tag_a_opening_readq
  681.          ld (executetag_endchar),a
  682. tag_a_opening_fail
  683.         ld a,'{'
  684.         call prcharvirtual_stateful
  685.         jp skiprestoftag
  686.  
  687.  
  688. ;skip until space/>/"/EOF
  689. ;if ", skip until another ", then skip space/>
  690. ;a=last char read
  691. ;out: a=last char (space/>/")
  692. htmlskipparam0
  693.         call RDBYTE;rdbyte
  694. htmlskipparam
  695.         or a
  696.         ret z
  697.         cp ' '
  698.         ret z
  699.         cp '>'
  700.         ret z
  701.         cp 34
  702.         jr nz,htmlskipparam0
  703. htmlskipparamquote0
  704.         call RDBYTE;rdbyte
  705.         or a
  706.         ret z
  707.         cp 34
  708.         jr nz,htmlskipparamquote0
  709.         jp RDBYTE;rdbyte ;skip space/>        
  710.  
  711. eatgivenword
  712. ;hl=word (asciiz)
  713. ;out: Z=OK (or else a=last char read)
  714. eatgivenword0
  715.         ld a,(hl)
  716.         or a
  717.         ret z
  718.         call RDBYTE;rdbyte
  719.         ;ld (executetag_endchar),a
  720. eatgivenword_go
  721.          or 0x20
  722.         cp (hl)
  723.         inc hl
  724.         jr z,eatgivenword0
  725.         ld (executetag_endchar),a
  726.         ret ;fail
  727.  
  728. getword_tag
  729. ;hl=string
  730. ;de=wordbuf
  731. ;out: hl=terminator/space/> addr, a=terminator/space/> char
  732. ;TODO проверять переполнение WORDBUFSIZE
  733. getword_tag0
  734.         call RDBYTE;rdbyte
  735. getword_tag_go
  736.         or a
  737.         jr z,getword_tagq
  738.         cp ' '
  739.         jr z,getword_tagq
  740.         cp '>'
  741.         jr z,getword_tagq
  742.          or 0x20
  743.         ld (de),a
  744.         inc de
  745.         jr getword_tag0
  746. getword_tagq
  747.         push af
  748.         xor a
  749.         ld (de),a
  750.         pop af
  751.         ret
  752.  
  753.  
  754. getword_mangledchar
  755. ;hl=string
  756. ;de=wordbuf
  757. ;out: hl=terminator/space/; addr, a=terminator/space/; char
  758. ;TODO проверять переполнение WORDBUFSIZE
  759. getword_mangledchar0
  760.         call RDBYTE;rdbyte
  761.         ;or a
  762.         ;jr z,getword_mangledcharq
  763.          cp "A"
  764.          jr c,getword_mangledcharq
  765.         ;cp ';'
  766.         ;jr z,getword_mangledcharq
  767.         ;cp '#'
  768.         ;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
  769.         ld (de),a
  770.         inc de
  771.         jr getword_mangledchar0
  772. getword_mangledcharq
  773.         push af
  774.         xor a
  775.         ld (de),a
  776.         pop af
  777.         ret
  778.  
  779. ;getword_param
  780. ;hl=string
  781. ;de=wordbuf
  782. ;out: hl=terminator/space/; addr, a=terminator/space/; char
  783. ;TODO проверять переполнение WORDBUFSIZE
  784. getword_param0
  785.         call RDBYTE;rdbyte
  786. getword_param_go ;в параметре могут быть закавыченные пробелы!
  787.         or a
  788.         jr z,getword_paramq
  789.          cp "'"
  790.          jr z,getword_paramquote
  791.          cp 34
  792.          jr z,getword_paramquote
  793.         cp ' '
  794.         jr z,getword_paramspaceq
  795.         ;cp ';'
  796.         ;jr z,getword_paramcharq
  797.         ;cp '#'
  798.         ;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
  799.         cp '>'
  800.         jr z,getword_paramq
  801. getword_param0ok
  802.          or 0x20
  803.         ld (de),a
  804.         inc de
  805.         jr getword_param0
  806. getword_paramquote
  807.         ld c,a
  808. getword_paramquote0
  809.         ld (de),a
  810.         inc de
  811.         call RDBYTE;rdbyte
  812.         cp c
  813.         jr nz,getword_paramquote0 ;TODO а если она никогда не закроетсЯ???
  814.         jr getword_param0ok
  815. getword_paramspaceq
  816. ;или тут проверЯть, в кавычках ли мы?
  817. getword_paramq
  818.         push af
  819.         xor a
  820.         ld (de),a
  821.         pop af
  822.         ret
  823.  
  824.  
  825.        
  826. strcp
  827. ;hl=s1
  828. ;de=s2
  829. ;out: Z (equal, hl=terminator of s1+1, de=terminator of s2+1), NZ (not equal, hl=erroraddr in s1, de=erroraddr in s2)
  830. strcp0.
  831.         ld a,[de] ;s2
  832.         cp [hl] ;s1
  833.         ret nz
  834.         inc hl
  835.         inc de
  836.         or a
  837.         jr nz,strcp0.
  838.         ret ;z
  839.  
  840. strcp_tillde0
  841. ;hl=s1
  842. ;de=s2
  843. ;out: Z (equal, hl=terminator of s1+1, de=terminator of s2+1), NZ (not equal, hl=erroraddr in s1, de=erroraddr in s2)
  844. strcp_tillde0_0.
  845.         ld a,[de] ;s2
  846.         or a
  847.         ret z
  848.         cp [hl] ;s1
  849.         ret nz
  850.         inc hl
  851.         inc de
  852.         jr strcp_tillde0_0.
  853.  
  854.        
  855. thref
  856.         db "href=",0
  857. tsrc
  858.         db "src=",0
  859. talt
  860.         db "alt=",0
  861.        
  862. rememberhrefyxposition
  863.         ld a,(prcharvirtual_stateful_x) ;для центрированных получается неправильно! на этом этапе экранный x ещё не известен!
  864.         ld (hrefxposition),a
  865.         ld hl,(curprintvirtualy)
  866.         ld (hrefyposition),hl
  867.         ret
  868.  
  869. tag_title
  870. ;not used, because header is skipped (TODO)
  871.         ;jp z,tag_titleclose
  872.         jp nz,tag_h1 ;open
  873. ;tag_titleclose
  874.          ;ld a,1
  875.          ;ld (utf8flag),a ;нельзя, т.к. title после charset
  876.         call prcharvirtual_crlf_stateful ;</title> forces newline
  877.         xor a ;z
  878.         jp tag_h1
  879.                
  880. tag_li ;list line (no closing tag)? но на msn.com куча <li ><a...>...</a></li>
  881.         push af
  882.         call prcharvirtual_crlf_stateful
  883.         pop af
  884.         jp z,skiprestoftag ;closing
  885.         ld a,'*';'-';'*' ;TODO с учётом UTF8
  886.         call prcharvirtual_stateful
  887.         ld a,' '
  888.         call prcharvirtual_stateful
  889.         jp skiprestoftag
  890.  
  891. tag_meta
  892. ;TODO find "charset=UTF-8" or "charset=windows-1251"
  893. tag_meta0
  894.         ld b,a
  895.         push bc
  896.         call RDBYTE;rdbyte
  897.         pop bc
  898.         or a
  899.         ret z
  900.         cp '>'
  901.         jp z,skiprestoftag0
  902.         or 0x20
  903.         cp 'w'
  904.         jr nz,tag_meta0
  905.         ld a,b
  906.         cp '='
  907.          ld a,'w'
  908.          jr nz,tag_meta0
  909.          xor a;ld a,0
  910.          ld (utf8flag),a
  911.         jp skiprestoftag_go
  912.  
  913. tag_style
  914. tag_script
  915. ;TODO skip until </script>
  916. tag_script0
  917.         ld b,a
  918.         push bc
  919.         call RDBYTE;rdbyte
  920.         pop bc
  921.         or a
  922.         ret z
  923.         cp '/'
  924.         jr nz,tag_script0
  925.         ld a,b
  926.         cp '<'
  927.          ld a,'/'
  928.         jr nz,tag_script0
  929.         jp skiprestoftag_go
  930.  
  931. htmlskipspaces
  932. htmlskipspaces0
  933.         call RDBYTE;rdbyte
  934. htmlskipspaces_go
  935.         cp ' '
  936.         jr z,htmlskipspaces0
  937.         cp 0x0d
  938.         jr z,htmlskipspaces0
  939.         cp 0x0a
  940.         jr z,htmlskipspaces0
  941.         ld (executetag_endchar),a
  942.         ret
  943.  
  944. tag_COMMENT
  945.         call RDBYTE
  946.         or a
  947.         ret z
  948.         cp '-'
  949.         jr nz,tag_COMMENT
  950.         call RDBYTE
  951.         or a
  952.         ret z
  953.         cp '-'
  954.         jr nz,tag_COMMENT
  955.         call RDBYTE
  956.         or a
  957.         ret z
  958.         cp '>'
  959.         jr nz,tag_COMMENT
  960.         ret
  961.        
  962. tag_font
  963. ;TODO push old font/pop old font
  964.  
  965. tag_link
  966. ;TODO find href
  967.  
  968. tag_dl
  969. tag_dt
  970. tag_doctype
  971. tag_span
  972. tag_html
  973. ;tag_ul      ;перенос не нужен, так как далее li
  974. tag_table   ;перенос не нужен, так как далее tr
  975. tag_tbody
  976.         jp skiprestoftag
  977.  
  978. tag_frameset ;before body
  979. tag_body
  980.         call htmlinitbody
  981.         jp skiprestoftag
  982.  
  983. htmlinitbody
  984.          xor a
  985.          ld (iscentered),a
  986.          inc a ;ld a,1
  987.          ld (printableflag),a
  988. ;эти манипуляции затрут уже напечатанные фреймы:
  989.          ;call prcharvirtual_x0
  990.          call setdefaultfontweight
  991.          jp setfontweight;call initstringbuf1 ;без этого не пишет коды установки цвета
  992.        
  993. skiprestoftag
  994. ;we can be at >/space/EOF (in executetag_endchar)
  995. executetag_endchar=$+1
  996.         ld a,0
  997. skiprestoftag0
  998.         cp '>'
  999.         ret z
  1000. skiprestoftag_go
  1001.         call RDBYTE;rdbyte
  1002.         or a
  1003.         ret z
  1004.         jr skiprestoftag0
  1005.  
  1006.        
  1007. wordbuf
  1008.         ds WORDBUFSIZE
  1009.