Subversion Repositories Kolibri OS

Rev

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