Subversion Repositories Kolibri OS

Rev

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