Subversion Repositories Kolibri OS

Rev

Rev 1343 | Rev 1456 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. proc mouse_wnd_main, edit:dword
  2.   push eax ebx ecx edi
  3.   mcall 37,2 ;get mouse buttons
  4.  
  5.   mov edi,dword[edit]
  6.  
  7.   cmp al,1
  8.   jne @f
  9.     mcall 37,1 ;get mouse coords
  10.     mov ebx,ted_wnd_t
  11.     add ebx,ted_rec_t
  12.     cmp ax,bx
  13.     jl @f ;y_mouse<y_wnd
  14.  
  15.     sub ebx,ted_rec_t
  16.     add ebx,ted_wnd_h
  17.     cmp bx,ax
  18.     jl @f ;y_mouse>y_wnd
  19.  
  20.     mov ebx,ted_wnd_l
  21.     add ebx,ted_rec_l
  22.     mov ecx,eax
  23.     shr ecx,16
  24.     cmp cx,bx
  25.     jl @f ;x_mouse<x_wnd
  26.  
  27.     sub ebx,ted_rec_l
  28.     add ebx,ted_wnd_w
  29.     cmp bx,cx
  30.     jl @f ;x_mouse>x_wnd
  31.  
  32.     stdcall draw_cursor_sumb, tedit0
  33.     call wnd_main_click
  34.     jmp .no_in_wnd
  35.   @@:
  36.     call wnd_main_mouse_scroll
  37.     cmp ted_drag_m,0
  38.     je .no_in_wnd
  39.       mov ted_drag_m,0
  40.       call draw_but_toolbar
  41.       stdcall draw_main_win, tedit0
  42.   .no_in_wnd:
  43.   pop edi ecx ebx eax
  44.   ret
  45. endp
  46.  
  47. ;input:
  48. ; eax -> (x,y)
  49. ; edi -> óêàçàòåëü íà ñòðóêòóðó tedit
  50. ;description:
  51. ; ôóíêöèÿ âûçûâåòñÿ ïðè íàæàòèè êíîïêîé ìûøè è ïîïàäåíèè êóðñîðîì â îêíî ðåäàêòîðà
  52. wnd_main_click:
  53.   push ecx edx
  54.  
  55.   push eax
  56.     shr eax,16
  57.     and eax,0xffff
  58.     sub eax,ted_wnd_l
  59.     sub eax,ted_rec_l
  60.  
  61.     xor edx,edx
  62.     mov ecx,ted_rec_w
  63.     div cx
  64.     ;inc eax
  65.     cmp eax,[hScr.cur_area]
  66.     jle @f
  67.       mov eax,[hScr.cur_area]
  68.     @@:
  69.     ;dec eax
  70.     mov [cur_x],eax
  71.   pop eax
  72.  
  73.   push eax
  74.     and eax,0xffff
  75.     sub eax,ted_wnd_t
  76.     sub eax,ted_rec_t
  77.  
  78.     xor edx,edx
  79.     mov ecx,ted_rec_h
  80.     div cx
  81.     inc eax
  82.     cmp eax,[wScr.cur_area]
  83.     jle @f
  84.       mov eax,[wScr.cur_area]
  85.     @@:
  86.     dec eax
  87.     mov [cur_y],eax
  88.   pop eax
  89.  
  90.   cmp ted_drag_m,0
  91.   je @f
  92.     call SelMove
  93.     jmp .sel_move
  94.   @@:
  95.     mov ted_drag_m,1
  96.     call SelStart
  97.   .sel_move:
  98.   pop edx ecx
  99.   ret
  100.  
  101. wnd_main_mouse_scroll:
  102.   push eax ebx
  103.   mcall 37,7
  104.   cmp ax,0
  105.   je .no_scroll
  106.     mov ebx,dword[wScr.position] ;copy old scroll position
  107.     and eax,0xffff
  108.     btr ax,15
  109.     jae @f
  110.       or eax,0xffff8000
  111.     @@:
  112.     add dword[wScr.position],eax
  113.  
  114.     mov eax,[wScr.position]
  115.     cmp eax,[wScr.max_area]
  116.     jb @f
  117.       mov dword[wScr.position],ebx ;if scroll position out of range
  118.       jmp .no_scroll
  119.     @@:
  120.     stdcall draw_main_win, tedit0
  121.   .no_scroll:
  122.   pop ebx eax
  123.   ret
  124.  
  125. draw_but_toolbar:
  126.  
  127.   push ebx ecx edx
  128.   mov ecx,0x40000000
  129. ;  mov edx,5*65536+25
  130.   mov edx,85*65536+2
  131.   call draw_but_icon
  132.  
  133.   inc cx
  134. ;  mov edx,30*65536+25
  135.   mov edx,110*65536+2
  136.   call draw_but_icon
  137.  
  138. call CanSave
  139. cmp al,1
  140. je @f
  141. and ecx,0xffff
  142. @@:
  143.   inc cx
  144. ;  mov edx,55*65536+25
  145.   mov edx,135*65536+2
  146.   call draw_but_icon
  147. or ecx,0x40000000
  148.  
  149.   inc cx
  150.   mov edx,85*65536+25
  151.   call draw_but_icon
  152.  
  153. stdcall IsSel, tedit0
  154. cmp al,0
  155. jne @f
  156. and ecx,0xffff
  157. @@:
  158.   inc cx ; Cut
  159.   mov edx,110*65536+25
  160.   call draw_but_icon
  161.  
  162.   inc cx ; Copy
  163.   mov edx,135*65536+25
  164.   call draw_but_icon
  165.  
  166.   mov cx,10 ; Upper
  167.   mov edx,265*65536+25
  168.   call draw_but_icon
  169.  
  170.   inc cx ; Lower
  171.   mov edx,290*65536+25
  172.   call draw_but_icon
  173.  
  174.   inc cx ; Reverse
  175.   mov edx,315*65536+25
  176.   call draw_but_icon
  177. or ecx,0x40000000
  178.  
  179. cmp byte[buf],0
  180. jne @f
  181. and ecx,0xffff
  182. @@:
  183.   mov cx,6 ; Paste
  184.   mov edx,160*65536+25
  185.   call draw_but_icon
  186. or ecx,0x40000000
  187.  
  188.   inc cx
  189.   mov edx,185*65536+25
  190.   call draw_but_icon
  191.  
  192.   inc cx
  193.   mov edx,210*65536+25
  194.   call draw_but_icon
  195.  
  196.   inc cx
  197.   mov edx,235*65536+25
  198.   call draw_but_icon
  199.  
  200. mov ebx,[tim_Undo]
  201. cmp [ch_tim],ebx
  202. jg @f
  203. and ecx,0xffff
  204. @@:
  205.   mov cx,13
  206.   mov edx,345*65536+25
  207.   call draw_but_icon
  208. or ecx,0x40000000
  209.  
  210. cmp [tim_Undo],1
  211. jge @f
  212. and ecx,0xffff
  213. @@:
  214.   inc cx
  215.   mov edx,370*65536+25
  216.   call draw_but_icon
  217. or ecx,0x40000000
  218.  
  219.   inc cx
  220.   mov edx,400*65536+25
  221.   call draw_but_icon
  222.  
  223.   inc cx
  224.   mov edx,425*65536+25
  225.   call draw_but_icon
  226.  
  227.   mov cx,17
  228.   mov edx,450*65536+25
  229.   call draw_but_icon
  230.  
  231.   pop edx ecx ebx
  232.   ret
  233.  
  234. ;input:
  235. ;  clear_o - åñëè =1 î÷èñòèòü îäíó ñòðîêó, =0 î÷èñòèòü âñå ñòðîêè îêíà äî íèçó
  236. proc clear_line_before_draw, edit:dword, coords:dword, clear_o:dword, numb_lin:dword
  237.   pushad
  238.     mov edi,dword[edit]
  239.     mov ebx,dword[coords]   ;ebx = x*2^16+y coords to left up point clear line
  240.     mov esi,dword[numb_lin] ;esi - number text line
  241.  
  242.     sub ebx,0x10001 ;îòíèìàåì îòñòóïû äëÿ âûðàâíèâàíèÿ áóêâû ïî öåíòðó
  243.     cmp dword[clear_o],0
  244.     jne @f
  245.       add ebx,ted_rec_h
  246.       inc esi
  247.       ror ebx,16
  248.           xor bx,bx
  249.       add ebx,ted_wnd_l
  250.       add ebx,ted_rec_l ;bx = ted_wnd_l+ted_rec_l
  251.       ror ebx,16
  252.     @@:
  253.  
  254.     mov eax,ted_wnd_h
  255.     add eax,ted_wnd_t
  256.     cmp ax,bx
  257.     jl .no_clear
  258.     sub ax,bx
  259.  
  260.     mov cx,bx
  261.     shl ecx,16
  262.  
  263.     xor bx,bx
  264.     add ebx,ted_wnd_w
  265.     sub ebx,ted_rec_l
  266.         xor cx,cx
  267.     add ecx,ted_rec_h
  268.     mov edx,[WND_WORK_COLOR]
  269.  
  270.     cmp dword[clear_o],0
  271.     je .pusto
  272.     cmp ax,cx
  273.     jge @f
  274.       .pusto:
  275.       mov cx,ax
  276.     @@:
  277.  
  278.     stdcall IsSel,edi
  279.     cmp al,0
  280.     je @f
  281.     cmp [seln.y0],esi
  282.     jg @f
  283.     cmp [seln.y1],esi
  284.     jl @f
  285.       mov edx,[SELECT_COLOR] ;draw selected line
  286.     @@:
  287.  
  288.     mov eax,13 ;rect
  289.     int 0x40
  290.  
  291.     stdcall IsSel,edi
  292.     cmp al,0
  293.     je .no_clear
  294.  
  295.     mov al,13 ;rect
  296.         xor cx,cx
  297.     add ecx,ted_rec_h
  298.     cmp [seln.y0],esi
  299.     jne @f
  300.       push bx
  301.       mov edx,[seln.x0] ; âåðõíÿÿ ïîëîñà (çàòèðàåò ñëåâà)
  302.       cmp edx,[hScr.position]
  303.       jle .in_wnd
  304.         sub edx,[hScr.position]
  305.         imul edx,ted_rec_w
  306.         mov bx,dx
  307.         jmp .no_wnd
  308.       .in_wnd:
  309.         mov bx,0
  310.       .no_wnd:
  311.       mov edx,[WND_WORK_COLOR]
  312.       int 0x40
  313.       pop bx
  314.     @@:
  315.     cmp [seln.y1],esi
  316.     jne @f
  317.       mov edx,[seln.x1] ; íèæíÿÿ ïîëîñà (çàòèðàåò ñïðàâà)
  318.       cmp edx,[hScr.position]
  319.       jle .in_wnd2
  320.         sub edx,[hScr.position]
  321.         imul edx,ted_rec_w
  322.         sub bx,dx
  323.         shl edx,16
  324.         add ebx,edx
  325.       .in_wnd2:
  326.  
  327.       mov edx,[WND_WORK_COLOR]
  328.       int 0x40
  329.     @@:
  330.  
  331.   .no_clear:
  332.   popad
  333.   ret
  334. endp
  335.  
  336.  
  337. proc draw_main_win, edit:dword
  338.   locals
  339.     line_num dd ?
  340.   endl
  341.   pushad
  342.   mov edi,dword[edit]
  343.  
  344.   mov eax,4 ;draw text
  345.   mov ecx,[tex_colors]
  346.   push dword[ecx]
  347.   pop ecx
  348.  
  349.   mov ebx,ted_wnd_l
  350.   add ebx,ted_rec_l
  351.   shl ebx,16
  352.   add ebx,ted_wnd_t
  353.   add ebx,ted_rec_t
  354.   add ebx,0x10001 ;äîáàâëÿåì îòñòóïû äëÿ âûðàâíèâàíèÿ áóêâû ïî öåíòðó
  355.  
  356.   call SelNormalize ;need before draw select
  357.   mov esi,[wScr.position]
  358.   mov dword[line_num],esi
  359.  
  360.   stdcall clear_line_before_draw, tedit0,ebx,1,esi
  361.   call GetFirstVisiblePos
  362.   cmp edx,0
  363.   je .no_draw_text
  364.   mov esi,1 ;äëèííà âûâîäèìîãî òåêñòà ïî 1-ìó ñèìâîëó
  365.   @@:
  366.     call IteratNext
  367.     cmp edx,[tex_1]
  368.     jle .no_draw_text
  369.  
  370.     ; *** öâåòîâàÿ ðàçìåòêà
  371.     cmp byte[mode_colored],0
  372.     je .no_col_change
  373.     cmp byte[edx+1],0
  374.     je .no_col_change
  375.       call GetSymbColor
  376.     .no_col_change:
  377.  
  378.     cmp byte [edx],13
  379.     jne .no_13
  380.       cmp [invis],1
  381.       jne .no_invis
  382.         push edx
  383.         mov edx,symbol_new_line
  384.         int 0x40
  385.         pop edx
  386.       .no_invis:
  387.       add ebx,ted_rec_h
  388.       ;optimized output \/
  389.       mov eax,ted_wnd_h
  390.       add eax,ted_wnd_t
  391.       cmp bx,ax
  392.       jg .no_draw_text
  393.       mov eax,4
  394.       ;optimized output /\       
  395.           and ebx,0xffff
  396.       ror ebx,16
  397.       add ebx,ted_wnd_l
  398.       add ebx,ted_rec_l
  399.       inc ebx
  400.       ror ebx,16
  401.       inc dword[line_num] ;increment line number
  402.       stdcall clear_line_before_draw, tedit0,ebx,1,dword[line_num]
  403.       call OptDrawLineLeft
  404.       jmp @b
  405.     .no_13:
  406.  
  407.     int 0x40
  408.     ror ebx,16
  409.     add ebx,ted_rec_w
  410.     mov esi,ted_wnd_l
  411.     add esi,ted_wnd_w
  412.     cmp bx,si
  413.     jl .no_opt
  414.       call OptDrawLineRight
  415.     .no_opt:
  416.         mov si,1
  417.     ror ebx,16
  418.     jmp @b
  419.   .no_draw_text:
  420.  
  421.   stdcall clear_line_before_draw, tedit0,ebx,0,dword[line_num]
  422.   stdcall draw_line_numbers, tedit0
  423.   stdcall draw_main_cursor, tedit0
  424.  
  425. ;---------------------------------------------
  426. ; set all_redraw flag for draw all ScrollBar
  427. ; In some cases it is necessity to draw only the area
  428. ; of moving of a "runner", for acceleration of output -
  429. ; in this case the flag needs to be reset to 0 (zero).
  430.         xor     eax,eax
  431.         inc     eax
  432.         mov     [wScr.all_redraw],eax
  433.         mov     [hScr.all_redraw],eax  
  434.  
  435. ; draw for Vertical ScrollBar
  436.         stdcall [scrollbar_ver_draw], dword wScr
  437.         stdcall [scrollbar_hor_draw], dword hScr
  438. ; reset all_redraw flag
  439.         xor     eax,eax
  440.         mov     [wScr.all_redraw],eax
  441.         mov     [hScr.all_redraw],eax
  442. ;---------------------------------------------
  443.  
  444.   mov eax,13
  445.   ;left-bottom square
  446.   mov ebx,ted_wnd_l
  447.   shl ebx,16
  448.   add ebx,ted_rec_l
  449.   mov ecx,ted_wnd_t
  450.   add ecx,ted_wnd_h
  451.   shl ecx,16
  452.   mov cx,word[hScr.size_y]
  453.   inc cx
  454.   mov edx,[sc.work]
  455.   int 0x40
  456.  
  457.   ;right-bottom square
  458.   mov ebx,ted_wnd_l
  459.   add ebx,ted_wnd_w
  460.   shl ebx,16
  461.   mov bx,word[wScr.size_x]
  462.   inc bx
  463.   int 0x40
  464.  
  465.   stdcall draw_panel_find, edi
  466.   stdcall draw_panel_syntax, edi
  467.   popad
  468.   ret
  469. endp
  470.  
  471. ;txtBUp db 24
  472. ;txtBDn db 25
  473. ;txtBRi db 26
  474. ;txtBLe db 27
  475. proc draw_panel_find, edit:dword
  476.   push edi
  477.   mov edi,dword[edit]
  478.  
  479.   cmp byte[panel_id],TE_PANEL_FIND ;if not panel
  480.   jne @f
  481.   push eax ebx ecx edx
  482.  
  483.   mov eax,13 ;ðèñîâàíèå ïðÿìîóãîëüíèêà
  484.   mov ebx,TE_PANEL_WIDTH
  485.   mov ecx,ted_wnd_t
  486.   shl ecx,16
  487.   mov cx,20
  488.   mov edx,[sc.work]
  489.   int 0x40
  490.  
  491.   mov eax,4 ;ðèñîâàíèå òåêñòà
  492.   mov ebx,30*65536+5
  493.   add ebx,ted_wnd_t
  494.   mov ecx,[sc.work_text]
  495.   or ecx,0x80000000
  496.   mov edx,txtFindCapt
  497.   int 0x40
  498.  
  499.   push dword edit2
  500.   call [edit_box_draw]
  501.  
  502.   mov eax,13 ;ðèñîâàíèå ïðÿìîóãîëüíèêà
  503.   mov ebx,TE_PANEL_WIDTH
  504.   mov ecx,ted_wnd_t
  505.   add cx,20+15 ; 15 - height text box
  506.   shl ecx,16
  507.   add ecx,ted_wnd_h
  508.   add cx,word[hScr.size_y]
  509.   sub cx,20+15-1 ; 15 - height text box
  510.   mov edx,[sc.work]
  511.   int 0x40
  512.  
  513.   mov eax,8 ;êíîïêà
  514.   mov ebx,5*65536+85
  515.   mov ecx,ted_wnd_t
  516.   add cx,20+15+5
  517.   shl ecx,16
  518.   mov cx,20
  519.   mov edx,201 ;button id
  520.   mov esi,[sc.work_button]
  521.   int 0x40
  522.  
  523.   mov eax,4 ;ðèñîâàíèå òåêñòà
  524.   mov ebx,15*65536+(20+15+10)
  525.   add ebx,ted_wnd_t
  526.   mov ecx,[sc.work_text]
  527.   or ecx,0x80000000
  528.   mov edx,txtFindNext
  529.   int 0x40
  530.  
  531.   pop edx ecx ebx eax
  532.   jmp .end_f
  533.   @@:
  534.   push eax edx
  535.     mov eax,8
  536.     mov edx,201
  537.     or edx,0x80000000
  538.     int 0x40
  539.   pop edx eax
  540.   .end_f:
  541.   pop edi
  542.   ret
  543. endp
  544.  
  545. proc draw_panel_syntax, edit:dword
  546.   push edi
  547.   mov edi,dword[edit]
  548.  
  549.   cmp byte[panel_id],TE_PANEL_SYNTAX ;if not panel
  550.   jne @f
  551.   push eax ebx ecx edx
  552.  
  553.   mov eax,13 ;ðèñîâàíèå ïðÿìîóãîëüíèêà
  554.   mov ebx,TE_PANEL_WIDTH
  555.   mov ecx,ted_wnd_t
  556.   shl ecx,16
  557.   mov cx,20
  558.   mov edx,[sc.work]
  559.   int 0x40 ;ðèñîâàíèå âåðõíåãî ôîíîâîãî ïðÿìîóãîëüíèêà
  560.  
  561.   stdcall dword[tl_draw], dword tree1
  562.   mov [ws_dir_lbox.all_redraw],1 ;äëÿ ïîëíîé ïåðåðèñîâêè äî÷åðíåãî ñêðîëëèíãà
  563.   stdcall dword[scrollbar_ver_draw], dword ws_dir_lbox
  564.  
  565.   ror ecx,16
  566.   add ecx,dword[tree1.box_height]
  567.   add ecx,20
  568.   and ecx,0xffff
  569.   ror ecx,16
  570.   add ecx,ted_wnd_h
  571.   add cx,word[hScr.size_y]
  572.   sub cx,20
  573.   sub ecx,dword[tree1.box_height]
  574.   inc cx
  575.   int 0x40 ;ðèñîâàíèå íèæíåãî ôîíîâîãî ïðÿìîóãîëüíèêà
  576.  
  577.   mov eax,8 ;êíîïêà
  578.   mov ebx,5*65536+65
  579.   mov ecx,ted_wnd_t
  580.   add ecx,25
  581.   add ecx,dword[tree1.box_height]
  582.   shl ecx,16
  583.   mov cx,20
  584.   mov edx,200 ;button id
  585.   mov esi,[sc.work_button]
  586.   int 0x40
  587.  
  588.   mov eax,4 ;ðèñîâàíèå òåêñòà
  589.   mov ebx,30*65536+5
  590.   add ebx,ted_wnd_t
  591.   mov ecx,[sc.work_text]
  592.   or ecx,0x80000000
  593.   mov edx,txtFormatCapt
  594.   int 0x40
  595.  
  596.   mov ebx,10*65536+30
  597.   add ebx,dword[tree1.box_height]
  598.   add ebx,ted_wnd_t
  599.   mov edx,txtFormatApply
  600.   int 0x40
  601.  
  602.   pop edx ecx ebx eax
  603.   jmp .end_f
  604.   @@:
  605.     push eax edx
  606.       mov eax,8
  607.       mov edx,200
  608.       or edx,0x80000000
  609.       int 0x40 ;åñëè íåò ïàíåëè òî óäàëÿåì êíîïêó
  610.     pop edx eax
  611.   .end_f:
  612.   pop edi
  613.   ret
  614. endp
  615.  
  616. proc draw_cur_line, edit:dword
  617.   pushad
  618.     mov edi,dword[edit]
  619.  
  620.     mov ebx,ted_wnd_l
  621.     add ebx,ted_rec_l
  622.     shl ebx,16
  623.     mov eax,[cur_y]
  624.     imul eax,ted_rec_h
  625.         mov bx,ax
  626.     add ebx,ted_wnd_t
  627.     add ebx,ted_rec_t ;ebx - êîîðäèíàòû äëÿ ïðÿìîóãîëüíèêà î÷èñòêè ëèíèè
  628.         add ebx,0x10001   ;äîáàâëÿåì îòñòóïû äëÿ âûðàâíèâàíèÿ áóêâû ïî öåíòðó
  629.  
  630.     call SelNormalize ;need before draw select
  631.         mov ecx,[cur_y]
  632.     add ecx,[wScr.position]
  633.     stdcall clear_line_before_draw, tedit0, ebx,1,ecx
  634.  
  635.     mov esi,[hScr.position]
  636.     call GetPosByParam
  637.  
  638.   cmp [gpOpt],2
  639.   jne .no_draw_text
  640. ;  mov eax,4 ;draw text
  641.   call GetSymbColor
  642.   mov esi,1 ;draw 1 symbol
  643.   @@:
  644.     ;call IteratNext
  645.     cmp edx,[tex_1]
  646.     jle .no_draw_text
  647.  
  648.     ; *** öâåòîâàÿ ðàçìåòêà
  649.     cmp byte[mode_colored],0
  650.     je .no_col_change
  651.     cmp byte[edx+1],0
  652.     je .no_col_change
  653.       call GetSymbColor
  654.     .no_col_change:
  655.  
  656.     mov eax,4 ;draw text
  657.     cmp byte [edx],13
  658.     jne .no_13
  659.       cmp [invis],1
  660.       jne .no_draw_text
  661.  push edx
  662.  mov edx,symbol_new_line
  663.  int 0x40
  664.  pop edx
  665.       jmp .no_draw_text
  666.     .no_13:
  667.  
  668.     int 0x40
  669.     ror ebx,16
  670.     add ebx,ted_rec_w
  671.     mov eax,ted_wnd_w
  672.     add eax,ted_wnd_l ;ax = îòñòóï ïî îñè x
  673.     cmp bx,ax
  674.     jge .no_draw_text ;Opt
  675.     ror ebx,16
  676.     call IteratNext
  677.     jmp @b
  678.   .no_draw_text:
  679.  
  680.   stdcall draw_main_cursor, tedit0
  681.   popad
  682.   ret
  683. endp
  684.  
  685. MIN_M_WND_H equ 100
  686. MIN_W_SCRL_ARE equ 3
  687. MIN_H_SCRL_ARE equ 3
  688. proc EvSize, edit:dword
  689.   push eax ecx edx edi
  690.   mov edi,dword[edit]
  691.  
  692.   m2m ted_wnd_w,[procinfo.client_box.width] ;ñòàâèì øèðèíó îêíà ðåäàêòîðà ðàâíîé øèðèíå âñåãî îêíà
  693.   mov eax,ted_wnd_l
  694.   sub ted_wnd_w,eax ;îòíèìàåì îòñòóï ñëåâà
  695.   mov eax,[wScr]    ;+0 size_x
  696.   and eax,0xffff
  697.   sub ted_wnd_w,eax ;îòíèìàåì øèðèíó âåðò. ñêðîëëèíãà
  698.  
  699.   m2m ted_wnd_h,[procinfo.client_box.height] ;ñòàâèì âûñîòó îêíà ðåäàêòîðà ðàâíîé âûñîòå âñåãî îêíà
  700.   cmp ted_wnd_h,MIN_M_WND_H
  701.   jg @f
  702.     mov ted_wnd_h,MIN_M_WND_H
  703.   @@:
  704.  
  705.   mov ax,word[hScr.size_y]
  706.   and eax,0xffff
  707.   sub ted_wnd_h,eax           ;îòíèìàåì âûñîòó ãîðèç. ñêðîëëèíãà
  708.     mov eax,ted_wnd_h         ;eax = âûñîòà îêíà - âûñîòà ãîðèç. ñêðîëëèíãà
  709.     mov word[hScr.start_y],ax ;ïåðåäâèãàåì ãîðèç. ñêðîëëèíã
  710.   mov eax,ted_wnd_t
  711.   sub ted_wnd_h,eax           ;îòíèìàåì îòñòóï ñâåðõó
  712.  
  713.   mov eax,ted_wnd_w
  714.   mov ecx,ted_wnd_l
  715.   add eax,ecx
  716.   mov word[wScr.start_x],ax   ;ïåðåäâèãàåì âåðò. ñêðîëëèíã
  717.   mov eax,ted_wnd_h
  718.   mov word[wScr.size_y],ax    ;çàäàåì âûñîòó âåðò. ñêðîëëèíãà
  719.  
  720.   add ecx,ted_rec_l     ;ecx=ted_wnd_l+ted_rec_l
  721.   mov [hScr.start_x],cx ;ñäâèãàåì ãîðèç. ñêðîëëèíã ïî ðàçìåðó ëåâîãî îòñòóïà äëÿ öèôð
  722.   mov eax,ted_wnd_w
  723.   sub eax,ted_rec_l
  724.   mov word[hScr.size_x],ax ;çàäàåì øèðèíó ãîðèç. ñêðîëëèíãà
  725.  
  726.   mov eax,ted_wnd_h ;calculate lines in page
  727.   sub eax,ted_rec_t
  728.   xor edx,edx
  729.   mov ecx,ted_rec_h
  730.   div ecx
  731.   cmp eax,MIN_W_SCRL_ARE
  732.   jg @f
  733.     mov eax,MIN_W_SCRL_ARE
  734.   @@:
  735.   mov [wScr.cur_area],eax
  736.  
  737.   mov eax,ted_wnd_w ;calculate cols in page
  738.   sub eax,ted_rec_l
  739.   xor edx,edx
  740.   mov ecx,ted_rec_w
  741.   div ecx
  742.   cmp eax,MIN_H_SCRL_ARE
  743.   jg @f
  744.     mov eax,MIN_H_SCRL_ARE
  745.   @@:
  746.   dec eax ; ???
  747.   mov [hScr.cur_area],eax
  748.  
  749.   mov eax,ted_wnd_t
  750.   mov edi,dword tree1
  751.   mov tl_box_top,eax ;=ted_wnd_t
  752.   add tl_box_top,20
  753.  
  754.   mov dword[edit2.top],eax ;=ted_wnd_t
  755.   add dword[edit2.top],20
  756.  
  757.   pop edi edx ecx eax
  758.   call OnInitialUpdate
  759.   ret
  760. endp
  761.  
  762. OnInitialUpdate:
  763.   mov [wScr.redraw],1
  764.   mov [hScr.redraw],1
  765.   ret
  766.  
  767. ;output:
  768. ; edx = pointer to symbol
  769. ; edx = 0 if text not in screen
  770. GetFirstVisiblePos:
  771.   push ecx
  772.   mov edx,[tex]
  773.   xor ecx,ecx
  774.   @@:
  775.     cmp ecx,[wScr.position]
  776.     je @f
  777.     call IteratNext
  778.     cmp edx,[tex_1]
  779.     jle @f
  780.     cmp byte [edx],13
  781.     jne @b
  782.     inc ecx
  783.     jmp @b
  784.   @@:
  785.  
  786.   cmp ecx,[wScr.position]
  787.   je @f
  788.     xor edx,edx
  789.   @@:
  790.   cmp ecx,[wScr.max_area]
  791.   jle @f
  792.     mov [wScr.max_area],ecx
  793.   @@:
  794.   pop ecx
  795.   call OptDrawLineLeft
  796.   ret
  797.  
  798.  
  799.  
  800. ;input:
  801. ; edx = pointer to symbol
  802. ;output:
  803. ; edx = pointer to first left symbol
  804. OptDrawLineLeft:
  805.   push ecx
  806.   mov ecx,[hScr.position]
  807.   cmp ecx,0
  808.   je .ret_f
  809.   push eax
  810.   mov eax,edx
  811.  
  812.   cmp edx,[tex]
  813.   jne @f
  814.     call IteratNext
  815.     jmp .beg_cycle
  816.   @@:
  817.  
  818.   cmp ecx,0
  819.   je @f
  820.  
  821.   cmp byte[edx],13
  822.   jne @f
  823.     call IteratNext
  824.     .beg_cycle:
  825.   @@:
  826.     cmp edx,[tex_1]
  827.     jle @f
  828.     cmp byte[edx],13
  829.     je @f
  830.     cmp ecx,0
  831.     je @f
  832.     mov eax,edx
  833.     call IteratNext
  834.     dec ecx
  835.     jmp @b
  836.   @@:
  837.     mov edx,eax
  838.   pop eax
  839.   .ret_f:
  840.   pop ecx
  841.   call GetSymbColor
  842.   ret
  843.  
  844. ;input:
  845. ; edx = pointer to symbol
  846. ;output:
  847. ; edx = pointer to 13 symbol
  848. OptDrawLineRight:
  849.   push eax
  850.   mov eax,edx
  851.   @@:
  852.     cmp edx,[tex_1]
  853.     jle @f
  854.     cmp byte[edx],13
  855.     je @f
  856.     mov eax,edx
  857.     call IteratNext
  858.     jmp @b
  859.   @@:
  860.   mov edx,eax ;perv sumbol
  861.   pop eax
  862.   call GetSymbColor
  863.   ret
  864.  
  865. proc draw_main_cursor, edit:dword
  866.   pushad
  867.   mov edi,dword[edit]
  868.  
  869.   mov eax,13 ;draw cursor
  870.   mov ecx,ted_wnd_t ;calc rect -> y0,y1
  871.   add ecx,ted_rec_t
  872.   mov edx,[cur_y]
  873.   imul edx,ted_rec_h
  874.   add ecx,edx
  875.  
  876.   cmp [curMod],1 ;ïðîâåðêà ðåæèìà ðàáîòû êóðñîðà (îáû÷íûé èëè âñòàâêà)
  877.   jne @f
  878.     mov edx,ted_rec_h
  879.     inc edx   ;1->1, 3->2, 5->3, ...
  880.     shr edx,1 ;edx = âûñîòà ñòðîêè äåëåííàÿ íà 2 (êîãäà êóðñîð íå ïîëíûé)
  881.     add ecx,edx
  882.   @@:
  883.   shl ecx,16
  884.   add ecx,ted_rec_h
  885.   cmp [curMod],1
  886.   jne @f
  887.     shr cx,1 ;äåëèì âûñîòó êóðñîðà íà 2
  888.   @@:
  889.  
  890.   mov ebx,ted_wnd_l ;calc rect -> x0,x1
  891.   add ebx,ted_rec_l
  892.   mov edx,[cur_x]
  893.   imul edx,ted_rec_w
  894.   add ebx,edx
  895.   shl ebx,16
  896.   add ebx,ted_rec_w
  897.  
  898.   mov edx,[CURSOR_COLOR]
  899.   int 0x40 ;âûâîä êóðñîðà
  900.  
  901.   call GetPos
  902.   cmp [gpOpt],2
  903.   jne @f
  904.     mov eax,4 ;draw text
  905.     mov esi,1
  906.     ror ecx,16
  907.     mov bx,cx
  908.     add ebx,0x10001
  909.     cmp [curMod],1
  910.     jne .no_up_tetx
  911.       mov ecx,ted_rec_h
  912.       inc cx ; 1->1, 3->2, 5->3, ...
  913.       shr cx,1
  914.       sub bx,cx
  915.     .no_up_tetx:
  916.     mov ecx,[CUR_TEXT_COLOR]
  917.     call ConvertInvisSymb
  918.     int 0x40
  919.   @@:
  920.  
  921.   mov eax,4
  922.   mov ebx,ted_wnd_l
  923.   add ebx,ted_rec_l
  924.   shl ebx,16
  925.   add ebx,ted_wnd_t
  926.   add ebx,3
  927.   mov ecx,[WND_BORD_COLOR]
  928.   or  ecx,0x80000000
  929.   mov edx,txtRow
  930.   int 0x40 ;âûâîä ïîäïèñè 'Ñòðîêà'
  931.  
  932.   add ebx,0x500000
  933.   mov edx,txtCol
  934.   int 0x40 ;âûâîä ïîäïèñè 'Çíàê'
  935.  
  936.   cmp [tim_Undo],0
  937.   je @f
  938.     add ebx,0x500000
  939.     mov edx,txtOtm
  940.     int 0x40
  941.     sub ebx,0x500000
  942.   @@:
  943.  
  944.   stdcall draw_bufer, edi
  945.   stdcall draw_help_f1, edi
  946.  
  947.   mov eax,47 ;draw cursor coords
  948.   mov esi,[WND_BORD_COLOR]
  949.   or  esi,0x40000000
  950.  
  951.   mov edx,ebx
  952.   ror edx,16
  953.   sub edx,35
  954.   ror edx,16
  955.   ;add edx,3
  956.   mov ebx,0x40000 ;Row=...
  957.   mov ecx,[cur_y]
  958.   inc ecx
  959.   add ecx,[wScr.position]
  960. ; edi <> tedit ----------------------------------------------------------------
  961.   mov edi,[WND_WORK_COLOR]
  962.   int 0x40
  963.  
  964.   ;mov ebx,0x40000 ;Col=...
  965.   mov ecx,[cur_x]
  966.   inc ecx
  967.   add ecx,[hScr.position]
  968.   add edx,0x500000
  969.   int 0x40
  970.  
  971.   cmp [tim_Undo],0
  972.   je @f
  973.     mov ecx,[tim_Undo]
  974.     add edx,0x500000
  975.     int 0x40
  976.   @@:
  977.  
  978.   popad
  979.   ret
  980. endp
  981.  
  982. proc draw_bufer, edit:dword
  983.   pushad
  984.   mov edi,dword[edit]
  985.  
  986.   cmp byte[buf],0
  987.   je @f
  988.     mov ebx,ted_wnd_l
  989.     add ebx,ted_rec_l
  990.   add bx,250
  991.     shl ebx,16
  992.     add ebx,ted_wnd_t
  993.     add ebx,3
  994.     mov ecx,[WND_BORD_COLOR]
  995.     or  ecx,0x40000000
  996.     mov edi,[WND_WORK_COLOR]
  997.    
  998.     mov edx,txtBuf
  999.     mov esi,buf
  1000.     call strlen
  1001. if lang eq ru
  1002.     cmp eax,15
  1003.     jle .crop_buf
  1004.       mov eax,15
  1005.     .crop_buf:
  1006.     mov esi,7 ;7=len(txtBuf)
  1007. else
  1008.     cmp eax,14
  1009.     jle .crop_buf
  1010.       mov eax,14
  1011.     .crop_buf:
  1012.     mov esi,8 ;8=len(txtBuf)
  1013. end if
  1014.     add esi,eax
  1015.  
  1016.     mov eax,4
  1017.     int 0x40
  1018.   @@:
  1019.   popad
  1020.   ret
  1021. endp
  1022.  
  1023. proc draw_help_f1, edit:dword
  1024.   pushad
  1025.   mov edi,dword[edit]
  1026.  
  1027.   mov eax,13 ;clear place before draw help
  1028.   mov ebx,ted_wnd_l
  1029.   add ebx,ted_rec_l
  1030.   shl ebx,16
  1031.   add ebx,ted_wnd_w
  1032.   sub ebx,ted_rec_l
  1033.   mov ecx,ted_wnd_t
  1034.   add ecx,13
  1035.   shl ecx,16
  1036.   add ecx,ted_rec_h
  1037.   mov edx,[WND_CAPT_COLOR]
  1038.   int 0x40
  1039.  
  1040.   cmp [help_id],-1
  1041.   je @f
  1042.     mov eax,[help_id]
  1043.     ColToIndexOffset eax,edx
  1044.  
  1045.     ;SetCoordinates
  1046.     mov ebx,ted_wnd_l
  1047.     add ebx,ted_rec_l
  1048.     shl ebx,16
  1049.     add ebx,ted_wnd_t
  1050.     add ebx,13 ;=3+10
  1051.  
  1052.     ;SetTextColor
  1053.     xor eax,eax
  1054.     mov al,byte[edx+MAX_COLOR_WORD_LEN+6]
  1055.     shl ax,2
  1056.     mov ecx,[tex_colors]
  1057.     add ecx,eax
  1058.     push dword[ecx]
  1059.     pop ecx
  1060.     or  ecx,0xc0000000 ;SetTextStyles
  1061.     mov edi,[WND_WORK_COLOR]
  1062. ; edi <> edit -----------------------------------------------------------------
  1063.     mov eax,4
  1064.     int 0x40
  1065.  
  1066.     ;*** draw help string ***
  1067.     mov ecx,[WND_BORD_COLOR]
  1068.     or ecx,0x80000000
  1069.     mov edi,dword[edx+MAX_COLOR_WORD_LEN]
  1070.     cmp edi,0
  1071.     je @f
  1072.       add edi,dword[tex_help_f1]
  1073.       mov edx,edi
  1074.       add ebx,0x500000
  1075.       int 0x40
  1076.   @@:
  1077.   popad
  1078.   ret
  1079. endp
  1080.  
  1081. proc draw_line_numbers, edit:dword
  1082.   pushad
  1083.   mov edi,dword[edit]
  1084.  
  1085.   ;top panel with caption
  1086.   mov ebx,ted_wnd_l
  1087. ;  add ebx,ted_rec_l
  1088.   shl ebx,16
  1089.   add ebx,ted_wnd_w
  1090. ;  sub ebx,ted_rec_l
  1091.   mov edx,[WND_WORK_COLOR]
  1092.   mov ecx,ted_wnd_t
  1093.   shl ecx,16
  1094.   add ecx,ted_rec_t
  1095.   mov eax,13
  1096.   mov edx,[WND_CAPT_COLOR]
  1097.   int 0x40
  1098.  
  1099.   ;line numbers
  1100.   mov ebx,0x40000 ;format
  1101.   mov ecx,[wScr.position]
  1102.   inc ecx
  1103.   mov edx,3
  1104.   add edx,ted_wnd_l
  1105.   rol edx,16
  1106.   add edx,ted_wnd_t
  1107.   add edx,ted_rec_t
  1108.   @@:
  1109.  
  1110. push ebx ecx edx
  1111.   ;left panel with numbers
  1112.   mov ebx,ted_wnd_l
  1113.   shl ebx,16
  1114.   add ebx,ted_rec_l
  1115.   mov ecx,ted_rec_h
  1116.   rol ecx,16
  1117.   mov cx,dx
  1118.   rol ecx,16
  1119.   mov eax,13
  1120.   mov edx,[WND_CAPT_COLOR]
  1121.   int 0x40 ;ðèñóåì ïðÿìîóãîëüíèê ïîä íîìåðîì ñòðîêè
  1122. pop edx ecx ebx
  1123.  
  1124.     mov eax,47
  1125.     mov esi,[WND_BORD_COLOR]
  1126.     int 0x40 ;ðèñóåì íîìåð ñòðîêè
  1127.     inc ecx
  1128.     add edx,ted_rec_h
  1129.     sub edx,ted_wnd_t
  1130.         mov esi,edx
  1131.         and esi,0xffff
  1132.     cmp esi,ted_wnd_h
  1133.     jge @f
  1134.     add edx,ted_wnd_t
  1135.     jmp @b
  1136.   @@:
  1137.  
  1138.   popad
  1139.   ret
  1140. endp
  1141.  
  1142. ;this function need to optimize output
  1143. proc draw_cursor_sumb, edit:dword
  1144.   push eax ecx edx edi
  1145.   mov edi,dword[edit]
  1146.  
  1147.   mov eax,13 ;rect
  1148.   mov ebx,ted_wnd_l
  1149.   add ebx,ted_rec_l
  1150.   mov edx,[cur_x]
  1151.   imul edx,ted_rec_w
  1152.   add ebx,edx
  1153.   shl ebx,16
  1154.   add ebx,ted_rec_w
  1155.  
  1156.   mov ecx,ted_wnd_t ;calc rect -> y0,y1
  1157.   add ecx,ted_rec_t
  1158.   mov edx,[cur_y]
  1159.   imul edx,ted_rec_h
  1160.   add ecx,edx
  1161.   shl ecx,16
  1162.   add ecx,ted_rec_h
  1163.  
  1164.   mov edx,[WND_WORK_COLOR]
  1165.   push ecx
  1166.     call SelNormalize
  1167.  
  1168.     mov ecx,[wScr.position]
  1169.     sub [seln.y0],ecx
  1170.     sub [seln.y1],ecx
  1171.  
  1172.     mov ecx,[cur_y]
  1173.     cmp ecx,[seln.y0]
  1174.     jl .no_cur_sel
  1175.     cmp ecx,[seln.y1]
  1176.     jg .no_cur_sel
  1177.     mov edx,[SELECT_COLOR]
  1178.    
  1179.     cmp ecx,[seln.y0]
  1180.     jne @f
  1181.       mov ecx,[cur_x]
  1182.       add ecx,[hScr.position]
  1183.       cmp ecx,[seln.x0]
  1184.       jge @f
  1185.         mov edx,[WND_WORK_COLOR]
  1186.     @@:
  1187.  
  1188.     mov ecx,[cur_y]
  1189.     cmp ecx,[seln.y1]
  1190.     jne .no_cur_sel
  1191.       mov ecx,[cur_x]
  1192.       add ecx,[hScr.position]
  1193.       cmp ecx,[seln.x1]
  1194.       jl .no_cur_sel
  1195.       mov edx,[WND_WORK_COLOR]
  1196.  
  1197.     .no_cur_sel:
  1198.   pop ecx
  1199.   int 0x40
  1200.  
  1201.   call GetPos
  1202.   cmp [gpOpt],2
  1203.   jne @f
  1204.     push esi
  1205.     mov eax,4 ;draw text
  1206.     mov esi,1
  1207.     ror ecx,16
  1208.     mov bx,cx
  1209.     add ebx,0x10001
  1210.     ;mov ecx,[WND_TEXT_COLOR]
  1211.     call GetSymbColor
  1212.     call ConvertInvisSymb
  1213.     int 0x40
  1214.     pop esi
  1215.   @@:
  1216.  
  1217.   pop edi edx ecx eax
  1218.   ret
  1219. endp
  1220.  
  1221.  
  1222. ;input:
  1223. ; edx = pointer to text
  1224. ;output:
  1225. ; ecx = color
  1226. ; if mode_colored=0 then ecx=WND_TEXT_COLOR
  1227. GetSymbColor:
  1228.   mov ecx,[WND_TEXT_COLOR]
  1229.  
  1230.   push eax edx
  1231.   cmp byte[mode_colored],0
  1232.   je .exit
  1233.     jmp .on_first
  1234.     @@:
  1235.       call IteratPerv
  1236.       cmp edx,[tex_1]
  1237.       jle .exit
  1238.     .on_first:
  1239.       xor eax,eax
  1240.       mov al,byte[edx+1]
  1241.       cmp al,0
  1242.     je @b
  1243.  
  1244.     ;cmp al,0xff
  1245.     ;je .exit
  1246.     cmp eax,[ColColor]
  1247.     jge .exit
  1248.  
  1249.     shl ax,2 ;*4
  1250.     mov ecx,[tex_colors]
  1251.     add ecx,eax
  1252.     push dword[ecx]
  1253.     pop ecx
  1254.   .exit:
  1255.   pop edx eax
  1256.   ret
  1257.  
  1258. ;input:
  1259. ; edx = pointer to text
  1260. ConvertInvisSymb:
  1261.   cmp [invis],1
  1262.   jne @f
  1263.   cmp byte [edx],13
  1264.   jne @f
  1265.     mov edx,symbol_new_line
  1266.   @@:
  1267.   ret
  1268.  
  1269. ;input:
  1270. ;  ecx = 0x4000____
  1271. ;   cx = icon index
  1272. ;  edx = x*2^16+y
  1273. draw_but_icon:
  1274.   push eax ebx
  1275.  
  1276.   mov eax,8 ;êíîïêà
  1277.   push ecx edx esi
  1278.   mov ebx,edx
  1279.   mov edx,ecx
  1280.   add edx,3
  1281.   mov cx,bx
  1282.   shl ecx,16
  1283.   mov cx,19 ;=20-1
  1284.   mov bx,19 ;=20-1
  1285.   mov esi,[sc.work_button]
  1286.   int 0x40
  1287.   pop esi edx ecx
  1288.  
  1289.   mov ebx,ecx
  1290.   ror ebx,16
  1291.   cmp bx,0x4000
  1292.   jne @f
  1293.  
  1294.   mov eax,7 ;bmp
  1295.   mov ebx,[bmp_icon]
  1296.   push ecx
  1297.   and ecx,0xffff
  1298.   imul ecx,1200
  1299.   add ebx,ecx
  1300.   mov ecx,20
  1301.   shl ecx,16
  1302.   add ecx,20
  1303.   int 0x40
  1304.   pop ecx
  1305.  
  1306.   @@:
  1307.   pop ebx eax
  1308.   ret
  1309.  
  1310.