Subversion Repositories Kolibri OS

Rev

Rev 4894 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4428 leency 1
//Leency 2008-2014
4042 leency 2
 
4428 leency 3
byte copy_to[4096];
4
byte cut_active=0;
4896 punk_joker 5
 
4042 leency 6
enum {NOCUT, CUT, COPY_PASTE_END};
4427 punk_joker 7
 
8
Clipboard clipboard;
9
 
4896 punk_joker 10
void Copy(dword pcth, char cut)
4698 punk_joker 11
{
4896 punk_joker 12
	if (mark_active == 0) {
13
		strlcpy(#elements_path.element_list[elements_path.count].Item, pcth);
14
		elements_path.count++;
4864 punk_joker 15
	}
4896 punk_joker 16
	elements_path.size = sizeof(elements_path);
17
	clipboard.SetSlotData(sizeof(elements_path), #elements_path);
4042 leency 18
	cut_active = cut;
19
}
20
 
21
void copyf_Draw_Progress(dword filename) {
4428 leency 22
	#define WIN_W 300
23
	#define WIN_H 50
4076 leency 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);
4042 leency 28
	if (CheckEvent()==evButton)
29
	{
30
		notify(T_CANCEL_PASTE);
4861 leency 31
		CopyExit();
4042 leency 32
	}
33
}
34
 
35
void Paste()
36
{
37
	char copy_rezult;
4428 leency 38
	byte copy_from[4096];
4894 punk_joker 39
	int tst, count, j;
4864 punk_joker 40
	dword buf;
4042 leency 41
 
4864 punk_joker 42
	buf = clipboard.GetSlotData(clipboard.GetSlotCount()-1);
43
	count = DSINT[buf+8];
4894 punk_joker 44
	if (DSDWORD[buf+4] != 3) return;
4864 punk_joker 45
	debugi(count);
46
 
47
	for (j = 0; j < count; j++) {
4698 punk_joker 48
		tst = j*4096;
4864 punk_joker 49
		strlcpy(#copy_from, buf+12+tst, 4096);
4861 leency 50
		if (!copy_from) CopyExit();
4042 leency 51
		strcpy(#copy_to, #path);
52
		strcat(#copy_to, #copy_from+strrchr(#copy_from,'/'));
4698 punk_joker 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...");
4861 leency 62
			CopyExit();
4698 punk_joker 63
		}
64
		if (copy_rezult = copyf(#copy_from,#copy_to))
65
		{
66
			Write_Error(copy_rezult);
67
		}
4894 punk_joker 68
 
69
		else if (cut_active)
70
		{
71
			strcpy(#file_path, #copy_from);
72
			Del_File(true);
73
 
74
		}
4042 leency 75
	}
4894 punk_joker 76
	if (cut_active)
4042 leency 77
	{
78
		cut_active=false;
79
	}
4896 punk_joker 80
	mark_default();
4861 leency 81
	CopyExit();
82
}
83
 
84
void CopyExit()
85
{
86
	action_buf = COPY_PASTE_END;
4042 leency 87
	ActivateWindow(GetProcessSlot(Form.ID));
88
	ExitProcess();
4861 leency 89
}