?login_element?

Subversion Repositories NedoOS

Rev

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