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