Subversion Repositories Kolibri OS

Rev

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