Subversion Repositories Kolibri OS

Rev

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