Subversion Repositories Kolibri OS

Rev

Rev 4861 | 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. byte id_add_to_copy=0;
  6. byte add_to_copy_active=0;
  7. enum {NOCUT, CUT, COPY_PASTE_END};
  8.  
  9. struct path_str {
  10.         char Item[4096];
  11. };
  12.  
  13. #define MAX_HISTORY_NUM 10
  14.  
  15. Clipboard clipboard;
  16.  
  17. struct Copy_Path {
  18.         dword   size;
  19.         dword   type;
  20.         int     count;
  21.         path_str copy_list[MAX_HISTORY_NUM];
  22. };     
  23.  
  24. Copy_Path copy_path;
  25.  
  26. void add_to_copy(dword pcth)
  27. {
  28.         strlcpy(#copy_path.copy_list[id_add_to_copy].Item, pcth);
  29.         if (add_to_copy_active == 1)
  30.         {
  31.                 id_add_to_copy++;
  32.                 copy_path.count = id_add_to_copy;
  33.         }
  34.         else copy_path.count = 1;
  35. }
  36.  
  37.  
  38. void Copy(dword pcth, char cut)
  39. {
  40.         if (add_to_copy_active == 0) add_to_copy(pcth);
  41.         copy_path.type = 3;
  42.         copy_path.size = sizeof(copy_path);
  43.         clipboard.SetSlotData(sizeof(copy_path), #copy_path);
  44.         cut_active = cut;
  45. }
  46.  
  47. void copyf_Draw_Progress(dword filename) {
  48.         #define WIN_W 300
  49.         #define WIN_H 50
  50.         DefineAndDrawWindow(Form.left+Form.width-200,Form.top+90,WIN_W,GetSkinHeight()+WIN_H-1,0x34,sc.work,T_PASTE_WINDOW);
  51.         WriteText(5,8, 0x80, sc.work_text, T_PASTE_WINDOW_TEXT);
  52.         DrawBar(5, 26, WIN_W-10, 10, sc.work);
  53.         WriteText(5,26, 0x80, sc.work_text, filename);
  54.         if (CheckEvent()==evButton)
  55.         {
  56.                 notify(T_CANCEL_PASTE);
  57.                 CopyExit();
  58.         }
  59. }
  60.  
  61.  
  62. void Paste()
  63. {
  64.         char copy_rezult;
  65.         byte copy_from[4096];
  66.         int tst, count;
  67.         dword buf;
  68.        
  69.         buf = clipboard.GetSlotData(clipboard.GetSlotCount()-1);
  70.         count = DSINT[buf+8];
  71.         debugi(count);
  72.        
  73.         add_to_copy_active=0;
  74.         id_add_to_copy=0;
  75.        
  76.         for (j = 0; j < count; j++) {
  77.                 tst = j*4096;
  78.                 strlcpy(#copy_from, buf+12+tst, 4096);
  79.                 debug(#copy_from);
  80.                 if (!copy_from) CopyExit();
  81.                 strcpy(#copy_to, #path);
  82.                 strcat(#copy_to, #copy_from+strrchr(#copy_from,'/'));
  83.                 if (!strcmp(#copy_from,#copy_to))
  84.                 {
  85.                         strcpy(#copy_to, #path);
  86.                         strcat(#copy_to, "new_");
  87.                         strcat(#copy_to, #copy_from+strrchr(#copy_from,'/'));
  88.                 }
  89.                 if (strstr(#copy_to, #copy_from))
  90.                 {
  91.                         notify("Copy directory into itself is a bad idea...");
  92.                         CopyExit();
  93.                 }
  94.                 if (copy_rezult = copyf(#copy_from,#copy_to))
  95.                 {
  96.                         Write_Error(copy_rezult);
  97.                 }
  98.         }
  99.         if (copy_rezult = copyf(#copy_from,#copy_to))
  100.         {
  101.                 Write_Error(copy_rezult);
  102.         }
  103.         else if (cut_active)
  104.         {
  105.                 strcpy(#file_path, #copy_from);
  106.                 Del_File(true);
  107.                 cut_active=false;
  108.         }
  109.         for (j = 0; j < MAX_HISTORY_NUM; j++) strcpy(#copy_path.copy_list[j].Item[0], 0);
  110.         CopyExit();
  111. }
  112.  
  113. void CopyExit()
  114. {
  115.         action_buf = COPY_PASTE_END;
  116.         ActivateWindow(GetProcessSlot(Form.ID));
  117.         ExitProcess();
  118. }