Subversion Repositories Kolibri OS

Rev

Rev 8012 | Rev 8240 | 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-2020
  2. //GNU GPL license.
  3.  
  4. // 70.5 - get volume info and label
  5.  
  6. #define TITLE "Eolite File Manager 4.46d"
  7. #define ABOUT_TITLE "EOLITE 4.46d"
  8.  
  9. #ifndef AUTOBUILD
  10. #include "lang.h--"
  11. #endif
  12.  
  13. //libraries
  14. #define MEMSIZE 1024 * 720
  15. #include "../lib/clipboard.h"
  16. #include "../lib/strings.h"
  17. #include "../lib/mem.h"
  18. #include "../lib/fs.h"
  19. #include "../lib/gui.h"
  20. #include "../lib/list_box.h"
  21. #include "../lib/random.h"
  22. #include "../lib/kfont.h"
  23. #include "../lib/collection.h"
  24. #include "../lib/copyf.h"
  25.  
  26. #include "../lib/obj/libini.h"
  27. #include "../lib/obj/box_lib.h"
  28. #include "../lib/obj/libimg.h"
  29.  
  30. #include "../lib/patterns/history.h"
  31.  
  32. #include "imgs/images.h"
  33.  
  34. //Button IDs
  35. enum {
  36.         PATH_BTN = 10,
  37.         POPUP_BTN1 = 201,
  38.         POPUP_BTN2 = 202,
  39.         BREADCRUMB_ID = 300
  40. };
  41.  
  42. //NewElement options
  43. enum {
  44.         CREATE_FILE=1,
  45.         CREATE_FOLDER,
  46.         RENAME_ITEM
  47. };
  48.  
  49. //OpenDir options
  50. enum {
  51.         ONLY_SHOW,
  52.         WITH_REDRAW,
  53.         ONLY_OPEN
  54. };
  55.  
  56. _history history;
  57.  
  58. struct Eolite_colors
  59. {
  60.         bool  def;
  61.         dword lpanel;
  62.         dword list_vert_line; //vertical line between columns in list
  63.         dword selec;
  64.         dword selec_active;
  65.         dword selec_inactive;
  66.         dword selec_text;
  67.         dword list_bg;
  68.         dword list_gb_text;
  69.         dword list_text_hidden;
  70.         dword work_gradient[24];
  71.         dword slider_bg_big;
  72.         dword slider_bg_left;
  73.         dword odd_line;
  74. } col;
  75.  
  76. int toolbar_buttons_x[7]={9,46,85,134,167,203};
  77.  
  78. bool active_about = false;
  79. bool active_settings = false;
  80. bool _not_draw = false;
  81. bool exif_load = false;
  82. bool dir_at_fat16 = NULL;
  83.  
  84. word about_thread_id;
  85. word settings_window;
  86.  
  87. byte del_active=0;
  88. byte new_element_active=0;
  89.  
  90. llist files, files_active, files_inactive;
  91.  
  92. byte list_full_redraw;
  93.  
  94. dword buf;
  95. collection_int items=0;
  96. int selected_count;
  97. int count_dir;
  98.  
  99. byte path[4096];
  100. byte file_path[4096];
  101. byte file_name[256];
  102. byte new_element_name[256];
  103. byte temp[4096];
  104. bool itdir;
  105.  
  106. char active_path[4096], inactive_path[4096];
  107.  
  108. dword eolite_ini_path[4096];
  109. _ini ini;
  110.  
  111. char scroll_used=false;
  112.  
  113. dword about_stak=0,properties_stak=0,settings_stak=0,delete_stak=0;
  114.  
  115. proc_info Form;
  116. int sc_slider_h;
  117. int action_buf;
  118. int rand_n;
  119.  
  120. char sort_type=2;
  121. bool sort_desc=false;
  122. int active_panel=1;
  123.  
  124. libimg_image icons16_default;
  125. libimg_image icons16_selected;
  126.  
  127. libimg_image icons32_default;
  128. libimg_image icons32_selected;
  129.  
  130. #define STATUS_BAR_H 16;
  131. int status_bar_h = 0;
  132.  
  133. int icon_size = 16;
  134.  
  135. edit_box new_file_ed = {200,213,180,0xFFFFFF,0x94AECE,0xFFFFFF,0xFFFFFF,0x10000000,
  136.         248,#new_element_name,0,100000000000010b,6,0};
  137. PathShow_data FileShow = {0, 56,215, 8, 100, 1, 0, 0x0, 0xFFFfff, #file_name, #temp, 0};
  138. byte cmd_free=0;
  139. #include "include\translations.h"
  140.  
  141. #include "include\gui.h"
  142. #include "include\settings.h"
  143. #include "include\progress_dialog.h"
  144. #include "include\copy_and_delete.h"
  145. #include "include\sorting.h"
  146. #include "include\icons.h"
  147. #include "include\left_panel.h"
  148. #include "include\menu.h"
  149. #include "include\about.h"
  150. #include "include\properties.h"
  151. #include "include\breadcrumbs.h"
  152.  
  153. void load_libraries()
  154. {
  155.         load_dll(boxlib, #box_lib_init,0);
  156.         load_dll(libini, #lib_init,1);
  157.         load_dll(libio,  #libio_init,1);
  158.         load_dll(libimg, #libimg_init,1);
  159. }
  160.  
  161. void handle_param()
  162. {
  163.         //-p <path> : just show file/folder properties dialog
  164.         //-d <path> : delete file/folder
  165.         //-v : paste files/folder from clipboard
  166.         if (param) && (param[0]=='-') switch (param[1])
  167.         {
  168.                 case 'p':
  169.                         strcpy(#file_path, #param + 3);
  170.                         itdir = dir_exists(#file_path);
  171.                         strcpy(#file_name, #param + strrchr(#param, '/'));
  172.                         param[strrchr(#param, '/')-1] = '\0';
  173.                         strcpy(#path, #param + 3);
  174.                         properties_dialog();
  175.                         ExitProcess();
  176.                         return;
  177.                 case 'd':
  178.                         strcpy(#file_path, #param + 3);
  179.                         itdir = dir_exists(#file_path);
  180.                         DisplayOperationForm(DELETE_FLAG);
  181.                         DeleteSingleElement();
  182.                         ExitProcess();
  183.                         return;
  184.                 case 'v':
  185.                         cut_active = param[2] - '0';
  186.                         strcpy(#path, #param + 4);
  187.                         PasteThread();
  188.                         ExitProcess();
  189.                         return;
  190.         }
  191. }
  192.  
  193. void main()
  194. {
  195.         dword id;
  196.         int old_cur_y;
  197.  
  198.         rand_n = random(80);
  199.  
  200.         load_libraries();
  201.        
  202.         SetAppColors();
  203.         LoadIniSettings();
  204.         SystemDiscs.Get();
  205.  
  206.         handle_param();
  207.  
  208.         ESBYTE[0] = NULL;
  209.  
  210.         if (param)
  211.         {
  212.                 if (strlen(#param)>1) && (param[strlen(#param)-1]=='/') param[strlen(#param)-1]=NULL; //no "/" at the end
  213.  
  214.                 if (dir_exists(#param)) {
  215.                         strcpy(#path, #param);
  216.                 } else {
  217.                         file_size stdcall (#param);
  218.                         if (EAX==-1) notify(T_NOTIFY_APP_PARAM_WRONG);
  219.                         else {
  220.                                 param[strrchr(#param, '/')-1] = '\0';
  221.                                 strcpy(#path, #param);
  222.                                 SelectFileByName(#param+strlen(#param)+1);
  223.                         }
  224.                 }
  225.         }
  226.        
  227.         Open_Dir(#path,ONLY_OPEN);
  228.         strcpy(#inactive_path, #path);
  229.         llist_copy(#files_inactive, #files);
  230.         SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
  231.         loop() switch(@WaitEventTimeout(80))
  232.         {
  233.                 case evMouse:
  234.                         if (del_active) || (Form.status_window>2) break;
  235.                         if (new_element_active)
  236.                         {
  237.                                 edit_box_mouse stdcall(#new_file_ed);
  238.                                 break;
  239.                         }                              
  240.                        
  241.                         mouse.get();
  242.  
  243.                         ProceedMouseGestures();
  244.  
  245.                         if (mouse.vert)
  246.                         {
  247.                                 if (files.MouseScroll(mouse.vert)) List_ReDraw();
  248.                                 break;
  249.                         }
  250.  
  251.                         if (files.MouseOver(mouse.x, mouse.y))
  252.                         {
  253.                                 //select file
  254.                                 if (mouse.key&MOUSE_LEFT) && (mouse.up)
  255.                                 {
  256.                                         GetKeyModifier();
  257.                                         old_cur_y = files.cur_y;
  258.                                         if (files.ProcessMouse(mouse.x, mouse.y)) && (!key_modifier) {
  259.                                                 List_ReDraw();
  260.                                                 break;
  261.                                         }
  262.                                         if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
  263.                                                 EventChooseFilesRange(old_cur_y, files.cur_y);
  264.                                         } else if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) {
  265.                                                 EventChooseFile(files.cur_y);
  266.                                                 DrawStatusBar();
  267.                                                 List_ReDraw();
  268.                                         } else {
  269.                                                 if (mouse.y - files.y / files.item_h + files.first == files.cur_y) Open(0);
  270.                                         }
  271.                                 }
  272.                                 //file menu
  273.                                 if (mouse.key&MOUSE_RIGHT) && (mouse.up)
  274.                                 {
  275.                                         if (files.ProcessMouse(mouse.x, mouse.y)) List_ReDraw();
  276.                                         if (getElementSelectedFlag(files.cur_y) == false) selected_count = 0; //on redraw selection would be flashed, see [L001]
  277.                                         EventShowListMenu();
  278.                                 }
  279.                                 break;
  280.                         }
  281.  
  282.                         if (mouse.x>=files.x+files.w) && (mouse.x<=files.x+files.w+16) && (mouse.y>files.y-17) && (mouse.y<files.y)
  283.                         {
  284.                                 if (mouse.lkm) DrawRectangle3D(files.x+files.w+1,files.y-16,14,14,sc.work_dark,sc.work_light);
  285.                                 WHILE (mouse.lkm) && (files.first>0)
  286.                                 {
  287.                                         pause(8);
  288.                                         files.first--;
  289.                                         List_ReDraw();
  290.                                         mouse.get();
  291.                                 }
  292.                                 DrawRectangle3D(files.x+files.w+1,files.y-16,14,14,sc.work_light,sc.work_dark);
  293.                         }
  294.  
  295.                         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)
  296.                         {
  297.                                 if (mouse.lkm) DrawRectangle3D(files.x+files.w+1,files.y+files.h-15,14,14,sc.work_dark,sc.work_light);
  298.                                 while (mouse.lkm) && (files.first<files.count-files.visible)
  299.                                 {
  300.                                         pause(8);
  301.                                         files.first++;
  302.                                         List_ReDraw();
  303.                                         mouse.get();
  304.                                 }
  305.                                 DrawRectangle3D(files.x+files.w+1,files.y+files.h-15,14,14,sc.work_light,sc.work_dark);
  306.                         }
  307.  
  308.                         //Scrooll
  309.                         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();}
  310.                         if (scroll_used) && (mouse.up) { scroll_used=false; Scroll(); }
  311.                        
  312.                         if (scroll_used)
  313.                         {
  314.                                 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
  315.                                 id = files.first;
  316.                                 files.first = -sc_slider_h / 2 + mouse.y -files.y * files.count;
  317.                                 files.first /= files.h - 18;
  318.                                 if (files.visible+files.first>files.count) files.first=files.count-files.visible;
  319.                                 if (files.first<0) files.first=0;
  320.                                 if (id!=files.first) List_ReDraw();
  321.                                 break;
  322.                         }
  323.  
  324.                         if (two_panels.checked) && (mouse.y > files.y) && (mouse.down) {
  325.                                 if (mouse.x<Form.cwidth/2)
  326.                                 {
  327.                                         if (active_panel!=1)
  328.                                         {
  329.                                                 active_panel = 1;
  330.                                                 ChangeActivePanel();
  331.                                         }
  332.                                 }
  333.                                 else
  334.                                 {
  335.                                         if (active_panel!=2)
  336.                                         {
  337.                                                 active_panel = 2;
  338.                                                 ChangeActivePanel();
  339.                                         }
  340.                                 }
  341.                         }
  342.                         break;  
  343. //Button pressed-----------------------------------------------------------------------------
  344.                 case evButton:
  345.                         id = @GetButtonID();
  346.  
  347.                         if (new_element_active) || (del_active) {
  348.                                 if (POPUP_BTN1==id) && (del_active) EventDelete();
  349.                                 if (POPUP_BTN1==id) && (new_element_active) NewElement();
  350.                                 if (POPUP_BTN2==id) EventClosePopinForm();
  351.                                 break;                                 
  352.                         }
  353.  
  354.                         switch(id)
  355.                         {
  356.                                 case CLOSE_BTN:
  357.                                                 KillProcess(about_thread_id);
  358.                                                 SaveIniSettings();
  359.                                                 ExitProcess();
  360.                                 case PATH_BTN:
  361.                                                 notify(COPY_PATH_STR);
  362.                                                 Clipboard__CopyText(#path);
  363.                                                 break;
  364.                                 case 21: //Back
  365.                                                 EventHistoryGoBack();
  366.                                                 break;
  367.                                 case 22: //Forward
  368.                                                 EventHistoryGoForward();
  369.                                                 break;
  370.                                 case 23:
  371.                                                 Dir_Up();
  372.                                                 break;
  373.                                 case 24:
  374.                                                 EventCopy(CUT);
  375.                                                 break;
  376.                                 case 25:
  377.                                                 EventCopy(NOCUT);
  378.                                                 break;
  379.                                 case 26:
  380.                                                 EventPaste();
  381.                                                 break;
  382.                                 case 31...33:
  383.                                                 EventSort(id-30);
  384.                                                 break;
  385.                                 case 51:
  386.                                                 EventShowBurgerMenu();
  387.                                                 break;
  388.                                 case 52...60: //Actions
  389.                                                 FnProcess(id-50);
  390.                                                 break;
  391.                                 case 61: // Set path as default
  392.                                                 SetDefaultPath(#path);
  393.                                                 break;
  394.                                 case 100...120:
  395.                                         SystemDiscs.Click(id-100);
  396.                                         break;
  397.                                 case BREADCRUMB_ID...360:
  398.                                         ClickOnBreadCrumb(id-BREADCRUMB_ID);
  399.                                         break;
  400.                         }
  401.                         break;
  402.                        
  403. //Key pressed-----------------------------------------------------------------------------
  404.                 case evKey:
  405.                         GetKeys();
  406.  
  407.                         if (Form.status_window>2) break;
  408.  
  409.                         if (new_element_active) || (del_active)
  410.                         {
  411.                                 if (del_active)
  412.                                 {
  413.                                         if (key_scancode == SCAN_CODE_ENTER) EventDelete();
  414.                                         if (key_scancode == SCAN_CODE_ESC) EventClosePopinForm();
  415.                                 }
  416.                                 if (new_element_active)
  417.                                 {
  418.                                         if (key_scancode == SCAN_CODE_ENTER) NewElement();
  419.                                         if (key_scancode == SCAN_CODE_ESC) EventClosePopinForm();
  420.                                         EAX = key_editbox;
  421.                                         edit_box_key stdcall (#new_file_ed);
  422.                                 }
  423.                                 break;
  424.                         }
  425.  
  426.                         if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
  427.                                 old_cur_y = files.cur_y;
  428.                                 files.ProcessKey(key_scancode);
  429.                                 EventChooseFilesRange(old_cur_y, files.cur_y);
  430.                                 break;
  431.                         }
  432.  
  433.                         if (files.ProcessKey(key_scancode))
  434.                         {
  435.                                 List_ReDraw();
  436.                                 break;
  437.                         }
  438.  
  439.                         if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL)
  440.                         {
  441.                                 switch(key_scancode)
  442.                                 {
  443.                                         case SCAN_CODE_F1...SCAN_CODE_F3:
  444.                                                         EventSort(key_scancode - 58);
  445.                                                         break;
  446.                                         case SCAN_CODE_1...SCAN_CODE_10:
  447.                                                         key_scancode-=2;
  448.                                                         if (key_scancode >= SystemDiscs.list.count) break;
  449.                                                         if (!two_panels.checked)
  450.                                                         {
  451.                                                                 DrawRectangle(17,key_scancode*16+74,159,16, 0); //display click
  452.                                                                 pause(7);                                                                              
  453.                                                         }
  454.                                                         SystemDiscs.Click(key_scancode);
  455.                                                         break;
  456.                                         case SCAN_CODE_KEY_X:
  457.                                                         EventCopy(CUT);
  458.                                                         break;                                         
  459.                                         case SCAN_CODE_KEY_C:
  460.                                                         EventCopy(NOCUT);
  461.                                                         break;
  462.                                         case SCAN_CODE_KEY_G:
  463.                                                         EventOpenConsoleHere();
  464.                                                         break;
  465.                                         case SCAN_CODE_KEY_V:
  466.                                                         EventPaste();
  467.                                                         break;
  468.                                         case SCAN_CODE_KEY_D: //set image as bg
  469.                                                         strlcpy(#temp, "\\S__",4);
  470.                                                         strcat(#temp, #file_path);
  471.                                                         RunProgram("/sys/media/kiv", #temp);
  472.                                                         break;
  473.                                         case SCAN_CODE_KEY_N:
  474.                                                         EventOpenNewEolite();
  475.                                                         break;
  476.                                         case SCAN_CODE_KEY_M:
  477.                                                         Open_Dir(#inactive_path,WITH_REDRAW);
  478.                                                         break;
  479.                                         case SCAN_CODE_ENTER:
  480.                                                         if (!itdir) ShowOpenWithDialog();
  481.                                                         else Open(1);
  482.                                                         break;
  483.                                         case SCAN_CODE_KEY_A:
  484.                                                         EventChooseAllFiles(true);
  485.                                                         break;
  486.                                         case SCAN_CODE_KEY_U: //unselect all files
  487.                                                         EventChooseAllFiles(false);
  488.                                                         break;
  489.                                 }
  490.                                 break;
  491.                         }
  492.  
  493.                         switch (key_scancode)
  494.                         {
  495.                                         case SCAN_CODE_BS:
  496.                                                         //EventHistoryGoBack();
  497.                                                         Dir_Up();
  498.                                                         break;
  499.                                         case SCAN_CODE_ENTER:
  500.                                                         Open(0);
  501.                                                         break;
  502.                                         case SCAN_CODE_TAB:
  503.                                                         if (!two_panels.checked) break;
  504.                                                         if (active_panel==1) active_panel=2; else active_panel=1;
  505.                                                         ChangeActivePanel();
  506.                                                         DrawFilePanels();
  507.                                                         break;
  508.                                         case SCAN_CODE_MENU:
  509.                                                         mouse.x = files.x+15;
  510.                                                         mouse.y = files.cur_y - files.first * files.item_h + files.y + 5;
  511.                                                         EventShowListMenu();
  512.                                                         break;
  513.                                         case SCAN_CODE_DEL:
  514.                                                         Del_Form();
  515.                                                         break;
  516.                                         case SCAN_CODE_INS:
  517.                                                         EventChooseFile(files.cur_y);
  518.                                                         files.KeyDown();
  519.                                                         DrawStatusBar();
  520.                                                         List_ReDraw();
  521.                                                         break;
  522.                                         case SCAN_CODE_F1...SCAN_CODE_F10:
  523.                                                         FnProcess(key_scancode-58);
  524.                                                         break;
  525.                                         default:
  526.                                                         EventSelectFileByKeyPress();
  527.                         }                        
  528.                 break;
  529.                 case evIPC:
  530.                 case evReDraw:
  531.                         draw_window();
  532.                         if (CheckActiveProcess(Form.ID)) && (GetMenuClick()) break;
  533.                         if (action_buf==OPERATION_END)
  534.                         {
  535.                                 FnProcess(5);
  536.                                 action_buf=0;
  537.                         }
  538.                 break;
  539.                 default:
  540.                         if (Form.status_window>2) break;
  541.                         EventRefreshDisksAndFolders();
  542.         }
  543.        
  544.         if(cmd_free)
  545.         {
  546.                 if(cmd_free==2) about_stak=free(about_stak);
  547.                 else if(cmd_free==3) properties_stak=free(properties_stak);
  548.                 else if(cmd_free==4) settings_stak=free(settings_stak);
  549.                 else if(cmd_free==6) delete_stak=free(delete_stak);
  550.                 cmd_free = false;
  551.         }
  552. }
  553.  
  554. void draw_window()
  555. {
  556.         dword i;
  557.         if (show_status_bar.checked) status_bar_h = STATUS_BAR_H; else status_bar_h = 0;
  558.         DefineAndDrawWindow(Form.left+rand_n,Form.top+rand_n,Form.width,Form.height,0x73,NULL,TITLE,0);
  559.         GetProcessInfo(#Form, SelfInfo);
  560.         if (Form.status_window>2) return;
  561.         if (Form.height < 350) { MoveSize(OLD,OLD,OLD,350); return; }
  562.         if (!two_panels.checked) && (Form.width < 480) { MoveSize(OLD,OLD,480,OLD); return; }
  563.         if ( two_panels.checked) && (Form.width < 573) { MoveSize(OLD,OLD,573,OLD); return; }
  564.         GetProcessInfo(#Form, SelfInfo);
  565.         SetAppColors();
  566.         ESDWORD[#toolbar_pal] = sc.work;
  567.         ESDWORD[#toolbar_pal+4] = MixColors(0, sc.work, 35);
  568.         PutPaletteImage(#toolbar, 246, 34, 0, 0, 8, #toolbar_pal);
  569.         DrawBar(127, 8, 1, 25, sc.work_graph);
  570.         for (i=0; i<3; i++) DefineHiddenButton(toolbar_buttons_x[i]+2,7,31-5,29-5,21+i);
  571.         for (i=3; i<6; i++) DefineHiddenButton(toolbar_buttons_x[i],  5,31,  29,  21+i);
  572.         DrawBar(246,0, Form.cwidth - 246, 34, sc.work);
  573.         DrawDot(Form.cwidth-17,12);
  574.         DrawDot(Form.cwidth-17,12+6);
  575.         DrawDot(Form.cwidth-17,12+12);
  576.         DefineHiddenButton(Form.cwidth-24,7,20,25,51+BT_NOFRAME); //dots
  577.         //main rectangles
  578.         DrawRectangle(1,40,Form.cwidth-3,Form.cheight - 42-status_bar_h,sc.work_graph);
  579.         DrawRectangle(0,39,Form.cwidth-1,-show_status_bar.checked*status_bar_h + Form.cheight - 40,col.work_gradient[4]); //bg
  580.         for (i=0; i<6; i++) DrawBar(0, 34+i, Form.cwidth, 1, MixColors(sc.work_dark, sc.work, i*10));
  581.         for (i=0; i<6; i++) DrawBar(0, 5-i, Form.cwidth, 1, MixColors(sc.work_light, sc.work, i*10));
  582.         llist_copy(#files_active, #files);
  583.         strcpy(#active_path, #path);
  584.         DrawStatusBar();
  585.         if (!selected_count) Open_Dir(#path,ONLY_OPEN); //if there are no selected files -> refresh folder [L001]
  586.         DrawFilePanels();
  587. }
  588.  
  589. void DrawList()
  590. {
  591.         word sorting_arrow_x;
  592.         dword sorting_arrow_t = "\x19";
  593.         if (sort_desc) sorting_arrow_t = "\x18";
  594.         DrawFlatButtonSmall(files.x, files.y-17,     files.w - 141,16,31,T_FILE);
  595.         DrawFlatButtonSmall(files.x + files.w - 141, files.y-17,73,16,32,T_TYPE);
  596.         DrawFlatButtonSmall(files.x + files.w -  68, files.y-17,68,16,33,T_SIZE);
  597.         DrawFlatButtonSmall(files.x + files.w,       files.y-17,16,16, 0,"\x18");
  598.         DrawFlatButtonSmall(files.x + files.w,files.y+files.h-16,16,16,0,"\x19");
  599.         if (sort_type==1) sorting_arrow_x = files.w - 141 / 2 + files.x + 18;
  600.         if (sort_type==2) sorting_arrow_x = files.x + files.w - 90;
  601.         if (sort_type==3) sorting_arrow_x = strlen(T_SIZE)*3-30+files.x+files.w;
  602.         WriteText(sorting_arrow_x,files.y-12,0x80, sc.work_text, sorting_arrow_t);
  603.         DrawBar(files.x+files.w,files.y,1,files.h,sc.work_graph);
  604.         if (two_panels.checked) && (files.x<5) DrawBar(files.x+files.w+16,files.y,1,files.h,sc.work_graph);    
  605. }
  606.  
  607. void DrawStatusBar()
  608. {
  609.         char status_bar_str[80];
  610.         int go_up_folder_exists=0;
  611.         if (!show_status_bar.checked) return;
  612.         if (files.count>0) && (streq(items.get(0)*304+buf+72,"..")) go_up_folder_exists=1;
  613.         DrawBar(0, Form.cheight - status_bar_h, Form.cwidth,  status_bar_h, sc.work);
  614.         sprintf(#status_bar_str, T_STATUS_EVEMENTS, count_dir-go_up_folder_exists, files.count-count_dir);
  615.         WriteText(6,Form.cheight - 13,0x80,sc.work_text,#status_bar_str);
  616.         if (selected_count) {
  617.                 sprintf(#status_bar_str, T_STATUS_SELECTED, selected_count);
  618.                 WriteText(Form.cwidth - calc(strlen(#status_bar_str)*6)-6,Form.cheight - 13,
  619.                         0x80,sc.work_text,#status_bar_str);
  620.         }
  621. }
  622.  
  623. void DrawFilePanels()
  624. {
  625.         int files_y;
  626.         if (!two_panels.checked)
  627.         {
  628.                 DrawDeviceAndActionsLeftPanel();
  629.                 files.SetSizes(192, 57, Form.cwidth - 210, Form.cheight - 59 - status_bar_h, files.item_h);
  630.                 DrawList();
  631.                 Open_Dir(#path,ONLY_SHOW);
  632.         }
  633.         else
  634.         {
  635.                 SystemDiscs.Get();
  636.                 llist_copy(#files, #files_inactive);
  637.                 strcpy(#path, #inactive_path);
  638.                 col.selec = col.selec_inactive;
  639.                 SystemDiscs.Draw();
  640.                 files_y = files.y;
  641.  
  642.                 if (active_panel==1)
  643.                 {
  644.                         llist_copy(#files, #files_inactive);
  645.                         strcpy(#path, #inactive_path);
  646.                         col.selec = col.selec_inactive; //this is a bad code: need to use some var to set inactive panel for DrawList();
  647.                         files.SetSizes(Form.cwidth/2, files_y, Form.cwidth/2 -17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
  648.                         DrawList();
  649.                         Open_Dir(#path,WITH_REDRAW);
  650.                         llist_copy(#files, #files_active);
  651.                         strcpy(#path, #active_path);
  652.                         col.selec = col.selec_active;
  653.                         files.SetSizes(2, files_y, Form.cwidth/2-2-17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
  654.                         DrawList();
  655.                         Open_Dir(#path,WITH_REDRAW);
  656.                 }
  657.                 if (active_panel==2)
  658.                 {
  659.                         files.SetSizes(2, files_y, Form.cwidth/2-2-17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
  660.                         DrawList();
  661.                         Open_Dir(#path,WITH_REDRAW);
  662.                         llist_copy(#files, #files_active);
  663.                         strcpy(#path, #active_path);
  664.                         col.selec = col.selec_active;
  665.                         files.SetSizes(Form.cwidth/2, files_y, Form.cwidth/2 -17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
  666.                         DrawList();
  667.                         Open_Dir(#path,WITH_REDRAW);
  668.                 }
  669.         }
  670. }
  671.  
  672.  
  673. void List_ReDraw()
  674. {
  675.         int all_lines_h;
  676.         dword j;
  677.         static int old_cur_y, old_first;
  678.  
  679.         files.CheckDoesValuesOkey(); //prevent some shit
  680.  
  681.         if (list_full_redraw) || (old_first != files.first)
  682.         {
  683.                 old_cur_y = files.cur_y;
  684.                 old_first = files.first;
  685.                 list_full_redraw = false;
  686.                 goto _ALL_LIST_REDRAW;
  687.         }
  688.         if (old_cur_y != files.cur_y)
  689.         {
  690.                 if (old_cur_y-files.first<files.visible) Line_ReDraw(col.list_bg, old_cur_y-files.first);
  691.                 Line_ReDraw(col.selec, files.cur_y-files.first);
  692.                 old_cur_y = files.cur_y;
  693.                 return;
  694.         }
  695.  
  696.         _ALL_LIST_REDRAW:
  697.  
  698.         for (j=0; j<files.visible; j++) {
  699.                 if (files.cur_y-files.first!=j) Line_ReDraw(col.list_bg, j);
  700.                 else Line_ReDraw(col.selec, files.cur_y-files.first);          
  701.         }
  702.         //in the bottom
  703.         all_lines_h = j * files.item_h;
  704.         DrawBar(files.x,all_lines_h + files.y,files.w,files.h - all_lines_h, col.list_bg);
  705.         DrawBar(files.x+files.w-141,all_lines_h + files.y,1,files.h - all_lines_h,col.list_vert_line);
  706.         DrawBar(files.x+files.w-68,all_lines_h + files.y,1,files.h - all_lines_h,col.list_vert_line);
  707.         Scroll();
  708.  
  709.         if (del_active) Del_Form();
  710.         if (new_element_active) && (col.selec != 0xCCCccc) NewElement_Form(new_element_active, #new_element_name);
  711. }
  712.  
  713. bool file_name_is_8_3(dword name)
  714. {
  715.         int name_len = strlen(name);
  716.         int dot_pos = strrchr(name, '.');
  717.         if (name_len<=12)
  718.         {
  719.                 if (dot_pos) {
  720.                         if (name_len - dot_pos > 3) return false;
  721.                 }
  722.                 else {
  723.                         if (name_len>8) return false;
  724.                 }
  725.                 return true;
  726.         }
  727.         return false;
  728. }
  729.  
  730. void Line_ReDraw(dword bgcol, filenum){
  731.         dword text_col=col.list_gb_text,
  732.                   ext1, attr,
  733.                   file_offet,
  734.                   file_name_off,
  735.                   file_size=0,
  736.                   y=filenum*files.item_h+files.y,
  737.                   icon_y = files.item_h-icon_size/2+1+y;
  738.                   BDVK file;
  739.                   char full_path[4096];
  740.         char label_file_name[4096];
  741.         if (filenum==-1) return;
  742.         DrawBar(files.x,y,4,files.item_h,bgcol);
  743.         DrawBar(files.x+4,y,icon_size,icon_y-y,bgcol);
  744.         if (files.item_h>icon_size) DrawBar(files.x+4,icon_y+icon_size-1,icon_size,y+files.item_h-icon_y-icon_size+1,bgcol);
  745.         if (colored_lines.checked) && (bgcol!=col.selec) && (filenum%2) bgcol=col.odd_line;
  746.         DrawBar(files.x+icon_size+4,y,files.w-icon_size-4,files.item_h,bgcol);
  747.  
  748.         file_offet = items.get(filenum+files.first)*304 + buf+32;
  749.         attr = ESDWORD[file_offet];
  750.         file.selected = ESBYTE[file_offet+7];
  751.         file.sizelo   = ESDWORD[file_offet+32];
  752.         file.sizehi   = ESDWORD[file_offet+36];
  753.         file_name_off = file_offet+40;
  754.         sprintf(#full_path,"%s/%s",#path,file_name_off);
  755.  
  756.         if (! TestBit(attr, 4) ) //file or folder?
  757.         {      
  758.                 ext1 = strrchr(file_name_off,'.') + file_name_off;
  759.                 if (ext1==file_name_off) ext1 = NULL; //if no extension then show nothing
  760.                 file_size = ConvertSize64(file.sizelo, file.sizehi);
  761.                 if (ext1) && (strlen(ext1)<9) WriteTextCenter(files.x+files.w-140, files.text_y+y+1, 72, col.list_gb_text, ext1);
  762.         }
  763.         else
  764.         {
  765.                 if (!strcmp(file_name_off,"..")) ext1="<up>"; else {
  766.                         ext1="<DIR>";
  767.                         WriteTextCenter(files.x+files.w-140, files.text_y+y+1, 72, col.list_gb_text, ext1);
  768.                 }
  769.                 if (chrnum(#path, '/')==1) file_size = GetDeviceSizeLabel(#full_path);
  770.         }
  771.         if (file_size) WriteText(7-strlen(file_size)*6+files.x+files.w-58,
  772.                         files.text_y+y+1, files.font_type, col.list_gb_text, file_size);
  773.         DrawIconByExtension(#full_path, ext1, files.x+4, icon_y, bgcol);
  774.  
  775.         if (TestBit(attr, 1)) || (TestBit(attr, 2)) text_col=col.list_text_hidden; //system or hiden?
  776.         if (bgcol==col.selec)
  777.         {
  778.                 file_name_is_8_3(file_name_off);
  779.                 itdir = TestBit(attr, 4);
  780.                 strcpy(#file_name, file_name_off);
  781.                 if (!strcmp(#path,"/")) sprintf(#file_path,"%s%s",#path,file_name_off);
  782.                         else sprintf(#file_path,"%s/%s",#path,file_name_off);
  783.                 if (text_col==col.list_text_hidden) {
  784.                         text_col=MixColors(col.selec_text, col.list_text_hidden, 65);
  785.                 } else text_col=col.selec_text;
  786.         }
  787.         if (file.selected) text_col=0xFF0000;
  788.         if (kfont.size.pt==9) || (!kfont.font)
  789.         {
  790.                 if (Form.width>=480)
  791.                 {
  792.                         FileShow.start_x = files.x + 23;
  793.                         FileShow.font_color = text_col;
  794.                         FileShow.area_size_x = files.w - 164;
  795.                         FileShow.text_pointer = file_name_off;
  796.                         FileShow.start_y = files.text_y + y - 3;
  797.                         PathShow_prepare stdcall(#FileShow);
  798.                         PathShow_draw stdcall(#FileShow);
  799.                 }              
  800.         }
  801.         else
  802.         {
  803.                 strcpy(#label_file_name, file_name_off);
  804.                 if (kfont.getsize(kfont.size.pt, #label_file_name) + 141 + 26 > files.w)
  805.                 {
  806.                         while (kfont.getsize(kfont.size.pt, #label_file_name) + 141 + 26 > files.w) {
  807.                                 ESBYTE[#label_file_name+strlen(#label_file_name)-1] = NULL;
  808.                         }
  809.                         strcpy(#label_file_name+strlen(#label_file_name)-2, "...");                    
  810.                 }
  811.                 kfont.WriteIntoWindow(files.x + icon_size+7, files.item_h - kfont.height / 2 + y,
  812.                         bgcol, text_col, kfont.size.pt, #label_file_name);
  813.         }
  814.         DrawBar(files.x+files.w-141,y,1,files.item_h,col.list_vert_line); //gray line 1
  815.         DrawBar(files.x+files.w-68,y,1,files.item_h,col.list_vert_line); //gray line 2
  816. }
  817.  
  818.  
  819. void Open_Dir(dword dir_path, redraw){
  820.         int errornum, maxcount, i;
  821.         if (redraw!=ONLY_SHOW)
  822.         {
  823.                 selected_count = 0;
  824.                 if (buf) free(buf);
  825.                 errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT);
  826.                 if (errornum)
  827.                 {
  828.                         history.add(#path);
  829.                         EventHistoryGoBack();
  830.                         Write_Error(errornum);
  831.                         return;
  832.                 }
  833.                 if (files.count>0) && (files.cur_y-files.first==-1) files.cur_y=0;
  834.         }
  835.         if (files.count!=-1)
  836.         {
  837.                 if(!_not_draw) if (show_breadcrumb.checked) DrawBreadCrumbs(); else DrawPathBar();
  838.                 history.add(#path);
  839.                 SystemDiscs.Draw();
  840.                 files.visible = files.h / files.item_h;
  841.                 if (files.count < files.visible) files.visible = files.count;
  842.                 if (!strncmp(dir_path, "/rd/1/",5))
  843.                         dir_at_fat16 = true; else dir_at_fat16 = false;
  844.                 if (redraw!=ONLY_SHOW) Sorting();
  845.                 list_full_redraw = true;
  846.                 if (redraw!=ONLY_OPEN)&&(!_not_draw) {DrawStatusBar(); List_ReDraw();}
  847.                 SetCurDir(dir_path);
  848.         }
  849.         if (files.count==-1) && (redraw!=ONLY_OPEN)
  850.         {
  851.                 files.KeyHome();
  852.                 if(!_not_draw) { list_full_redraw=true; DrawStatusBar(); List_ReDraw(); }
  853.         }
  854. }
  855.  
  856. inline Sorting()
  857. {
  858.         dword d=0, f=1;
  859.         int j=0;
  860.         dword tmp;
  861.         dword file_off;
  862.  
  863.         items.drop();
  864.  
  865.         if (!strcmp(#path,"/")) //do not sort root folder
  866.         {
  867.                 for(d=1;d<files.count;d++;) items.set(d, d);
  868.                 count_dir = d;
  869.                 return;
  870.         }
  871.         for (j=files.count-1, file_off=files.count-1*304+buf+32; j>=0; j--, file_off-=304;)  //files | folders
  872.         {
  873.                 if (dir_at_fat16) && (file_name_is_8_3(file_off+40)) strttl(file_off+40);
  874.                 if (TestBit(ESDWORD[file_off],4)) //directory?
  875.                 {
  876.                         items.set(d, j);
  877.                         d++;
  878.                 }
  879.                 else
  880.                 {
  881.                         items.set(files.count-f, j);
  882.                         f++;
  883.                 }
  884.         }
  885.         count_dir = d;
  886.         //sorting: files first, then folders
  887.         Sort_by_Name(0,d-1);
  888.         if (sort_type==1) Sort_by_Name(d,files.count-1);
  889.         else if (sort_type==2) Sort_by_Type(d,files.count-1);
  890.         else if (sort_type==3) Sort_by_Size(d,files.count-1);
  891.         //reversed sorting
  892.         if (sort_desc) {
  893.                 for (j=0; j<f/2; j++) {
  894.                         items.swap(files.count-j-1, d+j);
  895.                 }
  896.                 //if (sort_type==1) for (j=0; j<d/2; j++) items[d-j]><items[j];
  897.         }
  898.         //make ".." first item in list
  899.         if (d>0) && (strncmp(items.get(0)*304+buf+72,"..",2)!=0)
  900.                 for(d--; d>0; d--;) if (!strncmp(items.get(d)*304+buf+72,"..",2)) {items.swap(d,0); break;}
  901. }
  902.  
  903.  
  904. void Del_Form()
  905. {
  906.         byte f_count[128];
  907.         int dform_x = files.w - 220 / 2 + files.x;
  908.         if (!selected_count) && (!strncmp(#file_name,"..",2)) return;
  909.         else
  910.         {
  911.                 if (!files.count) return;
  912.                 DrawEolitePopup(T_YES, T_NO);
  913.                 WriteText(-strlen(T_DELETE_FILE)*3+110+dform_x,175,0x80,sc.work_text,T_DELETE_FILE);
  914.                 if (selected_count)
  915.                 {
  916.                         sprintf(#f_count,"%s%d%s",DEL_MORE_FILES_1,selected_count,DEL_MORE_FILES_2);
  917.                         WriteText(-strlen(#f_count)*3+110+dform_x,190,0x80,sc.work_text,#f_count);
  918.                 }
  919.                 else
  920.                 {
  921.                         if (strlen(#file_name)<28)
  922.                         {
  923.                                 WriteText(strlen(#file_name)*3+110+dform_x+2,190,0x80,sc.work_text,"?");
  924.                                 WriteText(-strlen(#file_name)*3+110+dform_x,190,0x80,sc.work_text,#file_name);
  925.                         }
  926.                         else
  927.                         {
  928.                                 WriteText(164+dform_x,190,0x80,0,"...?");
  929.                                 ESI = 24;
  930.                                 WriteText(dform_x+20,190,0,0,#file_name);
  931.                         }
  932.                 }              
  933.                 del_active=1;
  934.         }
  935. }
  936.  
  937. void SelectFileByName(dword that_file)
  938. {
  939.         int ind;
  940.         files.KeyHome();
  941.         Open_Dir(#path,ONLY_OPEN);
  942.         if (dir_at_fat16) && (file_name_is_8_3(that_file)) strttl(that_file);
  943.         for (ind=files.count-1; ind>=0; ind--;) { if (streq(items.get(ind)*304+buf+72,that_file)) break; }
  944.         files.cur_y = ind - 1;
  945.         files.KeyDown();
  946.         DrawStatusBar();
  947.         List_ReDraw();
  948. }
  949.  
  950.  
  951. void Dir_Up()
  952. {
  953.         int iii;
  954.         char old_folder_name[4096];
  955.         iii=strlen(#path)-1;
  956.         if (iii==0) return;
  957.         iii = strrchr(#path, '/');
  958.         strcpy(#old_folder_name, #path+iii);
  959.         if (iii>1) path[iii-1]=NULL; else path[iii]=NULL;
  960.         SelectFileByName(#old_folder_name);
  961. }
  962.  
  963. void Open(byte rez)
  964. {
  965.         byte temp[4096];
  966.         selected_count = 0;
  967.         if (rez)
  968.         {
  969.                 if (!strncmp(#file_name,"..",3)) return;
  970.                 strcpy(#temp, #file_path);
  971.                 RunProgram(I_Path, #temp);
  972.                 return;
  973.         }
  974.         if (!files.count) return;
  975.         if (!itdir)
  976.         {
  977.                 if (strrchr(#file_name, '.')==0) RunProgram(#file_path, ""); else RunProgram("/sys/@open", #file_path);
  978.         }
  979.         else
  980.         {
  981.                 if (!strncmp(#file_name,"..",3)) { Dir_Up(); return; }
  982.                 strcpy(#path, #file_path);
  983.                 files.first=files.cur_y=0;
  984.                 Open_Dir(#path,WITH_REDRAW);
  985.         }
  986. }
  987.  
  988. inline fastcall void EventHistoryGoBack()
  989. {
  990.         char cur_folder[4096];
  991.         strcpy(#cur_folder, #path);
  992.         if (history.back()) {
  993.                 strcpy(#path, history.current());
  994.                 SelectFileByName(#cur_folder+strrchr(#cur_folder,'/'));
  995.         }
  996. }
  997.  
  998. void ShowOpenWithDialog()
  999. {
  1000.         byte open_param[4097];
  1001.         sprintf(#open_param,"~%s",#file_path);
  1002.         RunProgram("/sys/@open", #open_param);
  1003. }
  1004.  
  1005. void NewElement()
  1006. {
  1007.         BDVK element_info;
  1008.         byte del_rezult, copy_rezult, info_result;
  1009.  
  1010.         sprintf(#temp,"%s/%s",#path,new_file_ed.text);
  1011.         info_result = GetFileInfo(#temp, #element_info);
  1012.         switch(new_element_active)
  1013.         {
  1014.                 case CREATE_FILE:
  1015.                         if (info_result==5)
  1016.                         {
  1017.                                 CreateFile(0, 0, #temp);
  1018.                                 if (EAX)
  1019.                                 {
  1020.                                         if (EAX==5) notify(NOT_CREATE_FILE);
  1021.                                         else Write_Error(EAX);
  1022.                                 }
  1023.                         }
  1024.                         else
  1025.                         {
  1026.                                 notify(FS_ITEM_ALREADY_EXISTS);
  1027.                         }
  1028.                         break;
  1029.                 case CREATE_FOLDER:
  1030.                         if (info_result==5)
  1031.                         {
  1032.                                 CreateDir(#temp);
  1033.                                 if (EAX)
  1034.                                 {
  1035.                                         if (EAX==5) notify(NOT_CREATE_FOLDER);
  1036.                                         else Write_Error(EAX);
  1037.                                 }
  1038.                         }
  1039.                         else
  1040.                         {
  1041.                                 notify(FS_ITEM_ALREADY_EXISTS);
  1042.                         }
  1043.                         break;
  1044.                 case RENAME_ITEM:
  1045.                         if (info_result==5)
  1046.                         {
  1047.                                 if (itdir)
  1048.                                 {
  1049.                                         //rename only empty folders
  1050.                                         if (del_rezult = DeleteFile(#file_path))
  1051.                                         {
  1052.                                                 Write_Error(del_rezult);
  1053.                                                 return;
  1054.                                         }
  1055.                                         if (CreateDir(#temp)) CreateDir(#file_path);
  1056.                                         Open_Dir(#path,WITH_REDRAW);
  1057.                                         SelectFileByName(new_file_ed.text);
  1058.                                 }
  1059.                                 else
  1060.                                 {
  1061.                                         if (copy_rezult = CopyFile(#file_path,#temp))
  1062.                                         {
  1063.                                                 Write_Error(copy_rezult);
  1064.                                         }
  1065.                                         else
  1066.                                         {
  1067.                                                 DeleteFile(#file_path);
  1068.                                                 SelectFileByName(new_file_ed.text);
  1069.                                         }
  1070.                                 }
  1071.                         }
  1072.                         else
  1073.                         {
  1074.                                 notify(FS_ITEM_ALREADY_EXISTS);
  1075.                         }
  1076.         }
  1077.         Open_Dir(#path,WITH_REDRAW);
  1078.         SelectFileByName(new_file_ed.text);
  1079.         EventClosePopinForm();
  1080. }
  1081.  
  1082. void NewElement_Form(byte crt, dword strng)
  1083. {
  1084.         int dform_x=files.w-220/2+files.x;
  1085.         if (!new_element_active)
  1086.         {
  1087.                 new_element_active = crt;
  1088.                 strcpy(#new_element_name, strng);
  1089.                 EditBox_UpdateText(#new_file_ed, ed_focus+ed_always_focus);
  1090.         }
  1091.         if (new_element_active==3) DrawEolitePopup(T_RENAME, T_CANCEL);
  1092.         else DrawEolitePopup(T_CREATE, T_CANCEL);
  1093.         new_file_ed.left = dform_x+10;
  1094.         DrawEditBox(#new_file_ed);
  1095. }
  1096.  
  1097. void FnProcess(byte N)
  1098. {
  1099.         switch(N)
  1100.         {
  1101.                 case 1:
  1102.                         if (!active_about) {
  1103.                                 about_stak = malloc(4096);
  1104.                                 about_thread_id = CreateThread(#about_dialog,about_stak+4092);
  1105.                                 break;
  1106.                         } else {
  1107.                                 ActivateWindow(GetProcessSlot(about_thread_id));
  1108.                         }
  1109.                         break;
  1110.                 case 2:
  1111.                         if (files.count) NewElement_Form(RENAME_ITEM, #file_name);
  1112.                         break;
  1113.                 case 3:
  1114.                         if (files.count) && (!itdir) RunProgram("/sys/tinypad", #file_path);
  1115.                         break;
  1116.                 case 4:
  1117.                         if (files.count) && (!itdir) RunProgram("/sys/develop/heed", #file_path);
  1118.                         break;
  1119.                 case 5: //refresh cur dir & devs
  1120.                         if (two_panels.checked)
  1121.                         {
  1122.                                 DrawFilePanels();
  1123.                         }
  1124.                         else
  1125.                         {
  1126.                                 Tip(56, T_DEVICES, 55, "-");
  1127.                                 Open_Dir(#path,WITH_REDRAW);
  1128.                                 pause(10);
  1129.                                 SystemDiscs.Get();
  1130.                                 Open_Dir(#path,WITH_REDRAW);
  1131.                                 DrawDeviceAndActionsLeftPanel();                               
  1132.                         }
  1133.                         break;
  1134.                 case 6:
  1135.                         NewElement_Form(CREATE_FOLDER, T_NEW_FOLDER);
  1136.                         break;
  1137.                 case 7:
  1138.                         NewElement_Form(CREATE_FILE, T_NEW_FILE);
  1139.                         break;
  1140.                 case 8:
  1141.                         EventShowProperties();
  1142.                         break;
  1143.                 case 10: //F10
  1144.                         if (!active_settings)
  1145.                         {
  1146.                                 settings_stak = malloc(4096);
  1147.                                 settings_window = CreateThread(#settings_dialog, settings_stak+4092);
  1148.                                 break;
  1149.                         }
  1150.                         else
  1151.                         {
  1152.                                 ActivateWindow(GetProcessSlot(settings_window));
  1153.                         }
  1154.                         break;
  1155.         }
  1156. }
  1157.  
  1158. void ChangeActivePanel()
  1159. {
  1160.         llist_copy(#files_active, #files_inactive);
  1161.         llist_copy(#files_inactive, #files);
  1162.         strcpy(#active_path, #inactive_path);
  1163.         strcpy(#inactive_path, #path);
  1164.         DrawFilePanels();
  1165. }
  1166.  
  1167. void EventSelectFileByKeyPress()
  1168. {
  1169.         int i;
  1170.         for (i=files.cur_y+1; i<files.count; i++)
  1171.         {
  1172.                 strcpy(#temp, items.get(i)*304+buf+72);
  1173.                 if (temp[0]==key_ascii) || (temp[0]==key_ascii-32)
  1174.                 {
  1175.                         files.cur_y = i - 1;
  1176.                         files.KeyDown();
  1177.                         List_ReDraw();
  1178.                         return;
  1179.                 }
  1180.         }
  1181. }
  1182.  
  1183. dword GetDeviceSizeLabel(dword path)
  1184. {
  1185.         BDVK bdvk;
  1186.         char cdname[8];
  1187.         if (ESBYTE[path+1] == '/') path++;
  1188.         if (ESBYTE[path+1] == 'c') && (ESBYTE[path+2] == 'd')
  1189.                 && (ESBYTE[path+4] == 0) return 0;
  1190.         GetFileInfo(path, #bdvk);
  1191.         return ConvertSize64(bdvk.sizelo, bdvk.sizehi);
  1192. }
  1193.  
  1194. int GetRealFileCountInFolder(dword folder_path)
  1195. {
  1196.         int fcount;
  1197.         dword countbuf;
  1198.  
  1199.         GetDir(#countbuf, #fcount, folder_path, DIRS_NOROOT);
  1200.         if (countbuf) free(countbuf);
  1201.  
  1202.         return fcount;
  1203. }
  1204.  
  1205. void EventRefreshDisksAndFolders()
  1206. {
  1207.         if(GetRealFileCountInFolder("/")+dir_exists("/kolibrios") != SystemDiscs.dev_num) {
  1208.                 FnProcess(5);
  1209.         }
  1210.         if(two_panels.checked)
  1211.         {
  1212.                 if(GetRealFileCountInFolder(#inactive_path) != files_inactive.count) {
  1213.                         ChangeActivePanel();
  1214.                         Open_Dir(#path,WITH_REDRAW);
  1215.                         ChangeActivePanel();
  1216.                 }
  1217.                 if(GetRealFileCountInFolder(#path) != files.count) Open_Dir(#path,WITH_REDRAW);
  1218.         }
  1219.         else
  1220.         {
  1221.                 if(GetRealFileCountInFolder(#path) != files.count) Open_Dir(#path,WITH_REDRAW);
  1222.         }
  1223. }
  1224.  
  1225. void EventSort(dword id)
  1226. {
  1227.         char selected_filename[256];
  1228.         if (sort_type == id) sort_desc ^= 1;
  1229.         else sort_type = id;
  1230.         strcpy(#selected_filename, #file_name);
  1231.         DrawList();
  1232.         Open_Dir(#path,WITH_REDRAW);
  1233.         SelectFileByName(#selected_filename);
  1234. }
  1235.  
  1236. void EventHistoryGoForward()
  1237. {
  1238.         if (history.forward()) {
  1239.                 strcpy(#path, history.current());
  1240.                 files.KeyHome();
  1241.                 Open_Dir(#path,WITH_REDRAW);
  1242.         }
  1243. }
  1244.  
  1245. void EventOpenNewEolite()
  1246. {
  1247.         RunProgram(I_Path, #path);
  1248. }
  1249.  
  1250. void EventOpenConsoleHere()
  1251. {
  1252.         sprintf(#param, "pwd cd %s", #path);
  1253.         RunProgram("/sys/shell", #param);
  1254. }
  1255.  
  1256. void ProceedMouseGestures()
  1257. {
  1258.         char stats;
  1259.         signed x_old, y_old, dif_x, dif_y, adif_x, adif_y;
  1260.         if (!mouse.mkm) && (stats>0) stats = 0;
  1261.         if (mouse.mkm) && (!stats)
  1262.         {
  1263.                 x_old = mouse.x;
  1264.                 y_old = mouse.y;
  1265.                 stats = 1;
  1266.         }
  1267.         if (mouse.mkm) && (stats==1)
  1268.         {
  1269.                 dif_x = mouse.x-x_old;
  1270.                 dif_y = mouse.y-y_old;
  1271.                 adif_x = fabs(dif_x);
  1272.                 adif_y = fabs(dif_y);
  1273.                
  1274.                 if (adif_x>adif_y) {
  1275.                         if (dif_x > 150) {
  1276.                                 EventHistoryGoForward();
  1277.                                 stats = 0;
  1278.                         }
  1279.                         if (dif_x < -150) {
  1280.                                 EventHistoryGoBack();
  1281.                                 stats = 0;
  1282.                         }
  1283.                 } else {
  1284.                         if (dif_y < -100) {
  1285.                                 Dir_Up();
  1286.                                 stats = 0;
  1287.                         }
  1288.                 }
  1289.         }
  1290. }
  1291.  
  1292. void EventPaste() {
  1293.         char paste_line[4096+6];
  1294.         sprintf(#paste_line, "-v%i %s", cut_active, #path);
  1295.         RunProgram(#program_path, #paste_line);
  1296.         EventClosePopinForm();
  1297. }
  1298.  
  1299. void EventDelete()
  1300. char line_param[4096+5];
  1301. {
  1302.         EventClosePopinForm();
  1303.         if (!selected_count) {
  1304.                 sprintf(#line_param, "-d %s", #file_path);
  1305.                 RunProgram(#program_path, #line_param);
  1306.         } else {
  1307.                 delete_stak = malloc(40000);
  1308.                 CreateThread(#DeleteSelectedElements,delete_stak+40000-4);
  1309.         }
  1310. }
  1311.  
  1312. void EventClosePopinForm()
  1313. {
  1314.         del_active=0;
  1315.         new_element_active = 0;
  1316.         draw_window();
  1317.         DeleteButton(POPUP_BTN1);
  1318.         DeleteButton(POPUP_BTN2);
  1319. }
  1320.  
  1321. void EventShowProperties()
  1322. char line_param[4096+5];
  1323. {
  1324.         if (!selected_count) {
  1325.                 sprintf(#line_param, "-p %s", #file_path);
  1326.                 RunProgram(#program_path, #line_param);
  1327.         } else {
  1328.                 properties_stak = malloc(8096);
  1329.                 CreateThread(#properties_dialog, properties_stak+8092);
  1330.         }
  1331. }
  1332.  
  1333. void EventChooseFile(int _id)
  1334. {
  1335.         if (getElementSelectedFlag(_id) == true) {
  1336.                 setElementSelectedFlag(_id, false);
  1337.         } else {
  1338.                 setElementSelectedFlag(_id, true);
  1339.         }
  1340. }
  1341.  
  1342. void EventChooseFilesRange(int _start, _end)
  1343. {
  1344.         if (_start > _end) _start >< _end;
  1345.         if (_end - _start > 1) list_full_redraw = true;
  1346.         while (_start < _end) {
  1347.                 EventChooseFile(_start);
  1348.                 _start++;
  1349.         }
  1350.         DrawStatusBar();
  1351.         List_ReDraw();
  1352. }
  1353.  
  1354. void EventChooseAllFiles(dword state)
  1355. {
  1356.         int i;
  1357.         for (i=0; i<files.count; i++) setElementSelectedFlag(i, state);
  1358.         List_ReDraw();
  1359.         DrawStatusBar();
  1360. }
  1361.  
  1362.  
  1363.  
  1364. stop:
  1365.