Subversion Repositories Kolibri OS

Rev

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