Subversion Repositories Kolibri OS

Rev

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