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