Subversion Repositories Kolibri OS

Rev

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