Subversion Repositories Kolibri OS

Rev

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