Subversion Repositories Kolibri OS

Rev

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

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