Subversion Repositories Kolibri OS

Rev

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