Subversion Repositories Kolibri OS

Rev

Rev 7757 | Rev 7786 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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