Rev 4864 | 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; |
||
4864 | punk_joker | 20 | int count; |
4698 | punk_joker | 21 | path_str copy_list[MAX_HISTORY_NUM]; |
22 | }; |
||
4042 | leency | 23 | |
4698 | punk_joker | 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); |
||
4864 | punk_joker | 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; |
||
4698 | punk_joker | 35 | } |
36 | |||
37 | |||
4042 | leency | 38 | void Copy(dword pcth, char cut) |
39 | { |
||
4864 | punk_joker | 40 | if (add_to_copy_active == 0) add_to_copy(pcth); |
4698 | punk_joker | 41 | copy_path.type = 3; |
42 | copy_path.size = sizeof(copy_path); |
||
43 | clipboard.SetSlotData(sizeof(copy_path), #copy_path); |
||
4042 | leency | 44 | cut_active = cut; |
45 | } |
||
46 | |||
47 | void copyf_Draw_Progress(dword filename) { |
||
4428 | leency | 48 | #define WIN_W 300 |
49 | #define WIN_H 50 |
||
4076 | leency | 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); |
||
4042 | leency | 54 | if (CheckEvent()==evButton) |
55 | { |
||
56 | notify(T_CANCEL_PASTE); |
||
4861 | leency | 57 | CopyExit(); |
4042 | leency | 58 | } |
59 | } |
||
60 | |||
61 | |||
62 | void Paste() |
||
63 | { |
||
64 | char copy_rezult; |
||
4428 | leency | 65 | byte copy_from[4096]; |
4894 | punk_joker | 66 | int tst, count, j; |
4864 | punk_joker | 67 | dword buf; |
4042 | leency | 68 | |
4864 | punk_joker | 69 | buf = clipboard.GetSlotData(clipboard.GetSlotCount()-1); |
70 | count = DSINT[buf+8]; |
||
4894 | punk_joker | 71 | if (DSDWORD[buf+4] != 3) return; |
4864 | punk_joker | 72 | debugi(count); |
73 | |||
74 | add_to_copy_active=0; |
||
75 | id_add_to_copy=0; |
||
76 | |||
77 | for (j = 0; j < count; j++) { |
||
4698 | punk_joker | 78 | tst = j*4096; |
4864 | punk_joker | 79 | strlcpy(#copy_from, buf+12+tst, 4096); |
4861 | leency | 80 | if (!copy_from) CopyExit(); |
4042 | leency | 81 | strcpy(#copy_to, #path); |
82 | strcat(#copy_to, #copy_from+strrchr(#copy_from,'/')); |
||
4698 | punk_joker | 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..."); |
||
4861 | leency | 92 | CopyExit(); |
4698 | punk_joker | 93 | } |
94 | if (copy_rezult = copyf(#copy_from,#copy_to)) |
||
95 | { |
||
96 | Write_Error(copy_rezult); |
||
97 | } |
||
4894 | punk_joker | 98 | |
99 | else if (cut_active) |
||
100 | { |
||
101 | strcpy(#file_path, #copy_from); |
||
102 | Del_File(true); |
||
103 | |||
104 | } |
||
4042 | leency | 105 | } |
4894 | punk_joker | 106 | if (cut_active) |
4042 | leency | 107 | { |
108 | cut_active=false; |
||
109 | } |
||
4894 | punk_joker | 110 | for (j = 0; j < count; j++) strcpy(#copy_path.copy_list[j].Item[0], 0); |
4861 | leency | 111 | CopyExit(); |
112 | } |
||
113 | |||
114 | void CopyExit() |
||
115 | { |
||
116 | action_buf = COPY_PASTE_END; |
||
4042 | leency | 117 | ActivateWindow(GetProcessSlot(Form.ID)); |
118 | ExitProcess(); |
||
4861 | leency | 119 | }>> |