?login_element?

Subversion Repositories NedoOS

Rev

Rev 1135 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. htmlview
  2.         call showtime
  3.  
  4.         ld hl,(curprintvirtualy)
  5.         ld (html_endy),hl
  6.         call prcharmc_stateful_resethandler
  7.         ;ld hl,0
  8.         ;ld (html_curtopy),hl
  9.        
  10.         ld hl,(firstpointer)
  11.         ld (htmlshowline_accessedpointer),hl
  12.         ld a,(firstpointerHSB)
  13.         ld (htmlshowline_accessedpointerHSB),a
  14.        
  15. html_redrawloop
  16. ;redraw interface (TODO test)
  17.         call cleanstatusline
  18.         call browser_editline_print
  19.  
  20.         call htmlshowpage
  21.         ;call setpgs_scr
  22.        
  23. html_mainloop
  24.  
  25. htmlcursorxy=$+1
  26.         ld de,HTMLTOPY*256
  27.         call html_setxy
  28.         call setpgs_scr
  29.         ld e,(hl)
  30.         push de ;e=oldcolor
  31.         ld a,0x38
  32.         call html_prattr
  33.  
  34. html_getkeyloop0
  35.         ;YIELD ;halt ;если сделать просто di:rst #38, то 1.сдвинем таймер и 2.можем потерять кадровое прерывание, а если без ei, то будут глюки
  36.         ;GET_KEY ;OS_GETKEYNOLANG
  37.         ; jr nz,html_getkeyloop0 ;no focus
  38.         ;ld a,c ;keynolang        
  39.         ;cp NOKEY
  40.         call yieldgetkeynolang
  41.         jr nz,html_mainloop_keyq
  42. ;control_imer_oldmousecoords=$+1
  43. ;        ld bc,0
  44. ;        ld (control_imer_oldmousecoords),de
  45. ;        ld a,b
  46. ;        sub d
  47. ;        ld d,a
  48. ;        ld a,e
  49. ;        sub c
  50. ;        ld e,a
  51. ;        ld (control_imer_mousecoordsdelta),de
  52.        
  53.         ;call nvview_panel
  54.         jr html_getkeyloop0
  55. ;html_mainloop_keyq_nokey
  56. ;        xor a
  57. html_mainloop_keyq
  58.  
  59.         pop de ;e=oldcolor
  60.         push af
  61.         push de
  62.         ld de,(htmlcursorxy)
  63.         call html_setxy
  64.         pop de
  65.         ld a,e
  66.         call html_prattr
  67.  
  68. control_imer_mousecoordsdelta=$+1
  69.         ld de,0
  70.         call html_mousemove
  71.  
  72.         pop af
  73.         cp key_redraw
  74.         jr z,html_redrawloop
  75.         ;cp key_esc
  76.         ;jp z,browser_quit
  77.         call globalbuttons
  78.         ld hl,html_mainloop
  79.         push hl
  80.         cp key_up
  81.         jp z,html_up
  82.         cp key_up_scroll
  83.         jp z,html_up_scroll
  84.         cp key_down
  85.         jp z,html_down
  86.         cp key_down_scroll
  87.         jp z,html_down_scroll
  88.         cp key_right
  89.         jp z,html_right
  90.         cp key_left
  91.         jp z,html_left
  92.         cp key_enter
  93.         jp z,html_enter
  94.         cp 'l'
  95.         jr z,html_download
  96.         ;cp 's'
  97.         ;jp z,browser_downloadthis
  98.         ;cp '5'
  99.         ;jp z,browser_reload
  100.         cp 'u'
  101.         jr z,html_changeencoding
  102.         ;cp key_backspace
  103.         ;jp z,browser_backspace
  104.         cp key_pgup
  105.         jp z,html_pgup
  106.         cp key_pgdown
  107.         jp z,html_pgdown
  108.         cp key_home
  109.         jp z,html_home
  110.         cp key_end
  111.         jp z,html_endkey
  112.         ret
  113.  
  114. html_changeencoding
  115.         ld hl,defaultunicodeflag
  116.         ld a,(hl)
  117.         xor 1
  118.         ld (hl),a
  119.         jp browser_reload
  120.        
  121. html_download
  122.         call html_enter_find
  123.         call keepcurlink
  124. ;linkbuf=relative link
  125.         call makefulllink
  126. ;curfulllink=url
  127.  
  128. wgetloaded_pid=$+1
  129.         ld a,0
  130.         or a
  131.         call z,reloadwget
  132.  
  133. ;TODO проверить, что wget жив:
  134.         ld a,(wgetloaded_pid)
  135.         ld e,a
  136.         OS_CHECKPID
  137.         or a
  138.         call z,reloadwget ;dead
  139.  
  140. ;ждём готовности wget
  141. waitwgetinit0
  142.         YIELD
  143. wgetmainpg=$+1
  144.         ld a,0
  145.         SETPG32KHIGH
  146.         ld a,(0xc000+COMMANDLINE)
  147.         inc a
  148.         jr z,waitwgetinit0
  149.        
  150.         ld hl,curfulllink
  151.         ld de,0xc000+WGETBUF
  152.         call strcopy
  153.         ld a,0xff
  154.         ld (0xc000+COMMANDLINE),a ;строка задания готова
  155.        
  156.         jp remembercurlink
  157.         ;jp browser_godownload
  158.  
  159. reloadwget
  160.         call setpgtemp8000
  161.         ld de,0x8000;oldpath
  162.         OS_GETPATH
  163.  
  164.         OS_SETSYSDRV
  165.         ld de,wgetfilename
  166.         call openstream_file
  167.         or a
  168.         ret nz
  169.        
  170.         ld de,0x8000;oldpath
  171.         OS_CHDIR
  172.        
  173.         OS_NEWAPP ;на момент создания должна быть включена текущая директория!!!
  174.         or a
  175.         jr nz,html_download_closeq ;error
  176. ;dehl=номера страниц в 0000,4000,8000,c000 нового приложения, b=id, a=error
  177.         push bc ;b=id
  178.         ld a,d
  179.         ld (wgetmainpg),a
  180.         SETPG32KHIGH
  181.         ;push de
  182.         ;push hl
  183.         ld hl,0xc000+COMMANDLINE
  184.         ld (hl),0xff ;daemon mode
  185.         inc hl
  186.         ld (hl),0
  187.         ;pop hl
  188.         ;pop de
  189.         ld de,0xc100
  190.         ld hl,0x3f00
  191.         call readstream_file
  192.         pop af
  193.         ld (wgetloaded_pid),a
  194.         ld e,a ;e=id
  195.         OS_RUNAPP
  196. html_download_closeq
  197.         jp closestream_file
  198.  
  199. html_enter
  200. ;click on href
  201.         call html_enter_find
  202.         jp browser_go
  203.  
  204. html_enter_find
  205.         ld a,(htmlcursorxy+1)
  206.         sub HTMLTOPY
  207.         ld c,a
  208.         ld b,0
  209.         ld hl,(html_curtopy)
  210.         add hl,bc
  211.         ld (html_enter_virtualy),hl
  212.  
  213.          ;jr $
  214.         ld hl,(first2pointer)
  215.         ld a,(first2pointerHSB)
  216. html_enter_find0
  217.         call isnull
  218.         jr z,html_enter_findq
  219.         push af
  220.         push hl
  221.        
  222.         if 1==0
  223.        
  224.         ld bc,HREF_Y
  225.         add hl,bc
  226.         adc a,0
  227.         call readword ;de=beginy
  228.         ex de,hl
  229. html_enter_virtualy=$+1
  230.         ld bc,0
  231.         or a
  232.         sbc hl,bc ;HREF_Y - y
  233.         ex de,hl
  234.         jr z,html_enter_findlineok ;для правильной ссылки HREF_Y<=y
  235.          ;jr c,html_enter_findlineok_hrefy_lessthan_y
  236.        
  237.         endif
  238.          
  239. ;for long linktexts: beginyx<=yx<endyx
  240. ;можно первичную фильтрацию (beginy<=y<=endy), но неудобно
  241.  
  242.         ld bc,HREF_Y
  243.         add hl,bc
  244.         adc a,b;0
  245.         call readword ;de=beginy
  246.         call readbyte ;c=beginx
  247. html_enter_virtualy=$+1
  248.         ld hl,0
  249.         ld a,(htmlcursorxy)
  250.         ;hla=Yyx
  251.         ;dec=beginYyx
  252.         cp c
  253.         sbc hl,de
  254.         jr c,html_enter_findnext
  255.         pop hl
  256.         pop af
  257.         push af
  258.         push hl
  259.         ld bc,HREF_ENDY
  260.         add hl,bc
  261.         adc a,b;0
  262.         call readword ;de=endy
  263.         call readbyte ;c=endx
  264.         ld hl,(html_enter_virtualy)
  265.         ld a,(htmlcursorxy)
  266.         ;hla=Yyx
  267.         ;dec=endYyx
  268.         cp c
  269.         sbc hl,de
  270.         ;jr nc,html_enter_findnext
  271.         jr c,html_enter_findok
  272.  
  273. html_enter_findnext
  274.         pop hl
  275.         pop af
  276.         call getnextelement
  277.         jr html_enter_find0
  278.        
  279.        
  280.         if 1==0
  281.        
  282. html_enter_findlineok_hrefy_lessthan_y
  283.  
  284.        
  285. html_enter_findlineok
  286.         call readbyte ;c=beginx
  287.         ld b,a
  288.         ld a,(htmlcursorxy)
  289.         cp c
  290.         ld a,b
  291. ;x<beginx => fail
  292.         jr c,html_enter_findnext
  293.          ;jr $
  294.         call readword ;de=endy
  295.         push hl
  296.         ld hl,(html_enter_virtualy)
  297.         or a
  298.         sbc hl,de
  299.         pop hl
  300. ;y==endy => ok (long linktext)
  301.         push af
  302.         call readbyte ;c=endx
  303.         pop af
  304.         ;jr z,html_enter_findok_endy
  305.  
  306.         ld b,a
  307.         ld a,(htmlcursorxy)
  308.         cp c
  309.         ld a,b
  310. ;x>=endx =>fail
  311.         jr nc,html_enter_findnext
  312.         ;jr html_enter_findok
  313.                
  314. html_enter_findok_endy
  315.         endif
  316.  
  317. html_enter_findok
  318.          ;pop bc
  319.          ;pop bc
  320.         ;call readbyte ;skip VISITED
  321.          
  322.          pop hl
  323.          pop af
  324.         ld bc,HREF_TEXT
  325.         add hl,bc
  326.         adc a,b;0
  327.          
  328.         ld de,linkbuf
  329. html_enter_findok_copyname0
  330.         call readbyte
  331.         ex de,hl
  332.         ld (hl),c
  333.         inc hl
  334.         ex de,hl
  335.         inc c
  336.         dec c
  337.         jr nz,html_enter_findok_copyname0
  338.                
  339.          ;jr $
  340.         ret
  341.        
  342. html_enter_findq
  343.         pop af
  344.         ret
  345.  
  346. html_prattr
  347.         ld de,40
  348.         ld b,8
  349. html_prattr0
  350.         ld (hl),a
  351.         add hl,de
  352.         djnz html_prattr0
  353.         ret
  354.  
  355. html_setxy
  356. ;de=yx (kept)
  357.         push de
  358.         sla d
  359.         sla d
  360.         sla d
  361.         call setxymc
  362.         res 6,h
  363.         pop de
  364.         ret
  365.  
  366. html_left
  367.         ld a,(htmlcursorxy)
  368.         sub 1
  369.         ret c
  370.         ld (htmlcursorxy),a
  371.         ret
  372.        
  373. html_right
  374.         ld a,(htmlcursorxy)
  375.         inc a
  376.         cp 80
  377.         ret nc
  378.         ld (htmlcursorxy),a
  379.         ret
  380.  
  381. MOUSEFACTOR=8
  382. html_mousemove
  383. ;de=mouse delta
  384. ;чтобы двигать не резко, надо отдельно хранить младшие части x,y (не отображаемые на экране)
  385.         ld hl,(htmlcursorxy)
  386. htmlcursorxylow=$+1
  387.         ld bc,0 ;bits 7..5 (for Y) 7..6 (for X), others=0
  388.         dup 3
  389.         sla b
  390.         rl h
  391.         edup        
  392.         ld a,h
  393.         add a,d
  394.         bit 7,d
  395.         jr z,html_mousemove_yplus
  396.         jr nc,html_mousemove_yminus_overflow
  397.         cp HTMLTOPY*MOUSEFACTOR
  398.         jr nc,html_mousemove_yq
  399. html_mousemove_yminus_overflow
  400.         ld a,HTMLTOPY*MOUSEFACTOR
  401.         jr html_mousemove_yq
  402. html_mousemove_yplus
  403.         jr c,html_mousemove_yplus_overflow
  404.         cp MOUSEFACTOR*(HTMLTOPY+HTMLHGT-1)
  405.         jr c,html_mousemove_yq
  406. html_mousemove_yplus_overflow
  407.         ld a,MOUSEFACTOR*(HTMLTOPY+HTMLHGT-1)
  408. html_mousemove_yq  
  409.         srl a
  410.         rr b
  411.         rra
  412.         rr b
  413.         rra
  414.         rr b
  415.         ld (htmlcursorxy+1),a
  416.  
  417.         ld h,0
  418.         sla c
  419.         rl l
  420.         sla c
  421.         adc hl,hl
  422.         ld a,e
  423.         rla
  424.         sbc a,a
  425.         ld d,a
  426.         add hl,de
  427.         bit 7,e
  428.         jr z,html_mousemove_xplus
  429.         jr c,html_mousemove_xq
  430.         ld hl,0 ;ld a,HTMLTOPY*MOUSEFACTOR
  431.         jr html_mousemove_xq
  432. html_mousemove_xplus
  433.         ld de,MOUSEFACTOR/2*(80-1)
  434.         jr c,html_mousemove_xplus_overflow
  435.         ;or a
  436.         sbc hl,de
  437.         add hl,de
  438.         jr c,html_mousemove_xq
  439. html_mousemove_xplus_overflow
  440.         ex de,hl
  441. html_mousemove_xq
  442.         ld a,l
  443.         rr h
  444.         rra
  445.         rr c
  446.         rra
  447.         rr c
  448.         ld (htmlcursorxy),a
  449.  
  450.         ld (htmlcursorxylow),bc
  451.         ret
  452.        
  453. html_up
  454.         ld a,(htmlcursorxy+1)
  455.         cp HTMLTOPY
  456.         jr z,html_up_scroll1
  457.         dec a
  458.         ld (htmlcursorxy+1),a
  459.         ret
  460. html_up_scroll
  461. mouse_scrollvalue=$+1
  462.         ld a,0 ;*-0x10
  463. html_up_scroll0
  464.         push af
  465.         call html_up_scroll1
  466.         pop af
  467.         add a,0x10;sub 0x10
  468.         jr nz,html_up_scroll0
  469.         ret
  470. html_up_scroll1
  471.         ld hl,(html_curtopy)
  472.         ld a,h
  473.         or l
  474.         ret z
  475.         dec hl
  476.         ld (html_curtopy),hl
  477.         push hl
  478.         call scrollmcdown
  479.         pop hl
  480.         ld d,HTMLTOPY
  481. ;hl=virtual Y
  482. ;d=scry
  483.         jp htmlcleanshowline
  484.        
  485. html_down
  486.         ld a,(htmlcursorxy+1)
  487.         cp HTMLTOPY+HTMLHGT-1
  488.         jr z,html_down_scroll1
  489.         inc a
  490.         ld (htmlcursorxy+1),a
  491.         ret
  492. html_down_scroll
  493.         ld a,(mouse_scrollvalue) ;*+0x10
  494. html_down_scroll0
  495.         push af
  496.         call html_down_scroll1
  497.         pop af
  498.         sub 0x10;add a,0x10
  499.         jr nz,html_down_scroll0
  500.         ret
  501. html_down_scroll1
  502.         ld hl,(html_curtopy)
  503.         inc hl
  504.         ld (html_curtopy),hl
  505.         push hl
  506.         call scrollmcup
  507.         pop hl
  508.         ld bc,HTMLHGT-1
  509.         add hl,bc
  510.         ld d,HTMLTOPY+HTMLHGT-1
  511. ;hl=virtual Y
  512. ;d=scry
  513.         jp htmlcleanshowline
  514.  
  515. html_pgup
  516.         ld hl,(html_curtopy)
  517.         ld bc,HTMLHGT-1
  518.         xor a
  519.         sbc hl,bc
  520.         jr nc,$+4
  521.         ld h,a
  522.         ld l,a
  523. topy_showpage_slearkeyboardbuffer
  524.         ld (html_curtopy),hl
  525.         call htmlshowpage
  526. clear_keyboardbuffer
  527.         push bc
  528.         ld b,5
  529. clear_keyboardbuffer0
  530.         push bc
  531.         GET_KEY
  532.         pop bc
  533.         djnz clear_keyboardbuffer0
  534.         pop bc
  535.         ret
  536.        
  537. html_pgdown
  538.         ld hl,(html_curtopy)
  539.         ld bc,HTMLHGT-1
  540.         add hl,bc
  541.         jr topy_showpage_slearkeyboardbuffer
  542.         ;ld (html_curtopy),hl
  543.         ;call htmlshowpage
  544.         ;ret
  545.        
  546. html_home
  547.         ld hl,0
  548.         jr topy_showpage_slearkeyboardbuffer
  549.  
  550. html_endkey
  551. html_endy=$+1
  552.         ld hl,0
  553.         jr topy_showpage_slearkeyboardbuffer
  554.        
  555. htmlshowpage
  556.         ld d,HTMLTOPY
  557. html_curtopy=$+1
  558.         ld hl,0
  559. htmlshowpage0
  560. ;hl=virtual Y
  561. ;d=scry
  562.         call htmlcleanshowline
  563.         inc hl
  564.         inc d
  565.         ld a,d
  566.         cp HTMLTOPY+HTMLHGT
  567.         jr nz,htmlshowpage0
  568.         ret
  569.  
  570. htmlcleanshowline
  571. ;hl=virtual Y
  572. ;d=scry
  573.         push de
  574.         push hl
  575.         ld e,0
  576.         sla d
  577.         sla d
  578.         sla d
  579.         call setxymc ;hl=0xc000+        
  580.         call setpgs_scr
  581.         xor a
  582.         call cleanlinemc
  583.         call setpgtemp8000
  584.         pop hl
  585.         pop de
  586.        
  587.         ;jr $
  588.         push de
  589.         push hl
  590.         call htmlshowline
  591.         pop hl
  592.         pop de
  593.         ret
  594.        
  595. htmlshowline
  596. ;hl=virtual Y
  597. ;d=scry
  598.         ;jr $
  599.         ld a,d
  600.         add a,a
  601.         add a,a
  602.         add a,a
  603.         ld (htmlshowline_scry),a
  604.         ld (htmlshowline_virtualy),hl
  605.  
  606. htmlshowline_accessedpointer=$+1
  607.         ld hl,0
  608. htmlshowline_accessedpointerHSB=$+1
  609.         ld a,0
  610.        
  611. ;ищем вниз, если (accessedpointer.HREF_Y < y), иначе ищем вверх
  612.         push af
  613.         push hl
  614.         call getandcompareHREF_Y ;CY = (HREF_Y < y)
  615.         jr c,htmlshowline_finddown
  616.  
  617. ;htmlshowline_findup
  618.         pop hl
  619.         pop af
  620. htmlshowline_findup0
  621.         call isnull
  622.         jr z,htmlshowline_findq
  623.         push af
  624.         push hl
  625.         call getandcompareHREF_Y
  626.         jr z,htmlshowline_findok
  627.          jr c,htmlshowline_pop2findq
  628.         pop hl
  629.         pop af
  630.         call getprevelement
  631.         jr htmlshowline_findup0
  632.  
  633. htmlshowline_finddown
  634.         pop hl
  635.         pop af
  636. htmlshowline_finddown0
  637.         call isnull
  638.         jr z,htmlshowline_findq
  639.         push af
  640.         push hl
  641. ;        ld bc,HREF_Y
  642. ;        add hl,bc
  643. ;        adc a,b;0
  644. ;        call readword ;de
  645. ;        ex de,hl
  646. ;htmlshowline_virtualy=$+1
  647. ;        ld bc,0
  648. ;        or a
  649. ;        sbc hl,bc
  650. ;        ex de,hl
  651.         call getandcompareHREF_Y
  652.         jr z,htmlshowline_findok
  653.          jr nc,htmlshowline_pop2findq
  654.         pop hl
  655.         pop af
  656.         call getnextelement
  657.         jr htmlshowline_finddown0
  658.        
  659. getandcompareHREF_Y
  660.         ld bc,HREF_Y
  661.         add hl,bc
  662.         adc a,b;0
  663.         call readword ;de
  664.         ex de,hl
  665. htmlshowline_virtualy=$+1
  666.         ld bc,0
  667.         or a
  668.         sbc hl,bc
  669.         ex de,hl
  670.         ret ;CY = (HREF_Y < y), Z = equal
  671.  
  672. htmlshowline_findok
  673.         push af
  674.         push hl
  675.         ld bc,HREF_Y+2
  676.         or a
  677.         sbc hl,bc
  678.         sbc a,b;0
  679.         ld (htmlshowline_accessedpointer),hl
  680.         ld (htmlshowline_accessedpointerHSB),a
  681.         pop hl
  682.         pop af
  683.  
  684.         call readbyte ;x
  685.         ld e,c
  686. htmlshowline_scry=$+1
  687.         ld d,0
  688.         push af
  689.         push hl
  690.         call setxymc_stateful
  691.         pop hl
  692.         pop af
  693. htmlshowline_showtext0
  694.         call readbyte ;c
  695.         inc c
  696.         dec c
  697.         jr z,htmlshowline_showtextq
  698.         push af
  699.         push hl
  700.         ld a,c
  701.         call prcharmc_stateful
  702.         pop hl
  703.         pop af
  704.         jr htmlshowline_showtext0
  705. htmlshowline_showtextq
  706.        
  707. htmlshowline_pop2findq
  708.         pop hl
  709.         pop af
  710.        
  711. htmlshowline_findq
  712.  
  713.         ret
  714.        
  715.         if 1==0
  716.         ld hl,(firstpointer)
  717.         ld a,(firstpointerHSB)
  718. loadhtml_showtexts0
  719.         call isnull
  720.         jr z,loadhtml_showtextsq
  721.         push af
  722.         push hl
  723.         ld bc,stringbuf1-stringbuf1header
  724.         add hl,bc
  725.         adc a,0
  726.         ;jr $
  727. loadhtml_showtext0
  728.         call readbyte ;c
  729.         inc c
  730.         dec c
  731.         jr z,loadhtml_showtextq
  732.         push af
  733.         push hl
  734.         ld a,c
  735.         call prcharmc_stateful
  736.         pop hl
  737.         pop af
  738.         jr loadhtml_showtext0
  739. loadhtml_showtextq
  740.         call prcharmc_crlf_stateful
  741.         pop hl
  742.         pop af
  743.         call getnextelement
  744.         jr loadhtml_showtexts0
  745. loadhtml_showtextsq
  746.        
  747.        
  748.         ld hl,(first2pointer)
  749.         ld a,(first2pointerHSB)
  750. loadhtml_showhrefs0
  751.         call isnull
  752.         jr z,loadhtml_showhrefsq
  753.         push af
  754.         push hl
  755.         ld bc,stringbuf2-stringbuf2header
  756.         add hl,bc
  757.         adc a,0
  758.         ;jr $
  759. loadhtml_showhref0
  760.         call readbyte ;c
  761.         inc c
  762.         dec c
  763.         jr z,loadhtml_showhrefq
  764.         push af
  765.         push hl
  766.         ld a,c
  767.         call prcharmc_stateful
  768.         pop hl
  769.         pop af
  770.         jr loadhtml_showhref0
  771. loadhtml_showhrefq
  772.         call prcharmc_crlf_stateful
  773.         pop hl
  774.         pop af
  775.         call getnextelement
  776.         jr loadhtml_showhrefs0
  777. loadhtml_showhrefsq
  778.  
  779.         jp closequit
  780.         endif
  781.