Subversion Repositories Kolibri OS

Rev

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