Subversion Repositories Kolibri OS

Rev

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