Subversion Repositories Kolibri OS

Rev

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