Subversion Repositories Kolibri OS

Rev

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