Subversion Repositories Kolibri OS

Rev

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

  1. ;-----------------------------------------------------------------------------
  2. func check_cur_vis_inv ;//////////////////////////////////////////////////////
  3. ;-----------------------------------------------------------------------------
  4.         push    eax ebx
  5.         xor     bl,bl
  6.   .chk_y:
  7.         mov     eax,[cur_tab.Editor.Caret.Y] ;! eax,[pos.y]
  8.         or      eax,eax
  9.         jge     @f
  10.         mov     [cur_tab.Editor.Caret.Y],0 ;! [pos.y],0
  11.         jmp     .chk_dy
  12.     @@: cmp     eax,[cur_tab.Editor.Lines] ;! eax,[lines]
  13.         jl      .chk_dy
  14.         mov     eax,[cur_tab.Editor.Lines] ;! eax,[lines]
  15.         dec     eax
  16.         mov     [cur_tab.Editor.Caret.Y],eax ;! [pos.y],eax
  17.   .chk_dy:
  18.         mov     eax,[cur_tab.Editor.TopLeft.Y] ;! eax,[top_line]
  19.         cmp     eax,[cur_tab.Editor.Caret.Y] ;! eax,[pos.y]
  20.         jle     @f
  21.         m2m     [cur_tab.Editor.TopLeft.Y],[cur_tab.Editor.Caret.Y]
  22. ;!      push    [pos.y]
  23. ;!      pop     [top_line]
  24.         inc     bl
  25.     @@: add     eax,[lines.scr]
  26.         cmp     eax,[cur_tab.Editor.Caret.Y] ;! eax,[pos.y]
  27.         jg      .chk_x
  28.         mov     eax,[cur_tab.Editor.Caret.Y] ;! eax,[pos.y]
  29.         sub     eax,[lines.scr]
  30.         inc     eax
  31.         mov     [cur_tab.Editor.TopLeft.Y],eax ;! [top_line],eax
  32.         inc     bl
  33.   .chk_x:
  34.         mov     eax,[cur_tab.Editor.Caret.X] ;! eax,[pos.x]
  35.         or      eax,eax
  36.         jge     @f
  37.         mov     [cur_tab.Editor.Caret.X],0 ;! [pos.x],0
  38.         jmp     .chk_dx
  39.     @@: cmp     eax,[cur_tab.Editor.Columns] ;! eax,[columns]
  40.         jl      .chk_dx
  41.         mov     eax,[cur_tab.Editor.Columns] ;! eax,[columns]
  42.         mov     [cur_tab.Editor.Caret.X],eax ;! [pos.x],eax
  43.   .chk_dx:
  44.         mov     eax,[cur_tab.Editor.TopLeft.X] ;! eax,[left_col]
  45.         cmp     eax,[cur_tab.Editor.Caret.X] ;! eax,[pos.x]
  46.         jle     @f
  47.         m2m     [cur_tab.Editor.TopLeft.X],[cur_tab.Editor.Caret.X]
  48. ;!      push    [pos.x]
  49. ;!      pop     [left_col]
  50.         inc     bl
  51.     @@: add     eax,[columns.scr]
  52.         cmp     eax,[cur_tab.Editor.Caret.X] ;! eax,[pos.x]
  53.         jg      @f
  54.         mov     eax,[cur_tab.Editor.Caret.X] ;! eax,[pos.x]
  55.         sub     eax,[columns.scr]
  56.         inc     eax
  57.         mov     [cur_tab.Editor.TopLeft.X],eax ;! [left_col],eax
  58.         inc     bl
  59.     @@: cmp     [mev],MEV_LDOWN
  60.         jne     .exit
  61.         push    [cur_tab.Editor.Caret.X] [cur_tab.Editor.Caret.Y] ;! [pos.x] [pos.y]
  62.         pop     [cur_tab.Editor.SelStart.Y] [cur_tab.Editor.SelStart.X] ;! [sel.y] [sel.x]
  63.   .exit:
  64.         or      bl,bl
  65.         clc
  66.         jz      @f
  67.         call    draw_file
  68.         stc
  69.     @@: pop     ebx eax
  70.         ret
  71. endf
  72.  
  73. ;-----------------------------------------------------------------------------
  74. func clear_selection ;////////////////////////////////////////////////////////
  75. ;-----------------------------------------------------------------------------
  76.         push    eax ebx
  77.         mov     eax,[cur_tab.Editor.SelStart.Y] ;! eax,[sel.y]
  78.         mov     ebx,[cur_tab.Editor.Caret.Y] ;! ebx,[pos.y]
  79.         cmp     eax,ebx
  80.         jle     @f
  81.         xchg    eax,ebx
  82.     @@: push    [cur_tab.Editor.Caret.X] [cur_tab.Editor.Caret.Y] ;! [pos.x] [pos.y]
  83.         pop     [cur_tab.Editor.SelStart.Y] [cur_tab.Editor.SelStart.X] ;! [sel.y] [sel.x]
  84.         call    draw_file.ex
  85.         pop     ebx eax
  86.         ret
  87. endf
  88.  
  89. ;-----------------------------------------------------------------------------
  90. func pt_in_rect ;/////////////////////////////////////////////////////////////
  91. ;-----------------------------------------------------------------------------
  92.         cmp     eax,[ecx+0x0]
  93.         jl      @f
  94.         cmp     ebx,[ecx+0x4]
  95.         jl      @f
  96.         cmp     eax,[ecx+0x8]
  97.         jg      @f
  98.         cmp     ebx,[ecx+0xC]
  99.         jg      @f
  100.         stc
  101.         ret
  102.     @@: clc
  103.         ret
  104. endf
  105.  
  106. ;-----------------------------------------------------------------------------
  107. func check_bottom_right ;/////////////////////////////////////////////////////
  108. ;-----------------------------------------------------------------------------
  109.         push    eax
  110.         mov     eax,[cur_tab.Editor.TopLeft.Y] ;! eax,[top_line]
  111.         add     eax,[lines.scr]
  112.         cmp     eax,[cur_tab.Editor.Lines] ;! eax,[lines]
  113.         jbe     .lp1
  114.         mov     eax,[cur_tab.Editor.Lines] ;! eax,[lines]
  115.         sub     eax,[lines.scr]
  116.         jns     @f
  117.         xor     eax,eax
  118.     @@: mov     [cur_tab.Editor.TopLeft.Y],eax ;! [top_line],eax
  119.   .lp1: mov     eax,[cur_tab.Editor.TopLeft.X] ;! eax,[left_col]
  120.         add     eax,[columns.scr]
  121.         cmp     eax,[cur_tab.Editor.Columns] ;! eax,[columns]
  122.         jbe     .exit
  123.         mov     eax,[cur_tab.Editor.Columns] ;! eax,[columns]
  124.         sub     eax,[columns.scr]
  125.         jns     @f
  126.         xor     eax,eax
  127.     @@: mov     [cur_tab.Editor.TopLeft.X],eax ;! [left_col],eax
  128.   .exit:
  129.         pop     eax
  130.         ret
  131. endf
  132.  
  133. ;-----------------------------------------------------------------------------
  134. func check_inv_str ;//////////////////////////////////////////////////////////
  135. ;-----------------------------------------------------------------------------
  136. @^
  137.         mov     eax,[pos.y]
  138.         mov     ecx,[top_line]
  139.   .skip_init:
  140.         call    check_cur_vis
  141.         mov     [pos.y],eax
  142.         mov     [top_line],ecx
  143.   .skip_check:
  144. ;       call    invalidate_string
  145.         call    drawfile
  146.         ret
  147. ^@
  148. endf
  149.  
  150. ;-----------------------------------------------------------------------------
  151. func check_inv_all ;//////////////////////////////////////////////////////////
  152. ;-----------------------------------------------------------------------------
  153.         mov     eax,[cur_tab.Editor.Caret.Y] ;! eax,[pos.y]
  154.         mov     ecx,[cur_tab.Editor.TopLeft.Y] ;! ecx,[top_line]
  155.   .skip_init:
  156.         call    check_cur_vis
  157.         mov     [cur_tab.Editor.Caret.Y],eax ;! [pos.y],eax
  158.         mov     [cur_tab.Editor.TopLeft.Y],ecx ;! [top_line],ecx
  159.   .skip_check:
  160. ;       call    clear_screen
  161.         call    draw_file
  162.         ret
  163. endf
  164.  
  165. ;-----------------------------------------------------------------------------
  166. func check_cur_vis ;//////////////////////////////////////////////////////////
  167. ;-----------------------------------------------------------------------------
  168.         cmp     eax,ecx
  169.         jb      .low
  170.         mov     edx,ecx
  171.         add     edx,[lines.scr]
  172.         cmp     edx,[cur_tab.Editor.Lines] ;! edx,[lines]
  173.         jbe     @f
  174.         mov     edx,[cur_tab.Editor.Lines] ;! edx,[lines]
  175.     @@: cmp     eax,edx
  176.         jb      @f
  177.         lea     ecx,[eax+1]
  178.         sub     ecx,[lines.scr]
  179.         jns     @f
  180.         xor     ecx,ecx
  181.         jmp     @f
  182.   .low: mov     ecx,eax
  183.     @@: mov     edx,ecx
  184.         add     edx,[lines.scr]
  185.         cmp     edx,[cur_tab.Editor.Lines] ;! edx,[lines]
  186.         jbe     @f
  187.         mov     ecx,[cur_tab.Editor.Lines] ;! ecx,[lines]
  188.         sub     ecx,[lines.scr]
  189.         jns     @f
  190.         xor     ecx,ecx
  191.     @@:;mov     [top_line],ecx
  192.  
  193.         pushad
  194.         mov     eax,[cur_tab.Editor.Caret.X] ;! eax,[pos.x]
  195.         mov     ebx,[cur_tab.Editor.TopLeft.X] ;! ebx,[left_col]
  196.         mov     ecx,ebx
  197.         add     ecx,[columns.scr]
  198.         cmp     eax,ebx
  199.         jb      .lp1
  200.         cmp     eax,ecx
  201.         jb      .exit
  202.         lea     ebx,[eax]
  203.         sub     ebx,[columns.scr]
  204.         jmp     @f
  205.   .lp1: mov     ebx,eax
  206.     @@: mov     [cur_tab.Editor.TopLeft.X],ebx ;! [left_col],ebx
  207.  
  208.   .exit:
  209.         mov     [cur_tab.Editor.Caret.X],eax ;! [pos.x],eax
  210.         popad
  211.  
  212.         ret
  213. endf
  214.  
  215. ;-----------------------------------------------------------------------------
  216. func get_real_length ;////////////////////////////////////////////////////////
  217. ;-----------------------------------------------------------------------------
  218.         movzx   eax,word[esi]
  219.     @@: cmp     byte[esi+eax+4-1],' '
  220.         jne     @f
  221.         dec     eax
  222.         jnz     @b
  223.     @@: ret
  224. endf
  225.  
  226. ;-----------------------------------------------------------------------------
  227. func get_line_offset ;////////////////////////////////////////////////////////
  228. ;-----------------------------------------------------------------------------
  229. ; Input:
  230. ;  ECX = line number
  231. ; Output:
  232. ;  ESI = line data offset
  233. ;-----------------------------------------------------------------------------
  234.         push    eax ecx
  235.         mov     esi,[cur_tab.Editor.Data] ;! AREA_EDIT
  236.     @@: dec     ecx
  237.         js      .exit
  238.         movzx   eax,word[esi]
  239.         lea     esi,[esi+eax+4]
  240.         jmp     @b
  241.   .exit:
  242.         pop     ecx eax
  243.         ret
  244. endf
  245.  
  246. ;-----------------------------------------------------------------------------
  247. func init_sel_vars ;//////////////////////////////////////////////////////////
  248. ;-----------------------------------------------------------------------------
  249.         pushad
  250.         mov     [sel.selected],1
  251.         mov     eax,[cur_tab.Editor.SelStart.X] ;! eax,[sel.x]
  252.         mov     ebx,[cur_tab.Editor.SelStart.Y] ;! ebx,[sel.y]
  253.         mov     ecx,[cur_tab.Editor.Caret.X] ;! ecx,[pos.x]
  254.         mov     edx,[cur_tab.Editor.Caret.Y] ;! edx,[pos.y]
  255.         cmp     ebx,edx
  256.         jl      .lp2
  257.         jne     @f
  258.         cmp     eax,ecx
  259.         jl      .lp2
  260.         jne     .lp1
  261.         dec     [sel.selected]
  262.         jmp     .lp2
  263.     @@: xchg    ebx,edx
  264.   .lp1: xchg    eax,ecx
  265.   .lp2: mov     [sel.begin.x],eax
  266.         mov     [sel.begin.y],ebx
  267.         mov     [sel.end.x],ecx
  268.         mov     [sel.end.y],edx
  269.         popad
  270.         ret
  271. endf
  272.  
  273. ;-----------------------------------------------------------------------------
  274. func get_scroll_vars ;////////////////////////////////////////////////////////
  275. ;-----------------------------------------------------------------------------
  276. ; Input:
  277. ;  EAX = maximum data size      (units)
  278. ;  EBX = visible data size      (units)
  279. ;  ECX = current data position  (units)
  280. ;  EDX = scrolling area size    (pixels)
  281. ; Output:
  282. ;  EAX = srcoller offset        (pixels)
  283. ;  EBX = scroller size          (pixels)
  284. ;-----------------------------------------------------------------------------
  285.         push    eax ebx edx
  286. ;       sub     eax,ebx
  287.         mov     esi,eax
  288.         mov     eax,edx
  289.         imul    ebx
  290.         idiv    esi
  291.         cmp     eax,[esp]
  292.         jge     .null
  293.         cmp     eax,AMINS
  294.         jge     @f
  295.         neg     eax
  296.         add     eax,AMINS
  297.         sub     [esp],eax
  298.         mov     eax,AMINS
  299.     @@: mov     [esp+4],eax     ; scroller size
  300.         mov     eax,[esp]
  301.         imul    ecx
  302.         idiv    esi
  303.         or      eax,eax
  304.         jns     @f
  305.         xor     eax,eax
  306.    @@:  mov     [esp+8],eax    ; scroller offset
  307.         add     eax,[esp+4]
  308.         cmp     eax,[esp]
  309.         jle     @f
  310. ;        mov     eax,[esp]
  311. ;        sub     eax,[esp+4]
  312. ;        js      @f
  313. ;        mov     [esp+8],eax
  314.     @@:
  315.         pop     edx ebx eax
  316.         ret
  317.   .null:
  318.         mov     dword[esp+4],0
  319.         mov     dword[esp+8],0
  320.         jmp     @b
  321. endf
  322.  
  323. ;-----------------------------------------------------------------------------
  324. func uint2strz ;//////////////////////////////////////////////////////////////
  325. ;-----------------------------------------------------------------------------
  326.         dec     ebx
  327.         jz      @f
  328.         xor     edx,edx
  329.         div     ecx
  330.         push    edx
  331.         call    uint2strz
  332.         pop     eax
  333.     @@: cmp     al,10
  334.         sbb     al,$69
  335.         das
  336.         stosb
  337.         ret
  338. endf
  339.  
  340. ;-----------------------------------------------------------------------------
  341. func uint2str ;///////////////////////////////////////////////////////////////
  342. ;-----------------------------------------------------------------------------
  343.         cmp     eax,ecx
  344.         jb      @f
  345.         xor     edx,edx
  346.         div     ecx
  347.         push    edx
  348.         call    uint2str
  349.         pop     eax
  350.     @@: cmp     al,10
  351.         sbb     al,$69
  352.         das
  353.         stosb
  354.         ret
  355. endf
  356.  
  357. ;-----------------------------------------------------------------------------
  358. func strlen ;/////////////////////////////////////////////////////////////////
  359. ;-----------------------------------------------------------------------------
  360.         push    ebx
  361.         mov     ebx,eax
  362.         xor     eax,eax
  363.     @@: cmp     byte[ebx+eax],0
  364.         je      @f
  365.         inc     eax
  366.         jmp     @b
  367.     @@: pop     ebx
  368.         ret
  369. endf
  370.  
  371. ;-----------------------------------------------------------------------------
  372. func rgb_to_gray ;////////////////////////////////////////////////////////////
  373. ;-----------------------------------------------------------------------------
  374.         push    0 eax
  375.         and     dword[esp],0x000000FF
  376.         fild    dword[esp]
  377.         fmul    [float_gray_b]
  378.         shr     eax,8
  379.         mov     [esp],eax
  380.         and     dword[esp],0x000000FF
  381.         fild    dword[esp]
  382.         fmul    [float_gray_g]
  383.         faddp
  384.         shr     eax,8
  385.         and     eax,0x000000FF
  386.         mov     [esp],eax
  387.         fild    dword[esp]
  388.         fmul    [float_gray_r]
  389.         faddp
  390.         frndint
  391.         fist    dword[esp]
  392.         fist    dword[esp+1]
  393.         fistp   dword[esp+2]
  394.         pop     eax
  395.         add     esp,4
  396.         ret
  397. endf
  398.  
  399. ;float_gray_r dd 0.30f
  400. ;float_gray_g dd 0.59f
  401. ;float_gray_b dd 0.11f
  402.  
  403. ;-----------------------------------------------------------------------------
  404. func get_active_menu_item ;///////////////////////////////////////////////////
  405. ;-----------------------------------------------------------------------------
  406.         pushad
  407.         mov     [mi_cur],0
  408.         mcall   37,1
  409.         movsx   ebx,ax
  410.         sar     eax,16
  411.         mov     ecx,__rc
  412.         pushd   2 0 (main_menu.width+7) (ATOPH-2)
  413.         popd    [__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0]
  414. ;       add     [__rc+0xC],ATOPH-2
  415.         call    pt_in_rect
  416.         jnc     .outside_menu
  417.         m2m     dword[ecx+0x8],dword[ecx+0x0]
  418.         mov     edx,main_menu
  419.     @@: inc     [mi_cur]
  420.         movzx   esi,word[edx+0]
  421.         add     [ecx+0x8],esi
  422.         call    pt_in_rect
  423.         jc      .exit
  424.         m2m     dword[ecx+0x0],dword[ecx+0x8]
  425.         add     edx,8+1
  426.         movzx   esi,byte[edx-1]
  427.         add     edx,esi
  428.         cmp     byte[edx+8],0
  429.         jne     @b
  430.         mov     [mi_cur],0
  431.   .exit:
  432.         popad
  433.         ret
  434.   .outside_menu:
  435.         or      [mi_cur],-1
  436.     @@: popad
  437.         ret
  438. endf
  439.  
  440. ;-----------------------------------------------------------------------------
  441. func get_active_popup_item ;//////////////////////////////////////////////////
  442. ;-----------------------------------------------------------------------------
  443.         pushad
  444.         mov     [pi_cur],0
  445.         mcall   37,1
  446.         movsx   ebx,ax
  447.         sar     eax,16
  448.         mov     ecx,__rc
  449.         mov     dword[ecx+0x0],0
  450.         mov     dword[ecx+0x4],0
  451.         movzx   edx,[ebp+POPUP.width]
  452.         mov     dword[ecx+0x8],edx;POP_WIDTH
  453.         movzx   edx,[ebp+POPUP.height]
  454.         mov     dword[ecx+0xC],edx;POP_HEIGHT
  455.         call    pt_in_rect
  456.         jnc     .outside_window
  457.         inc     dword[ecx+0x0]
  458.         mov     dword[ecx+0x4],3
  459.         dec     dword[ecx+0x8]
  460.         mov     dword[ecx+0xC],3+POP_IHEIGHT-1
  461.         mov     edx,[ebp+POPUP.data];popup_text.data
  462.     @@: inc     [pi_cur]
  463.         inc     edx
  464.         movzx   esi,byte[edx-1]
  465.         cmp     byte[edx],'-'
  466.         jne     .lp1
  467.         pushd   [ecx+0xC]
  468.         sub     dword[ecx+0xC],POP_IHEIGHT-4
  469.         call    pt_in_rect
  470.         popd    [ecx+0xC]
  471.         jc      .separator
  472.         add     dword[ecx+0x4],4
  473.         add     dword[ecx+0xC],4
  474.         jmp     .lp3
  475.   .lp1: call    pt_in_rect
  476.         jnc     .lp2
  477.         mov     eax,[pi_cur]
  478.         test    byte[ebp+eax-1],1;byte[popup_text+eax-1],1
  479.         jnz     .exit
  480.         jmp     .separator
  481.   .lp2: add     dword[ecx+0x4],POP_IHEIGHT
  482.         add     dword[ecx+0xC],POP_IHEIGHT
  483.         add     edx,esi
  484.         inc     edx
  485.         movzx   esi,byte[edx-1]
  486.   .lp3: add     edx,esi
  487.         cmp     byte[edx],0
  488.         jne     @b
  489.   .separator:
  490.         mov     [pi_cur],0
  491.   .exit:
  492.         popad
  493.         ret
  494.   .outside_window:
  495.         or      [pi_cur],-1
  496.         jmp     .exit
  497. endf
  498.  
  499. ;-----------------------------------------------------------------------------
  500. func line_add_spaces ;////////////////////////////////////////////////////////
  501. ;-----------------------------------------------------------------------------
  502. ; esi = line offset
  503. ; ecx = needed line length
  504. ;-----------------------------------------------------------------------------
  505.         pushad
  506.         movzx   edx,word[esi]
  507.         cmp     ecx,edx
  508.         jbe     .exit
  509.         sub     ecx,edx
  510.         push    ecx
  511.         mov     edi,[cur_tab.Editor.Data] ;! AREA_TEMP2
  512.         add     edi,[edi-4]
  513.         dec     edi
  514.         mov     eax,esi
  515.         mov     esi,edi
  516.         sub     esi,ecx
  517.         lea     ecx,[eax+4]
  518.         add     ecx,edx;[eax]
  519.         push    ecx
  520.         neg     ecx
  521.         lea     ecx,[esi+ecx+1]
  522.         std
  523. diff16 '32DC',0,$
  524.         rep     movsb
  525.         pop     edi ecx
  526.         add     [eax],cx
  527.         mov     al,' '
  528.         cld
  529.         rep     stosb
  530.   .exit:
  531.         popad
  532.         ret
  533. endf
  534.  
  535. ;-----------------------------------------------------------------------------
  536. func delete_selection ;///////////////////////////////////////////////////////
  537. ;-----------------------------------------------------------------------------
  538. ;       call    init_sel_vars
  539.  
  540.         cmp     [sel.selected],0
  541.         je      .exit.2
  542.  
  543.         pushad
  544.         mov     ecx,[sel.begin.y]
  545.         cmp     ecx,[sel.end.y]
  546.         je      .single_line
  547.         call    get_line_offset
  548.         and     dword[esi],not 0x00020000
  549.         or      dword[esi],0x00010000
  550.         mov     ecx,[sel.begin.x]
  551.         call    line_add_spaces
  552.         lea     edi,[esi+4]
  553.         mov     ecx,[sel.end.y]
  554.         call    get_line_offset
  555.         call    get_real_length
  556.         cmp     eax,[sel.end.x]
  557.         jbe     @f
  558.         mov     eax,[sel.end.x]
  559.     @@: movzx   ecx,word[esi]
  560.         sub     ecx,eax
  561.         mov     ebx,[sel.begin.x]
  562.         add     ebx,ecx
  563.         mov     [edi-4],bx
  564.         add     edi,[sel.begin.x]
  565.         lea     esi,[esi+eax+4]
  566.         mov     ecx,[cur_tab.Editor.Data] ;! AREA_TEMP2
  567.         add     ecx,[ecx-4]
  568.         sub     ecx,esi
  569.         cld
  570.         rep     movsb
  571.         mov     eax,[sel.end.y]
  572.         sub     eax,[sel.begin.y]
  573.         sub     [cur_tab.Editor.Lines],eax ;! [lines],eax
  574.         jmp     .exit
  575.  
  576.   .single_line:
  577.         call    get_line_offset
  578.         and     dword[esi],not 0x00020000
  579.         or      dword[esi],0x00010000
  580.         call    get_real_length
  581.         cmp     eax,[sel.begin.x]
  582.         jbe     .exit
  583.         mov     ecx,[sel.end.x]
  584.         cmp     ecx,eax
  585.         jbe     @f
  586.         mov     ecx,eax
  587.     @@: sub     ecx,[sel.begin.x]
  588.         sub     [esi],cx
  589.         lea     edi,[esi+4]
  590.         add     edi,[sel.begin.x]
  591.         lea     esi,[edi+ecx]
  592.         mov     ecx,[cur_tab.Editor.Data] ;! AREA_TEMP2
  593.         add     ecx,[ecx-4]
  594.         sub     ecx,esi
  595.         cld
  596.         rep     movsb
  597.  
  598.   .exit:
  599.         mov     eax,[sel.begin.x]
  600.         mov     [cur_tab.Editor.Caret.X],eax ;! [pos.x],eax
  601.         mov     [cur_tab.Editor.SelStart.X],eax ;! [sel.x],eax
  602.         mov     eax,[sel.begin.y]
  603.         mov     [cur_tab.Editor.Caret.Y],eax ;! [pos.y],eax
  604.         mov     [cur_tab.Editor.SelStart.Y],eax ;! [sel.y],eax
  605.         popad
  606.         mov     [cur_tab.Editor.Modified],1 ;! [modified],1
  607.         clc
  608.         ret
  609.  
  610.   .exit.2:
  611.         stc
  612.         ret
  613. endf
  614.  
  615. ;-----------------------------------------------------------------------------
  616. func get_selection_size ;/////////////////////////////////////////////////////
  617. ;-----------------------------------------------------------------------------
  618.         push    ecx esi
  619.         mov     ecx,[sel.end.y]
  620.         inc     ecx
  621.         call    get_line_offset
  622.         mov     eax,esi
  623.         mov     ecx,[sel.begin.y]
  624.         call    get_line_offset
  625.         sub     eax,esi
  626.         pop     esi ecx
  627.         ret
  628. endf
  629.  
  630. ;-----------------------------------------------------------------------------
  631. func get_lines_in_file ;//////////////////////////////////////////////////////
  632. ;-----------------------------------------------------------------------------
  633. ; ESI = data pointer
  634. ; ECX = data length
  635. ;-----------------------------------------------------------------------------
  636.         push    ebx ecx esi
  637.         or      ebx,-1
  638.   .lp0: inc     ebx
  639.   .lp1: dec     ecx
  640.         jle     .lp2
  641.         lodsb
  642.         cmp     al,10
  643.         je      .LF
  644.         cmp     al,13
  645.         je      .CR
  646.         jmp     .lp1
  647.   .lp2: mov     eax,ebx
  648.         pop     esi ecx ebx
  649.         ret
  650.  
  651.    .CR: cmp     byte[esi],10
  652.         jne     .lp0
  653.         lodsb
  654.    .LF: jmp     .lp0
  655. endf
  656.  
  657. ;-----------------------------------------------------------------------------
  658. func mem.Alloc ;//////////////////////////////////////////////////////////////
  659. ;-----------------------------------------------------------------------------
  660.         push    ebx ecx
  661.         lea     ecx,[eax+4+4095]
  662.         and     ecx,not 4095
  663.         mcall   68,12
  664.         add     ecx,-4
  665.         mov     [eax],ecx
  666.         add     eax,4
  667.         pop     ecx ebx
  668.         ret
  669. endf
  670.  
  671. ;-----------------------------------------------------------------------------
  672. func mem.ReAlloc ;////////////////////////////////////////////////////////////
  673. ;-----------------------------------------------------------------------------
  674.         push    ebx ecx esi edi eax
  675.         or      eax,eax
  676.         jz      @f
  677.         lea     ecx,[ebx+4+4095]
  678.         and     ecx,not 4095
  679.         add     ecx,-4
  680.         cmp     ecx,[eax-4]
  681.         je      .exit
  682.     @@: mov     eax,ebx
  683.         call    mem.Alloc
  684.         xchg    eax,[esp]
  685.         or      eax,eax
  686.         jz      .exit
  687.         mov     esi,eax
  688.         xchg    eax,[esp]
  689.         mov     edi,eax
  690.         mov     ecx,[esi-4]
  691.         cmp     ecx,[edi-4]
  692.         jbe     @f
  693.         mov     ecx,[edi-4]
  694.     @@: add     ecx,3
  695.         shr     ecx,2
  696.         cld
  697.         rep     movsd
  698.         xchg    eax,[esp]
  699.         call    mem.Free
  700.   .exit:
  701.         pop     eax edi esi ecx ebx
  702.         ret
  703. endf
  704.  
  705. ;-----------------------------------------------------------------------------
  706. func mem.Free ;///////////////////////////////////////////////////////////////
  707. ;-----------------------------------------------------------------------------
  708.         push    ebx ecx
  709.         lea     ecx,[eax-4]
  710.         mcall   68,13
  711.         pop     ecx ebx
  712.         ret
  713. endf
  714.