Subversion Repositories Kolibri OS

Rev

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