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