Subversion Repositories Kolibri OS

Rev

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

  1.  
  2. sz s_defname,'Untitled',0
  3.  
  4. ;-----------------------------------------------------------------------------
  5. func flush_cur_tab ;//////////////////////////////////////////////////////////
  6. ;-----------------------------------------------------------------------------
  7. ; EBP = TABITEM*
  8. ;-----------------------------------------------------------------------------
  9.         push    ecx esi edi
  10.         mov     esi,cur_tab
  11.         mov     edi,[tab_bar.Current.Ptr]
  12.         mov     ecx,sizeof.TABITEM/4
  13.         cld
  14.         rep     movsd
  15.         pop     edi esi ecx
  16.         ret
  17. endf
  18.  
  19. ;-----------------------------------------------------------------------------
  20. func set_cur_tab ;////////////////////////////////////////////////////////////
  21. ;-----------------------------------------------------------------------------
  22. ; EBP = TABITEM*
  23. ;-----------------------------------------------------------------------------
  24.         push    ecx esi edi
  25.         cmp     [tab_bar.Current.Ptr],0
  26.         je      @f
  27.         call    flush_cur_tab
  28.     @@: mov     esi,ebp
  29.         mov     edi,cur_tab
  30.         mov     ecx,sizeof.TABITEM/4
  31.         rep     movsd
  32.         mov     [tab_bar.Current.Ptr],ebp
  33.         call    update_caption
  34.         pop     edi esi ecx
  35.         ret
  36. endf
  37.  
  38. ;-----------------------------------------------------------------------------
  39. func create_tab ;/////////////////////////////////////////////////////////////
  40. ;-----------------------------------------------------------------------------
  41.         push    eax ecx esi edi
  42.  
  43.         inc     [tab_bar.Items.Count]
  44.         imul    ebx,[tab_bar.Items.Count],sizeof.TABITEM
  45.         mov     eax,[tab_bar.Items]
  46.         mov     ecx,eax
  47.         call    mem.ReAlloc
  48.         mov     [tab_bar.Items],eax
  49.         sub     ecx,eax
  50.         sub     [tab_bar.Current.Ptr],ecx
  51.         lea     ebp,[eax+ebx-sizeof.TABITEM]
  52.         call    set_cur_tab
  53.  
  54.         mov     eax,1024
  55.         call    mem.Alloc
  56.         mov     [cur_tab.Editor.Data],eax
  57.         mov     [cur_tab.Editor.Lines],1
  58.         mov     [cur_tab.Editor.Columns],1
  59.         xor     eax,eax
  60.         mov     [cur_tab.Editor.TopLeft.X],eax
  61.         mov     [cur_tab.Editor.TopLeft.Y],eax
  62.         mov     [cur_tab.Editor.Caret.X],eax
  63.         mov     [cur_tab.Editor.Caret.Y],eax
  64.         mov     [cur_tab.Editor.SelStart.X],eax
  65.         mov     [cur_tab.Editor.SelStart.Y],eax
  66.         mov     edi,[cur_tab.Editor.Data]
  67.         add     edi,4
  68.         mov     ecx,10
  69.         mov     [edi-4],ecx
  70.         mov     [edi+10],eax
  71.         mov     al,' '
  72.         cld
  73.         rep     stosb
  74.  
  75.         mov     esi,s_defname
  76.         mov     edi,cur_tab.Editor.FilePath
  77.         mov     ecx,s_defname.size
  78.         rep     movsb
  79.         mov     [cur_tab.Editor.FileName],0
  80.  
  81.         mov     [f_info.length],0
  82.         mov     [cur_tab.Editor.Modified],0
  83.         mov     [cur_tab.Editor.AsmMode],0
  84.  
  85.         call    flush_cur_tab
  86.         call    update_caption
  87.         call    drawwindow
  88.  
  89.         mov     ebp,cur_tab
  90.         pop     edi esi ecx eax
  91.         ret
  92. endf
  93.  
  94. ;-----------------------------------------------------------------------------
  95. func delete_tab ;/////////////////////////////////////////////////////////////
  96. ;-----------------------------------------------------------------------------
  97.         ret
  98. endf
  99.  
  100. ;-----------------------------------------------------------------------------
  101. func get_tab_size ;///////////////////////////////////////////////////////////
  102. ;-----------------------------------------------------------------------------
  103. ; EBP = TABITEM*
  104. ;-----------------------------------------------------------------------------
  105.         push    eax
  106.         cmp     [tab_bar.Style],3
  107.         jae     .lp1
  108.         lea     eax,[ebp+TABITEM.Editor.FilePath]
  109.         add     eax,[ebp+TABITEM.Editor.FileName]
  110.         call    strlen
  111.         imul    ebx,eax,6
  112.         add     ebx,9
  113.         jmp     .lp2
  114.   .lp1: call    get_max_tab_width
  115.         mov     ebx,eax
  116.   .lp2: mov     ecx,TBARH-1
  117.         pop     eax
  118.         ret
  119. endf
  120.  
  121. ;-----------------------------------------------------------------------------
  122. func draw_tabctl ;////////////////////////////////////////////////////////////
  123. ;-----------------------------------------------------------------------------
  124.  
  125.         mov     ebx,[tab_bar.Bounds.Left-2]
  126.         mov     bx,word[tab_bar.Bounds.Right]
  127.         sub     bx,word[tab_bar.Bounds.Left]
  128.         inc     ebx
  129.         mov     ecx,[tab_bar.Bounds.Top-2]
  130.         mov     cx,word[tab_bar.Bounds.Bottom]
  131.         sub     cx,word[tab_bar.Bounds.Top]
  132.         inc     ecx
  133.         mov     edx,[cl_3d_normal]
  134.         call    draw_framerect
  135.  
  136.         mov     al,[tab_bar.Style]
  137.         dec     al
  138.         jz      .tabs_on_top
  139.         dec     al
  140.         jz      .tabs_on_bottom
  141.         dec     al
  142.         jz      .tabs_on_left
  143.         dec     al
  144.         jz      .tabs_on_right
  145.         ret
  146.  
  147.   .tabs_on_top:
  148.         add     ebx,1*65536-2
  149.         mov     ecx,[tab_bar.Bounds.Top-2]
  150.         xor     cx,cx
  151.         add     ecx,1*65536+TBARH
  152.         mcall   13
  153.         add     ecx,(TBARH-2)*65536-(TBARH-3)
  154.         mov     edx,[cl_3d_inset]
  155.         call    draw_framerect
  156.         ret
  157.  
  158.   .tabs_on_bottom:
  159.         add     ebx,1*65536-2
  160.         mov     ecx,[tab_bar.Bounds.Bottom-2]
  161.         xor     cx,cx
  162.         add     ecx,-TBARH*65536+TBARH
  163.         mcall   13
  164.         mov     cx,1
  165.         mcall   ,,,[sc.work]
  166.         add     ecx,-1*65536+2;-(TBARH-3)
  167.         mov     edx,[cl_3d_inset]
  168.         call    draw_framerect
  169.  
  170.         mov     ecx,[tab_bar.Items.Count]
  171.         mov     ebp,[tab_bar.Items]
  172.         mov     esi,[tab_bar.Bounds.Left]
  173.         inc     esi
  174.         mov     edi,[tab_bar.Bounds.Bottom]
  175.         add     edi,-TBARH+1
  176.     @@: push    ecx
  177.  
  178.         call    get_tab_size
  179.         rol     ebx,16
  180.         mov     bx,si
  181.         rol     ebx,16
  182.         rol     ecx,16
  183.         mov     cx,di
  184.         rol     ecx,16
  185.         mov     edx,[cl_3d_inset]
  186.         call    draw_framerect
  187.  
  188.         cmp     ebp,[tab_bar.Current.Ptr]
  189.         jne     .lp1
  190.         push    ebx ecx
  191.         add     ebx,1*65536-2
  192.         dec     ecx
  193.         mcall   13,,,[sc.work]
  194.         pop     ecx ebx
  195.   .lp1:
  196.         pushad
  197.         lea     eax,[ebp+TABITEM.Editor.FilePath]
  198.         add     eax,[ebp+TABITEM.Editor.FileName]
  199.         mov     edx,eax
  200.         call    strlen
  201.         mov     esi,eax
  202.         shr     ecx,16
  203.         mov     bx,cx
  204.         add     ebx,0x00050005
  205.         mcall   4,,0x00000000
  206.         popad
  207.  
  208.         movzx   ebx,bx
  209.         lea     esi,[esi+ebx+1]
  210.         add     ebp,sizeof.TABITEM
  211.  
  212.         pop     ecx
  213.         dec     ecx
  214.         jnz     @b
  215.  
  216.         ret
  217.  
  218.   .tabs_on_left:
  219.         call    get_max_tab_width
  220.         mov     ebx,[tab_bar.Bounds.Left-2]
  221.         mov     bx,ax
  222.         add     ebx,1*65536
  223.         add     ecx,1*65536-2
  224.         push    eax
  225.         mcall   13
  226.         pop     eax
  227.         add     eax,-2
  228.         shl     eax,16
  229.         add     ebx,eax
  230.         mov     bx,3
  231.         mov     edx,[cl_3d_inset]
  232.         call    draw_framerect
  233.         ret
  234.  
  235.   .tabs_on_right:
  236.         call    get_max_tab_width
  237.         mov     ebx,[tab_bar.Bounds.Right-2]
  238.         mov     bx,ax
  239.         shl     eax,16
  240.         sub     ebx,eax
  241.         add     ecx,1*65536-2
  242.         mcall   13
  243.         add     ebx,-1*65536
  244.         mov     bx,3
  245.         mov     edx,[cl_3d_inset]
  246.         call    draw_framerect
  247.         ret
  248. endf
  249.  
  250. func get_max_tab_width
  251.         mov     eax,100
  252.         ret
  253. endf
  254.  
  255. func align_editor_in_tab
  256.         m2m     [cur_tab.Editor.Bounds.Left],[tab_bar.Bounds.Left]
  257.         m2m     [cur_tab.Editor.Bounds.Top],[tab_bar.Bounds.Top]
  258.         m2m     [cur_tab.Editor.Bounds.Right],[tab_bar.Bounds.Right]
  259.         m2m     [cur_tab.Editor.Bounds.Bottom],[tab_bar.Bounds.Bottom]
  260.  
  261.         inc     [cur_tab.Editor.Bounds.Left]
  262.         inc     [cur_tab.Editor.Bounds.Top]
  263.         dec     [cur_tab.Editor.Bounds.Right]
  264.         dec     [cur_tab.Editor.Bounds.Bottom]
  265.  
  266.         mov     al,[tab_bar.Style]
  267.         dec     al
  268.         jz      .tabs_on_top
  269.         dec     al
  270.         jz      .tabs_on_bottom
  271.         dec     al
  272.         jz      .tabs_on_left
  273.         dec     al
  274.         jz      .tabs_on_right
  275.         ret
  276.  
  277.   .tabs_on_top:
  278.         add     [cur_tab.Editor.Bounds.Top],TBARH
  279.         ret
  280.  
  281.   .tabs_on_bottom:
  282.         sub     [cur_tab.Editor.Bounds.Bottom],TBARH
  283.         ret
  284.  
  285.   .tabs_on_left:
  286.         call    get_max_tab_width
  287.         add     [cur_tab.Editor.Bounds.Left],eax
  288.         ret
  289.  
  290.   .tabs_on_right:
  291.         call    get_max_tab_width
  292.         sub     [cur_tab.Editor.Bounds.Right],eax
  293.         ret
  294. endf