Subversion Repositories Kolibri OS

Rev

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