?login_element?

Subversion Repositories NedoOS

Rev

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