Rev 4040 | Rev 4049 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3363 | leency | 1 | //Leency & Veliant 2008-2013 |
2 | //GNU GPL licence. |
||
3 | |||
4022 | leency | 4 | #ifndef AUTOBUILD |
5 | #include "lang.h--" |
||
6 | #endif |
||
7 | |||
3363 | leency | 8 | //libraries |
9 | #define MEMSIZE 0xA0000 |
||
10 | #include "..\lib\kolibri.h" |
||
11 | #include "..\lib\strings.h" |
||
12 | #include "..\lib\mem.h" |
||
13 | #include "..\lib\dll.h" |
||
14 | #include "..\lib\lib.obj\box_lib.h" |
||
15 | #include "..\lib\file_system.h" |
||
16 | #include "..\lib\figures.h" |
||
3412 | leency | 17 | #include "..\lib\encoding.h" |
3434 | leency | 18 | #include "..\lib\list_box.h" |
19 | #include "..\lib\copyf.h" |
||
3363 | leency | 20 | //images |
21 | #include "imgs\toolbar.txt" |
||
22 | #include "imgs\left_p.txt" |
||
23 | |||
3848 | punk_joker | 24 | #ifdef LANG_RUS |
25 | ?define T_FILE "Файл" |
||
26 | ?define T_TYPE "Тип" |
||
27 | ?define T_SIZE "Размер" |
||
28 | ?define T_NEW_FOLDER "Новая папка" |
||
29 | ?define T_NEW_FILE "Новый файл" |
||
30 | ?define T_DELETE_FILE "Вы действительно хотите удалить" |
||
31 | ?define T_YES "Да" |
||
32 | ?define T_NO "Нет" |
||
33 | ?define T_DEL_ERROR_1 "Ошибка. Папка не пустая." |
||
3997 | leency | 34 | ?define WAIT_DELETING_FOLDER "Удаляется папка. Подожите..." |
3848 | punk_joker | 35 | ?define NOT_CREATE_FOLDER "Не удалось создать папку." |
36 | ?define NOT_CREATE_FILE "Не удалось создать файл." |
||
37 | ?define ERROR_1 "Ошибка при загрузке библиотеки /rd/1/lib/box_lib.obj" |
||
3883 | leency | 38 | ?define T_PASTE_WINDOW "Копирую..." |
39 | ?define T_PASTE_WINDOW_TEXT "Копируется файл:" |
||
4022 | leency | 40 | ?define T_CANCEL_PASTE "Копирование прекращено. Папка скопирована не полностью." |
3933 | kaitz | 41 | #elif LANG_EST |
42 | ?define T_FILE "Fail" |
||
43 | ?define T_TYPE "T№№p" |
||
44 | ?define T_SIZE "Suurus" |
||
45 | ?define T_NEW_FOLDER "Uus kataloog" |
||
46 | ?define T_NEW_FILE "Uus fail" |
||
47 | ?define T_DELETE_FILE "Kas sa tahad tїesti kustutada" |
||
48 | ?define T_YES "Jah" |
||
49 | ?define T_NO "Ei" |
||
50 | ?define T_DEL_ERROR_1 "Viga. Kataloog ei ole t№hi." |
||
3997 | leency | 51 | ?define WAIT_DELETING_FOLDER "Deleting folder. Please, wait..." |
3933 | kaitz | 52 | ?define NOT_CREATE_FOLDER "Kataloogi ei saa luua." |
53 | ?define NOT_CREATE_FILE "Faili ei saa luua." |
||
54 | ?define ERROR_1 "Viga teegi laadimisel /rd/1/lib/box_lib.obj" |
||
55 | ?define T_PASTE_WINDOW "Kopeerin..." |
||
56 | ?define T_PASTE_WINDOW_TEXT "Kopeerin faili:" |
||
4022 | leency | 57 | ?define T_CANCEL_PASTE "Copy process terminated. Folder copied incompletely." |
3848 | punk_joker | 58 | #else |
59 | ?define T_FILE "File" |
||
60 | ?define T_TYPE "Type" |
||
61 | ?define T_SIZE "Size" |
||
62 | ?define T_NEW_FOLDER "New folder" |
||
63 | ?define T_NEW_FILE "New file" |
||
64 | ?define T_DELETE_FILE "Do you really want to delete" |
||
65 | ?define T_YES "Yes" |
||
66 | ?define T_NO "No" |
||
67 | ?define T_DEL_ERROR_1 "Error. Folder isn't empty." |
||
3997 | leency | 68 | ?define WAIT_DELETING_FOLDER "Deleting folder. Please, wait..." |
3848 | punk_joker | 69 | ?define NOT_CREATE_FOLDER "Folder can not be created." |
70 | ?define NOT_CREATE_FILE "File can not be created." |
||
71 | ?define ERROR_1 "Error while loading library /rd/1/lib/box_lib.obj" |
||
3883 | leency | 72 | ?define T_PASTE_WINDOW "Copying..." |
73 | ?define T_PASTE_WINDOW_TEXT "Copying file:" |
||
4022 | leency | 74 | ?define T_CANCEL_PASTE "Copy process terminated. Folder copied incompletely." |
3848 | punk_joker | 75 | #endif |
76 | |||
3444 | leency | 77 | enum {ONLY_SHOW, WITH_REDRAW, ONLY_OPEN}; //OpenDir |
78 | |||
4042 | leency | 79 | #define TITLE "Eolite File Manager v1.98.8" |
80 | #define ABOUT_TITLE "Eolite v1.98.8" |
||
3363 | leency | 81 | dword col_work = 0xE4DFE1; |
3444 | leency | 82 | dword col_border = 0x9098B0; //A0A0B8; //0x819FC5; |
3363 | leency | 83 | dword col_padding = 0xC8C9C9; |
84 | dword col_selec = 0x94AECE; |
||
85 | dword col_lpanel = 0x00699C; |
||
86 | |||
3434 | leency | 87 | int toolbar_buttons_x[7]={9,46,85,134,167,203}; |
88 | char tmp_disk_del_param[3]="d0"; |
||
89 | struct path_string { char Item[4096]; }; |
||
3363 | leency | 90 | |
4040 | punk_joker | 91 | int active_about=0; |
92 | |||
3434 | leency | 93 | llist files; |
94 | |||
95 | byte |
||
3363 | leency | 96 | path[4096], |
97 | file_path[4096], |
||
3404 | leency | 98 | file_name[256], |
3434 | leency | 99 | temp[4096]; |
100 | byte |
||
3439 | leency | 101 | rename_active=0, |
102 | del_active=0, |
||
3434 | leency | 103 | show_dev_name=1, |
104 | sort_num=2, |
||
3441 | leency | 105 | itdir; |
3363 | leency | 106 | |
107 | proc_info Form; |
||
108 | mouse m; |
||
4022 | leency | 109 | int mouse_dd, scroll_used, scroll_size, sorting_arrow_x; |
3434 | leency | 110 | dword buf, off; |
111 | dword file_mas[6898]; |
||
112 | int j, i; |
||
4028 | leency | 113 | int action_buf; |
3363 | leency | 114 | |
4028 | leency | 115 | edit_box edit2 = {250,213,80,0xFFFFCC,0x94AECE,0xFFFFCC,0xffffff,0,248,#file_name,#mouse_dd,64,6,6}; |
3434 | leency | 116 | PathShow_data PathShow = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, #path, #temp, 0}; |
3363 | leency | 117 | PathShow_data FileShow = {0, 56,215, 6, 100, 0, 0, 0x0, 0xFFFfff, #file_name, #temp, 0}; |
118 | |||
4042 | leency | 119 | #include "include\copy.h" |
120 | #include "include\other.h" |
||
3363 | leency | 121 | #include "include\sorting.h" |
4042 | leency | 122 | #include "include\icons.h" |
3363 | leency | 123 | #include "include\ini.h" |
124 | #include "include\left_panel.h" |
||
125 | #include "include\history.h" |
||
4042 | leency | 126 | #include "include\menu.h" |
127 | #include "include\about.h" |
||
128 | #include "include\open_with.h" |
||
3363 | leency | 129 | |
130 | void main() |
||
131 | { |
||
3444 | leency | 132 | word key, id, can_show, can_select, m_selected; |
3363 | leency | 133 | |
3434 | leency | 134 | files.line_h=18; |
3363 | leency | 135 | mem_Init(); |
3848 | punk_joker | 136 | if (load_dll2(boxlib, #box_lib_init,0)!=0) notify(ERROR_1); |
3434 | leency | 137 | SystemDiscsGet(); |
3432 | leency | 138 | GetIni(1); |
3363 | leency | 139 | if (param) |
140 | { |
||
141 | strcpy(#path, #param); |
||
3434 | leency | 142 | if (path[strlen(#path)-1]!='/') chrcat(#path, '/'); //add "/" to the end of the string |
3363 | leency | 143 | } |
144 | else |
||
3695 | leency | 145 | { |
3432 | leency | 146 | strcpy(#path, "/rd/1/"); |
3695 | leency | 147 | } |
3363 | leency | 148 | Open_Dir(#path,ONLY_OPEN); |
3432 | leency | 149 | SetEventMask(0x27); |
3434 | leency | 150 | loop() switch(WaitEvent()) |
3363 | leency | 151 | { |
152 | case evMouse: |
||
3434 | leency | 153 | IF (del_active) break; |
3363 | leency | 154 | id=GetProcessSlot(Form.ID); |
3444 | leency | 155 | IF (id!=GetActiveProcess()) || (Form.status_window>2) break; |
3434 | leency | 156 | IF (rename_active) { edit_box_mouse stdcall(#edit2); break; } |
3363 | leency | 157 | |
158 | m.get(); |
||
159 | |||
3444 | leency | 160 | if (m.x > files.x) && (m.x < files.x + files.w) && (m.y > files.y) && (m.y < files.y+files.h) && (!can_select) |
3363 | leency | 161 | { |
4042 | leency | 162 | m_selected = m.y - files.y / files.line_h; |
3434 | leency | 163 | if (m.lkm) can_select = 1; |
164 | if (m.pkm) |
||
165 | { |
||
166 | can_show = 1; |
||
4042 | leency | 167 | if (m.y - files.y / files.line_h != files.current) can_select = 1; |
3434 | leency | 168 | } |
169 | } |
||
170 | |||
171 | //select/open file { |
||
172 | if (!m.lkm) && (!m.pkm) && (can_select) |
||
173 | { |
||
174 | can_select = 0; |
||
4042 | leency | 175 | if (m.y>=files.y) |
3695 | leency | 176 | { |
4042 | leency | 177 | id = m.y - files.y / files.line_h; |
3695 | leency | 178 | if (id!=m_selected) |
179 | { |
||
180 | can_show=0; |
||
181 | break; |
||
182 | } |
||
183 | if (files.current!=id) |
||
3876 | leency | 184 | { |
185 | if (id |
||
186 | } |
||
3695 | leency | 187 | else |
188 | Open(); |
||
189 | } |
||
3434 | leency | 190 | }; |
191 | // } select/open file |
||
192 | |||
193 | //file menu { |
||
194 | if (!m.pkm) && (!m.lkm) && (can_show) |
||
195 | { |
||
196 | can_show = 0; |
||
4042 | leency | 197 | if (m.y>=files.y) |
3695 | leency | 198 | { |
199 | SwitchToAnotherThread(); |
||
200 | CreateThread(#FileMenu,#menu_stak); |
||
201 | } |
||
3434 | leency | 202 | break; |
203 | } |
||
204 | // } file menu |
||
3363 | leency | 205 | |
3434 | leency | 206 | if (m.vert) |
207 | { |
||
208 | files.MouseScroll(m.vert); |
||
209 | List_ReDraw(); |
||
210 | break; |
||
211 | } |
||
212 | |||
4042 | leency | 213 | if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>40) && (m.y |
3363 | leency | 214 | { |
215 | IF (m.lkm==1) DrawRectangle3D(onLeft(26,0),41,14,14,0xC7C7C7,0xFFFFFF); |
||
3434 | leency | 216 | WHILE (m.lkm==1) && (files.first>0) |
3363 | leency | 217 | { |
3434 | leency | 218 | pause(8); |
219 | files.first--; |
||
3363 | leency | 220 | List_ReDraw(); |
221 | m.get(); |
||
222 | } |
||
223 | DrawRectangle3D(onLeft(26,0),41,14,14,0xFFFFFF,0xC7C7C7); |
||
224 | } |
||
225 | |||
226 | if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>onTop(22,0)+1) && (m.y |
||
227 | { |
||
228 | IF (m.lkm==1) DrawRectangle3D(onLeft(26,0),onTop(21,0),14,14,0xC7C7C7,0xFFFFFF); |
||
3434 | leency | 229 | while (m.lkm==1) && (files.first |
3363 | leency | 230 | { |
3434 | leency | 231 | pause(8); |
232 | files.first++; |
||
3363 | leency | 233 | List_ReDraw(); |
234 | m.get(); |
||
235 | } |
||
236 | DrawRectangle3D(onLeft(26,0),onTop(21,0),14,14,0xFFFFFF,0xC7C7C7); |
||
237 | } |
||
238 | |||
3434 | leency | 239 | //Scrooll |
240 | if (!m.lkm) && (scroll_used) { scroll_used=NULL; Scroll(); } |
||
241 | if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>56) && (m.y |
||
3363 | leency | 242 | |
243 | if (scroll_used) |
||
244 | { |
||
4042 | leency | 245 | IF (scroll_size/2+files.y>m.y) || (m.y<0) || (m.y>4000) m.y=scroll_size/2+files.y; //anee eo?ni? iaa ieiii |
3434 | leency | 246 | id=files.first; |
3363 | leency | 247 | j= scroll_size/2; |
4042 | leency | 248 | files.first = m.y -j -files.y * files.count; |
249 | files.first /= onTop(22,files.y); |
||
3434 | leency | 250 | IF (files.visible+files.first>files.count) files.first=files.count-files.visible; |
3444 | leency | 251 | IF (id!=files.first) List_ReDraw(); |
3363 | leency | 252 | } |
253 | break; |
||
254 | //Button pressed----------------------------------------------------------------------------- |
||
255 | case evButton: |
||
256 | id=GetButtonID(); |
||
3439 | leency | 257 | if (id==1) ExitProcess(); |
258 | if (rename_active) break; |
||
259 | if (del_active) |
||
3363 | leency | 260 | { |
261 | IF (id==301) || (id==302) Del_File(302-id); |
||
262 | break; |
||
263 | } |
||
3439 | leency | 264 | |
3363 | leency | 265 | switch(id) |
266 | { |
||
267 | case 21: //Back |
||
268 | GoBack(); |
||
269 | break; |
||
270 | case 22: //Forward |
||
271 | if (HistoryPath(GO_FORWARD)) |
||
272 | { |
||
3434 | leency | 273 | files.first=files.current=NULL; //aaa?o nienea |
3363 | leency | 274 | Open_Dir(#path,WITH_REDRAW); |
275 | } |
||
276 | break; |
||
277 | case 23: //up! |
||
278 | Dir_Up(); |
||
279 | break; |
||
280 | case 24: //cut |
||
3846 | punk_joker | 281 | Copy(#file_path, CUT); |
3444 | leency | 282 | break; |
3363 | leency | 283 | case 25: //copy |
3846 | punk_joker | 284 | Copy(#file_path, NOCUT); |
3444 | leency | 285 | break; |
3363 | leency | 286 | case 26: //paste |
3444 | leency | 287 | CreateThread(#Paste,#copy_stak); |
3363 | leency | 288 | break; |
289 | case 31...33: //sort |
||
4022 | leency | 290 | IF(sort_num==1) DrawFilledBar(sorting_arrow_x,42,6,10); |
291 | IF(sort_num==2) DrawFilledBar(sorting_arrow_x,42,6,10); |
||
292 | IF(sort_num==3) DrawFilledBar(sorting_arrow_x,42,6,10); |
||
3363 | leency | 293 | sort_num=id-30; |
3434 | leency | 294 | Open_Dir(#path,WITH_REDRAW); |
3363 | leency | 295 | break; |
3434 | leency | 296 | case 50...60: //Actions |
3444 | leency | 297 | FnProcess(id-50); |
3363 | leency | 298 | break; |
299 | case 100...120: |
||
300 | DEVICE_MARK: |
||
3444 | leency | 301 | DrawRectangle(17,id-100*16+74,159,16, 0); //auaaeaiea |
3363 | leency | 302 | strcpy(#path, #disk_list[id-100].Item); |
3434 | leency | 303 | files.first=files.current=0; |
3444 | leency | 304 | Open_Dir(#path,WITH_REDRAW); |
3363 | leency | 305 | pause(5); |
3444 | leency | 306 | DrawRectangle(17,id-100*16+74,159,16, 0xFFFFFF); |
3363 | leency | 307 | break; |
308 | case 130...160: |
||
309 | tmp_disk_del_param[1]=disk_list[id-130].Item[4]; |
||
310 | RunProgram("/sys/tmpdisk", #tmp_disk_del_param); |
||
311 | pause(10); |
||
3434 | leency | 312 | SystemDiscsGet(); |
3363 | leency | 313 | Open_Dir(#path,WITH_REDRAW); |
314 | DrawLeftPanel(); |
||
315 | break; |
||
316 | } |
||
317 | break; |
||
318 | //Key pressed----------------------------------------------------------------------------- |
||
319 | case evKey: |
||
320 | key = GetKey(); |
||
321 | if (Form.status_window>2) break; |
||
322 | IF (del_active) |
||
323 | { |
||
324 | IF (key==013) Del_File(true); |
||
325 | IF (key==027) Del_File(false); |
||
326 | break; |
||
327 | } |
||
3444 | leency | 328 | IF (edit2.flags!=64) && (key!=13) && (key!=27) |
3363 | leency | 329 | { |
330 | EAX=key<<8; |
||
331 | edit_box_key stdcall (#edit2); |
||
332 | break; |
||
333 | } |
||
334 | switch (key) |
||
335 | { |
||
336 | case 209...217: |
||
337 | id=key-110; |
||
338 | IF (id-100>=disc_num) break; |
||
339 | GOTO DEVICE_MARK; |
||
3434 | leency | 340 | case 008: |
3363 | leency | 341 | //GoBack(); |
342 | Dir_Up(); |
||
343 | break; |
||
3434 | leency | 344 | case 004: //Ctrl+D set as bg |
3363 | leency | 345 | strcpy(#temp, "\\S__"); |
346 | strcat(#temp, #file_path); |
||
347 | RunProgram("/sys/media/kiv", #temp); |
||
348 | break; |
||
3434 | leency | 349 | case 014: //Ctrl+N new window |
3363 | leency | 350 | IF (Form.left==98) MoveSize(Form.left-20,Form.top-20,OLD,OLD); |
351 | RunProgram("/sys/File Managers/Eolite", #path); |
||
352 | break; |
||
353 | case 024: //Ctrl+X |
||
3444 | leency | 354 | Copy(#file_path, CUT); |
355 | break; |
||
3363 | leency | 356 | case 003: //Ctrl+C |
3444 | leency | 357 | Copy(#file_path, NOCUT); |
3363 | leency | 358 | break; |
359 | case 022: //Ctrl+V |
||
3444 | leency | 360 | CreateThread(#Paste,#copy_stak); |
3363 | leency | 361 | break; |
362 | case 027: //Esc |
||
363 | IF (rename_active==1) ReName(false); |
||
364 | break; |
||
365 | case 013: //Enter |
||
366 | IF (rename_active==1) {ReName(true); break;} |
||
3434 | leency | 367 | Open(); |
3363 | leency | 368 | break; |
369 | case 178: //up |
||
3444 | leency | 370 | List_Current(-1); |
3363 | leency | 371 | break; |
372 | case 177: //down |
||
3444 | leency | 373 | List_Current(1); |
3363 | leency | 374 | break; |
375 | case 180: //home |
||
3434 | leency | 376 | files.first=0; |
377 | files.current=0; |
||
3363 | leency | 378 | List_ReDraw(); |
379 | break; |
||
380 | case 181: //end |
||
3447 | leency | 381 | files.first = files.count - files.visible; |
382 | files.current = files.visible - 1; |
||
3363 | leency | 383 | List_ReDraw(); |
384 | break; |
||
385 | case 183: //Page Down |
||
3444 | leency | 386 | List_Current(files.visible-1); |
3363 | leency | 387 | break; |
388 | case 184: //Page Up |
||
3444 | leency | 389 | List_Current(-files.visible+1); |
3363 | leency | 390 | break; |
3434 | leency | 391 | case 182: //del |
392 | Del_Form(); |
||
3363 | leency | 393 | break; |
3434 | leency | 394 | case 050...059: //F1-F10 |
3444 | leency | 395 | FnProcess(key-49); |
3363 | leency | 396 | break; |
397 | default: |
||
3434 | leency | 398 | for (i=files.current+files.first+1; i |
3363 | leency | 399 | { |
400 | strcpy(#temp, file_mas[i]*304+buf+72); |
||
401 | IF (temp[0]==key) || (temp[0]==key-32) |
||
402 | { |
||
3444 | leency | 403 | List_Current(i-files.current-files.first); |
3363 | leency | 404 | break; |
405 | } |
||
406 | } |
||
407 | } |
||
408 | break; |
||
409 | case evReDraw: |
||
4042 | leency | 410 | draw_window(); |
4028 | leency | 411 | if (action_buf) { menu_action(action_buf); action_buf=0;} |
3363 | leency | 412 | } |
413 | } |
||
414 | |||
4028 | leency | 415 | void menu_action(dword id) |
416 | { |
||
417 | if (id==COPY_PASTE_END) |
||
418 | { |
||
419 | FnProcess(5); |
||
420 | SelectFile(#copy_to+strrchr(#copy_to,'/')); |
||
421 | } |
||
422 | if (id==100) Open(); |
||
4042 | leency | 423 | if (id==201) |
424 | { |
||
425 | pause(10); |
||
426 | SwitchToAnotherThread(); |
||
427 | CreateThread(#OpenWith,#open_with_stak); |
||
428 | } |
||
4028 | leency | 429 | if (id==202) FnProcess(3); //F3 |
430 | if (id==203) FnProcess(4); //F4 |
||
431 | if (id==104) Copy(#file_path, NOCUT); |
||
432 | if (id==105) Copy(#file_path, CUT); |
||
433 | if (id==106) CreateThread(#Paste,#copy_stak); |
||
4034 | leency | 434 | if (id==207) FnProcess(2); |
4028 | leency | 435 | if (id==108) Del_Form(); |
436 | if (id==109) FnProcess(5); |
||
437 | } |
||
3363 | leency | 438 | |
4028 | leency | 439 | |
3444 | leency | 440 | void draw_window() |
441 | { |
||
442 | DefineAndDrawWindow(40,20,550,500,0x73,col_work,TITLE); |
||
443 | GetProcessInfo(#Form, SelfInfo); |
||
444 | if (Form.status_window>2) return; |
||
445 | files.SetSizes(192, 57, onLeft(192,27), onTop(57,6), disc_num*16+195,files.line_h); |
||
446 | if (Form.height < files.min_h) MoveSize(OLD,OLD,OLD,files.min_h); |
||
447 | if (Form.width<480) MoveSize(OLD,OLD,480,OLD); |
||
448 | GetProcessInfo(#Form, SelfInfo); //if win_size changed |
||
449 | |||
3363 | leency | 450 | PutPaletteImage(#toolbar,246,34,0,0,8,#toolbar_pal); |
3444 | leency | 451 | DrawBar(127, 8, 1, 25, col_border); |
3363 | leency | 452 | for (j=0; j<3; j++) DefineButton(toolbar_buttons_x[j]+2,5+2,31-5,29-5,21+j+BT_HIDE,col_work); |
453 | for (j=3; j<6; j++) DefineButton(toolbar_buttons_x[j],5,31,29,21+j+BT_HIDE,col_work); |
||
3444 | leency | 454 | DrawBar(246,0,onLeft(246,60),12, col_work); //upper editbox |
455 | DrawBar(246,29,onLeft(246,60),5,col_work); //under editbox |
||
456 | DrawRectangle(246,12,onLeft(66,246),16,col_border); |
||
457 | DefineButton(onLeft(34,0),6,27,28,51+BT_HIDE+BT_NOFRAME,0); //about |
||
3363 | leency | 458 | PutPaletteImage(#goto_about,56,34,Form.width-65,0,8,#goto_about_pal); |
3434 | leency | 459 | //main rectangles |
3444 | leency | 460 | DrawRectangle(1,40,Form.cwidth-3,onTop(46,0),col_border); |
461 | DrawRectangle(0,39,Form.cwidth-1,onTop(44,0),col_palette[4]); //bg |
||
3363 | leency | 462 | for (i=0; i<5; i++) DrawBar(0, 34+i, Form.cwidth, 1, col_palette[8-i]); |
463 | DrawLeftPanel(); |
||
3434 | leency | 464 | //ListBox |
3848 | punk_joker | 465 | DrawFlatButton(files.x,40,onLeft(files.x,168),16,31,col_work,T_FILE); |
466 | DrawFlatButton(onLeft(168,0),40,73,16,32,col_work,T_TYPE); |
||
467 | DrawFlatButton(onLeft(95,0),40,68,16,33,col_work,T_SIZE); |
||
4042 | leency | 468 | DrawBar(onLeft(27,0),files.y,1,onTop(22,files.y),col_border); //line to the left from the scroll |
3434 | leency | 469 | DrawFlatButton(onLeft(27,0),40,16,16,0,col_work,"\x18"); |
470 | DrawFlatButton(onLeft(27,0),onTop(22,0),16,16,0,col_work,"\x19"); |
||
3363 | leency | 471 | Open_Dir(#path,ONLY_SHOW); |
472 | if (del_active) Del_Form(); |
||
4002 | leency | 473 | //if (itdir) ShowMessage(WAIT_DELETING_FOLDER, 0); |
3444 | leency | 474 | if (rename_active) FnProcess(2); |
3363 | leency | 475 | } |
476 | |||
477 | |||
478 | void KEdit() |
||
479 | { |
||
3434 | leency | 480 | if (Form.width<480) return; |
3363 | leency | 481 | PathShow.area_size_x = Form.cwidth-306; |
482 | DrawBar(PathShow.start_x-3, PathShow.start_y-4, PathShow.area_size_x+2, 15, 0xFFFfff); |
||
483 | PathShow_prepare stdcall(#PathShow); |
||
484 | PathShow_draw stdcall(#PathShow); |
||
485 | } |
||
486 | |||
487 | |||
3444 | leency | 488 | void List_Current(int cur) |
3363 | leency | 489 | { |
3434 | leency | 490 | if (cur<=0) //up |
3363 | leency | 491 | { |
3434 | leency | 492 | IF (files.first==0) && (files.current<=0) return; |
493 | IF (-cur-1 |
||
3363 | leency | 494 | { |
3434 | leency | 495 | Line_ReDraw(0xFFFFFF, files.current); |
496 | files.current+=cur; |
||
497 | Line_ReDraw(col_selec, files.current); |
||
3363 | leency | 498 | return; |
499 | } |
||
500 | ELSE |
||
501 | { |
||
3434 | leency | 502 | IF (-cur |
503 | files.current=0; |
||
3363 | leency | 504 | List_ReDraw(); |
505 | return; |
||
506 | } |
||
507 | } |
||
3434 | leency | 508 | else //down |
3363 | leency | 509 | { |
3434 | leency | 510 | IF (files.first==files.count-files.visible) && (files.current==files.visible-1) return; |
511 | IF (files.visible-files.current>cur) |
||
3363 | leency | 512 | { |
3434 | leency | 513 | Line_ReDraw(0xFFFFFF, files.current); |
514 | files.current+=cur; |
||
515 | Line_ReDraw(col_selec, files.current); |
||
3363 | leency | 516 | return; |
517 | } |
||
518 | else |
||
519 | { |
||
3434 | leency | 520 | IF(files.first+files.current+cur>=files.count) |
3363 | leency | 521 | { |
3434 | leency | 522 | files.first=files.count-files.visible; |
523 | files.current=cur-files.first+files.current; |
||
3363 | leency | 524 | } |
525 | ELSE |
||
526 | { |
||
3434 | leency | 527 | files.first+=cur+files.current-files.visible+1; |
528 | files.current=files.visible-1; |
||
3363 | leency | 529 | } |
530 | |||
3434 | leency | 531 | IF (files.current<0) || (files.current>files.visible) |
3363 | leency | 532 | { |
3434 | leency | 533 | files.current=files.visible-1; |
3363 | leency | 534 | } |
535 | List_ReDraw(); |
||
536 | } |
||
537 | } |
||
538 | } |
||
539 | |||
540 | |||
541 | void List_ReDraw() |
||
542 | { |
||
3434 | leency | 543 | int paint_y; |
3876 | leency | 544 | //we are in the end of the list => maximize window => there will be white lines after the last element |
3434 | leency | 545 | if (files.count-files.first |
546 | { files.first=files.count-files.visible; files.current=files.visible-1; } |
||
3444 | leency | 547 | for (j=0; j |
3434 | leency | 548 | //in the bottom |
549 | paint_y = j * files.line_h + files.y; |
||
550 | DrawBar(files.x,paint_y,files.w,onTop(paint_y,6),0xFFFFFF); |
||
3447 | leency | 551 | DrawBar(Form.cwidth-159,paint_y,1,onTop(paint_y,6),col_work); |
552 | DrawBar(Form.cwidth-86,paint_y,1,onTop(paint_y,6),col_work); |
||
3434 | leency | 553 | Scroll(); |
3363 | leency | 554 | } |
555 | |||
3444 | leency | 556 | |
3363 | leency | 557 | void Line_ReDraw(dword color, filenum){ |
3467 | leency | 558 | dword text_col=0, |
559 | name_len=0, |
||
560 | attr, |
||
4042 | leency | 561 | y=filenum*files.line_h+files.y; |
3447 | leency | 562 | DrawBar(files.x,y,3,files.line_h,color); |
563 | DrawBar(files.x+19,y,files.w-19,files.line_h,color); |
||
564 | DrawBar(files.x+3,y+17,16,1,color); |
||
565 | if (files.line_h>18) DrawBar(files.x+3,y+18,16,files.line_h-18,color); |
||
566 | if (files.line_h>15) DrawBar(files.x+3,y,16,files.line_h-15,color); |
||
3363 | leency | 567 | |
3434 | leency | 568 | off=file_mas[filenum+files.first]*304 + buf+72; |
3467 | leency | 569 | attr = ESDWORD[off - 40]; |
3363 | leency | 570 | |
3467 | leency | 571 | if (! TestBit(attr, 4) ) //file or folder? |
3363 | leency | 572 | { |
3447 | leency | 573 | Put_icon(off+_strrchr(off,'.'), files.line_h/2-7+y, color); |
3434 | leency | 574 | WriteText(7-strlen(ConvertMemSize(ESDWORD[off-8]))*6+onLeft(75,0),files.line_h-6/2+y,0x80,0,ConvertMemSize(ESDWORD[off-8])); //size |
3363 | leency | 575 | } |
576 | else |
||
577 | if (!strcmp("..",off)) |
||
3434 | leency | 578 | Put_icon("..", files.line_h/2-7+y, color); |
3363 | leency | 579 | else |
3434 | leency | 580 | Put_icon(" |
3467 | leency | 581 | if ( TestBit(attr, 1) ) || ( TestBit(attr, 2) ) text_col=0xA6A6B7; //system or hiden? |
3444 | leency | 582 | if (color!=0xFFFfff) |
3363 | leency | 583 | { |
3467 | leency | 584 | itdir = TestBit(attr, 4); |
3363 | leency | 585 | strcpy(#file_name, off); |
586 | strcpy(#file_path, #path); |
||
3434 | leency | 587 | strcat(#file_path, #file_name); |
3363 | leency | 588 | if (text_col==0xA6A6B7) text_col=0xFFFFFF; |
589 | } |
||
3434 | leency | 590 | if (Form.width>=480) |
591 | { |
||
3447 | leency | 592 | FileShow.start_x = files.x + 23; |
3434 | leency | 593 | FileShow.font_color = text_col; |
594 | FileShow.area_size_x = Form.width - 380; |
||
595 | FileShow.text_pointer = off; |
||
596 | FileShow.start_y = files.line_h/2-3+y; |
||
597 | PathShow_prepare stdcall(#FileShow); |
||
598 | PathShow_draw stdcall(#FileShow); |
||
599 | } |
||
3447 | leency | 600 | DrawBar(Form.cwidth-159,y,1,files.line_h,col_work); //gray line 1 |
601 | DrawBar(Form.cwidth-86,y,1,files.line_h,col_work); //gray line 2 |
||
3363 | leency | 602 | } |
603 | |||
604 | |||
3444 | leency | 605 | void Open_Dir(dword dir_path, redraw){ |
606 | int errornum, maxcount; |
||
3434 | leency | 607 | |
3444 | leency | 608 | if (redraw!=ONLY_SHOW) |
3363 | leency | 609 | { |
3444 | leency | 610 | if (ESBYTE[dir_path+1]!='\0') ESBYTE[dir_path+strlen(dir_path)-1] = '\0'; |
3363 | leency | 611 | if (buf) free(buf); |
3444 | leency | 612 | errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT); |
613 | if (ESBYTE[dir_path+1]!='\0') chrcat(dir_path, '/'); |
||
614 | if (errornum) |
||
3363 | leency | 615 | { |
616 | HistoryPath(ADD_NEW_PATH); |
||
617 | GoBack(); |
||
618 | Write_Error(errornum); |
||
619 | return; |
||
620 | } |
||
3444 | leency | 621 | maxcount = sizeof(file_mas)/sizeof(dword)-1; |
622 | if (files.count>maxcount) files.count = maxcount; |
||
3363 | leency | 623 | } |
3444 | leency | 624 | if (files.count!=-1) |
3363 | leency | 625 | { |
626 | KEdit(); |
||
627 | HistoryPath(ADD_NEW_PATH); |
||
3444 | leency | 628 | files.visible = files.h / files.line_h; |
629 | IF (files.count < files.visible) files.visible = files.count; |
||
4022 | leency | 630 | IF (sort_num==1) sorting_arrow_x = Form.width+60/2; |
631 | IF (sort_num==2) sorting_arrow_x = Form.width-115; |
||
632 | IF (sort_num==3) sorting_arrow_x = strlen(T_SIZE)*3-30+files.x+files.w; |
||
633 | WriteText(sorting_arrow_x,45,0x80,col_border,"\x19"); |
||
3444 | leency | 634 | IF (redraw!=ONLY_SHOW) Sorting(); |
635 | IF (redraw!=ONLY_OPEN) List_ReDraw(); |
||
3363 | leency | 636 | } |
3444 | leency | 637 | IF (files.count==-1) && (redraw!=ONLY_OPEN) {files.visible=files.count=0; List_ReDraw();} |
3363 | leency | 638 | } |
639 | |||
640 | |||
641 | inline Sorting() |
||
642 | { |
||
643 | dword k=0, l=1; |
||
644 | int i; |
||
3434 | leency | 645 | if (!strcmp(#path,"/")) //do not sort |
3363 | leency | 646 | { |
3434 | leency | 647 | FOR(k=1;k |
3363 | leency | 648 | return; |
649 | } |
||
3434 | leency | 650 | FOR (j=files.count-1, off=files.count-1*304+buf+32; j>=0; j--, off-=304;) //files | folders |
3363 | leency | 651 | { |
652 | strttl(off+40); |
||
3441 | leency | 653 | if (TestBit(ESDWORD[off],4)) //directory? |
3363 | leency | 654 | { |
655 | file_mas[k]=j; |
||
656 | k++; |
||
657 | } |
||
658 | else |
||
659 | { |
||
3434 | leency | 660 | file_mas[files.count-l]=j; |
3363 | leency | 661 | l++; |
662 | } |
||
663 | } |
||
3434 | leency | 664 | //sorting: files first, then folders |
3363 | leency | 665 | Sort_by_Name(0,k-1); |
3434 | leency | 666 | IF (sort_num==1) Sort_by_Name(k,files.count-1); |
667 | IF (sort_num==2) Sort_by_Type(k,files.count-1); |
||
668 | IF (sort_num==3) Sort_by_Size(k,files.count-1); |
||
669 | //".." should be first |
||
3444 | leency | 670 | IF (k>0) && (strcmp(file_mas[0]*304+buf+72,"..")!=0) |
671 | FOR(k--; k>0; k--;) IF (!strcmp(file_mas[k]*304+buf+72,"..")) {file_mas[k]> |
||
3363 | leency | 672 | } |
673 | |||
674 | |||
675 | void Del_Form() |
||
676 | { |
||
4002 | leency | 677 | int dform_x=files.w-220/2+files.x; |
4022 | leency | 678 | if (strcmp(#file_name,".")==0) || (strcmp(#file_name,"..")==0) return; |
4002 | leency | 679 | if (del_active==2) |
3991 | leency | 680 | { |
4002 | leency | 681 | if (itdir) ShowMessage(WAIT_DELETING_FOLDER, 0); |
3991 | leency | 682 | } |
683 | else |
||
684 | { |
||
4002 | leency | 685 | if (!files.count) return; |
686 | DrawPopup(dform_x,160,220,80,1,col_work,col_border); |
||
687 | WriteText(-strlen(T_DELETE_FILE)*3+110+dform_x,175,0x80,0,T_DELETE_FILE); |
||
688 | IF (strlen(#file_name)<28) |
||
689 | { |
||
690 | WriteText(strlen(#file_name)*3+110+dform_x+2,190,0x80,0,"?"); |
||
691 | WriteText(-strlen(#file_name)*3+110+dform_x,190,0x80,0,#file_name); |
||
692 | } |
||
693 | else |
||
694 | { |
||
695 | WriteText(164+dform_x,190,0x80,0,"...?"); |
||
696 | ESI = 24; |
||
697 | WriteText(dform_x+20,190,0,0,#file_name); |
||
698 | } |
||
699 | DrawFlatButton(dform_x+27,208,70,20,301,0xFFB6B5,T_YES); |
||
700 | DrawFlatButton(dform_x+120,208,70,20,302,0xC6DFC6,T_NO); |
||
701 | del_active=1; |
||
3991 | leency | 702 | } |
3363 | leency | 703 | } |
704 | |||
4022 | leency | 705 | int del_error; |
706 | int Del_File2(dword way) |
||
3980 | punk_joker | 707 | { |
708 | dword dirbuf, fcount, i, filename; |
||
4022 | leency | 709 | int error; |
710 | char del_from[4096]; |
||
711 | if (isdir(way)) |
||
3997 | leency | 712 | { |
4022 | leency | 713 | if (error = GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL)) del_error = error; |
3997 | leency | 714 | for (i=0; i |
3980 | punk_joker | 715 | { |
4002 | leency | 716 | if (CheckEvent()==evReDraw) draw_window(); |
3997 | leency | 717 | filename = i*304+dirbuf+72; |
718 | strcpy(#del_from, way); |
||
719 | chrcat(#del_from, '/'); |
||
720 | strcat(#del_from, filename); |
||
721 | if ( TestBit(ESDWORD[filename-40], 4) ) |
||
722 | Del_File2(#del_from); |
||
723 | else |
||
4022 | leency | 724 | { |
725 | if (error = DeleteFile(#del_from)) del_error = error; |
||
726 | } |
||
3980 | punk_joker | 727 | } |
3997 | leency | 728 | } |
4022 | leency | 729 | if (error = DeleteFile(way)) del_error = error; |
3980 | punk_joker | 730 | } |
731 | |||
732 | |||
3363 | leency | 733 | void Del_File(byte dodel) |
4022 | leency | 734 | { |
3980 | punk_joker | 735 | if (dodel==true) |
3363 | leency | 736 | { |
4002 | leency | 737 | del_active=2; |
3997 | leency | 738 | if (itdir) ShowMessage(WAIT_DELETING_FOLDER, 0); |
4022 | leency | 739 | del_error = 0; |
3980 | punk_joker | 740 | Del_File2(#file_path); |
4022 | leency | 741 | if (del_error) Write_Error(del_error); |
3363 | leency | 742 | } |
743 | del_active=0; |
||
3997 | leency | 744 | DeleteButton(301); |
745 | DeleteButton(302); |
||
3444 | leency | 746 | Open_Dir(#path,WITH_REDRAW); |
3363 | leency | 747 | } |
748 | |||
749 | |||
750 | void ReName(byte rename) |
||
751 | { |
||
3404 | leency | 752 | int del_rezult, copy_rezult; |
3363 | leency | 753 | char edit_name[256]; |
754 | rename_active=0; |
||
755 | edit2.flags=64; |
||
756 | if (rename==true) |
||
757 | { |
||
758 | strcpy(#temp, #path); |
||
3434 | leency | 759 | strcpy(#edit_name, #file_name); //save edit name to select it later |
3363 | leency | 760 | strcat(#temp, #file_name); |
3444 | leency | 761 | if (strcmp(#file_path,#temp)!=0) && (file_name) |
762 | if (itdir) |
||
3363 | leency | 763 | { |
4029 | leency | 764 | if (del_rezult = DeleteFile(#file_path)) |
3363 | leency | 765 | { |
3404 | leency | 766 | Write_Error(del_rezult); |
3997 | leency | 767 | ShowMessage(T_DEL_ERROR_1, 150); |
3363 | leency | 768 | return; |
769 | } |
||
4029 | leency | 770 | if (CreateDir(#temp)) CreateDir(#file_path); |
3444 | leency | 771 | Open_Dir(#path,WITH_REDRAW); |
4029 | leency | 772 | SelectFile(#edit_name); |
3363 | leency | 773 | } |
3877 | leency | 774 | else |
3363 | leency | 775 | { |
4029 | leency | 776 | if (copy_rezult = CopyFile(#file_path,#temp)) |
777 | { |
||
778 | Write_Error(copy_rezult); |
||
779 | } |
||
780 | else |
||
781 | { |
||
782 | Del_File(true); |
||
783 | SelectFile(#edit_name); |
||
784 | } |
||
3363 | leency | 785 | } |
786 | } |
||
3434 | leency | 787 | Line_ReDraw(col_selec,files.current); |
3363 | leency | 788 | } |
789 | |||
790 | |||
791 | void SelectFile(dword that_file) |
||
792 | { |
||
3434 | leency | 793 | files.first=files.current=0; |
3363 | leency | 794 | Open_Dir(#path,ONLY_OPEN); |
795 | strttl(that_file); |
||
3434 | leency | 796 | for (i=files.count-1; i>=0; i--;) |
3363 | leency | 797 | if (!strcmp(file_mas[i]*304+buf+72,that_file)) break; |
3444 | leency | 798 | List_Current(i); |
3363 | leency | 799 | List_ReDraw(); |
800 | } |
||
801 | |||
802 | |||
803 | void Dir_Up() |
||
804 | { |
||
805 | char cur_folder[4096]; |
||
806 | i=strlen(#path)-1; |
||
807 | if (i==0) return; |
||
808 | path[i]=0x00; |
||
809 | i = strrchr(#path, '/'); |
||
810 | strcpy(#cur_folder, #path+i); |
||
811 | path[i]=0x00; |
||
812 | SelectFile(#cur_folder); |
||
813 | } |
||
814 | |||
3434 | leency | 815 | void Open() |
816 | { |
||
3444 | leency | 817 | if (!files.count) return; |
3441 | leency | 818 | if (!itdir) |
3434 | leency | 819 | { |
820 | GetIni(0); |
||
821 | } |
||
822 | else |
||
823 | { |
||
824 | if (!strcmp(#file_name,"..")) { Dir_Up(); return; } |
||
825 | strcpy(#path, #file_path); |
||
826 | if (path[strlen(#path)-1]!='/') chrcat(#path, '/'); //need "/" in the end |
||
827 | files.first=files.current=0; |
||
3444 | leency | 828 | Open_Dir(#path,WITH_REDRAW); |
3434 | leency | 829 | } |
830 | } |
||
3363 | leency | 831 | |
3434 | leency | 832 | |
833 | inline fastcall void GoBack() |
||
3363 | leency | 834 | { |
835 | char cur_folder[4096]; |
||
836 | strcpy(#cur_folder, GetCurrentFolder()); |
||
837 | if (HistoryPath(GO_BACK)) SelectFile(#cur_folder); |
||
838 | } |
||
839 | |||
3444 | leency | 840 | void FnProcess(char N) |
3434 | leency | 841 | { |
842 | switch(N) |
||
843 | { |
||
844 | case 1: |
||
845 | SwitchToAnotherThread(); |
||
3444 | leency | 846 | CreateThread(#about_dialog,#about_stak); |
3434 | leency | 847 | break; |
848 | case 2: |
||
849 | if (!files.count) break; |
||
3447 | leency | 850 | edit2.flags = 100000000000010b; //set active |
851 | edit2.left = files.x + 21; |
||
852 | edit2.width = files.w - 26; |
||
3434 | leency | 853 | edit2.top=files.current*files.line_h+59; |
854 | edit2.size=edit2.pos=strlen(#file_name); |
||
855 | edit_box_draw stdcall (#edit2); |
||
3447 | leency | 856 | DrawBar(edit2.left,files.current*files.line_h+58,edit2.width+1,1,0xFFFFCC); //bg |
3434 | leency | 857 | rename_active=1; |
858 | break; |
||
859 | case 3: |
||
3441 | leency | 860 | IF (!itdir) RunProgram("/sys/tinypad", #file_path); |
3434 | leency | 861 | break; |
862 | case 4: |
||
3441 | leency | 863 | IF (!itdir) RunProgram("/sys/develop/heed", #file_path); |
3434 | leency | 864 | break; |
3440 | leency | 865 | case 5: //refresh cur dir & devs |
3854 | leency | 866 | Tip(56, T_DEVICES, 55, "-"); |
3440 | leency | 867 | Open_Dir(#path,WITH_REDRAW); |
868 | pause(10); |
||
869 | GetIni(1); |
||
870 | SystemDiscsGet(); |
||
3444 | leency | 871 | Open_Dir(#path,WITH_REDRAW); |
3440 | leency | 872 | DrawLeftPanel(); |
3434 | leency | 873 | break; |
874 | case 6: |
||
875 | strcpy(#temp, #path); |
||
3848 | punk_joker | 876 | strcat(#temp, T_NEW_FOLDER); |
3434 | leency | 877 | CreateDir(#temp); |
878 | if (!EAX){ |
||
3848 | punk_joker | 879 | SelectFile(T_NEW_FOLDER); |
3444 | leency | 880 | FnProcess(2); |
3434 | leency | 881 | } |
882 | else |
||
883 | { |
||
884 | Write_Error(EAX); |
||
3997 | leency | 885 | ShowMessage(NOT_CREATE_FOLDER, 150); |
3434 | leency | 886 | } |
887 | break; |
||
888 | case 7: |
||
889 | strcpy(#temp, #path); |
||
3848 | punk_joker | 890 | strcat(#temp, T_NEW_FILE); |
3434 | leency | 891 | WriteFile(0, 0, #temp); |
892 | if (!EAX){ |
||
3848 | punk_joker | 893 | SelectFile(T_NEW_FILE); |
3444 | leency | 894 | FnProcess(2); |
3434 | leency | 895 | } |
896 | else |
||
897 | { |
||
898 | Write_Error(EAX); |
||
3997 | leency | 899 | ShowMessage(NOT_CREATE_FILE, 150); |
3434 | leency | 900 | } |
901 | break; |
||
902 | case 10: //F10 |
||
903 | RunProgram(EDITOR_PATH, abspath("Eolite.ini")); |
||
904 | break; |
||
905 | } |
||
906 | } |
||
907 | |||
908 | |||
3363 | leency | 909 | stop: |
910 | |||
3444 | leency | 911 | char about_stak[512]; |
912 | char menu_stak[512]; |
||
4042 | leency | 913 | char open_with_stak[512]; |
3846 | punk_joker | 914 | char copy_stak[4096];28)>>0)> |