Subversion Repositories Kolibri OS

Rev

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

  1. //Leency, Veliant, Punk_Joker & KolibriOS Team 2008-2015
  2. //GNU GPL licence.
  3.  
  4. #ifndef AUTOBUILD
  5. #include "lang.h--"
  6. #endif
  7.  
  8. //libraries
  9. #define MEMSIZE 0xD0000
  10. #include "..\lib\kolibri.h"
  11. #include "..\lib\clipboard.h"
  12. #include "..\lib\strings.h"
  13. #include "..\lib\mem.h"
  14. #include "..\lib\dll.h"
  15. #include "..\lib\file_system.h"
  16. #include "..\lib\gui.h"
  17. #include "..\lib\list_box.h"
  18. #include "..\lib\copyf.h"
  19. #include "..\lib\random.h"
  20. //obj
  21. #include "..\lib\obj\libini.h"
  22. #include "..\lib\obj\box_lib.h"
  23. //images
  24. #include "imgs\toolbar.txt"
  25. #include "imgs\left_p.txt"
  26. #include "imgs\icons.txt"
  27.  
  28. #ifdef LANG_RUS
  29.         ?define T_FILE "” ©«"
  30.         ?define T_TYPE "’¨¯"
  31.         ?define T_SIZE " §¬¥à"
  32.         ?define T_NEW_FOLDER "®¢ ï ¯ ¯ª "
  33.         ?define T_NEW_FILE "®¢ë© ä ©«"
  34.         ?define T_DELETE_FILE "‚ë ¤¥©á⢨⥫쭮 å®â¨â¥ 㤠«¨âì"
  35.         ?define T_YES "„ "
  36.         ?define T_NO "¥â"
  37.         ?define T_CANCEL "Žâ¬¥­ "
  38.         ?define T_CREATE "‘®§¤ âì"
  39.         ?define T_RENAME "¥à¥¨¬¥­®¢ âì"
  40.         ?define FILE_EXISTS "” ©« á â ª¨¬ ¨¬¥­¥¬ áãé¥áâ¢ã¥â"
  41.         ?define FOLDER_EXISTS " ¯ª  á â ª¨¬ ¨¬¥­¥¬ áãé¥áâ¢ã¥â"
  42.         ?define T_DEL_ERROR_1 "Žè¨¡ª .  ¯ª  ­¥ ¯ãáâ ï."
  43.         ?define WAIT_DELETING_FOLDER "“¤ «ï¥âáï ¯ ¯ª . ®¤®¦¨â¥..."
  44.         ?define NOT_CREATE_FOLDER "¥ 㤠«®áì ᮧ¤ âì ¯ ¯ªã."
  45.         ?define NOT_CREATE_FILE "¥ 㤠«®áì ᮧ¤ âì ä ©«."
  46.         ?define ERROR_1 "Žè¨¡ª  ¯à¨ § £à㧪¥ ¡¨¡«¨®â¥ª¨ /rd/1/lib/box_lib.obj"
  47.         ?define T_PASTE_WINDOW_TITLE "Š®¯¨àãî..."
  48.         ?define T_PASTE_WINDOW_TEXT "Š®¯¨àã¥âáï ä ©«:"
  49.         ?define T_PASTE_WINDOW_BUTTON "à¥à¢ âì"       
  50.         ?define INFO_AFTER_COPY "Š®¯¨à®¢ ­¨¥ § ¢¥à襭®"
  51.         ?define T_CANCEL_PASTE "Š®¯¨à®¢ ­¨¥ ¯à¥ªà é¥­®.  ¯ª  ᪮¯¨à®¢ ­  ­¥ ¯®«­®áâìî."
  52.         ?define T_SELECT_APP_TO_OPEN_WITH "‚ë¡¥à¨â¥ ¯à®£à ¬¬ã ¤«ï ®âªàëâ¨ï ä ©« "
  53.         ?define DEL_MORE_FILES_1 "¢ë¡à ­­ë¥ í«¥¬¥­âë ("
  54.         ?define DEL_MORE_FILES_2 " èâ.)?"
  55. #elif LANG_EST
  56.         ?define T_FILE "Fail"
  57.         ?define T_TYPE "Tüüp"
  58.         ?define T_SIZE "Suurus"
  59.         ?define T_NEW_FOLDER "Uus kataloog"
  60.         ?define T_NEW_FILE "Uus fail"
  61.         ?define T_DELETE_FILE "Kas sa tahad tõesti kustutada"
  62.         ?define T_YES "Jah"
  63.         ?define T_NO "Ei"
  64.         ?define T_CANCEL "Cancel"
  65.         ?define T_CREATE "Create"
  66.         ?define T_RENAME "Rename"
  67.         ?define FILE_EXISTS "The file with the same name exists"
  68.         ?define FOLDER_EXISTS "A folder with the same name exists"
  69.         ?define T_DEL_ERROR_1 "Viga. Kataloog ei ole tühi."
  70.         ?define WAIT_DELETING_FOLDER "Deleting folder. Please, wait..."
  71.         ?define NOT_CREATE_FOLDER "Kataloogi ei saa luua."
  72.         ?define NOT_CREATE_FILE "Faili ei saa luua."
  73.         ?define ERROR_1 "Viga teegi laadimisel /rd/1/lib/box_lib.obj"
  74.         ?define T_PASTE_WINDOW_TITLE "Kopeerin..."
  75.         ?define T_PASTE_WINDOW_TEXT "Kopeerin faili:"
  76.         ?define T_PASTE_WINDOW_BUTTON "Abort"
  77.         ?define INFO_AFTER_COPY "Copy finished"
  78.         ?define T_CANCEL_PASTE "Copy process terminated. Folder copied incompletely."
  79.         ?define T_SELECT_APP_TO_OPEN_WITH "Select application to open file"
  80.         ?define DEL_MORE_FILES_1 "selected items("
  81.         ?define DEL_MORE_FILES_2 " pcs.)?"
  82. #else
  83.         ?define T_FILE "File"
  84.         ?define T_TYPE "Type"
  85.         ?define T_SIZE "Size"
  86.         ?define T_NEW_FOLDER "New folder"
  87.         ?define T_NEW_FILE "New file"
  88.         ?define T_DELETE_FILE "Do you really want to delete"
  89.         ?define T_YES "Yes"
  90.         ?define T_NO "No"
  91.         ?define T_CANCEL "Cancel"
  92.         ?define T_CREATE "Create"
  93.         ?define T_RENAME "Rename"
  94.         ?define FILE_EXISTS "The file with the same name exists"
  95.         ?define FOLDER_EXISTS "A folder with the same name exists"
  96.         ?define T_DEL_ERROR_1 "Error. Folder isn't empty."
  97.         ?define WAIT_DELETING_FOLDER "Deleting folder. Please, wait..."
  98.         ?define NOT_CREATE_FOLDER "Folder can not be created."
  99.         ?define NOT_CREATE_FILE "File can not be created."
  100.         ?define ERROR_1 "Error while loading library /rd/1/lib/box_lib.obj"
  101.         ?define T_PASTE_WINDOW_TITLE "Copying..."
  102.         ?define T_PASTE_WINDOW_TEXT "Copying file:"
  103.         ?define T_PASTE_WINDOW_BUTTON "Abort"
  104.         ?define INFO_AFTER_COPY "Copy finished"
  105.         ?define T_CANCEL_PASTE "Copy process terminated. Folder copied incompletely."
  106.         ?define T_SELECT_APP_TO_OPEN_WITH "Select application to open file"
  107.         ?define DEL_MORE_FILES_1 "selected items("
  108.         ?define DEL_MORE_FILES_2 " pcs.)?"
  109. #endif
  110.  
  111. enum {ONLY_SHOW, WITH_REDRAW, ONLY_OPEN}; //OpenDir
  112. enum { CREATE_FILE=1, CREATE_FOLDER, RENAME_ITEM }; //NewElement
  113.  
  114. #define TITLE "Eolite File Manager v2.81"
  115. #define ABOUT_TITLE "Eolite v2.81"
  116. dword col_padding, col_selec, col_lpanel;
  117.  
  118. int toolbar_buttons_x[7]={9,46,85,134,167,203};
  119. struct path_string { char Item[4096]; };
  120.  
  121. byte active_about=0;
  122. word about_window;
  123. byte active_settings=0;
  124. word settings_window;
  125.  
  126. byte menu_call_mouse=0;
  127.  
  128. llist files;
  129.  
  130. byte
  131.         path[4096],
  132.         file_path[4096],
  133.         file_name[256],
  134.         new_element_name[256],
  135.         temp[4096];      
  136. byte
  137.         del_active=0,
  138.         new_element_active=0,
  139.         show_dev_name=1,
  140.         real_files_names_case=0,
  141.         use_big_fonts=0,
  142.         font_type,
  143.         info_after_copy=0,
  144.         sort_num=2,
  145.         itdir;
  146.  
  147. dword eolite_ini_path;
  148.  
  149. proc_info Form;
  150. system_colors sc;
  151. mouse m;
  152. int mouse_dd, scroll_used, sc_slider_h, sorting_arrow_x, kolibrios_drive;
  153. dword buf;
  154. dword file_mas[6898];
  155. int j, i;
  156. int action_buf;
  157. int rand_n;
  158. int selected_count;
  159.  
  160. mouse gestures;
  161. signed x_old, y_old, dif_x, dif_y, adif_x, adif_y;
  162. byte stats;
  163.  
  164. edit_box edit2 = {250,213,80,0xFFFFCC,0x94AECE,0xFFFFCC,0xFFFFFF,0,248,#file_name,#mouse_dd,64,6,6};
  165. edit_box new_file_ed = {171,213,180,0xFFFFFF,0x94AECE,0xFFFFFF,0xFFFFFF,0,248,#new_element_name,#mouse_dd,100000000000010b,6,0};
  166. PathShow_data PathShow = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, #path, #temp, 0};
  167. PathShow_data FileShow = {0, 56,215, 6, 100, 0, 0, 0x0, 0xFFFfff, #file_name, #temp, 0};
  168. byte cmd_free;
  169. #include "include\copy.h"
  170. #include "include\gui.h"
  171. #include "include\sorting.h"
  172. #include "include\icons.h"
  173. #include "include\left_panel.h"
  174. #include "include\history.h"
  175. #include "include\menu.h"
  176. #include "include\about.h"
  177. #include "include\settings.h"
  178. #include "include\properties.h"
  179.  
  180. dword menu_stak,about_stak,properties_stak,settings_stak,copy_stak;
  181.  
  182. void main()
  183. {
  184.         word key, id, can_show, can_select, m_selected;
  185.         dword selected_offset;
  186.         rand_n = random(40);
  187.         gestures.get();
  188.         mem_Init();
  189.         if (load_dll2(boxlib, #box_lib_init,0)!=0) notify(ERROR_1);
  190.     if (load_dll2(libini, #lib_init,1)!=0) notify("Error: library doesn't exists - libini");
  191.         eolite_ini_path = abspath("Eolite.ini");
  192.         LoadIniSettings();
  193.         GetSystemDiscs();
  194.         SetAppColors();
  195.         if (param)
  196.         {
  197.                 strcpy(#path, #param);
  198.                 if (path[strlen(#path)-1]!='/') chrcat(#path, '/'); //add "/" to the end of the string
  199.         }
  200.         else
  201.         {
  202.                 strcpy(#path, "/rd/1/");               
  203.         }
  204.         Open_Dir(#path,ONLY_OPEN);
  205.         SetEventMask(0x27);
  206.         loop(){ switch(WaitEvent())
  207.         {
  208.                 case evMouse:
  209.                         if (del_active) || (!CheckActiveProcess(Form.ID)) || (Form.status_window>2) break;
  210.                         if (new_element_active) || (!CheckActiveProcess(Form.ID)) || (Form.status_window>2)
  211.                         {
  212.                                 edit_box_mouse stdcall(#new_file_ed);
  213.                                 break;
  214.                         }                              
  215.                        
  216.                         m.get();
  217.                        
  218.                        
  219.                         gestures.get();
  220.                         if (!gestures.mkm) && (stats>0) stats = 0;
  221.                         if (gestures.mkm) && (stats==0)
  222.                         {
  223.                                 x_old = gestures.x;
  224.                                 y_old = gestures.y;
  225.                                 stats = 1;
  226.                         }
  227.                         if (gestures.mkm) && (stats==1)
  228.                         {
  229.                                 dif_x = gestures.x-x_old;
  230.                                 dif_y = gestures.y-y_old;
  231.                                 adif_x = fabs(dif_x);
  232.                                 adif_y = fabs(dif_y);
  233.                                
  234.                                 if (adif_x>adif_y)
  235.                                 {
  236.                                         if (dif_x > 150)
  237.                                         {
  238.                                                 if (HistoryPath(GO_FORWARD))
  239.                                                         {
  240.                                                                 files.first=files.current=NULL;
  241.                                                                 Open_Dir(#path,WITH_REDRAW);
  242.                                                         }
  243.                                                 stats = 0;
  244.                                         }
  245.                                         if (dif_x < -150)
  246.                                         {
  247.                                                 GoBack();
  248.                                                 stats = 0;
  249.                                         }
  250.                                 }
  251.                                 else
  252.                                 {
  253.                                         if (dif_y < -100)
  254.                                         {
  255.                                                 Dir_Up();
  256.                                                 stats = 0;
  257.                                         }
  258.                                 }
  259.                         }      
  260.                         if (files.MouseOver(m.x, m.y))&&((m.up)||(m.down)||(m.dblclick))
  261.                         {
  262.                                 //select/open file {
  263.                                 if (m.key&MOUSE_LEFT)&&((m.down)||(m.dblclick))
  264.                                 {
  265.                                         if (m.y>=files.y)//&&(m.click)
  266.                                         {
  267.                                                 id = m.y - files.y / files.line_h;
  268.                                                 if (files.current!=id)
  269.                                                 {
  270.                                                         m.clearTime();
  271.                                                         if (id<files.visible) List_Current(id-files.current);
  272.                                                 }
  273.                                                 else if(m.dblclick)Open(0);
  274.                                         }
  275.                                 }
  276.                                 // } select/open file
  277.                                 else
  278.                                 //file menu {
  279.                                 if (m.key&MOUSE_RIGHT)&&(m.up)
  280.                                 {
  281.                                         menu_call_mouse = 1;
  282.                                         if (m.y>=files.y)//&&(m.click)
  283.                                         {
  284.                                                 id = m.y - files.y / files.line_h;
  285.                                                 if (files.current!=id) List_Current(id-files.current);
  286.                                                 //SwitchToAnotherThread();
  287.                                                 menu_stak = malloc(4096);
  288.                                                 CreateThread(#FileMenu,menu_stak+4092);
  289.                                         }
  290.                                         break;
  291.                                 }
  292.                                 // } file menu
  293.                         }
  294.  
  295.                         if (m.vert)
  296.                         {
  297.                                 if (files.MouseScroll(m.vert)) List_ReDraw();
  298.                                 break;
  299.                         }
  300.  
  301.                         if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>40) && (m.y<files.y)
  302.                         {
  303.                                 IF (m.lkm==1) DrawRectangle3D(Form.cwidth - 17,41,14,14,0xC7C7C7,0xFFFFFF);
  304.                                 WHILE (m.lkm==1) && (files.first>0)
  305.                                 {
  306.                                         pause(8);
  307.                                         files.first--;
  308.                                         List_ReDraw();
  309.                                         m.get();
  310.                                 }
  311.                                 DrawRectangle3D(Form.cwidth - 17,41,14,14,0xFFFFFF,0xC7C7C7);
  312.                         }
  313.  
  314.                         if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>onTop(22,0)+1) && (m.y<onTop(22,0)+16)
  315.                         {
  316.                                 IF (m.lkm==1) DrawRectangle3D(Form.cwidth - 17,onTop(21,0),14,14,0xC7C7C7,0xFFFFFF);
  317.                                 while (m.lkm==1) && (files.first<files.count-files.visible)
  318.                                 {
  319.                                         pause(8);
  320.                                         files.first++;
  321.                                         List_ReDraw();
  322.                                         m.get();
  323.                                 }
  324.                                 DrawRectangle3D(Form.cwidth - 17,onTop(21,0),14,14,0xFFFFFF,0xC7C7C7);
  325.                         }
  326.  
  327.                         //Scrooll
  328.                         if (!m.lkm) && (scroll_used) { scroll_used=NULL; Scroll(); }
  329.                         if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>56) && (m.y<Form.height) && (m.lkm) && (!scroll_used) {scroll_used=1;Scroll();}
  330.                        
  331.                         if (scroll_used)
  332.                         {
  333.                                 IF (sc_slider_h/2+files.y>m.y) || (m.y<0) || (m.y>4000) m.y=sc_slider_h/2+files.y; //anee eo?ni? iaa ieiii
  334.                                 id=files.first;
  335.                                 j= sc_slider_h/2;
  336.                                 files.first = m.y -j -files.y * files.count;
  337.                                 files.first /= onTop(22,files.y);
  338.                                 IF (files.visible+files.first>files.count) files.first=files.count-files.visible;
  339.                                 IF (id!=files.first) List_ReDraw();
  340.                         }
  341.                         break;  
  342. //Button pressed-----------------------------------------------------------------------------
  343.                 case evButton:
  344.                         id=GetButtonID();
  345.                         if (id==1)
  346.                         {
  347.                                 KillProcess(about_window);
  348.                                 ExitProcess();
  349.                         }
  350.                         if (del_active)
  351.                         {
  352.                                 IF (id==301) || (id==302) Del_File(302-id);
  353.                                 break;
  354.                         }
  355.                         if (new_element_active)
  356.                         {
  357.                                 IF (id==301) || (id==302) NewElement(302-id);
  358.                                 break;
  359.                         }
  360.                        
  361.                         switch(id)
  362.                         {
  363.                                 case 21: //Back
  364.                                                 GoBack();
  365.                                                 break;
  366.                                 case 22: //Forward
  367.                                                 if (HistoryPath(GO_FORWARD))
  368.                                                 {
  369.                                                         files.first=files.current=NULL; //aaa?o nienea
  370.                                                         Open_Dir(#path,WITH_REDRAW);
  371.                                                 }
  372.                                                 break;
  373.                                 case 23: //up!
  374.                                                 Dir_Up();
  375.                                                 break;
  376.                                 case 24: //cut
  377.                                                 Copy(#file_path, CUT);
  378.                                                 break;
  379.                                 case 25: //copy
  380.                                                 Copy(#file_path, NOCUT);
  381.                                                 break;
  382.                                 case 26: //paste
  383.                                                 copy_stak = malloc(4096);
  384.                                                 CreateThread(#Paste,copy_stak+4092);
  385.                                                 break;
  386.                                 case 31...33: //sort
  387.                                                 IF(sort_num==1) DrawFilledBar(sorting_arrow_x,42,6,10);
  388.                                                 IF(sort_num==2) DrawFilledBar(sorting_arrow_x,42,6,10);
  389.                                                 IF(sort_num==3) DrawFilledBar(sorting_arrow_x,42,6,10);
  390.                                                 sort_num=id-30;
  391.                                                 Open_Dir(#path,WITH_REDRAW);
  392.                                                 break;
  393.                                 case 50...60: //Actions
  394.                                                 FnProcess(id-50);
  395.                                                 break;
  396.                                 case 100...120:
  397.                                         DEVICE_MARK:
  398.                                                 DrawRectangle(17,id-100*16+74,159,16, 0); //auaaeaiea
  399.                                                 strcpy(#path, #disk_list[id-100].Item);
  400.                                                 files.first=files.current=0;
  401.                                                 Open_Dir(#path,WITH_REDRAW);
  402.                                                 pause(5);
  403.                                                 DrawRectangle(17,id-100*16+74,159,16, 0xFFFFFF);
  404.                                                 break;
  405.                         }
  406.                         break;
  407. //Key pressed-----------------------------------------------------------------------------
  408.                 case evKey:
  409.                         key = GetKey();
  410.                         if (Form.status_window>2) break;
  411.                         IF (del_active)
  412.                         {
  413.                                 IF (key==013) Del_File(true);
  414.                                 IF (key==027) Del_File(false);
  415.                                 break;
  416.                         }
  417.                         IF (new_element_active)
  418.                         {
  419.                                 IF (key==027) NewElement(0);
  420.                                 IF (key==013) NewElement(1);
  421.                                 EAX=key<<8;
  422.                                 edit_box_key stdcall (#new_file_ed);
  423.                                 break;
  424.                         }
  425.                         IF (edit2.flags!=64) && (key!=13) && (key!=27)
  426.                         {
  427.                                 EAX=key<<8;
  428.                                 edit_box_key stdcall (#edit2);
  429.                                 break;
  430.                         }
  431.                         switch (key)
  432.                         {
  433.                                         case 209...217:
  434.                                                         id=key-110;
  435.                                                         IF (id-100>=disc_num) break;
  436.                                                         GOTO DEVICE_MARK;
  437.                                         case ASCII_KEY_BS:
  438.                                                         //GoBack();
  439.                                                         Dir_Up();
  440.                                                         break;
  441.                                         case 004: //Ctrl+D set as bg
  442.                                                         strcpy(#temp, "\\S__");
  443.                                                         strcat(#temp, #file_path);
  444.                                                         RunProgram("/sys/media/kiv", #temp);
  445.                                                         break;
  446.                                         case 014: //Ctrl+N new window
  447.                                                         IF (Form.left==98) MoveSize(Form.left-20,Form.top-20,OLD,OLD);
  448.                                                         RunProgram("/sys/File Managers/Eolite", #path);
  449.                                                         break;
  450.                                         case 024: //Ctrl+X
  451.                                                         Copy(#file_path, CUT);
  452.                                                         break;
  453.                                         case 003: //Ctrl+C
  454.                                                         Copy(#file_path, NOCUT);
  455.                                                         break;
  456.                                         case 022: //Ctrl+V
  457.                                                         copy_stak = malloc(4096);
  458.                                                         CreateThread(#Paste,copy_stak+4092);
  459.                                                         break;
  460.                                         case 001: //Ctrl+A
  461.                                                         debugln("press Ctrl+A");
  462.                                                         for (i=0; i<files.count; i++)
  463.                                                         {
  464.                                                                 selected_offset = file_mas[i]*304 + buf+32 + 7;
  465.                                                                 ESBYTE[selected_offset] = 1;
  466.                                                                 selected_count++;
  467.                                                         }
  468.                                                         List_ReDraw();
  469.                                                         break;
  470.                                         case 021: //Ctrl+U
  471.                                                         debugln("press Ctrl+A");
  472.                                                         for (i=0; i<files.count; i++)
  473.                                                         {
  474.                                                                 selected_offset = file_mas[i]*304 + buf+32 + 7;
  475.                                                                 ESBYTE[selected_offset] = 0;
  476.                                                         }
  477.                                                         selected_count = 0;
  478.                                                         List_ReDraw();
  479.                                                         break;
  480.                                         case ASCII_KEY_ESC:
  481.                                                         break;
  482.                                         case ASCII_KEY_ENTER:
  483.                                                         Open(0);
  484.                                                         break;
  485.                                         case 074: //menu
  486.                                                         menu_call_mouse=0;
  487.                                                         //SwitchToAnotherThread();
  488.                                                         menu_stak = malloc(4096);
  489.                                                         CreateThread(#FileMenu,menu_stak+4092);
  490.                                                         break;
  491.                                         case 173: //Ctrl+Enter
  492.                                                         if (!itdir) ShowOpenWithDialog();
  493.                                                         else Open(1);
  494.                                                         break;
  495.                                         case ASCII_KEY_UP:
  496.                                                         List_Current(-1);
  497.                                                         break;
  498.                                         case ASCII_KEY_DOWN:
  499.                                                         List_Current(1);
  500.                                                         break;
  501.                                         case ASCII_KEY_HOME:
  502.                                                         if (files.KeyHome()) List_ReDraw();
  503.                                                         break;
  504.                                         case ASCII_KEY_END:
  505.                                                         if (files.KeyEnd()) List_ReDraw();
  506.                                                         break;
  507.                                         case ASCII_KEY_PGDN:
  508.                                                         List_Current(files.visible-1);
  509.                                                         break;
  510.                                         case ASCII_KEY_PGUP:
  511.                                                         List_Current(-files.visible+1);
  512.                                                         break;
  513.                                         case ASCII_KEY_DEL:
  514.                                                         Del_Form();
  515.                                                         break;
  516.                                         case ASCII_KEY_INS:
  517.                                                         selected_offset = file_mas[files.current+files.first]*304 + buf+32 + 7;
  518.                                                         if (ESBYTE[selected_offset])
  519.                                                         {
  520.                                                                 ESBYTE[selected_offset]=0;
  521.                                                                 selected_count--;
  522.                                                         }
  523.                                                         else
  524.                                                         {
  525.                                                                 ESBYTE[selected_offset] = 1;
  526.                                                                 selected_count++;
  527.                                                         }
  528.                                                         List_Current(1);
  529.                                                         break;
  530.                                         case 048...059: //F1-F10
  531.                                                         FnProcess(key-49);
  532.                                                         break;
  533.                                         default:    
  534.                                                         for (i=files.current+files.first+1; i<files.count; i++)
  535.                                                         {
  536.                                                                 strcpy(#temp, file_mas[i]*304+buf+72);
  537.                                                                 IF (temp[0]==key) || (temp[0]==key-32)
  538.                                                                 {
  539.                                                                         List_Current(i-files.current-files.first);
  540.                                                                         break;
  541.                                                                 }
  542.                                                         }
  543.                         }                        
  544.                         break;
  545.                 case evReDraw:
  546.                         draw_window();
  547.                         if (action_buf) { menu_action(action_buf); action_buf=0;}
  548.         }
  549.                 if(cmd_free){
  550.                         if(cmd_free==1)     free(menu_stak);
  551.                         else if(cmd_free==2)free(about_stak);
  552.                         else if(cmd_free==3)free(properties_stak);
  553.                         else if(cmd_free==4)free(settings_stak);
  554.                         else if(cmd_free==5)free(copy_stak);
  555.                         cmd_free = 0;
  556.                 }
  557.         }
  558. }
  559.  
  560.  
  561. inline fastcall signed int _strrchr( ESI,BL)
  562. {
  563.         int jj=0, last=strlen(ESI);
  564.         do{
  565.                 jj++;
  566.                 $lodsb
  567.                 IF(AL==BL) last=jj;
  568.         } while(AL!=0);
  569.         return last;
  570. }
  571.  
  572.  
  573. void menu_action(dword id)
  574. {
  575.         if (id==COPY_PASTE_END)
  576.         {
  577.                 FnProcess(5);
  578.                 SelectFile(#copy_to+strrchr(#copy_to,'/'));
  579.         }
  580.         if (id==100) Open(0);
  581.         if (id==201) ShowOpenWithDialog();
  582.         if (id==202) FnProcess(3); //F3
  583.         if (id==203) FnProcess(4); //F4
  584.         if (id==104) Copy(#file_path, NOCUT);
  585.         if (id==105) Copy(#file_path, CUT);
  586.         if (id==106) { copy_stak = malloc(4096); CreateThread(#Paste,copy_stak+4092);}
  587.         if (id==207) FnProcess(2);
  588.         if (id==108) Del_Form();
  589.         if (id==109) FnProcess(5);
  590.         if (id==110) FnProcess(8);
  591.         if (id==300) { FnProcess(5); List_ReDraw(); }
  592. }
  593.  
  594.  
  595. void draw_window()
  596. {
  597.         DefineAndDrawWindow(GetScreenWidth()-550/4+rand_n,rand_n+30,550,500,0x73,sc.work,TITLE,0);
  598.         GetProcessInfo(#Form, SelfInfo);
  599.         if (Form.status_window>2) return;
  600.         files.SetSizes(192, 57, Form.cwidth - 210, onTop(57,6), disc_num*16+195,files.line_h);
  601.         if (Form.height < files.min_h) MoveSize(OLD,OLD,OLD,files.min_h);
  602.         if (Form.width<480) MoveSize(OLD,OLD,480,OLD);
  603.         GetProcessInfo(#Form, SelfInfo); //if win_size changed
  604.  
  605.         PutPaletteImage(#toolbar,246,34,0,0,8,#toolbar_pal);
  606.         DrawBar(127, 8, 1, 25, sc.work_graph);
  607.         for (j=0; j<3; j++) DefineButton(toolbar_buttons_x[j]+2,5+2,31-5,29-5,21+j+BT_HIDE,sc.work);
  608.         for (j=3; j<6; j++) DefineButton(toolbar_buttons_x[j],5,31,29,21+j+BT_HIDE,sc.work);
  609.         DrawBar(246,0,Form.cwidth - 297,12, sc.work); //upper editbox
  610.         DrawBar(246,29,Form.cwidth - 297,5,sc.work);  //under editbox
  611.         DrawRectangle(246,12,Form.cwidth - 303,16,sc.work_graph);
  612.         DefineButton(Form.cwidth - 32,6,27,28,51+BT_HIDE+BT_NOFRAME,0); //about
  613.         PutPaletteImage(#goto_about,56,34,Form.width-65,0,8,#goto_about_pal);
  614.         //main rectangles
  615.         DrawRectangle(1,40,Form.cwidth-3,onTop(46,0),sc.work_graph);
  616.         DrawRectangle(0,39,Form.cwidth-1,onTop(44,0),col_palette[4]); //bg
  617.         for (i=0; i<5; i++) DrawBar(0, 34+i, Form.cwidth, 1, col_palette[8-i]);
  618.         DrawLeftPanel();
  619.         //ListBox
  620.         DrawFlatButton(files.x,40,Form.cwidth - files.x - 159,16,31,sc.work,T_FILE);
  621.         DrawFlatButton(Form.cwidth - 159,40,73,16,32,sc.work,T_TYPE);
  622.         DrawFlatButton(Form.cwidth - 86,40,68,16,33,sc.work,T_SIZE);
  623.         DrawBar(files.x+files.w,files.y,1,onTop(22,files.y),sc.work_graph); //line to the left from the scroll
  624.         DrawFlatButton(files.x+files.w,40,16,16,0,sc.work,"\x18");
  625.         DrawFlatButton(files.x+files.w,onTop(22,0),16,16,0,sc.work,"\x19");
  626.         Open_Dir(#path,ONLY_SHOW);
  627.         if (del_active) Del_Form();
  628.         if (new_element_active) NewElement_Form(new_element_active, #new_element_name);
  629. }
  630.  
  631.  
  632. void KEdit()
  633. {
  634.         if (Form.width<480) return;
  635.         PathShow.area_size_x = Form.cwidth-306;
  636.         DrawBar(PathShow.start_x-3, PathShow.start_y-4, PathShow.area_size_x+2, 15, 0xFFFfff);
  637.         PathShow_prepare stdcall(#PathShow);
  638.         PathShow_draw stdcall(#PathShow);
  639. }
  640.  
  641.  
  642. void List_Current(signed int cur)
  643. {
  644.         if (cur<=0) //up
  645.         {
  646.                 IF (files.first==0) && (files.current<=0) return;
  647.                 IF (-cur-1<files.current)
  648.                 {
  649.                         Line_ReDraw(0xFFFFFF, files.current);
  650.                         files.current+=cur;
  651.                         Line_ReDraw(col_selec, files.current);
  652.                         return;
  653.                 }
  654.                 ELSE
  655.                 {
  656.                         IF (-cur<files.first) files.first+=cur; ELSE files.first=0;
  657.                         files.current=0;
  658.                         List_ReDraw();
  659.                         return;
  660.                 }
  661.         }
  662.         else  //down
  663.         {
  664.                 IF (files.first==files.count-files.visible) && (files.current==files.visible-1)
  665.                 {
  666.                         Line_ReDraw(col_selec, files.current);
  667.                         return;
  668.                 }
  669.                 IF (files.visible-files.current>cur)
  670.                 {
  671.                         Line_ReDraw(0xFFFFFF, files.current);
  672.                         files.current+=cur;
  673.                         Line_ReDraw(col_selec, files.current);
  674.                         return;
  675.                 }
  676.                 else
  677.                 {
  678.                         IF(files.first+files.current+cur>=files.count)
  679.                         {
  680.                                 files.first=files.count-files.visible;
  681.                                 files.current=cur-files.first+files.current;
  682.                                 }
  683.                         ELSE
  684.                         {
  685.                                 files.first+=cur+files.current-files.visible+1;
  686.                                 files.current=files.visible-1;
  687.                         }
  688.                        
  689.                         IF (files.current<0) || (files.current>files.visible)
  690.                         {
  691.                                 files.current=files.visible-1;
  692.                         }
  693.                         List_ReDraw();
  694.                 }
  695.         }
  696. }
  697.  
  698.  
  699. void List_ReDraw()
  700. {
  701.         int paint_y;
  702.         //we are in the end of the list => maximize window => there will be white lines after the last element
  703.         if (files.count-files.first<files.visible) || (files.current>files.visible-1)
  704.         { files.first=files.count-files.visible; files.current=files.visible-1; }
  705.         for (j=0; j<files.visible; j++) if (files.current!=j) Line_ReDraw(0xFFFFFF, j); else Line_ReDraw(col_selec, files.current);
  706.         //in the bottom
  707.         paint_y = j * files.line_h + files.y;
  708.         DrawBar(files.x,paint_y,files.w,onTop(paint_y,6),0xFFFFFF);
  709.         DrawBar(Form.cwidth-159,paint_y,1,onTop(paint_y,6),sc.work);
  710.         DrawBar(Form.cwidth-86,paint_y,1,onTop(paint_y,6),sc.work);
  711.         Scroll();
  712. }
  713.  
  714.  
  715. void Line_ReDraw(dword color, filenum){
  716.         dword text_col=0,
  717.               ext1, attr,
  718.               file_offet,
  719.               file_name_off,
  720.               y=filenum*files.line_h+files.y;
  721.               BDVK file;
  722.         if (filenum==-1) return;
  723.         DrawBar(files.x,y,3,files.line_h,color);
  724.         DrawBar(files.x+19,y,files.w-19,files.line_h,color);
  725.         DrawBar(files.x+3,y+17,16,1,color);
  726.         if (files.line_h>18) DrawBar(files.x+3,y+18,16,files.line_h-18,color);
  727.         if (files.line_h>15) DrawBar(files.x+3,y,16,files.line_h-15,color);
  728.  
  729.         file_offet = file_mas[filenum+files.first]*304 + buf+32;
  730.         attr = ESDWORD[file_offet];
  731.         file.selected = ESBYTE[file_offet+7];
  732.         file.sizelo   = ESDWORD[file_offet+32];
  733.         file_name_off = file_offet+40;
  734.  
  735.         if (! TestBit(attr, 4) ) //file or folder?
  736.         {      
  737.                 Put_icon(file_name_off+_strrchr(file_name_off,'.'), files.x+3, files.line_h/2-7+y, color, 0);
  738.                 WriteText(7-strlen(ConvertSize(file.sizelo))*6+Form.cwidth - 76,files.line_h-6/2+y,font_type,0,ConvertSize(file.sizelo));
  739.         }
  740.         else
  741.         {
  742.                 if (strcmp("..",file_name_off)==0) ext1=".."; else ext1="<DIR>";
  743.                 Put_icon(ext1, files.x+3, files.line_h/2-7+y, color, 0);               
  744.         }
  745.  
  746.         if (TestBit(attr, 1)) || (TestBit(attr, 2)) text_col=0xA6A6B7; //system or hiden?
  747.         if (color!=0xFFFfff)
  748.         {
  749.                 itdir = TestBit(attr, 4);
  750.                 strcpy(#file_name, file_name_off);
  751.                 strcpy(#file_path, #path);
  752.                 strcat(#file_path, #file_name);
  753.                 if (text_col==0xA6A6B7) text_col=0xFFFFFF;
  754.         }
  755.         if (file.selected) text_col=0xFF0000;
  756.         if (Form.width>=480)
  757.         {
  758.                 FileShow.start_x = files.x + 23;
  759.                 FileShow.font_color = text_col;
  760.                 FileShow.area_size_x = Form.width - 380;
  761.                 FileShow.text_pointer = file_name_off;
  762.                 FileShow.start_y = files.text_y+y;
  763.                 PathShow_prepare stdcall(#FileShow);
  764.                 PathShow_draw stdcall(#FileShow);
  765.         }
  766.         DrawBar(Form.cwidth-159,y,1,files.line_h,sc.work); //gray line 1
  767.         DrawBar(Form.cwidth-86,y,1,files.line_h,sc.work); //gray line 2
  768. }
  769.  
  770.  
  771. void Open_Dir(dword dir_path, redraw){
  772.         int errornum, maxcount;
  773.  
  774.         if (redraw!=ONLY_SHOW)
  775.         {
  776.                 if (ESBYTE[dir_path+1]!='\0') ESBYTE[dir_path+strlen(dir_path)-1] = '\0';
  777.                 if (buf) free(buf);
  778.                 errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT);
  779.                 if (ESBYTE[dir_path+1]!='\0') chrcat(dir_path, '/');
  780.                 if (errornum)
  781.                 {
  782.                         HistoryPath(ADD_NEW_PATH);
  783.                         GoBack();
  784.                         Write_Error(errornum);
  785.                         return;
  786.                 }
  787.                 maxcount = sizeof(file_mas)/sizeof(dword)-1;
  788.                 if (files.count>maxcount) files.count = maxcount;
  789.                 if (files.count>0) && (files.current==-1) files.current=0;
  790.         }
  791.         if (files.count!=-1)
  792.         {
  793.                 KEdit();
  794.                 HistoryPath(ADD_NEW_PATH);
  795.                 files.visible = files.h / files.line_h;
  796.                 IF (files.count < files.visible) files.visible = files.count;
  797.                 IF (sort_num==1) sorting_arrow_x = Form.width+60/2;
  798.                 IF (sort_num==2) sorting_arrow_x = Form.width-115;
  799.                 IF (sort_num==3) sorting_arrow_x = strlen(T_SIZE)*3-30+files.x+files.w;
  800.                 WriteText(sorting_arrow_x,45,0x80,sc.work_graph,"\x19");
  801.                 IF (redraw!=ONLY_SHOW) Sorting();
  802.                 IF (redraw!=ONLY_OPEN) List_ReDraw();
  803.         }
  804.         IF (files.count==-1) && (redraw!=ONLY_OPEN) {files.visible=files.count=0; List_ReDraw();}
  805. }
  806.  
  807.  
  808. inline Sorting()
  809. {
  810.         dword k=0, l=1;
  811.         dword file_off;
  812.         int i;
  813.         if (!strcmp(#path,"/")) //do not sort
  814.         {
  815.                 FOR(k=1;k<files.count;k++;) file_mas[k]=k;
  816.                 return;
  817.         }
  818.         FOR (j=files.count-1, file_off=files.count-1*304+buf+32; j>=0; j--, file_off-=304;)  //files | folders
  819.         {
  820.                 if (!real_files_names_case) strttl(file_off+40);
  821.                 if (TestBit(ESDWORD[file_off],4)) //directory?
  822.                 {
  823.                         file_mas[k]=j;
  824.                         k++;
  825.                 }
  826.                 else
  827.                 {
  828.                         file_mas[files.count-l]=j;
  829.                         l++;
  830.                 }
  831.         }
  832.         //sorting: files first, then folders
  833.         Sort_by_Name(0,k-1);
  834.         IF (sort_num==1) Sort_by_Name(k,files.count-1);
  835.         IF (sort_num==2) Sort_by_Type(k,files.count-1);
  836.         IF (sort_num==3) Sort_by_Size(k,files.count-1);
  837.         //make ".." first item in list
  838.         IF (k>0) && (strcmp(file_mas[0]*304+buf+72,"..")!=0)
  839.                 FOR(k--; k>0; k--;) IF (!strcmp(file_mas[k]*304+buf+72,"..")) {file_mas[k]><file_mas[0]; break;}
  840. }
  841.  
  842.  
  843. void Del_Form()
  844. {
  845.         dword selected_offset2;
  846.         int cont = 0;
  847.         byte f_count[128];
  848.         int dform_x = files.w - 220 / 2 + files.x;
  849.         if (strcmp(#file_name,".")==0) || (strcmp(#file_name,"..")==0) return;
  850.         if (del_active==2)
  851.         {
  852.                 if (itdir) ShowMessage(WAIT_DELETING_FOLDER, 0);
  853.         }
  854.         else
  855.         {
  856.                 if (!files.count) return;
  857.                 DrawPopup(dform_x,160,220,85,1,sc.work,sc.work_graph);
  858.                 WriteText(-strlen(T_DELETE_FILE)*3+110+dform_x,175,0x80,sc.work_text,T_DELETE_FILE);
  859.                 for (i=0; i<files.count; i++)
  860.                 {
  861.                         selected_offset2 = file_mas[i]*304 + buf+32 + 7;
  862.                         if (ESBYTE[selected_offset2]) cont++;
  863.                 }
  864.                 if (cont)
  865.                 {
  866.                         sprintf(#f_count,"%s%d%s",DEL_MORE_FILES_1,cont,DEL_MORE_FILES_2);
  867.                         WriteText(-strlen(#f_count)*3+110+dform_x,190,0x80,sc.work_text,#f_count);
  868.                 }
  869.                 else
  870.                 {
  871.                         IF (strlen(#file_name)<28)
  872.                         {
  873.                                 WriteText(strlen(#file_name)*3+110+dform_x+2,190,0x80,sc.work_text,"?");
  874.                                 WriteText(-strlen(#file_name)*3+110+dform_x,190,0x80,sc.work_text,#file_name);
  875.                         }
  876.                         else
  877.                         {
  878.                                 WriteText(164+dform_x,190,0x80,0,"...?");
  879.                                 ESI = 24;
  880.                                 WriteText(dform_x+20,190,0,0,#file_name);
  881.                         }
  882.                 }
  883.                 DrawFlatButton(dform_x+27,208,70,20,301,0xFFB6B5,T_YES);
  884.                 DrawFlatButton(dform_x+120,208,70,20,302,0xC6DFC6,T_NO);               
  885.                 del_active=1;
  886.         }
  887. }
  888.  
  889. int del_error;
  890. int Del_File2(dword way)
  891. {    
  892.         dword dirbuf, fcount, i, filename;
  893.         int error;
  894.         char del_from[4096];
  895.         if (isdir(way))
  896.         {
  897.                 if (error = GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL)) del_error = error;
  898.                 for (i=0; i<fcount; i++)
  899.                 {
  900.                         if (CheckEvent()==evReDraw) draw_window();
  901.                         filename = i*304+dirbuf+72;
  902.                         strcpy(#del_from, way);
  903.                         chrcat(#del_from, '/');
  904.                         strcat(#del_from, filename);
  905.                         if ( TestBit(ESDWORD[filename-40], 4) )
  906.                         {
  907.                                 Del_File2(#del_from);
  908.                         }
  909.                         else
  910.                         {
  911.                                 if (error = DeleteFile(#del_from)) del_error = error;
  912.                         }
  913.                 }
  914.         }
  915.         if (error = DeleteFile(way)) del_error = error;
  916. }
  917.  
  918.  
  919. void Del_File(byte dodel)
  920. {  
  921.         byte del_from[4096];
  922.         dword selected_offset2;
  923.         int tst, count, i;
  924.        
  925.         if (dodel==true)
  926.         {
  927.                 del_active=2;
  928.                 if (itdir) ShowMessage(WAIT_DELETING_FOLDER, 0);
  929.                 del_error = 0;
  930.                
  931.                 if (selected_count)
  932.                 {
  933.                    for (i=0; i<files.count; i++)
  934.            {
  935.                 selected_offset2 = file_mas[i]*304 + buf+32 + 7;
  936.                 if (ESBYTE[selected_offset2]) {
  937.                     strcpy(#del_from, #path);
  938.                     strcat(#del_from, file_mas[i]*304+buf+72);
  939.                     Del_File2(#del_from);
  940.                 }
  941.             }
  942.                 }
  943.                 else
  944.                 {
  945.                    Del_File2(#file_path);                      
  946.                 }
  947.                 if (del_error) Write_Error(del_error);
  948.         }
  949.         del_active=0;
  950.         DeleteButton(301);
  951.         DeleteButton(302);
  952.         Open_Dir(#path,WITH_REDRAW);
  953. }
  954.  
  955.  
  956. void SelectFile(dword that_file)
  957. {
  958.         files.first=files.current=0;
  959.         Open_Dir(#path,ONLY_OPEN);
  960.         if (!real_files_names_case) strttl(that_file);
  961.         for (i=files.count-1; i>=0; i--;)
  962.                 if (!strcmp(file_mas[i]*304+buf+72,that_file)) break;
  963.         List_Current(i);
  964.         List_ReDraw();
  965. }
  966.  
  967.  
  968. void Dir_Up()
  969. {
  970.         char cur_folder[4096];
  971.         i=strlen(#path)-1;
  972.         if (i==0) return;
  973.         path[i]=0x00;
  974.         i = strrchr(#path, '/');
  975.         strcpy(#cur_folder, #path+i);
  976.         path[i]=0x00;
  977.         SelectFile(#cur_folder);
  978. }
  979.  
  980. void Open(byte rez)
  981. {
  982.         byte temp[4096];
  983.         selected_count = 0;
  984.         if (rez)
  985.         {
  986.                 if (!strcmp(#file_name,"..")) return;
  987.                 strcpy(#temp, #file_path);
  988.                 if (path[strlen(#temp)-1]!='/') chrcat(#temp, '/'); //need "/" in the end
  989.                 RunProgram("/sys/File Managers/Eolite", #temp);
  990.                 return;
  991.         }
  992.         if (!files.count) return;
  993.         if (!itdir)
  994.         {
  995.                 if (strrchr(#file_name, '.')==0) RunProgram(#file_path, ""); else RunProgram("/sys/@open", #file_path);
  996.         }
  997.         else
  998.         {
  999.                 if (!strcmp(#file_name,"..")) { Dir_Up(); return; }
  1000.                 strcpy(#path, #file_path);
  1001.                 if (path[strlen(#path)-1]!='/') chrcat(#path, '/'); //need "/" in the end
  1002.                 files.first=files.current=0;
  1003.                 Open_Dir(#path,WITH_REDRAW);
  1004.         }
  1005. }
  1006.  
  1007.  
  1008. inline fastcall void GoBack()
  1009. {
  1010.         char cur_folder[4096];
  1011.         strcpy(#cur_folder, GetCurrentFolder());
  1012.         if (HistoryPath(GO_BACK)) SelectFile(#cur_folder);
  1013. }
  1014.  
  1015. void ShowOpenWithDialog()
  1016. {
  1017.         byte param[4097];
  1018.         param[0] = '~';
  1019.         param[1] = '\0';
  1020.         strcat(#param, #file_path);
  1021.         RunProgram("/sys/@open", #param);
  1022. }
  1023.  
  1024. void NewElement(byte newf)
  1025. {
  1026.         BDVK element_info;
  1027.         byte del_rezult, copy_rezult, info_result;
  1028.         if (newf)
  1029.         {
  1030.                 strcpy(#temp, #path);
  1031.                 strcat(#temp, new_file_ed.text);
  1032.                 info_result = GetFileInfo(#temp, #element_info);
  1033.                 switch(new_element_active)
  1034.                 {
  1035.                         case CREATE_FILE:
  1036.                                 if (info_result==5)
  1037.                                 {
  1038.                                         WriteFile(0, 0, #temp);
  1039.                                         if (EAX)
  1040.                                         {
  1041.                                                 Write_Error(EAX);
  1042.                                                 ShowMessage(NOT_CREATE_FILE, 150);
  1043.                                         }
  1044.                                 }
  1045.                                 else
  1046.                                 {
  1047.                                         notify(FILE_EXISTS);
  1048.                                 }
  1049.                                 break;
  1050.                         case CREATE_FOLDER:
  1051.                                 if (info_result==5)
  1052.                                 {
  1053.                                         CreateDir(#temp);
  1054.                                         if (EAX)
  1055.                                         {
  1056.                                                 Write_Error(EAX);
  1057.                                                 ShowMessage(NOT_CREATE_FOLDER, 150);
  1058.                                         }
  1059.                                 }
  1060.                                 else
  1061.                                 {
  1062.                                         notify(FOLDER_EXISTS);
  1063.                                 }
  1064.                                 break;
  1065.                         case RENAME_ITEM:
  1066.                                 if (info_result==5)
  1067.                                 {
  1068.                                         if (itdir)
  1069.                                         {
  1070.                                                 if (del_rezult = DeleteFile(#file_path))
  1071.                                                 {
  1072.                                                         Write_Error(del_rezult);
  1073.                                                         ShowMessage(T_DEL_ERROR_1, 150);
  1074.                                                         return;
  1075.                                                 }
  1076.                                                 if (CreateDir(#temp)) CreateDir(#file_path);
  1077.                                                 Open_Dir(#path,WITH_REDRAW);
  1078.                                                 SelectFile(new_file_ed.text);
  1079.                                         }
  1080.                                         else
  1081.                                         {
  1082.                                                 if (copy_rezult = CopyFile(#file_path,#temp))
  1083.                                                 {
  1084.                                                         Write_Error(copy_rezult);
  1085.                                                 }
  1086.                                                 else
  1087.                                                 {
  1088.                                                         Del_File(true);
  1089.                                                         SelectFile(new_file_ed.text);
  1090.                                                 }
  1091.                                         }
  1092.                                 }
  1093.                                 else
  1094.                                 {
  1095.                                         notify(FILE_EXISTS);
  1096.                                 }
  1097.                 }
  1098.                 new_element_active = 0;
  1099.                 Open_Dir(#path,WITH_REDRAW);
  1100.                 SelectFile(new_file_ed.text);
  1101.         }
  1102.         new_element_active = 0;
  1103.         Open_Dir(#path,WITH_REDRAW);
  1104. }
  1105.  
  1106. void NewElement_Form(byte crt, dword strng)
  1107. {
  1108.         int dform_x=files.w-220/2+files.x;
  1109.         if (!new_element_active)
  1110.         {
  1111.                 new_element_active = crt;
  1112.                 strcpy(#new_element_name, strng);
  1113.                 new_file_ed.size = new_file_ed.pos = strlen(strng);
  1114.         }
  1115.         DrawPopup(dform_x,160,220,85,1,sc.work,sc.work_graph);
  1116.         new_file_ed.left = dform_x+24;
  1117.         edit_box_draw  stdcall (#new_file_ed);
  1118.         DrawRectangle(new_file_ed.left-1, new_file_ed.top-1, new_file_ed.width+2, 16, 0xFFFfff);
  1119.         DrawRectangle(new_file_ed.left-2, new_file_ed.top-2, new_file_ed.width+4, 18, sc.work_graph);
  1120.         IF (new_element_active==3) DrawFlatButton(dform_x+22,208,85,22,301,0xFFB6B5,T_RENAME);
  1121.         ELSE DrawFlatButton(dform_x+27,208,70,22,301,0xFFB6B5,T_CREATE);
  1122.         DrawFlatButton(dform_x+120,208,70,22,302,0xC6DFC6,T_CANCEL);
  1123. }
  1124.  
  1125. void FnProcess(byte N)
  1126. {
  1127.         switch(N)
  1128.         {
  1129.                 case 1:
  1130.                         if (!active_about)
  1131.                         {
  1132.                                 //SwitchToAnotherThread();
  1133.                                 about_stak = malloc(4096);
  1134.                                 about_window = CreateThread(#about_dialog,about_stak+4092);
  1135.                                 break;
  1136.                         }
  1137.                         else
  1138.                         {
  1139.                                 ActivateWindow(GetProcessSlot(about_window));
  1140.                         }
  1141.                         break;
  1142.                 case 2:
  1143.                         if (!files.count) break;
  1144.                         NewElement_Form(RENAME_ITEM, #file_name);
  1145.                         break;
  1146.                 case 3:
  1147.                         IF (!itdir) RunProgram("/sys/tinypad", #file_path);
  1148.                         break;
  1149.                 case 4:
  1150.                         IF (!itdir) RunProgram("/sys/develop/heed", #file_path);
  1151.                         break;
  1152.                 case 5: //refresh cur dir & devs
  1153.                         Tip(56, T_DEVICES, 55, "-");
  1154.                         Open_Dir(#path,WITH_REDRAW);
  1155.                         pause(10);
  1156.                         LoadIniSettings();
  1157.                         GetSystemDiscs();
  1158.                         Open_Dir(#path,WITH_REDRAW);
  1159.                         DrawLeftPanel();
  1160.                         break;
  1161.                 case 6:
  1162.                         NewElement_Form(CREATE_FOLDER, T_NEW_FOLDER);
  1163.                         break;
  1164.                 case 7:
  1165.                         NewElement_Form(CREATE_FILE, T_NEW_FILE);
  1166.                         break;
  1167.                 case 8:
  1168.                         //SwitchToAnotherThread();
  1169.                         properties_stak = malloc(8096);
  1170.                         CreateThread(#properties_dialog, properties_stak+8092);
  1171.                         break;
  1172.                 case 10: //F10
  1173.                         if (!active_settings)
  1174.                         {
  1175.                                 //SwitchToAnotherThread();
  1176.                                 settings_stak = malloc(4096);
  1177.                                 settings_window = CreateThread(#settings_dialog, settings_stak+4092);
  1178.                                 break;
  1179.                         }
  1180.                         else
  1181.                         {
  1182.                                 ActivateWindow(GetProcessSlot(settings_window));
  1183.                         }
  1184.                         break;
  1185.         }
  1186. }
  1187.  
  1188. //need to remove these functiones, they are a very old shit :)
  1189. dword onTop(dword down,up) {EAX=Form.height-GetSkinHeight()-down-up;}
  1190.  
  1191.  
  1192. stop:
  1193.