Subversion Repositories Kolibri OS

Rev

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