Subversion Repositories Kolibri OS

Rev

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