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