Subversion Repositories Kolibri OS

Rev

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