Subversion Repositories Kolibri OS

Rev

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

  1.  
  2. put_to_clipboard:
  3.         mov     edi,[clipboard_buf]
  4.         test    edi,edi
  5.         jz      .end
  6.         add     edi,12
  7.         mov     esi,[copy_buf]
  8.         mov     edx,[copy_count]
  9.         mov     ax,0x0a0d       ; End of String
  10.         cld
  11. @@:     ; convert format from Tinypad to clipboard
  12.         mov     ecx,[esi]
  13.         add     esi,sizeof.EDITOR_LINE_DATA
  14.         rep movsb
  15.         stosw
  16.         dec     edx
  17.         jnz     @b
  18.  
  19.         sub     edi,2           ; delete last EoS
  20.         xor     eax,eax
  21.         stosb
  22. ; build the clipboard slot header
  23.         mov     esi,[clipboard_buf]
  24.         sub     edi,esi
  25.         mov     [esi],edi       ; clipboard area size
  26.         xor     eax,eax
  27.         mov     [esi+4],eax     ; type 'text'
  28.         inc     eax
  29.         mov     [esi+8],eax     ; cp866 text encoding
  30. ; put slot to the kernel clipboard
  31.         mov     edx,[clipboard_buf]
  32.         mov     ecx,[edx]
  33.         mcall   54,2
  34.         stdcall mem.Free,[clipboard_buf]
  35.         stdcall mem.Free,[copy_buf]
  36.         xor     eax,eax
  37.         mov     [copy_buf],eax
  38.         mov     [copy_size],eax
  39.         mov     [copy_count],eax
  40.         mov     [clipboard_buf],eax
  41. .end:
  42.         ret
  43. ;---------------------------------------------------------------
  44. get_from_clipboard:
  45.         mov     [copy_size],0
  46.         pushad
  47.         mcall   54,0
  48.         test    eax,eax
  49.         jz      .exit   ; no slots of clipboard
  50.         inc     eax
  51.         jz      .exit   ; main list area not found
  52.         sub     eax,2
  53.         mov     ecx,eax
  54.         mcall   54,1
  55.         inc     eax
  56.         jz      .exit   ; main list area not found
  57.         sub     eax,2
  58.         jz      .exit   ; error
  59.         inc     eax
  60.         mov     [clipboard_buf],eax
  61. ; check contents of container
  62.         mov     ebx,[eax+4]
  63.         test    ebx,ebx
  64.         jnz     .freeMemory     ; not text
  65.         mov     ebx,[eax+8]
  66.         dec     ebx
  67.         jnz     .freeMemory     ; not cp866
  68.         mov     edi,[clipboard_buf]
  69.         mov     al, 10
  70.         mov     ecx,[edi]
  71.         add     edi,12
  72.         sub     ecx,12
  73.         jbe     .freeMemory
  74.         cmp     byte[edi],0
  75.         jz      .freeMemory
  76. @@:
  77.         dec     ecx
  78.         cmp     byte[edi+ecx],0
  79.         jz      @b
  80.         inc     ecx
  81.         push    ecx
  82.         cld
  83. @@:     ; count strings
  84.         repnz scasb
  85.         inc     ebx
  86.         test    ecx,ecx
  87.         jnz     @b
  88.         dec     edi
  89.         cmp     byte[edi],10
  90.         jnz     @f
  91.         inc     ebx
  92. @@:
  93.         mov     [copy_count],ebx
  94.         lea     eax,[ebx*4+ebx+2]
  95.         add     eax,[esp]
  96.         stdcall mem.Alloc,eax
  97.         mov     [copy_buf],eax
  98.         mov     esi,eax
  99.         mov     edi,[clipboard_buf]
  100.         add     edi,12
  101.         pop     ecx
  102.         mov     ebx,ecx
  103.         mov     al, 10
  104. .stringSize:    ; convert format from clipboard to Tinypad
  105.         repnz scasb
  106.         sub     ebx,ecx
  107.         mov     edx,edi
  108.         sub     edi,ebx
  109.         dec     ebx
  110.         test    ecx,ecx
  111.         jnz     .stringEnd
  112. .lastString:
  113.         cmp     byte[edi+ebx],10
  114.         jz      .stringEnd
  115.         cmp     byte[edi+ebx],0
  116.         jnz     @f
  117.         dec     ebx
  118.         jmp     .lastString
  119. .stringEnd:
  120.         dec     ebx
  121.         cmp     byte[edi+ebx],13
  122.         jz      .copyString
  123. @@:
  124.         inc     ebx
  125. .copyString:
  126.         mov     [esi],ebx
  127.         add     esi,sizeof.EDITOR_LINE_DATA
  128.         xchg    ebx,ecx
  129.         xchg    esi,edi
  130.         rep movsb
  131.         mov     ecx,ebx
  132.         jcxz    .done
  133.         mov     esi,edi
  134.         mov     edi,edx
  135.         jmp     .stringSize
  136. .done:
  137.         cmp     esi,edx
  138.         jz      @f
  139.         inc     ecx
  140.         mov     [edi],ecx
  141.         add     edi,sizeof.EDITOR_LINE_DATA
  142.         mov     byte[edi],' '
  143.         inc     edi
  144. @@:
  145.         sub     edi,[copy_buf]
  146.         mov     [copy_size],edi
  147. .freeMemory:
  148.         stdcall mem.Free,[clipboard_buf]
  149.         mov     [clipboard_buf],0
  150. .exit:
  151.         popad
  152.         ret
  153. ;---------------------------------------------------------------
  154. check_clipboard_for_popup:
  155.         pushad
  156.         mov     [popup_valid_text],0
  157.         mcall   54,0
  158.         test    eax,eax
  159.         jz      .exit   ; no slots of clipboard
  160.         inc     eax
  161.         jz      .exit   ; main list area not found
  162.         sub     eax,2
  163.         mov     ecx,eax
  164.         mcall   54,1
  165.         inc     eax
  166.         jz      .exit   ; main list area not found
  167.         sub     eax,2
  168.         jz      .exit   ; error
  169.         inc     eax
  170.         mov     [clipboard_buf],eax
  171. ; check contents of container
  172.         mov     ebx,[eax+4]
  173.         test    ebx,ebx
  174.         jnz     .freeMemory     ; not text
  175.         mov     ebx,[eax+8]
  176.         dec     ebx
  177.         jnz     .freeMemory     ; not cp866
  178.         mov     [popup_valid_text],1
  179. .freeMemory:
  180.         stdcall mem.Free,[clipboard_buf]
  181.         mov     [clipboard_buf],0
  182. .exit:
  183.         popad
  184.         ret
  185.