Subversion Repositories Kolibri OS

Rev

Rev 4894 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. //Leency 2008-2014
  2.  
  3. byte copy_to[4096];
  4. byte cut_active=0;
  5.  
  6. enum {NOCUT, CUT, COPY_PASTE_END};
  7.  
  8. Clipboard clipboard;
  9.  
  10. void Copy(dword pcth, char cut)
  11. {
  12.         if (mark_active == 0) {
  13.                 strlcpy(#elements_path.element_list[elements_path.count].Item, pcth);
  14.                 elements_path.count++;
  15.         }
  16.         elements_path.size = sizeof(elements_path);
  17.         clipboard.SetSlotData(sizeof(elements_path), #elements_path);
  18.         cut_active = cut;
  19. }
  20.  
  21. void copyf_Draw_Progress(dword filename) {
  22.         #define WIN_W 300
  23.         #define WIN_H 50
  24.         DefineAndDrawWindow(Form.left+Form.width-200,Form.top+90,WIN_W,GetSkinHeight()+WIN_H-1,0x34,sc.work,T_PASTE_WINDOW);
  25.         WriteText(5,8, 0x80, sc.work_text, T_PASTE_WINDOW_TEXT);
  26.         DrawBar(5, 26, WIN_W-10, 10, sc.work);
  27.         WriteText(5,26, 0x80, sc.work_text, filename);
  28.         if (CheckEvent()==evButton)
  29.         {
  30.                 notify(T_CANCEL_PASTE);
  31.                 CopyExit();
  32.         }
  33. }
  34.  
  35. void Paste()
  36. {
  37.         char copy_rezult;
  38.         byte copy_from[4096];
  39.         int tst, count, j;
  40.         dword buf;
  41.        
  42.         buf = clipboard.GetSlotData(clipboard.GetSlotCount()-1);
  43.         count = DSINT[buf+8];
  44.         if (DSDWORD[buf+4] != 3) return;
  45.         debugi(count);
  46.        
  47.         for (j = 0; j < count; j++) {
  48.                 tst = j*4096;
  49.                 strlcpy(#copy_from, buf+12+tst, 4096);
  50.                 if (!copy_from) CopyExit();
  51.                 strcpy(#copy_to, #path);
  52.                 strcat(#copy_to, #copy_from+strrchr(#copy_from,'/'));
  53.                 if (!strcmp(#copy_from,#copy_to))
  54.                 {
  55.                         strcpy(#copy_to, #path);
  56.                         strcat(#copy_to, "new_");
  57.                         strcat(#copy_to, #copy_from+strrchr(#copy_from,'/'));
  58.                 }
  59.                 if (strstr(#copy_to, #copy_from))
  60.                 {
  61.                         notify("Copy directory into itself is a bad idea...");
  62.                         CopyExit();
  63.                 }
  64.                 if (copy_rezult = copyf(#copy_from,#copy_to))
  65.                 {
  66.                         Write_Error(copy_rezult);
  67.                 }
  68.        
  69.                 else if (cut_active)
  70.                 {
  71.                         strcpy(#file_path, #copy_from);
  72.                         Del_File(true);
  73.                        
  74.                 }
  75.         }
  76.         if (cut_active)
  77.         {
  78.                 cut_active=false;
  79.         }
  80.         mark_default();
  81.         CopyExit();
  82. }
  83.  
  84. void CopyExit()
  85. {
  86.         action_buf = COPY_PASTE_END;
  87.         ActivateWindow(GetProcessSlot(Form.ID));
  88.         ExitProcess();
  89. }