Subversion Repositories Kolibri OS

Rev

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

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