?login_element?

Subversion Repositories NedoOS

Rev

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

  1. ;TODO в режиме wrap:
  2. ;- при стирании перерисовывать последнюю строку и всё за ней, если она уничтожена
  3. ;- при добавлении перерисовывать строки ниже, если изменилось число строк
  4. ;a) отслеживать последнюю позицию при печати (не годится для word wrap)
  5. ;б) отслеживать длину строки до и после (не годится для word wrap)
  6. ;в) отслеживать число подстрок до и после
  7. ;г) отслеживать список адресов всех подстрок на экране
  8.  
  9. texted_XYTOP=0x0000
  10. ;texted_HGT=24
  11. texted_WID=80
  12. _texted_PANELCOLOR=0x0700;0x38
  13.  
  14. textview
  15.         ;xor a
  16.         ;ld h,a
  17.         ;ld l,a
  18.         ;call texted_settop
  19.         ;ld (curlineaddr),hl
  20.         ;ld (curlineaddrHSB),a
  21.         ;ld hl,1
  22.         ;ld (texted_ncurline),hl
  23.         ;ld hl,0
  24.         ;ld (curxy),hl
  25.         call texted_gotobof
  26.        
  27.         call texted_panel        
  28.        
  29.         call texted_calclines
  30.  
  31. texted_redrawloop
  32.         call setredrawflag
  33. texted_mainloop
  34. texted_lineredrawflag=$
  35.         scf ;/or a
  36.         call c,texted_prcurline ;might set redrawflag
  37. texted_redrawflag=$
  38.         scf ;/or a
  39.         call c,texted_prcurpage
  40.  
  41. ;texted_waitkey_nokey
  42.         ld de,(curxy)
  43.         call nv_setxy
  44.        if 0
  45.         ld a,2
  46. mainloop_yieldkeep
  47.         ld (wasnokey),a
  48.         YIELDKEEP
  49.         ld a,55+128 ;"or a"
  50.         ld (texted_wasyield),a
  51.        endif
  52. texted_waitkey_nokey
  53.       if 0
  54.       else
  55.         YIELD
  56.       endif
  57.         GETKEY_ ;OS_GETKEYNOLANG
  58.         ;or a ;cp NOKEY ;keylang==0?
  59.         ;jr nz,texted_mainloop_keyq
  60.         ;cp c ;keynolang==0?
  61.         ;ld a,c ;keynolang
  62.         ;cp NOKEY ;TODO отличить от отсутствия фокуса nz? (не в фокусе клавиши не отдаются)
  63.         jr nz,texted_mainloop_keyq ;event
  64.         ;GETKEY_
  65.         ;jr nz,texted_mainloop_keyq ;event
  66.         ;GETKEY_
  67.         ;jr nz,texted_mainloop_keyq ;event бывает 3-символьный
  68.       if 0
  69.        ld a,(stdindatacount)
  70.        or a
  71.        jr nz,texted_mainloop
  72. ;если два раза подряд нет события, то делаем YIELD, иначе YIELDKEEP
  73. ;рисовать панельку только при отсутствии события после YIELD
  74. wasnokey=$+1
  75.         ld a,1
  76.         dec a
  77.         jr nz,mainloop_yieldkeep
  78. texted_wasyield=$
  79.         scf
  80.         jr nc,nopanel
  81.       endif
  82. texted_panelredrawflag=$
  83.         scf ;/or a
  84.         call c,texted_panel ;call c
  85.       if 0
  86.         ld de,(curxy)
  87.         call nv_setxy
  88. nopanel
  89.         YIELD
  90.         ld a,55 ;"scf"
  91.         ld (texted_wasyield),a
  92.         jr texted_waitkey_nokey
  93.       else
  94.         jr texted_mainloop
  95.       endif        
  96. texted_mainloop_keyq      
  97.  
  98.         cp key_redraw
  99.         jr z,texted_redrawloop
  100.        
  101.         ld hl,texted_mainloop
  102.         push hl
  103.         cp key_esc
  104.         jp z,texted_quit ;ret z
  105.         cp key_up
  106.         jp z,texted_up
  107.         cp key_down
  108.         jp z,texted_down
  109.         cp key_pgup
  110.         jp z,texted_pgup
  111.         cp key_pgdown
  112.         jp z,texted_pgdown
  113.          cp key_F10;extS
  114.          jp z,texted_changeencoding
  115.         cp key_home
  116.         jp z,texted_home
  117.         cp key_end
  118.         jp z,texted_end
  119.         cp key_left
  120.         jp z,texted_left
  121.         cp key_right
  122.         jp z,texted_right
  123.         cp key_sspgup;ext3
  124.         jp z,texted_gotobof;home
  125.         cp key_sspgdown;ext4
  126.         jp z,texted_gotoeof;end
  127.          cp extP
  128.          jp z,texted_playtext
  129.         ;cp extW
  130.         ;jp z,texted_wrap
  131.          cp key_ins
  132.          jp z,texted_wrap
  133.         cp key_backspace
  134.         jp z,texted_backspace
  135.         cp key_del
  136.         jp z,texted_del
  137.         cp key_enter
  138.         jp z,texted_enter
  139.         cp key_csenter
  140.         jp z,texted_save
  141.         cp key_F1
  142.         jp z,texted_help
  143.         cp key_F2
  144.         jp z,texted_save
  145.         cp key_F9
  146.         jp z,texted_build
  147.         cp 0x20
  148.         ret c ;прочие системные кнопки не нужны
  149. typein
  150.         ld c,a
  151.         ld a,(texted_prline_recodepatch)
  152.         or a
  153.         jr z,typein_nowin
  154.        ld h,t866towin/256
  155.        ld l,c
  156.        ld c,(hl)
  157. typein_nowin
  158.         call linesize_minus_x ;sz<x = error
  159.         call c,insert_minushl_spaces
  160.         call calccursoraddr
  161.         call insertbyte
  162. ;TODO wrap (reprint screen if needed)        
  163.         call setlineredrawflag;texted_prcurpage
  164.         jp texted_right
  165.  
  166. linesize_minus_x
  167. ;sz<x = CY
  168.         call calccurlinesz ;hl=sz
  169.         ex de,hl
  170.         call calccurlinex
  171.         ex de,hl
  172.         or a
  173.         sbc hl,de ;sz<x = error
  174.         ret
  175.  
  176. insert_minushl_spaces
  177.         push bc
  178. textinsertsymbol_pseudospace0
  179.         push hl ;sz-x < 0
  180.         call texted_end
  181.         call calccursoraddr
  182.         ld c,' '
  183.         call insertbyte
  184.         pop hl ;sz-x < 0
  185.         inc hl
  186.         inc h
  187.         dec h
  188.         jr nz,textinsertsymbol_pseudospace0
  189.         call texted_end
  190.         pop bc
  191.         ret
  192.  
  193. texted_quit
  194.         ld a,(fchanged)
  195.         cp ' '
  196.         jr z,texted_quit_ok
  197.         call setredrawflag;texted_prcurpage
  198.         ld de,_COLOR_RED
  199.        if PRSTDIO
  200.         SETCOLOR_
  201.        else
  202.         OS_SETCOLOR
  203.        endif
  204.         ld hl,winquit
  205.         call prwindow_waitkey ;CY=OK
  206.         push af
  207.         ld de,_COLOR
  208.        if PRSTDIO
  209.         SETCOLOR_
  210.        else
  211.         OS_SETCOLOR
  212.        endif
  213.         pop af
  214.         ret nc ;no quit
  215. texted_quit_ok
  216.         pop af
  217.         ret ;quit
  218.  
  219. texted_enter
  220.         call linesize_minus_x ;sz<x = error
  221.         ;jr nc,texted_enter_nopseudospaces
  222.         call c,texted_end
  223. ;texted_enter_nopseudospaces
  224.         call calccursoraddr
  225.         ld c,0x0d
  226.         call insertbyte
  227.         ld c,0x0a
  228.         call insertbyte
  229.         xor a
  230.         ld (curx),a
  231.         ld hl,0
  232.         ld (texted_prline_shift),hl
  233.  
  234.         call setredrawflag;texted_prcurpage
  235.  
  236.         call incnlines
  237.         jp texted_down
  238.        
  239. texted_save
  240. texted_filenameaddr=$+1
  241.         ld de,defaultfilename
  242.         OS_CREATEHANDLE
  243.         or a
  244.         ret nz
  245. ;b=new file handle
  246.         push bc
  247.         ld a,b
  248.         ld (cmd_savepage_handle),a
  249.  
  250.         ;ld de,(fcb+FCB_FSIZE)
  251.         ;ld hl,(fcb+FCB_FSIZE+2)
  252.         call getsize
  253.         ex de,hl
  254.         ld l,a
  255.         ld h,0
  256.         ld a,0 ;page number
  257. texted_save0
  258. ;a=page number in table (0..)
  259. ;hlde=remaining size
  260.         push af ;pg
  261.         push de ;remaining LSW
  262.         push hl ;remaining HSW
  263.         call setpg32k
  264.         ld a,d
  265.         and 0xc0
  266.         or h
  267.         or l
  268.         jr z,$+5 ;de=size
  269.         ld de,#4000
  270.         ex de,hl ;hl=pg size
  271.          push hl ;hl=pg size
  272.         call cmd_savepage
  273.          pop bc ;bc=pg size
  274.         pop hl ;remaining HSW
  275.         pop de ;remaining LSW
  276.         ex de,hl
  277.         or a
  278.         sbc hl,bc
  279.         ex de,hl
  280.         jr nc,$+3
  281.         dec hl ;size = size-pgsize
  282.         ld a,h
  283.         or l
  284.         or d
  285.         or e
  286.         jr z,texted_save_popq
  287.         pop af ;pg
  288.         inc a
  289.         jr texted_save0
  290. texted_save_popq
  291.         pop af
  292.         pop bc
  293.         OS_CLOSEHANDLE
  294.         call setunchanged
  295.         jp setpanelredrawflag
  296.  
  297. cmd_savepage
  298. ;hl=size
  299. ;out: a=error
  300. cmd_savepage_handle=$+1
  301.         ld b,0
  302.         ld de,#8000
  303. ;B = file handle, DE = Buffer address, HL = Number of bytes to write
  304.         OS_WRITEHANDLE
  305. ;HL = Number of bytes actually written, A=error
  306.         ret
  307.        
  308. setredrawflag
  309.         ld a,55 ;scf
  310.         ld (texted_redrawflag),a
  311.         ;ret
  312. setpanelredrawflag
  313.         ld a,55 ;scf
  314.         ld (texted_panelredrawflag),a
  315.         ret
  316. setlineredrawflag
  317.         ld a,55 ;scf
  318.         ld (texted_lineredrawflag),a
  319.         jr setpanelredrawflag;ret
  320.  
  321. calccurlinex
  322.         ld hl,(texted_prline_shift)
  323.         ld a,(curx)
  324.         add a,l
  325.         ld l,a
  326.         ret nc
  327.         inc h
  328.         ret
  329.        
  330. calccursoraddr
  331. ;TODO учитывать ширину строки (правее строки простое сложение бессмысленно)
  332.         call calccurlinex
  333.         ex de,hl
  334.         ld hl,(curlineaddr)
  335.         ld a,(curlineaddrHSB)
  336.         add hl,de
  337.         adc a,0
  338.         ret
  339.        
  340. texted_backspace
  341. ;TODO wrap (set y, reprint screen if needed)
  342.         call calccurlinex
  343.         ld a,h
  344.         or l
  345.         jr z,texted_backspace_startline
  346.  
  347.         call linesize_minus_x ;sz<x = error
  348.         jp c,texted_left
  349.  
  350.         call calccursoraddr
  351.         call prevbyte
  352.         ;call isbof
  353.         ;ret z
  354.         call deletebyte        
  355.         call setlineredrawflag
  356.         jp texted_left
  357. texted_backspace_startline
  358.         call calccursoraddr
  359.         call isbof
  360.         ret z
  361.         call prevbyte
  362.         call getbyte
  363.         push bc
  364.         call deletebyte
  365.         pop bc
  366.         ld b,a
  367.          ld a,c ;deleted byte
  368.          cp 0x0d
  369.          ld a,b
  370.          jr z,texted_backspace_startline_onlycr ;for CR texts
  371.         ld a,c
  372.         cp 0x0a
  373.         ld a,b
  374.         jr nz,texted_backspace_startline_onlycr
  375.         call isbof
  376.         jr z,texted_backspace_startline_onlycr
  377.         call prevbyte
  378.         call getbyte
  379.         ld b,a
  380.         ld a,c
  381.         cp 0x0d
  382.         ld a,b
  383.         ;jr nz,texted_backspace_startline_onlycr
  384.         call z,deletebyte ;0x0d
  385. texted_backspace_startline_onlycr
  386. ;ahl=at deleted CR/LF
  387. ;if not CR/LF before, go to "previous line" (after earlier CR/LF) and count difference
  388. ;else x=0
  389.          push af
  390.          push hl
  391.         call prevbyte
  392.         call getbyte ;c
  393.          pop hl
  394.          pop af
  395.          ld d,h
  396.          ld e,l
  397.         ld b,a
  398.         ld a,c
  399.         cp 0x0d
  400.         jr z,texted_backspace_startline_setxshift_hlminusde
  401.         cp 0x0a
  402.         jr z,texted_backspace_startline_setxshift_hlminusde
  403.         ld a,b
  404.  
  405.         ;push af
  406.         push hl
  407.         call texted_prevline ;CY=error (impossible?)
  408.         ex de,hl
  409.         ;ld c,a
  410.         pop hl ;hl=at deleted CR?,de=prevline
  411.         ;pop af
  412. texted_backspace_startline_setxshift_hlminusde
  413.         or a
  414.         sbc hl,de
  415.         ;sbc a,c
  416.         call setxshift_hl
  417.        
  418.         call setredrawflag
  419.  
  420.         call decnlines
  421.         jp texted_up
  422.  
  423. decnlines
  424.         push hl
  425.         ld hl,(nlines)
  426.         dec hl
  427.         ld (nlines),hl
  428.         pop hl
  429.         ret
  430. incnlines
  431.         push hl
  432.         ld hl,(nlines)
  433.         inc hl
  434.         ld (nlines),hl
  435.         pop hl
  436.         ret
  437.  
  438. texted_playtext
  439.         ld hl,(curlineaddr)
  440.         ld a,(curlineaddrHSB)
  441. ;ahl=line addr
  442.         ld de,textforplay
  443.         ld (playtextaddr),de
  444.         ld b,0
  445. texted_playtext0
  446.         call iseof
  447.         jr z,texted_playtext0q
  448.         call getbyte ;c=[ahl]
  449.         ex af,af' ;'
  450.         ld a,c
  451.         cp 0x0d
  452.         jr z,texted_playtext0q
  453.         ld (de),a
  454.         ex af,af' ;'
  455.         inc de
  456.         call nextbyte
  457.         djnz texted_playtext0
  458. texted_playtext0q
  459.         xor a
  460.         ld (de),a
  461. ;TODO on-int
  462. texted_playloop
  463.         call playtext
  464.         halt
  465.         ld hl,(playtextaddr)
  466.         ld de,playtextloopend
  467.         or a
  468.         sbc hl,de
  469.         jr nz,texted_playloop
  470.         ret
  471.  
  472. texted_home
  473. ;TODO wrap (set y)
  474.         ld hl,0
  475.         call setxshift_hl
  476.         jp setredrawflag
  477.  
  478. texted_end
  479. ;TODO wrap (set y)
  480.         ;call calccursoraddr
  481.         call calccurlinesz ;hl=sz
  482.         call setxshift_hl
  483.         jp setredrawflag
  484.  
  485. calccurlinesz_nowrap
  486. ;out: hl=sz (keeps bc)
  487.         ld hl,(curlineaddr)
  488.         ld a,(curlineaddrHSB)
  489. ;ahl=line addr
  490.         push bc
  491.         call texted_nextline_nowrap ;CY=error
  492.         jr calccurlinesz_go
  493. calccurlinesz
  494. ;out: hl=sz (keeps bc)
  495.         ld hl,(curlineaddr)
  496.         ld a,(curlineaddrHSB)
  497. ;ahl=line addr
  498.         push bc
  499.         call texted_nextline ;CY=error
  500. calccurlinesz_go
  501.         call c,getsize
  502.         call nc,skipbackcrlf
  503.         ld bc,(curlineaddr)
  504.         or a
  505.         sbc hl,bc
  506.         pop bc
  507.         ret
  508.  
  509. skipbackcrlf
  510. ;out: ahl=eof or endline+1 (at cr/lf)
  511.         call isbof
  512.         ret z
  513.         call prevbyte
  514.         call getbyte
  515.         ld b,a
  516.          ld a,c
  517.          cp 0x0d
  518.          ld a,b
  519.          ret z ;for CR texts
  520.         ld a,c
  521.         cp 0x0a
  522.         ld a,b
  523.         jp nz,nextbyte
  524.         call isbof
  525.         ret z
  526.         call prevbyte
  527.         call getbyte
  528.         ld b,a
  529.         ld a,c
  530.         cp 0x0d
  531.         ld a,b
  532.         jp nz,nextbyte
  533.         ret
  534.        
  535. setxshift_hl
  536. ;X=hl=ahl-startline
  537. ;x+shift = X:
  538. ;x = min(X,texted_WID-1), но под mod8 должен совпадать с X
  539. ;shift = X-x
  540.         ld bc,texted_WID-1
  541.         call minhl_bc_tobc
  542.         ld a,c
  543.         xor l
  544.         and %11111000
  545.         xor l
  546.         ld c,a
  547.         ld (curx),a
  548.         or a
  549.         sbc hl,bc
  550.         ld (texted_prline_shift),hl
  551.         ret
  552.        
  553. texted_del
  554. ;TODO wrap (set y, reprint screen if needed)
  555.         call linesize_minus_x ;sz<x = error
  556.         jr c,texted_del_newline
  557.         jr z,texted_del_newline
  558.         call texted_right
  559.         jp texted_backspace
  560. texted_del_newline
  561. ;удаление ентера справа (backspace не умеет)
  562. ;hl=sz-x
  563.         call c,insert_minushl_spaces
  564.         call setredrawflag
  565.         call calccursoraddr
  566.         call iseof
  567.         ret z
  568.         call decnlines
  569.         call getbyte
  570.         push af
  571.         call deletebyte
  572.         pop bc ;b=deleted byte
  573.         ld c,a
  574.         ld a,b
  575.         cp 0x0a
  576.         ld a,c
  577.         ret z ;endline = 0x0a
  578.         call iseof
  579.         ret z
  580.         call getbyte
  581.         ld b,a
  582.         ld a,c
  583.         cp 0x0a
  584.         ld a,b
  585.         ret nz
  586.         call deletebyte        
  587.         ret
  588.        
  589. texted_wrap
  590.         ld a,(wrapflag)
  591.         xor 128
  592.         ld (wrapflag),a
  593.         ld hl,0
  594.         ld (texted_prline_shift),hl
  595.         ld (curxy),hl
  596.         call texted_calclines
  597.         ld hl,(curtoptextaddr)
  598.         ld a,(curtoptextHSB)
  599.         ld (curlineaddr),hl
  600.         ld (curlineaddrHSB),a
  601.         call texted_calccurline
  602.         jp setredrawflag;texted_prcurpage
  603.        
  604. texted_right
  605. ;TODO X<16384
  606.         call setpanelredrawflag
  607.         ld de,(curxy)
  608.         inc e
  609.         ld a,e
  610.         cp texted_WID
  611.         ld (curx),a
  612.         ret c
  613.          call iswrapon ;CY=on
  614.          jr c,texted_right_wrap
  615.         ld hl,(texted_prline_shift)
  616.         ld bc,8
  617.         add hl,bc
  618.         ld (texted_prline_shift),hl
  619.         ld a,e
  620.         sub c;8
  621.         ld (curx),a
  622.         jp setredrawflag;texted_prcurpage
  623.        
  624. texted_right_wrap
  625.         xor a
  626.         ld (curx),a
  627.         jp texted_down
  628.        
  629. texted_left
  630.         call setpanelredrawflag
  631.         ld de,(curxy)
  632.         ld a,e
  633.         sub 1
  634.         ld e,a
  635.         ld (curx),a
  636.         ret nc
  637.         xor a
  638.         ld (curx),a
  639.         ld hl,(texted_prline_shift)
  640.         ld bc,8
  641.         or a
  642.         sbc hl,bc
  643.         ret c
  644.         ld (texted_prline_shift),hl
  645.         ld a,e
  646.         add a,c;8
  647.         ld (curx),a
  648.         jp setredrawflag;texted_prcurpage
  649.        
  650. texted_prcurline
  651.         ld a,55+0x80 ;or a
  652.         ld (texted_lineredrawflag),a
  653.         ld de,(curxy)
  654.         ld e,0
  655.         ;push de
  656.         call nv_setxy ;keeps de
  657.         ;pop de
  658. ;print lines until CR or EOF
  659. ;TODO если изменилось число подстрок, то печатаем всё ниже
  660. ;костыль: печатаем всё ниже, если у текущей строки последняя позиция печати=0 (бывает при стирании) или 1 (бывает при добавлении). можно сделать делением длины строки на 80
  661.       push de
  662.        call calccurlinesz_nowrap ;out: hl=sz (keeps bc)
  663.       pop de
  664.        ld bc,-80
  665.        add hl,bc
  666.        jr c,$-1
  667. ;hl=-80..-1 for line remainder = 0..79
  668.        ld a,l
  669.        sub c
  670.        cp 2
  671.         ld hl,(curlineaddr)
  672.         ld a,(curlineaddrHSB)
  673.        jr c,texted_prcurline_allbelow
  674. texted_prcurline_continue0
  675.         call texted_prline_nextline_nooverflow    
  676.         call texted_prcurline_continue ;z=no continue
  677.        ret z
  678.         inc d
  679.        ld b,a
  680.         ;ld a,texted_HGT
  681.         ld a,(textedhgt)
  682.         cp d
  683.        ld a,b
  684.         jr nz,texted_prcurline_continue0
  685.         ret
  686. texted_prcurline_allbelow
  687. texted_prcurline_allbelow0
  688.         call texted_prline_nextline_nooverflow    
  689.         call texted_prcurline_continue ;z=no continue
  690.         inc d
  691.        ld b,a
  692.         ;ld a,texted_HGT
  693.         ld a,(textedhgt)
  694.         cp d
  695.        ld a,b
  696.         jr nz,texted_prcurline_allbelow0
  697.         ret
  698.  
  699. texted_prline_nextline_nooverflow
  700.         push de
  701.         call texted_prline_nextline
  702.         pop de
  703.         call c,getsize ;при переполнении ahl=filesize
  704.         ret
  705.  
  706. texted_prcurline_continue
  707. ;out: z=no continue
  708.         call iseof
  709.         ret z
  710.         call prevbyte
  711.         call getbyte ;to c
  712.        push bc
  713.         call nextbyte
  714.        pop bc
  715.         ld b,a
  716.         ld a,c
  717.         cp 0x0d
  718.         jr z,texted_prcurline_continue_ab_z
  719.         cp 0x0a
  720. texted_prcurline_continue_ab_z
  721.         ld a,b
  722.         ;ret z
  723.         ret
  724.  
  725. texted_prcurpage
  726.          ;ld e,0
  727.          ;OS_CLS
  728.         ld a,55+0x80 ;or a
  729.         ld (texted_redrawflag),a
  730.         ld hl,(curtoptextaddr)
  731.         ld a,(curtoptextHSB)
  732.         jp texted_prpage
  733.        
  734. texted_gotobof
  735.         xor a
  736.         ld h,a
  737.         ld l,a
  738. ;texted_gotobof_ok
  739.         call texted_settop
  740.         ld (curlineaddr),hl
  741.         ld (curlineaddrHSB),a
  742.         ;ld hl,1
  743.         ;ld (texted_ncurline),hl
  744. ;ahl=curtextline (kept)
  745.         call texted_calccurline
  746.         ld hl,0
  747.         ld (curxy),hl
  748.         jp setredrawflag;texted_prcurpage
  749.  
  750. getsize
  751.         ld hl,(filesize)
  752.         ld a,(filesizeHSW)
  753.         ret
  754.        
  755. texted_gotoeof
  756.         call getsize
  757.         ;ld b,texted_HGT
  758.         ld bc,(textedhgt-1) ;b
  759. texted_end0
  760.         push bc
  761.         call texted_prevline
  762.         pop bc
  763.         djnz texted_end0
  764. ;ahl=curtextline (kept)
  765.         call texted_calccurline
  766.         jp texted_pgdown_bottom
  767.  
  768.  
  769. deccurline
  770.         push hl
  771.         ld hl,(texted_ncurline)
  772.         dec hl
  773.         ld (texted_ncurline),hl
  774.         pop hl
  775.         ret
  776. deccury
  777.         push hl
  778.         ld hl,cury
  779.         dec (hl)
  780.         pop hl
  781.         ret
  782.        
  783. inccurline
  784.         push hl
  785.         ld hl,(texted_ncurline)
  786.         inc hl
  787.         ld (texted_ncurline),hl
  788.         pop hl
  789.         ret
  790. inccury
  791.         push hl
  792.         ld hl,cury
  793.         inc (hl)
  794.         pop hl
  795.         ret
  796.  
  797. texted_up
  798.         ld hl,(curlineaddr)
  799.         ld a,(curlineaddrHSB)
  800.         call texted_prevline
  801.         ret c
  802.         ld (curlineaddr),hl
  803.         ld (curlineaddrHSB),a
  804.         push af
  805.         push hl
  806.         call deccurline
  807.         call setpanelredrawflag
  808.         pop hl
  809.         pop af
  810.         ld c,a
  811.         ld a,(cury)
  812.         sub 1
  813.         ld (cury),a
  814.         ret nc
  815.         inc a
  816.         ld (cury),a
  817.         ld a,c
  818.         call texted_settop
  819.         push af
  820.         push hl
  821.         ld de,texted_XYTOP
  822.         ;ld hl,256*texted_HGT + texted_WID
  823.         ld hl,(textedhgt-1) ;h
  824.         ld l,texted_WID
  825.         call scrolldown ;OS_SCROLLDOWN
  826.         ld de,texted_XYTOP
  827.         call nv_setxy
  828.         pop hl
  829.         pop af
  830.         call texted_prline
  831.         ret
  832.  
  833. texted_down
  834.         ld hl,(curlineaddr)
  835.         ld a,(curlineaddrHSB)
  836.         call texted_nextline
  837.         ret c
  838.         ld (curlineaddr),hl
  839.         ld (curlineaddrHSB),a
  840.         push af
  841.         push hl
  842.         call inccurline
  843.         call setpanelredrawflag
  844.         pop hl
  845.         pop af
  846.         ld c,a
  847.         ld de,(curxy)
  848.         inc d
  849.         ;ld a,texted_HGT
  850.         ld a,(textedhgt)
  851.         cp d
  852.         ld (curxy),de
  853.         ret nz;c
  854.         dec d
  855.         ld (curxy),de
  856.         ld a,c
  857.         push af
  858.         push hl
  859.         ld de,texted_XYTOP
  860.         ;ld hl,256*texted_HGT + texted_WID
  861.         ld hl,(textedhgt-1) ;h
  862.         ld l,texted_WID
  863.        push de
  864.        push hl
  865.         call scrollup ;OS_SCROLLUP
  866.        pop hl
  867.        pop de
  868.        dec h
  869.        ld l,0
  870.        add hl,de
  871.        ex de,hl ;de=texted_XYTOP+((texted_HGT-1)*256)
  872.         call nv_setxy
  873.         pop hl
  874.         pop af
  875.         call texted_prline;_nextline
  876. curtoptextaddr=$+1
  877.         ld hl,0
  878. curtoptextHSB=$+1
  879.         ld a,0
  880.         call texted_nextline
  881. texted_settop        
  882.         ld (curtoptextaddr),hl
  883.         ld (curtoptextHSB),a
  884.         ret
  885.  
  886. texted_pgup
  887.         call setpanelredrawflag
  888.         ld a,(cury)
  889.         or a
  890.         ld b,a
  891.         ld hl,(curlineaddr)
  892.         ld a,(curlineaddrHSB)
  893.         jr z,texted_pgup_top
  894. texted_pgup_gotop0
  895.         push bc
  896.         call texted_prevline
  897.          call nc,deccurline
  898.          call nc,deccury
  899.         pop bc
  900.         djnz texted_pgup_gotop0
  901.         ld (curlineaddr),hl
  902.         ld (curlineaddrHSB),a
  903.         ret
  904. texted_pgup_top
  905.         ;ld b,texted_HGT-1
  906.         ld bc,(textedhgt-1) ;b
  907.         dec b
  908. texted_pgup0
  909.         push bc
  910.         call texted_prevline
  911.          call nc,deccurline
  912.         pop bc
  913.         djnz texted_pgup0
  914.         call texted_settop
  915.         ld (curlineaddr),hl
  916.         ld (curlineaddrHSB),a
  917.         call setredrawflag
  918.         ret
  919.        
  920. texted_pgdown
  921.         call setpanelredrawflag
  922.         ;ld a,(cury)
  923.         ;sub texted_HGT-1
  924.         ;neg
  925.         ;ld b,a
  926.         ld a,(textedhgt)
  927.         dec a
  928.         ld hl,cury
  929.         sub (hl)
  930.         ld b,a
  931.         ld hl,(curlineaddr)
  932.         ld a,(curlineaddrHSB)
  933.         jr z,texted_pgdown_bottom
  934. texted_pgdown_gobottom0
  935.         push bc
  936.         call texted_nextline
  937.          call nc,inccurline
  938.          call nc,inccury
  939.         pop bc
  940.         djnz texted_pgdown_gobottom0
  941.         ld (curlineaddr),hl
  942.         ld (curlineaddrHSB),a
  943.         ret
  944. texted_pgdown_bottom
  945.         push af
  946.         xor a
  947.         ld (cury),a
  948.         pop af
  949.         call texted_settop
  950.         ;ld b,texted_HGT-1
  951.         ld bc,(textedhgt-1) ;b
  952.         dec b
  953. texted_pgdown0
  954.         push bc
  955.         call texted_nextline
  956.          call nc,inccurline
  957.          call nc,inccury
  958.         pop bc
  959.         djnz texted_pgdown0
  960.         ld (curlineaddr),hl
  961.         ld (curlineaddrHSB),a
  962.         jp setredrawflag
  963.        
  964. texted_calccurline
  965. ;ahl=curtextline (kept)
  966.         push af
  967.         push hl
  968.         ld (texted_calccurline_old),hl
  969.         ld (texted_calccurline_oldHSB),a
  970.         ld ix,1;0
  971.          or h
  972.          or l
  973.          jr z,texted_calccurline_countq
  974.         xor a
  975.         ld h,a
  976.         ld l,a
  977. texted_calccurline_count0
  978.         call texted_nextline ;texted_pseudoprline
  979.  
  980.         if 1==0
  981.         jr c,texted_calccurline_countq ;не помогает
  982.         ex de,hl
  983. texted_calccurline_old=$+1
  984.         ld hl,0
  985.         or a
  986.         sbc hl,de ;nc: hl<=old
  987.         ld l,a
  988. texted_calccurline_oldHSB=$+1
  989.         ld a,0
  990.         sbc a,l
  991.         ld a,l
  992.         inc ix
  993.         jr nc,texted_calccurline_count0 ;nc: ahl<=old
  994.         else
  995.        
  996.         push hl
  997. texted_calccurline_old=$+1
  998.         ld bc,0
  999.         or a
  1000.         sbc hl,bc ;nc: hl>=old
  1001.         ld l,a
  1002. texted_calccurline_oldHSB=$+1
  1003.         sbc a,0
  1004.         ld a,l
  1005.         pop hl
  1006.         inc ix
  1007.         jr c,texted_calccurline_count0 ;cy: ahl<old
  1008.         endif
  1009. texted_calccurline_countq
  1010.         ;push ix
  1011.         ;pop hl
  1012.         ld (texted_ncurline),ix;hl
  1013.         pop hl
  1014.         pop af
  1015.         ret
  1016.        
  1017. texted_calclines
  1018. ;sets nlines
  1019.         xor a
  1020.         ld h,a
  1021.         ld l,a
  1022.         ld (nlines),hl
  1023. texted_calclines0
  1024.         call incnlines
  1025.         call texted_nextline
  1026.         jr nc,texted_calclines0
  1027.         ret
  1028.        
  1029. clear_keyboardbuffer
  1030.         push bc
  1031.         ld b,50;5
  1032. clear_keyboardbuffer0
  1033.         push bc
  1034.         GETKEY_
  1035.         pop bc
  1036.         djnz clear_keyboardbuffer0
  1037.         pop bc
  1038.         ret
  1039.        
  1040. texted_changeencoding
  1041.         ld hl,texted_prline_recodepatch
  1042.         ld a,(hl)
  1043.         xor 0x7e ;"ld a,(hl)"
  1044.         ld (hl),a
  1045.         call setredrawflag;texted_prcurpage
  1046.         ;call texted_prcurpage
  1047.         ;ret
  1048. texted_panel
  1049.         ld a,55+0x80 ;or a
  1050.         ld (texted_panelredrawflag),a
  1051.         ;ld de,0x1800
  1052.         ld a,(stdiohgt)
  1053.         dec a
  1054.         ld d,a
  1055.         ld e,0
  1056.         call nv_setxy
  1057.         ld de,_texted_PANELCOLOR
  1058.         SETCOLOR_
  1059.        
  1060.         ld a,(texted_prline_recodepatch)
  1061.         or a
  1062.         ld hl,t866
  1063.         jr z,$+5
  1064.         ld hl,twin
  1065.         call prtext
  1066.        
  1067. fchanged=$+1
  1068.         ld a,' '
  1069.         PRCHAR_
  1070.         call calccurlinex
  1071.         inc hl
  1072.         call prword
  1073.         ld a,','
  1074.         PRCHAR_
  1075. texted_ncurline=$+1
  1076.         ld hl,0
  1077.         call prword
  1078.         ld a,'/'
  1079.         PRCHAR_
  1080.         ld hl,(nlines)
  1081.         ld de,0
  1082.         call prdword_dehl
  1083.         ld a,' '
  1084.         PRCHAR_
  1085.         call getsize
  1086.         ld e,a
  1087.         ld d,0
  1088.         call prdword_dehl
  1089.         ld de,tspaces_filename
  1090.         ld hl,TSPACES_FILENAME_SZ
  1091.         call sendchars
  1092.         ;ld de,_texted_PANELCOLOR;#38
  1093.         ;OS_PRATTR
  1094.         ld de,_COLOR
  1095.         SETCOLOR_
  1096.         ret
  1097.  
  1098. tspaces_filename
  1099.         db ' '
  1100. tshown_filename
  1101.         ds TSPACES_FILENAME_SZ,' '
  1102.        
  1103. twin
  1104.         db "WIN",0
  1105. t866
  1106.         db "866",0
  1107.  
  1108.      
  1109. isbof
  1110. ;out: z=bof
  1111.         push bc
  1112.         ld c,a
  1113.         or h
  1114.         or l
  1115.         ld a,c
  1116.         pop bc
  1117.         ret
  1118. iseof
  1119. ;out: z=eof
  1120.         push bc
  1121.         push de
  1122.         push hl
  1123.         ;ld de,(fcb+FCB_FSIZE)
  1124.         ;ld bc,(fcb+FCB_FSIZE+2)
  1125.         ;ld b,a
  1126.         ;or a
  1127.         ;sbc hl,de
  1128.         ;sbc a,c
  1129.         ;ld a,b
  1130.         ex de,hl
  1131.         ld c,a
  1132.         call getsize
  1133.         or a
  1134.         sbc hl,de
  1135.         sbc a,c
  1136.         or h
  1137.         or l
  1138.         ld a,c
  1139.         pop hl
  1140.         pop de
  1141.         pop bc
  1142.         ret
  1143.      
  1144. texted_prpage
  1145. ;ahl=addr
  1146.         ld (curtoptextaddr),hl
  1147.         ld (curtoptextHSB),a
  1148.         push af
  1149.         ld de,texted_XYTOP
  1150.         call nv_setxy
  1151.         pop af
  1152.         ;ld b,texted_HGT
  1153.         ld bc,(textedhgt-1) ;b
  1154. texted_prpage0
  1155.         push bc
  1156.         ;push de
  1157.         call texted_prline_nextline
  1158.         call c,getsize
  1159.         ;pop de
  1160.         pop bc
  1161.         ;inc d
  1162.         djnz texted_prpage0
  1163.         ;call clear_keyboardbuffer
  1164.         ret
  1165.        
  1166. texted_prevline
  1167. ;ahl=addr
  1168. ;line < 16K
  1169. ;out: ahl, CY=error
  1170.         call isbof
  1171.          scf
  1172.         ret z
  1173. ;перед нами может быть #0d или #0d,#0a или ничего
  1174.         ld (findprevline_old),hl
  1175.         ld (findprevline_oldHSB),a
  1176.        
  1177.         or a
  1178.         ld bc,0xffff
  1179.         jr nz,$+4
  1180.          ld b,h
  1181.          ld c,l
  1182.          
  1183.         ;push de
  1184.         ld de,0x4000
  1185.         or a
  1186.         sbc hl,de
  1187.         sbc a,e;0
  1188.         ;pop de
  1189.        
  1190.         push af
  1191.         push hl
  1192.         call ahl_to_pgaddr
  1193.         set 6,h
  1194. ;hl=c000+, можно уменьшать
  1195. ;bc=number of chars to go != 0
  1196.  
  1197. ;перед нами может быть #0d или #0d,#0a или ничего
  1198.         dec hl
  1199.         dec bc
  1200.         ld a,b
  1201.         or c
  1202.         jr z,texted_prevlineq
  1203.         ld a,0x0a
  1204.         cp (hl)
  1205.         jr nz,texted_prevline_nolf
  1206.         dec hl
  1207.         dec bc
  1208.         ld a,b
  1209.         or c
  1210.         jr z,texted_prevlineq
  1211. texted_prevline_nolf
  1212.         ld a,0x0d
  1213.         cp (hl)
  1214.         jr nz,texted_prevline_nocr
  1215.         dec hl
  1216.         dec bc
  1217.         ld a,b
  1218.         or c
  1219.         jr z,texted_prevlineq
  1220. texted_prevline_nocr
  1221. ;сейчас мы находимся перед символом конца предыдущей строки (не на нём)
  1222. texted_prevline0
  1223.         ld a,(hl)
  1224.         cp 0x0d
  1225.         jr z,texted_prevline_cr
  1226.         cp 0x0a
  1227.         jr z,texted_prevline_lf
  1228.         dec hl
  1229.         dec bc
  1230.         ld a,b
  1231.         or c
  1232.         jr nz,texted_prevline0
  1233. ;beginning of file
  1234.         jr texted_prevlineq
  1235. texted_prevline_cr
  1236. texted_prevline_lf
  1237. ;сейчас мы находимся на конце символа конца строки перед предыдущей
  1238.         inc hl
  1239. texted_prevlineq
  1240.         ex de,hl ;new addr (bits 13..0), bit 14 = overflow
  1241.         pop hl ;old addr
  1242.         pop af
  1243.         call pgaddr_to_ahl
  1244.         call iswrapon ;CY=on
  1245.         ret nc ;no wrap
  1246.  
  1247. findprevline_linewrap
  1248. ;ahl = в начале строки
  1249. ;перед ней может быть #0d или #0d,#0a
  1250. ;надо псевдонапечатать несколько псевдострок, пока не дойдём до текущей
  1251. findprevline_linewrap_count0
  1252.          push af
  1253.          push hl
  1254.         call texted_pseudoprline
  1255.         push hl
  1256. findprevline_old=$+1
  1257.         ld bc,0
  1258.         or a
  1259.         sbc hl,bc ;nc: hl>=old
  1260.         ld l,a
  1261. findprevline_oldHSB=$+1
  1262.         sbc a,0
  1263.         ld a,l
  1264.         pop hl
  1265.          pop de ;old addr
  1266.          pop bc ;b=old HSB
  1267.         jr c,findprevline_linewrap_count0
  1268.         ex de,hl
  1269.         ld a,b
  1270. ;ahl=на псевдострочку раньше
  1271.         ret ;nc
  1272.  
  1273. getmaxlinesize
  1274. ;ahl = addr
  1275. ;out: bc=max line size before eof, z=(bc==0) (keeps ahl)
  1276.          ;push de
  1277.         push af
  1278.         push hl
  1279.         ex de,hl
  1280.         ld c,a
  1281.         call getsize
  1282.         or a
  1283.         sbc hl,de
  1284.         sbc a,c
  1285.         ld bc,0
  1286.         jr c,getmaxlinesize_aftereof
  1287.         dec bc
  1288.         or a
  1289.         jr nz,$+4 ;filesize-addr >= 0x10000, will be 0xffff
  1290.          ld b,h
  1291.          ld c,l ;filesize-addr
  1292. getmaxlinesize_aftereof
  1293.         pop hl
  1294.         pop af
  1295.         ld e,a
  1296.         ld a,b
  1297.         or c
  1298.         ld a,e
  1299.          ;pop de
  1300.         ret
  1301.  
  1302. texted_prline_nextline
  1303.         push af
  1304.         push hl
  1305.         call texted_prline
  1306.         pop hl
  1307.         pop af
  1308. texted_nextline
  1309. ;if eof, returns CY and old addr (use call c,getsize) [eof addr]
  1310. ;ahl=addr
  1311. ;line < 16K
  1312. ;out: ahl, CY=error
  1313.         call iswrapon ;CY=on
  1314.         jp c,texted_pseudoprline
  1315. texted_nextline_nowrap ;для вычисления длины строки
  1316.         call getmaxlinesize ;bc=max line size before eof, z=(bc==0)
  1317.          scf
  1318.         ret z
  1319.         push af
  1320.         push hl
  1321.         call ahl_to_pgaddr
  1322. ;bc=number of chars to go != 0
  1323. texted_nextline0
  1324.         ld a,(hl)
  1325.         inc hl
  1326.         dec bc
  1327.         cp 0x0d
  1328.         jr z,texted_nextline_cr
  1329.         cp 0x0a
  1330.         jr z,texted_nextline_lf
  1331.         ld a,b
  1332.         or c
  1333.         jr nz,texted_nextline0
  1334. ;texted_nextline_eof
  1335.         pop hl ;old addr
  1336.         pop af
  1337.         scf ;error
  1338.         ret
  1339. texted_nextlineq
  1340.         ex de,hl ;new addr (bits 13..0), bit 14 = overflow
  1341.         pop hl ;old addr
  1342.         pop af
  1343.         jp pgaddr_to_ahl
  1344. texted_nextline_cr
  1345.         ld a,b
  1346.         or c
  1347.         jr z,texted_nextlineq
  1348.         ld a,(hl)
  1349.         cp 0x0a
  1350.         jr nz,texted_nextline_lf
  1351.         inc hl
  1352. texted_nextline_lf
  1353.         jr texted_nextlineq
  1354.        
  1355. texted_prline
  1356. ;ahl=addr
  1357. ;check for last line (vs. file size)
  1358. ;if filesize-addr < 80, then b=filesize-addr, else b=80
  1359.         call getmaxlinesize ;bc=max line size before eof, z=(bc==0)
  1360.         jr z,texted_prlinespc_all;ret z
  1361.         call ahl_to_pgaddr
  1362. ;hl=#8000+0..#3fff
  1363. ;bc=max line size before eof != 0
  1364. texted_prline_shift=$+1
  1365.         ld de,0
  1366.         call istherecr_or_lf ;add hl,de
  1367.         ;jr nz,$+3
  1368.         ;dec hl ;hl=cr/lf address
  1369.  
  1370.         push hl
  1371.         ld h,b
  1372.         ld l,c
  1373.         or a
  1374.         sbc hl,de
  1375.         ld b,h
  1376.         ld c,l ;bc=bc-lineshift
  1377.         pop hl
  1378.         ;ld a,texted_WID
  1379.         jr c,texted_prlinespc_all
  1380.         jr z,texted_prlinespc_all ;maxlinesize<=lineshift
  1381.  
  1382.         push hl
  1383.         ld hl,texted_WID
  1384.         call minhl_bc_tobc
  1385.         ld b,c
  1386.         pop hl
  1387. ;b=number of chars to print != 0
  1388.         ld de,prlinebuf
  1389.         ld c,texted_WID
  1390. texted_prline0
  1391.         ld a,(hl)
  1392.         inc hl
  1393.         cp 0x0d
  1394.         jr z,texted_prline_cr
  1395.         cp 0x0a
  1396.         jr z,texted_prline_cr;lf
  1397.         ;push bc
  1398.         push hl
  1399.         ld h,twinto866/256
  1400.         ld l,a
  1401. texted_prline_recodepatch=$
  1402.         nop ;/ld a,(hl)
  1403.         ld (de),a ;PRCHAR_
  1404.         inc de
  1405.         pop hl
  1406.         ;pop bc
  1407.         dec c
  1408.         djnz texted_prline0
  1409.         ;call print_prlinebuf
  1410.         ;jr nz,texted_prline_lf
  1411.         ;ret
  1412. texted_prline_cr
  1413.         call print_prlinebuf
  1414. ;texted_prline_lf
  1415. ;допечатать пробелы до конца строки
  1416.         jr texted_prlinespc
  1417. texted_prlinespc_all
  1418.         ld c,texted_WID
  1419. texted_prlinespc
  1420.         push af
  1421.         push hl
  1422.         ;ld l,b
  1423.         ;ld h,0
  1424.         ;ld de,tspaces
  1425.         ;call sendchars
  1426.          ld a,c
  1427.          or a
  1428.         call nz,clearrestofline_crlf
  1429.         pop hl
  1430.         pop af
  1431.         ret
  1432.  
  1433. print_prlinebuf
  1434.         push af
  1435.         push bc
  1436.         push hl
  1437. ;c=texted_WID-число символов
  1438.         ld de,prlinebuf
  1439.         ld a,texted_WID
  1440.         sub c
  1441.         ld l,a
  1442.         ld h,0
  1443.         call sendchars
  1444.         pop hl
  1445.         pop bc
  1446.         pop af
  1447.         ret
  1448.  
  1449. prlinebuf
  1450.         ds texted_WID
  1451.  
  1452. texted_pseudoprline
  1453. ;ahl=addr
  1454. ;out: ahl, CY=error
  1455. ;check for last line (vs. file size)
  1456. ;if filesize-addr < 80, then b=filesize-addr, else b=80
  1457.         call getmaxlinesize ;bc=max line size before eof, z=(bc==0)
  1458.          scf
  1459.         ret z
  1460.         push af
  1461.         push hl
  1462.         call ahl_to_pgaddr
  1463. ;hl=#8000+0..#3fff
  1464. ;bc=max line size before eof != 0
  1465.         push hl
  1466.         ld hl,texted_WID
  1467.         call minhl_bc_tobc
  1468.         ld b,c
  1469.         pop hl
  1470. ;b=number of chars to print != 0
  1471.         ld c,texted_WID
  1472. texted_pseudoprline0
  1473.         ld a,(hl)
  1474.         inc hl
  1475.         cp 0x0d
  1476.         jr z,texted_pseudoprline_cr
  1477.         cp 0x0a
  1478.         jr z,texted_pseudoprline_lf
  1479.         dec c
  1480.         djnz texted_pseudoprline0
  1481.          ld a,(hl)
  1482.          inc hl
  1483.          cp 0x0d
  1484.          jr z,texted_pseudoprline_crok
  1485.          cp 0x0a
  1486.          jr z,texted_pseudoprline_lf
  1487.          dec hl
  1488.         jp texted_nextlineq
  1489. texted_pseudoprline_cr
  1490.         dec b
  1491.         jp z,texted_nextlineq
  1492. texted_pseudoprline_crok
  1493.         ld a,(hl)
  1494.         cp 0x0a
  1495.         jr nz,texted_pseudoprline_lf
  1496.         inc hl
  1497. texted_pseudoprline_lf
  1498.         jp texted_nextlineq
  1499.        
  1500. ;по идее это псевдопечать N экранных позиций (там могут быть цветовые коды и т.п.)
  1501. istherecr_or_lf
  1502. ;hl=addr ;TODO ahl
  1503. ;de=length to search
  1504. ;out: z=found, hl=at match or after area (TODO ahl)
  1505.         ld a,d
  1506.         or e
  1507.         jr z,istherecr_or_lf_fail
  1508.          push hl
  1509.         ld a,0x0d
  1510.         call istherecrlfgo
  1511.         jr z,istherecr_or_lf_popafZret;ret z
  1512.          pop hl
  1513.         ld a,0x0a
  1514. istherecrlfgo
  1515.         push bc
  1516.         ld b,d
  1517.         ld c,e
  1518.         cpir ;TODO несколько раз через все блоки, если заканчиваются блоки, то их переключать
  1519.         pop bc
  1520.         ret nz ;nz=not found
  1521.          dec hl
  1522.         ret ;z=found
  1523. istherecr_or_lf_fail
  1524.         dec a
  1525.         ret ;nz=not found
  1526.        
  1527. istherecr_or_lf_popafZret
  1528.         pop af
  1529.         cp a ;Z
  1530.         ret
  1531.        
  1532. ;texted_closefcb
  1533. ;        ld de,fcb
  1534. ;        OS_FCLOSE
  1535. ;        ret
  1536.  
  1537. texted_help
  1538.         call clearterm
  1539.         ld hl,thelp
  1540.         call prtext
  1541.         call yieldgetkeyloop
  1542.         jp setredrawflag
  1543.  
  1544. thelp
  1545.         db "Keys in texted:\r\n"
  1546.         db "\r\n"
  1547.         db "стрелки, PageUp (Caps Shift+3), PageDown (Caps Shift+4) - движение курсора\r\n"
  1548.         db "Home (Symbol Shift+Q) - переход к началу строки\r\n"
  1549.         db "End (Symbol Shift+E) - переход к концу строки\r\n"
  1550.         db "Symbol Shift+PageUp - переход к началу текста\r\n"
  1551.         db "Symbol Shift+PageDown - переход к концу текста\r\n"
  1552.         db "BackSpace (Caps Shift+0) - удаление символа слева от курсора\r\n"
  1553.         db "Del (Caps Shift+9) - удаление символа справа от курсора\r\n"
  1554.         db "Break (Esc, Caps Shift+Space) - выход\r\n"
  1555.         db "Ins (Symbol Shift+W) - wrap on/off\r\n"
  1556.         db "F1 - help\r\n"
  1557.         db "F2 или Caps Shift+Enter - сохранение\r\n"
  1558.         db "F9 - запустить build.bat из директории с текстом\r\n"
  1559.         db "F10 - сменить кодировку (866/1251)"
  1560.         db 0
  1561.  
  1562.  
  1563. setunchanged
  1564.         ld a,' '
  1565.         jr setchanged_a
  1566. setchanged
  1567.         ld a,'*'
  1568. setchanged_a
  1569.         ld (fchanged),a
  1570.         ret
  1571.  
  1572. iswrapon
  1573. ;CY = on
  1574. wrapflag=$
  1575.         or a ;/scf
  1576.         ret
  1577.  
  1578. curlineaddr
  1579.         ds 3
  1580. curlineaddrHSB=$-1
  1581.  
  1582. nlines
  1583.         dw 0
  1584.  
  1585. curxy
  1586. curx
  1587.         db 0
  1588. cury
  1589.         db 0
  1590.        
  1591.         align 256
  1592. twinto866
  1593.         incbin "../_sdk/codepage/winto866"
  1594. t866towin
  1595.         ds 256,' ' ;incbin "../_sdk/codepage/866towin"
  1596.