Subversion Repositories Kolibri OS

Rev

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