Subversion Repositories Kolibri OS

Rev

Rev 5698 | Rev 5703 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. //Leency, Veliant, Punk_Joker & KolibriOS Team 2008-2015
  2. //GNU GPL licence.
  3.  
  4. #ifndef AUTOBUILD
  5. #include "lang.h--"
  6. #endif
  7.  
  8. //libraries
  9. #define MEMSIZE 500000
  10. #include "..\lib\clipboard.h"
  11. #include "..\lib\strings.h"
  12. #include "..\lib\mem.h"
  13. #include "..\lib\file_system.h"
  14. #include "..\lib\gui.h"
  15. #include "..\lib\list_box.h"
  16. #include "..\lib\copyf.h"
  17. #include "..\lib\random.h"
  18. //obj
  19. #include "..\lib\obj\libini.h"
  20. #include "..\lib\obj\box_lib.h"
  21. //images
  22. #include "imgs\toolbar.txt"
  23. #include "imgs\left_p.txt"
  24. #include "imgs\icons.txt"
  25.  
  26. enum {ONLY_SHOW, WITH_REDRAW, ONLY_OPEN}; //OpenDir
  27. enum {CREATE_FILE=1, CREATE_FOLDER, RENAME_ITEM }; //NewElement
  28.  
  29. dword col_padding, col_selec, col_lpanel;
  30.  
  31. int toolbar_buttons_x[7]={9,46,85,134,167,203};
  32. struct path_string { char Item[4096]; };
  33.  
  34. byte active_about=0;
  35. word about_window;
  36. byte active_settings=0;
  37. word settings_window;
  38. dword _not_draw = false;
  39. byte menu_call_mouse=0;
  40.  
  41. byte del_active=0,
  42.         new_element_active=0;
  43.  
  44. llist files;
  45.  
  46. byte list_full_redraw;
  47.  
  48. dword buf;
  49. dword file_mas[6898];
  50. int selected_count;
  51.  
  52.  
  53. byte
  54.         path[4096],
  55.         file_path[4096],
  56.         file_name[256],
  57.         new_element_name[256],
  58.         temp[4096],
  59.         itdir;
  60.  
  61. //struct t_settings {
  62. byte use_big_fonts=false,
  63.         font_type=0x80,
  64.         font_h=9,
  65.         sort_num=2,
  66.         show_dev_name=true,
  67.         real_files_names_case=false,
  68.         info_after_copy=false,
  69.         two_panels=false;
  70. //} settings;
  71.  
  72.  
  73. dword eolite_ini_path;
  74.  
  75. char scroll_used=false;
  76.  
  77. dword menu_stak,about_stak,properties_stak,settings_stak,copy_stak;
  78.  
  79. proc_info Form;
  80. int mouse_dd, sc_slider_h, sorting_arrow_x, kolibrios_drive;
  81. int j, i;
  82. int action_buf;
  83. int rand_n;
  84. byte CMD_REFRESH;
  85.  
  86. signed x_old, y_old, dif_x, dif_y, adif_x, adif_y;
  87.  
  88.  
  89. edit_box new_file_ed = {171,213,180,0xFFFFFF,0x94AECE,0xFFFFFF,0xFFFFFF,0,248,#new_element_name,#mouse_dd,100000000000010b,6,0};
  90. PathShow_data PathShow = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, #path, #temp, 0};
  91. PathShow_data FileShow = {0, 56,215, 6, 100, 0, 0, 0x0, 0xFFFfff, #file_name, #temp, 0};
  92. byte cmd_free=0;
  93. #include "include\translations.h"
  94. #include "include\copy.h"
  95. #include "include\gui.h"
  96. #include "include\sorting.h"
  97. #include "include\icons.h"
  98. #include "include\left_panel.h"
  99. #include "include\history.h"
  100. #include "include\menu.h"
  101. #include "include\about.h"
  102. #include "include\settings.h"
  103. #include "include\properties.h"
  104.  
  105.  
  106. void main()
  107. {
  108.         word key, key2, id;
  109.         dword status_key;
  110.         char can_show, can_select, stats;
  111.         dword selected_offset;
  112.         dword IPC_LEN,IPC_ID;
  113.         char IPC_BUF[10];
  114.         dword tmp;
  115.         rand_n = random(40);
  116.  
  117.         load_dll(boxlib, #box_lib_init,0);
  118.     load_dll(libini, #lib_init,1);
  119.         eolite_ini_path = abspath("Eolite.ini");
  120.         LoadIniSettings();
  121.         GetSystemDiscs();
  122.         SetAppColors();
  123.         if (param)
  124.         {
  125.                 tmp = strlen(#path);
  126.                 strlcpy(#path, #param, tmp);
  127.                 $dec tmp
  128.                 if (path[tmp]!='/') DSBYTE[#path+tmp] = '/'; //add "/" to the end of the string
  129.         }
  130.         else
  131.         {
  132.                 strlcpy(#path, "/rd/1/", 6);           
  133.         }
  134.         Open_Dir(#path,ONLY_OPEN);
  135.         SetEventMask(1100111b);
  136.         loop(){
  137.                 switch(WaitEvent())
  138.                 {
  139.                         case evMouse:
  140.                                 if (del_active) || (!CheckActiveProcess(Form.ID)) || (Form.status_window>2) break;
  141.                                 if (new_element_active) || (!CheckActiveProcess(Form.ID)) || (Form.status_window>2)
  142.                                 {
  143.                                         edit_box_mouse stdcall(#new_file_ed);
  144.                                         break;
  145.                                 }                              
  146.                                
  147.                                 mouse.get();
  148.                                
  149.                                 if (!mouse.mkm) && (stats>0) stats = 0;
  150.                                 if (mouse.mkm) && (!stats)
  151.                                 {
  152.                                         x_old = mouse.x;
  153.                                         y_old = mouse.y;
  154.                                         stats = 1;
  155.                                 }
  156.                                 if (mouse.mkm) && (stats==1)
  157.                                 {
  158.                                         dif_x = mouse.x-x_old;
  159.                                         dif_y = mouse.y-y_old;
  160.                                         adif_x = fabs(dif_x);
  161.                                         adif_y = fabs(dif_y);
  162.                                        
  163.                                         if (adif_x>adif_y)
  164.                                         {
  165.                                                 if (dif_x > 150)
  166.                                                 {
  167.                                                         if (HistoryPath(GO_FORWARD))
  168.                                                                 {
  169.                                                                         files.KeyHome();
  170.                                                                         Open_Dir(#path,WITH_REDRAW);
  171.                                                                 }
  172.                                                         stats = 0;
  173.                                                 }
  174.                                                 if (dif_x < -150)
  175.                                                 {
  176.                                                         GoBack();
  177.                                                         stats = 0;
  178.                                                 }
  179.                                         }
  180.                                         else
  181.                                         {
  182.                                                 if (dif_y < -100)
  183.                                                 {
  184.                                                         Dir_Up();
  185.                                                         stats = 0;
  186.                                                 }
  187.                                         }
  188.                                 }      
  189.                                 if (files.MouseOver(mouse.x, mouse.y))&&((mouse.down|mouse.dblclick|mouse.up))
  190.                                 {
  191.                                         //select/open file {
  192.                                         if (mouse.key&MOUSE_LEFT)&&((mouse.down)||(mouse.dblclick))
  193.                                         {
  194.                                                 if (mouse.y>=files.y)//&&(mouse.click)
  195.                                                 {
  196.                                                         id = mouse.y - files.y / files.line_h + files.first;
  197.                                                         if (files.current!=id)
  198.                                                         {
  199.                                                                 mouse.clearTime();
  200.                                                                 if(!mouse.up)&&(id-files.first<files.visible) {
  201.                                                                         files.current = id;
  202.                                                                         List_ReDraw();
  203.                                                                 }
  204.                                                         }
  205.                                                         else IF(mouse.dblclick)Open(0);
  206.                                                 }
  207.                                         }
  208.                                         // } select/open file
  209.                                         else
  210.                                         //file menu {
  211.                                         if (mouse.key&MOUSE_RIGHT)&&(mouse.up)
  212.                                         {
  213.                                                 menu_call_mouse = 1;
  214.                                                
  215.                                                 if (files.MouseOver(mouse.x, mouse.y))
  216.                                                 {
  217.                                                         files.current = mouse.y - files.y / files.line_h + files.first;
  218.                                                         menu_stak = malloc(4096);
  219.                                                         CreateThread(#FileMenu,menu_stak+4092);
  220.                                                 }
  221.                                                 break;
  222.                                         }
  223.                                         // } file menu
  224.                                 }
  225.  
  226.                                 if (mouse.vert)
  227.                                 {
  228.                                         if (files.MouseScroll(mouse.vert)) List_ReDraw();
  229.                                         break;
  230.                                 }
  231.  
  232.                                 if (mouse.x>=Form.width-26) && (mouse.x<=Form.width-6) && (mouse.y>40) && (mouse.y<files.y)
  233.                                 {
  234.                                         if (mouse.lkm==1) DrawRectangle3D(Form.cwidth - 17,41,14,14,0xC7C7C7,0xFFFFFF);
  235.                                         WHILE (mouse.lkm==1) && (files.first>0)
  236.                                         {
  237.                                                 pause(8);
  238.                                                 files.first--;
  239.                                                 List_ReDraw();
  240.                                                 mouse.get();
  241.                                         }
  242.                                         DrawRectangle3D(Form.cwidth - 17,41,14,14,0xFFFFFF,0xC7C7C7);
  243.                                 }
  244.  
  245.                                 if (mouse.x>=Form.width-26) && (mouse.x<=Form.width-6) && (mouse.y>onTop(22,0)+1) && (mouse.y<onTop(22,0)+16)
  246.                                 {
  247.                                         if (mouse.lkm==1) DrawRectangle3D(Form.cwidth - 17,onTop(21,0),14,14,0xC7C7C7,0xFFFFFF);
  248.                                         while (mouse.lkm==1) && (files.first<files.count-files.visible)
  249.                                         {
  250.                                                 pause(8);
  251.                                                 files.first++;
  252.                                                 List_ReDraw();
  253.                                                 mouse.get();
  254.                                         }
  255.                                         DrawRectangle3D(Form.cwidth - 17,onTop(21,0),14,14,0xFFFFFF,0xC7C7C7);
  256.                                 }
  257.  
  258.                                 //Scrooll
  259.                                 if (!mouse.lkm) && (scroll_used) { scroll_used=false; Scroll(); }
  260.                                 if (mouse.x>=Form.width-26) && (mouse.x<=Form.width-6) && (mouse.y>56) && (mouse.y<Form.height) && (mouse.lkm) && (!scroll_used) {scroll_used=true; Scroll();}
  261.                                
  262.                                 if (scroll_used)
  263.                                 {
  264.                                         if (sc_slider_h/2+files.y>mouse.y) || (mouse.y<0) || (mouse.y>4000) mouse.y=sc_slider_h/2+files.y; //anee eo?ni? iaa ieiii
  265.                                         id=files.first;
  266.                                         j= sc_slider_h/2;
  267.                                         files.first = mouse.y -j -files.y * files.count;
  268.                                         files.first /= onTop(22,files.y);
  269.                                         if (files.visible+files.first>files.count) files.first=files.count-files.visible;
  270.                                         if (id!=files.first) List_ReDraw();
  271.                                 }
  272.                                 break;  
  273.         //Button pressed-----------------------------------------------------------------------------
  274.                         case evButton:
  275.                                 id=GetButtonID();
  276.                                 if (id==1)
  277.                                 {
  278.                                         KillProcess(about_window);
  279.                                         ExitProcess();
  280.                                 }
  281.                                 if (del_active)
  282.                                 {
  283.                                         if (id==301) || (id==302) Del_File(302-id);
  284.                                         break;
  285.                                 }
  286.                                 if (new_element_active)
  287.                                 {
  288.                                         if (id==301) || (id==302) NewElement(302-id);
  289.                                         break;
  290.                                 }
  291.                                
  292.                                 switch(id)
  293.                                 {
  294.                                         case 21: //Back
  295.                                                         GoBack();
  296.                                                         break;
  297.                                         case 22: //Forward
  298.                                                         if (HistoryPath(GO_FORWARD))
  299.                                                         {
  300.                                                                 files.KeyHome();
  301.                                                                 Open_Dir(#path,WITH_REDRAW);
  302.                                                         }
  303.                                                         break;
  304.                                         case 23:
  305.                                                         Dir_Up();
  306.                                                         break;
  307.                                         case 24:
  308.                                                         Copy(#file_path, CUT);
  309.                                                         break;
  310.                                         case 25:
  311.                                                         Copy(#file_path, NOCUT);
  312.                                                         break;
  313.                                         case 26:
  314.                                                         Paste();
  315.                                                         break;
  316.                                         case 31...33: //sort
  317.                                                         if(sort_num==1) DrawFilledBar(sorting_arrow_x,42,6,10);
  318.                                                         if(sort_num==2) DrawFilledBar(sorting_arrow_x,42,6,10);
  319.                                                         if(sort_num==3) DrawFilledBar(sorting_arrow_x,42,6,10);
  320.                                                         sort_num=id-30;
  321.                                                         Open_Dir(#path,WITH_REDRAW);
  322.                                                         break;
  323.                                         case 50...60: //Actions
  324.                                                         FnProcess(id-50);
  325.                                                         break;
  326.                                         case 100...120:
  327.                                                 ClickOnDisk(id-100);
  328.                                                 break;
  329.                                 }
  330.                                 break;
  331.         //Key pressed-----------------------------------------------------------------------------
  332.                         case evKey:
  333.                                 GetFullKey();
  334.                                 key = AH;
  335.                                 $shr  eax,16
  336.                                 key2 = AL;
  337.                                 status_key = GetStatusKey();
  338.  
  339.                                 if (Form.status_window>2) break;
  340.                                 if (del_active)
  341.                                 {
  342.                                         if (key2 == SCAN_CODE_ENTER) Del_File(true);
  343.                                         if (key2 == SCAN_CODE_ESC) Del_File(false);
  344.                                         break;
  345.                                 }
  346.                                 if (new_element_active)
  347.                                 {
  348.                                         if (key2 == SCAN_CODE_ESC) NewElement(0);
  349.                                         if (key2 == SCAN_CODE_ENTER) NewElement(1);
  350.                                         EAX=key<<8;
  351.                                         edit_box_key stdcall (#new_file_ed);
  352.                                         break;
  353.                                 }
  354.                                 if (files.ProcessKey(key2))
  355.                                 {
  356.                                         List_ReDraw();
  357.                                         break;
  358.                                 }
  359.  
  360.                                 if (TestBit(status_key, 2))
  361.                                 {
  362.                                         switch(key2)
  363.                                         {
  364.                                                 case 059...068:
  365.                                                                 key2 -= 59;
  366.                                                                 if (key2<disc_num)
  367.                                                                 {
  368.                                                                         DrawRectangle(17,key2*16+74,159,16, 0); //display click
  369.                                                                         pause(7);
  370.                                                                         ClickOnDisk(key2);
  371.                                                                 }
  372.                                                                 break;
  373.                                                 case 45:  //Ctrl+X
  374.                                                                 Copy(#file_path, CUT);
  375.                                                                 break;                                         
  376.                                                 case 46:  //Ctrl+C
  377.                                                                 Copy(#file_path, NOCUT);
  378.                                                                 break;
  379.                                                 case 47:  //Ctrl+V
  380.                                                                 Paste();
  381.                                                                 break;
  382.                                                 case 032: //Ctrl+D - set as bg
  383.                                                                 strncpy(#temp, "\\S__",4);
  384.                                                                 strcat(#temp, #file_path);
  385.                                                                 RunProgram("/sys/media/kiv", #temp);
  386.                                                                 break;
  387.                                                 case 049: //Ctrl+N - create new window
  388.                                                                 if (Form.left==98) MoveSize(Form.left-20,Form.top-20,OLD,OLD);
  389.                                                                 RunProgram("/sys/File Managers/Eolite", #path);
  390.                                                                 break;
  391.                                                 case 028: //Ctrl+Enter
  392.                                                                 if (!itdir) ShowOpenWithDialog();
  393.                                                                 else Open(1);
  394.                                                                 break;
  395.                                                 case 030: //Ctrl+A - select all files
  396.                                                                 for (i=0; i<files.count; i++)
  397.                                                                 {
  398.                                                                         selected_offset = file_mas[i]*304 + buf+32 + 7;
  399.                                                                         if (!i) if (!strncmp(selected_offset+33, "..", 2)) continue; //do not selec ".." directory
  400.                                                                         ESBYTE[selected_offset] = 1;
  401.                                                                         selected_count++;
  402.                                                                 }
  403.                                                                 List_ReDraw();
  404.                                                                 break;
  405.                                                 case 022: //Ctrl+U - unselect all files
  406.                                                                 for (i=0; i<files.count; i++)
  407.                                                                 {
  408.                                                                         selected_offset = file_mas[i]*304 + buf+32 + 7;
  409.                                                                         ESBYTE[selected_offset] = 0;
  410.                                                                 }
  411.                                                                 selected_count = 0;
  412.                                                                 List_ReDraw();
  413.                                                                 break;
  414.                                         }
  415.                                         break;
  416.                                 }
  417.  
  418.                                 switch (key2)
  419.                                 {
  420.                                                 case 041:
  421.                                                                 two_panels ^= 1;
  422.                                                                 draw_window();
  423.                                                                 break;
  424.                                                 case SCAN_CODE_BS:
  425.                                                                 //GoBack();
  426.                                                                 Dir_Up();
  427.                                                                 break;
  428.                                                 case SCAN_CODE_ENTER:
  429.                                                                 Open(0);
  430.                                                                 break;
  431.                                                 case 093: //menu
  432.                                                                 menu_call_mouse=0;
  433.                                                                 menu_stak = malloc(4096);
  434.                                                                 CreateThread(#FileMenu,menu_stak+4092);
  435.                                                                 break;
  436.                                                 case SCAN_CODE_DEL:
  437.                                                                 Del_Form();
  438.                                                                 break;
  439.                                                 case SCAN_CODE_INS:
  440.                                                                 selected_offset = file_mas[files.current]*304 + buf+32 + 7;
  441.                                                                 if (files.current==0) && (!strncmp(selected_offset+33, "..", 2)) goto _INSERT_END; //do not selec ".." directory
  442.                                                                 if (ESBYTE[selected_offset])
  443.                                                                 {
  444.                                                                         ESBYTE[selected_offset]=0;
  445.                                                                         selected_count--;
  446.                                                                 }
  447.                                                                 else
  448.                                                                 {
  449.                                                                         ESBYTE[selected_offset] = 1;
  450.                                                                         selected_count++;
  451.                                                                 }
  452.                                                                 _INSERT_END:
  453.                                                                 if (files.KeyDown()) List_ReDraw();
  454.                                                                 break;
  455.                                                 case 059...068: //F1-F10
  456.                                                                 FnProcess(key2-58);
  457.                                                                 break;
  458.                                                 default:    
  459.                                                                 for (i=files.current+1; i<files.count; i++)
  460.                                                                 {
  461.                                                                         strcpy(#temp, file_mas[i]*304+buf+72);
  462.                                                                         if (temp[0]==key) || (temp[0]==key-32)
  463.                                                                         {
  464.                                                                                 files.current = i - 1;
  465.                                                                                 files.KeyDown();
  466.                                                                                 List_ReDraw();
  467.                                                                                 break;
  468.                                                                         }
  469.                                                                 }
  470.                                 }                        
  471.                         break;
  472.                         case evIPC:
  473.                         case evReDraw:
  474.                                 draw_window();
  475.                                 if (action_buf)
  476.                                 {
  477.                                         if (action_buf==COPY_PASTE_END)
  478.                                         {
  479.                                                 FnProcess(5);
  480.                                                 SelectFileByName(#copy_to+strrchr(#copy_to,'/'));
  481.                                         }
  482.                                         if (action_buf==100) Open(0);
  483.                                         if (action_buf==201) ShowOpenWithDialog();
  484.                                         if (action_buf==202) FnProcess(3); //F3
  485.                                         if (action_buf==203) FnProcess(4); //F4
  486.                                         if (action_buf==104) Copy(#file_path, NOCUT);
  487.                                         if (action_buf==105) Copy(#file_path, CUT);
  488.                                         if (action_buf==106) Paste();
  489.                                         if (action_buf==207) FnProcess(2);
  490.                                         if (action_buf==108) Del_Form();
  491.                                         if (action_buf==109) FnProcess(5);
  492.                                         if (action_buf==110) FnProcess(8);
  493.                                         if (action_buf==300) { FnProcess(5); List_ReDraw(); }
  494.                                         action_buf=0;
  495.                                 }
  496.                 }
  497.                
  498.                 if(cmd_free)
  499.                 {
  500.                         if(cmd_free==1)     free(menu_stak);
  501.                         else if(cmd_free==2)free(about_stak);
  502.                         else if(cmd_free==3)free(properties_stak);
  503.                         else if(cmd_free==4)free(settings_stak);
  504.                         else if(cmd_free==5)free(copy_stak);
  505.                         cmd_free = false;
  506.                 }
  507.         }
  508. }
  509.  
  510.  
  511. void draw_window()
  512. {
  513.         DefineAndDrawWindow(GetScreenWidth()-550/4+rand_n,rand_n+30,550,500,0x73,system.color.work,TITLE,0);
  514.         GetProcessInfo(#Form, SelfInfo);
  515.         if (Form.status_window>2) return;
  516.         if (Form.height < files.min_h) MoveSize(OLD,OLD,OLD,files.min_h);
  517.         if (Form.width<480) MoveSize(OLD,OLD,480,OLD);
  518.         GetProcessInfo(#Form, SelfInfo); //if win_size changed
  519.         PutPaletteImage(#toolbar,246,34,0,0,8,#toolbar_pal);
  520.         DrawBar(127, 8, 1, 25, system.color.work_graph);
  521.         for (j=0; j<3; j++) DefineButton(toolbar_buttons_x[j]+2,5+2,31-5,29-5,21+j+BT_HIDE,system.color.work);
  522.         for (j=3; j<6; j++) DefineButton(toolbar_buttons_x[j],5,31,29,21+j+BT_HIDE,system.color.work);
  523.         DrawBar(246,0,Form.cwidth - 297,12, system.color.work); //upper editbox
  524.         DrawBar(246,29,Form.cwidth - 297,5,system.color.work);  //under editbox
  525.         DrawRectangle(246,12,Form.cwidth - 303,16,system.color.work_graph);
  526.         DefineButton(Form.cwidth - 32,6,27,28,51+BT_HIDE+BT_NOFRAME,0); //about
  527.         PutPaletteImage(#goto_about,56,34,Form.width-65,0,8,#goto_about_pal);
  528.         //main rectangles
  529.         DrawRectangle(1,40,Form.cwidth-3,Form.cheight - 42,system.color.work_graph);
  530.         DrawRectangle(0,39,Form.cwidth-1,Form.cheight - 40,col_palette[4]); //bg
  531.         for (i=0; i<5; i++) DrawBar(0, 34+i, Form.cwidth, 1, col_palette[8-i]);
  532.         if (!two_panels)
  533.         {
  534.                 DrawLeftPanel();
  535.                 files.SetSizes(192, 57, Form.cwidth - 210, Form.cheight - 59, disc_num*16+3,files.line_h);     
  536.                 DrawListColumns();
  537.                 Open_Dir(#path,ONLY_SHOW);
  538.         }
  539.         else
  540.         {
  541.                 files.SetSizes(2, 57+18, Form.cwidth/2-2-17, Form.cheight-59-18, disc_num*16+3,files.line_h);
  542.                 DrawListColumns();
  543.                 Open_Dir(#path,ONLY_SHOW);             
  544.                 files.SetSizes(Form.cwidth/2, 57+18, Form.cwidth/2-17, Form.cheight-59-18, disc_num*16+3,files.line_h);
  545.                 DrawListColumns();
  546.                 Open_Dir(#path,ONLY_SHOW);
  547.         }
  548.         if (del_active) Del_Form();
  549.         if (new_element_active) NewElement_Form(new_element_active, #new_element_name);
  550. }
  551.  
  552. void DrawListColumns()
  553. {
  554.         DrawFlatButton(files.x,files.y -  17,  files.w - 141,16,31,system.color.work,T_FILE);
  555.         DrawFlatButton(files.x + files.w - 141,  files.y-17,73,16,32,system.color.work,T_TYPE);
  556.         DrawFlatButton(files.x + files.w -  68,  files.y-17,68,16,33,system.color.work,T_SIZE);
  557.         DrawFlatButton(files.x + files.w,        files.y-17,16,16, 0,system.color.work,"\x18");
  558.         DrawFlatButton(files.x + files.w,files.y+files.h-16,16,16, 0,system.color.work,"\x19");
  559.         DrawBar(files.x+files.w,files.y,1,files.h,system.color.work_graph);
  560. }
  561.  
  562.  
  563. void List_ReDraw()
  564. {
  565.         int paint_y;
  566.         static int old_current, old_first;
  567.  
  568.         files.CheckDoesValuesOkey(); //prevent some shit
  569.  
  570.         if (list_full_redraw) || (old_first != files.first)
  571.         {
  572.                 old_current = files.current;
  573.                 old_first = files.first;
  574.                 list_full_redraw = false;
  575.                 goto _ALL_LIST_REDRAW;
  576.         }
  577.         if (old_current != files.current)
  578.         {
  579.                 if (old_current-files.first<files.visible) Line_ReDraw(0xFFFFFF, old_current-files.first);
  580.                 Line_ReDraw(col_selec, files.current-files.first);
  581.                 old_current = files.current;
  582.                 return;
  583.         }
  584.  
  585.         _ALL_LIST_REDRAW:
  586.  
  587.         for (j=0; j<files.visible; j++) if (files.current-files.first!=j) Line_ReDraw(0xFFFFFF, j); else Line_ReDraw(col_selec, files.current-files.first);
  588.         //in the bottom
  589.         paint_y = j * files.line_h + files.y;
  590.         DrawBar(files.x,paint_y,files.w,onTop(paint_y,6),0xFFFFFF);
  591.         DrawBar(Form.cwidth-159,paint_y,1,onTop(paint_y,6),system.color.work);
  592.         DrawBar(Form.cwidth-86,paint_y,1,onTop(paint_y,6),system.color.work);
  593.         Scroll();
  594. }
  595.  
  596.  
  597. void Line_ReDraw(dword color, filenum){
  598.         dword text_col=0,
  599.               ext1, attr,
  600.               file_offet,
  601.               file_name_off,
  602.               y=filenum*files.line_h+files.y;
  603.               BDVK file;
  604.         if (filenum==-1) return;
  605.         DrawBar(files.x,y,3,files.line_h,color);
  606.         DrawBar(files.x+19,y,files.w-19,files.line_h,color);
  607.         DrawBar(files.x+3,y+17,16,1,color);
  608.         if (files.line_h>18) DrawBar(files.x+3,y+18,16,files.line_h-18,color);
  609.         if (files.line_h>15) DrawBar(files.x+3,y,16,files.line_h-15,color);
  610.  
  611.         file_offet = file_mas[filenum+files.first]*304 + buf+32;
  612.         attr = ESDWORD[file_offet];
  613.         file.selected = ESBYTE[file_offet+7];
  614.         file.sizelo   = ESDWORD[file_offet+32];
  615.         file_name_off = file_offet+40;
  616.  
  617.         if (! TestBit(attr, 4) ) //file or folder?
  618.         {      
  619.                 ext1 = strrchr(file_name_off,'.') + file_name_off;
  620.                 if (ext1==file_name_off) ext1 = " \0"; //if no extension then show nothing
  621.                 Put_icon(ext1, files.x+3, files.line_h/2-7+y, color, 0);
  622.                 WriteText(7-strlen(ConvertSize(file.sizelo))*6+Form.cwidth - 76, files.line_h - font_h/ 2 + y,font_type,0,ConvertSize(file.sizelo));
  623.         }
  624.         else
  625.         {
  626.                 if (!strncmp(file_name_off,"..",3)) ext1=".."; else ext1="<DIR>";
  627.                 Put_icon(ext1, files.x+3, files.line_h/2-7+y, color, 0);               
  628.         }
  629.  
  630.         if (TestBit(attr, 1)) || (TestBit(attr, 2)) text_col=0xA6A6B7; //system or hiden?
  631.         if (color!=0xFFFfff)
  632.         {
  633.                 itdir = TestBit(attr, 4);
  634.                 strcpy(#file_name, file_name_off);
  635.                 sprintf(#file_path,"%s%s",#path,file_name_off);
  636.                 if (text_col==0xA6A6B7) text_col=0xFFFFFF;
  637.         }
  638.         if (file.selected) text_col=0xFF0000;
  639.         if (Form.width>=480)
  640.         {
  641.                 FileShow.start_x = files.x + 23;
  642.                 FileShow.font_color = text_col;
  643.                 FileShow.area_size_x = files.w - 164;
  644.                 FileShow.text_pointer = file_name_off;
  645.                 FileShow.start_y = files.line_h - font_h/ 2 + y;
  646.                 PathShow_prepare stdcall(#FileShow);
  647.                 PathShow_draw stdcall(#FileShow);
  648.         }
  649.         DrawBar(Form.cwidth-159,y,1,files.line_h,system.color.work); //gray line 1
  650.         DrawBar(Form.cwidth-86,y,1,files.line_h,system.color.work); //gray line 2
  651. }
  652.  
  653.  
  654. void Open_Dir(dword dir_path, redraw){
  655.         int errornum, maxcount;
  656.  
  657.         if (redraw!=ONLY_SHOW)
  658.         {
  659.                 if (ESBYTE[dir_path+1]!='\0') ESBYTE[dir_path+strlen(dir_path)-1] = '\0';
  660.                 if (buf) free(buf);
  661.                 errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT);
  662.                 if (ESBYTE[dir_path+1]!='\0') chrcat(dir_path, '/');
  663.                 if (errornum)
  664.                 {
  665.                         HistoryPath(ADD_NEW_PATH);
  666.                         GoBack();
  667.                         Write_Error(errornum);
  668.                         return;
  669.                 }
  670.                 maxcount = sizeof(file_mas)/sizeof(dword)-1;
  671.                 if (files.count>maxcount) files.count = maxcount;
  672.                 if (files.count>0) && (files.current-files.first==-1) files.current=0;
  673.         }
  674.         if (files.count!=-1)
  675.         {
  676.                 if(!_not_draw)
  677.                 {
  678.                         PathShow.area_size_x = Form.cwidth-306;
  679.                         DrawBar(PathShow.start_x-3, PathShow.start_y-4, PathShow.area_size_x+2, 15, 0xFFFfff);
  680.                         PathShow_prepare stdcall(#PathShow);
  681.                         PathShow_draw stdcall(#PathShow);
  682.                 }
  683.                 HistoryPath(ADD_NEW_PATH);
  684.                 files.visible = files.h / files.line_h;
  685.                 if (files.count < files.visible) files.visible = files.count;
  686.                 if (sort_num==1) sorting_arrow_x = Form.width+60/2;
  687.                 if (sort_num==2) sorting_arrow_x = Form.width-115;
  688.                 if (sort_num==3) sorting_arrow_x = strlen(T_SIZE)*3-30+files.x+files.w;
  689.                 WriteText(sorting_arrow_x,45,0x80,system.color.work_graph,"\x19");
  690.                 if (redraw!=ONLY_SHOW) Sorting();
  691.                 list_full_redraw = true;
  692.                 if (redraw!=ONLY_OPEN)&&(!_not_draw) List_ReDraw();
  693.                 DrawSystemDiscs();
  694.         }
  695.         if (files.count==-1) && (redraw!=ONLY_OPEN)
  696.         {
  697.                 files.KeyHome();
  698.                 if(!_not_draw) { list_full_redraw=true; List_ReDraw(); }
  699.         }
  700. }
  701.  
  702.  
  703. inline Sorting()
  704. {
  705.         dword k=0, l=1;
  706.         dword file_off;
  707.         int i;
  708.         if (!strncmp(#path,"/",2)) //do not sort
  709.         {
  710.                 for(k=1;k<files.count;k++;) file_mas[k]=k;
  711.                 return;
  712.         }
  713.         for (j=files.count-1, file_off=files.count-1*304+buf+32; j>=0; j--, file_off-=304;)  //files | folders
  714.         {
  715.                 if (!real_files_names_case) strttl(file_off+40);
  716.                 if (TestBit(ESDWORD[file_off],4)) //directory?
  717.                 {
  718.                         file_mas[k]=j;
  719.                         k++;
  720.                 }
  721.                 else
  722.                 {
  723.                         file_mas[files.count-l]=j;
  724.                         l++;
  725.                 }
  726.         }
  727.         //sorting: files first, then folders
  728.         Sort_by_Name(0,k-1);
  729.         if (sort_num==1) Sort_by_Name(k,files.count-1);
  730.         if (sort_num==2) Sort_by_Type(k,files.count-1);
  731.         if (sort_num==3) Sort_by_Size(k,files.count-1);
  732.         //make ".." first item in list
  733.         if (k>0) && (!strncmp(file_mas[0]*304+buf+72,"..",3))
  734.                 for(k--; k>0; k--;) if (!strncmp(file_mas[k]*304+buf+72,"..",3)) {file_mas[k]><file_mas[0]; break;}
  735. }
  736.  
  737.  
  738. void Del_Form()
  739. {
  740.         dword selected_offset2;
  741.         int cont = 0;
  742.         byte f_count[128];
  743.         int dform_x = files.w - 220 / 2 + files.x;
  744.         if (!strncmp(#file_name,".",2)) || (!strncmp(#file_name,"..",2)) return;
  745.         if (del_active==2)
  746.         {
  747.                 if (itdir) ShowMessage(WAIT_DELETING_FOLDER, 0);
  748.         }
  749.         else
  750.         {
  751.                 if (!files.count) return;
  752.                 DrawPopup(dform_x,160,220,85,1,system.color.work,system.color.work_graph);
  753.                 WriteText(-strlen(T_DELETE_FILE)*3+110+dform_x,175,0x80,system.color.work_text,T_DELETE_FILE);
  754.                 for (i=0; i<files.count; i++)
  755.                 {
  756.                         selected_offset2 = file_mas[i]*304 + buf+32 + 7;
  757.                         if (ESBYTE[selected_offset2]) cont++;
  758.                 }
  759.                 if (cont)
  760.                 {
  761.                         sprintf(#f_count,"%s%d%s",DEL_MORE_FILES_1,cont,DEL_MORE_FILES_2);
  762.                         WriteText(-strlen(#f_count)*3+110+dform_x,190,0x80,system.color.work_text,#f_count);
  763.                 }
  764.                 else
  765.                 {
  766.                         if (strlen(#file_name)<28)
  767.                         {
  768.                                 WriteText(strlen(#file_name)*3+110+dform_x+2,190,0x80,system.color.work_text,"?");
  769.                                 WriteText(-strlen(#file_name)*3+110+dform_x,190,0x80,system.color.work_text,#file_name);
  770.                         }
  771.                         else
  772.                         {
  773.                                 WriteText(164+dform_x,190,0x80,0,"...?");
  774.                                 ESI = 24;
  775.                                 WriteText(dform_x+20,190,0,0,#file_name);
  776.                         }
  777.                 }
  778.                 DrawFlatButton(dform_x+27,208,70,20,301,0xFFB6B5,T_YES);
  779.                 DrawFlatButton(dform_x+120,208,70,20,302,0xC6DFC6,T_NO);               
  780.                 del_active=1;
  781.         }
  782. }
  783.  
  784. int del_error;
  785. int Del_File2(dword way)
  786. {    
  787.         dword dirbuf, fcount, i, filename;
  788.         int error;
  789.         char del_from[4096];
  790.         if (isdir(way))
  791.         {
  792.                 if (error = GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL)) del_error = error;
  793.                 for (i=0; i<fcount; i++)
  794.                 {
  795.                         if (CheckEvent()==evReDraw) draw_window();
  796.                         filename = i*304+dirbuf+72;
  797.                         sprintf(#del_from,"%s/%s",way,filename);
  798.                         if ( TestBit(ESDWORD[filename-40], 4) )
  799.                         {
  800.                                 Del_File2(#del_from);
  801.                         }
  802.                         else
  803.                         {
  804.                                 if (error = DeleteFile(#del_from)) del_error = error;
  805.                         }
  806.                 }
  807.         }
  808.         if (error = DeleteFile(way)) del_error = error;
  809. }
  810.  
  811.  
  812. void Del_File(byte dodel)
  813. {  
  814.         byte del_from[4096];
  815.         dword selected_offset2;
  816.         int tst, count, i;
  817.        
  818.         if (dodel==true)
  819.         {
  820.                 del_active=2;
  821.                 if (itdir) ShowMessage(WAIT_DELETING_FOLDER, 0);
  822.                 del_error = 0;
  823.                
  824.                 if (selected_count)
  825.                 {
  826.                    for (i=0; i<files.count; i++)
  827.            {
  828.                 selected_offset2 = file_mas[i]*304 + buf+32 + 7;
  829.                 if (ESBYTE[selected_offset2]) {
  830.                                         sprintf(#del_from,"%s%s",#path,file_mas[i]*304+buf+72);
  831.                     Del_File2(#del_from);
  832.                 }
  833.             }
  834.                 }
  835.                 else
  836.                 {
  837.                    Del_File2(#file_path);                      
  838.                 }
  839.                 if (del_error) Write_Error(del_error);
  840.         }
  841.         del_active=0;
  842.         DeleteButton(301);
  843.         DeleteButton(302);
  844.         Open_Dir(#path,WITH_REDRAW);
  845. }
  846.  
  847.  
  848. void SelectFileByName(dword that_file)
  849. {
  850.         int ind;
  851.         files.KeyHome();
  852.         Open_Dir(#path,ONLY_OPEN);
  853.         if (!real_files_names_case) strttl(that_file);
  854.         for (ind=files.count-1; ind>=0; ind--;) { if (!strcmp(file_mas[ind]*304+buf+72,that_file)) break; }
  855.         files.current = ind - 1;
  856.         files.KeyDown();
  857.         List_ReDraw();
  858. }
  859.  
  860.  
  861. void Dir_Up()
  862. {
  863.         char cur_folder[4096];
  864.         i=strlen(#path)-1;
  865.         if (i==0) return;
  866.         path[i]=0x00;
  867.         i = strrchr(#path, '/');
  868.         strcpy(#cur_folder, #path+i);
  869.         path[i]=0x00;
  870.         SelectFileByName(#cur_folder);
  871. }
  872.  
  873. void Open(byte rez)
  874. {
  875.         byte temp[4096];
  876.         selected_count = 0;
  877.         if (rez)
  878.         {
  879.                 if (!strncmp(#file_name,"..",3)) return;
  880.                 strcpy(#temp, #file_path);
  881.                 if (path[strlen(#temp)-1]!='/') chrcat(#temp, '/'); //need "/" in the end
  882.                 RunProgram("/sys/File Managers/Eolite", #temp);
  883.                 return;
  884.         }
  885.         if (!files.count) return;
  886.         if (!itdir)
  887.         {
  888.                 if (strrchr(#file_name, '.')==0) RunProgram(#file_path, ""); else RunProgram("/sys/@open", #file_path);
  889.         }
  890.         else
  891.         {
  892.                 if (!strncmp(#file_name,"..",3)) { Dir_Up(); return; }
  893.                 strcpy(#path, #file_path);
  894.                 if (path[strlen(#path)-1]!='/') chrcat(#path, '/'); //need "/" in the end
  895.                 files.first=files.current=0;
  896.                 Open_Dir(#path,WITH_REDRAW);
  897.         }
  898. }
  899.  
  900.  
  901. inline fastcall void GoBack()
  902. {
  903.         char cur_folder[4096];
  904.         strcpy(#cur_folder, GetCurrentFolder());
  905.         if (HistoryPath(GO_BACK)) SelectFileByName(#cur_folder);
  906. }
  907.  
  908. void ShowOpenWithDialog()
  909. {
  910.         byte param[4097];
  911.         sprintf(#param,"~%s",#file_path);
  912.         RunProgram("/sys/@open", #param);
  913. }
  914.  
  915. void NewElement(byte newf)
  916. {
  917.         BDVK element_info;
  918.         byte del_rezult, copy_rezult, info_result;
  919.         if (newf)
  920.         {
  921.                 sprintf(#temp,"%s%s",#path,new_file_ed.text);
  922.                 info_result = GetFileInfo(#temp, #element_info);
  923.                 switch(new_element_active)
  924.                 {
  925.                         case CREATE_FILE:
  926.                                 if (info_result==5)
  927.                                 {
  928.                                         WriteFile(0, 0, #temp);
  929.                                         if (EAX)
  930.                                         {
  931.                                                 Write_Error(EAX);
  932.                                                 ShowMessage(NOT_CREATE_FILE, 150);
  933.                                         }
  934.                                 }
  935.                                 else
  936.                                 {
  937.                                         notify(FS_ITEM_ALREADY_EXISTS);
  938.                                 }
  939.                                 break;
  940.                         case CREATE_FOLDER:
  941.                                 if (info_result==5)
  942.                                 {
  943.                                         CreateDir(#temp);
  944.                                         if (EAX)
  945.                                         {
  946.                                                 Write_Error(EAX);
  947.                                                 ShowMessage(NOT_CREATE_FOLDER, 150);
  948.                                         }
  949.                                 }
  950.                                 else
  951.                                 {
  952.                                         notify(FS_ITEM_ALREADY_EXISTS);
  953.                                 }
  954.                                 break;
  955.                         case RENAME_ITEM:
  956.                                 if (info_result==5)
  957.                                 {
  958.                                         if (itdir)
  959.                                         {
  960.                                                 if (del_rezult = DeleteFile(#file_path))
  961.                                                 {
  962.                                                         Write_Error(del_rezult);
  963.                                                         ShowMessage(T_DEL_ERROR_1, 150);
  964.                                                         return;
  965.                                                 }
  966.                                                 if (CreateDir(#temp)) CreateDir(#file_path);
  967.                                                 Open_Dir(#path,WITH_REDRAW);
  968.                                                 SelectFileByName(new_file_ed.text);
  969.                                         }
  970.                                         else
  971.                                         {
  972.                                                 if (copy_rezult = CopyFile(#file_path,#temp))
  973.                                                 {
  974.                                                         Write_Error(copy_rezult);
  975.                                                 }
  976.                                                 else
  977.                                                 {
  978.                                                         Del_File(true);
  979.                                                         SelectFileByName(new_file_ed.text);
  980.                                                 }
  981.                                         }
  982.                                 }
  983.                                 else
  984.                                 {
  985.                                         notify(FS_ITEM_ALREADY_EXISTS);
  986.                                 }
  987.                 }
  988.                 new_element_active = 0;
  989.                 Open_Dir(#path,WITH_REDRAW);
  990.                 SelectFileByName(new_file_ed.text);
  991.         }
  992.         new_element_active = 0;
  993.         Open_Dir(#path,WITH_REDRAW);
  994. }
  995.  
  996. void NewElement_Form(byte crt, dword strng)
  997. {
  998.         int dform_x=files.w-220/2+files.x;
  999.         if (!new_element_active)
  1000.         {
  1001.                 new_element_active = crt;
  1002.                 strcpy(#new_element_name, strng);
  1003.                 new_file_ed.size = new_file_ed.pos = strlen(strng);
  1004.         }
  1005.         DrawPopup(dform_x,160,220,85,1,system.color.work,system.color.work_graph);
  1006.         new_file_ed.left = dform_x+24;
  1007.         edit_box_draw  stdcall (#new_file_ed);
  1008.         DrawRectangle(new_file_ed.left-1, new_file_ed.top-1, new_file_ed.width+2, 16, 0xFFFfff);
  1009.         DrawRectangle(new_file_ed.left-2, new_file_ed.top-2, new_file_ed.width+4, 18, system.color.work_graph);
  1010.         if (new_element_active==3) DrawFlatButton(dform_x+22,208,85,22,301,0xFFB6B5,T_RENAME);
  1011.         else DrawFlatButton(dform_x+27,208,70,22,301,0xFFB6B5,T_CREATE);
  1012.         DrawFlatButton(dform_x+120,208,70,22,302,0xC6DFC6,T_CANCEL);
  1013. }
  1014.  
  1015. void FnProcess(byte N)
  1016. {
  1017.         switch(N)
  1018.         {
  1019.                 case 1:
  1020.                         if (!active_about)
  1021.                         {
  1022.                                 about_stak = malloc(4096);
  1023.                                 about_window = CreateThread(#about_dialog,about_stak+4092);
  1024.                                 break;
  1025.                         }
  1026.                         else
  1027.                         {
  1028.                                 ActivateWindow(GetProcessSlot(about_window));
  1029.                         }
  1030.                         break;
  1031.                 case 2:
  1032.                         if (!files.count) break;
  1033.                         NewElement_Form(RENAME_ITEM, #file_name);
  1034.                         break;
  1035.                 case 3:
  1036.                         if (!itdir) RunProgram("/sys/tinypad", #file_path);
  1037.                         break;
  1038.                 case 4:
  1039.                         if (!itdir) RunProgram("/sys/develop/heed", #file_path);
  1040.                         break;
  1041.                 case 5: //refresh cur dir & devs
  1042.                         Tip(56, T_DEVICES, 55, "-");
  1043.                         Open_Dir(#path,WITH_REDRAW);
  1044.                         pause(10);
  1045.                         LoadIniSettings();
  1046.                         GetSystemDiscs();
  1047.                         Open_Dir(#path,WITH_REDRAW);
  1048.                         DrawLeftPanel();
  1049.                         break;
  1050.                 case 6:
  1051.                         NewElement_Form(CREATE_FOLDER, T_NEW_FOLDER);
  1052.                         break;
  1053.                 case 7:
  1054.                         NewElement_Form(CREATE_FILE, T_NEW_FILE);
  1055.                         break;
  1056.                 case 8:
  1057.                         properties_stak = malloc(8096);
  1058.                         CreateThread(#properties_dialog, properties_stak+8092);
  1059.                         break;
  1060.                 case 10: //F10
  1061.                         if (!active_settings)
  1062.                         {
  1063.                                 settings_stak = malloc(4096);
  1064.                                 settings_window = CreateThread(#settings_dialog, settings_stak+4092);
  1065.                                 break;
  1066.                         }
  1067.                         else
  1068.                         {
  1069.                                 ActivateWindow(GetProcessSlot(settings_window));
  1070.                         }
  1071.                         break;
  1072.         }
  1073. }
  1074.  
  1075. //need to remove these functiones, they are a very old shit :)
  1076. dword onTop(dword down,up) {EAX=Form.height-GetSkinHeight()-down-up;}
  1077.  
  1078.  
  1079. stop:
  1080.