Subversion Repositories Kolibri OS

Rev

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