Subversion Repositories Kolibri OS

Rev

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