Subversion Repositories Kolibri OS

Rev

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