Subversion Repositories Kolibri OS

Rev

Rev 4896 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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