Subversion Repositories Kolibri OS

Rev

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

  1. //Leency & Veliant 2008-2013
  2. //GNU GPL licence.
  3.  
  4. //libraries
  5. #define MEMSIZE 0xA0000
  6. #include "..\lib\kolibri.h"
  7. #include "..\lib\strings.h"
  8. #include "..\lib\mem.h"
  9. #include "..\lib\dll.h"
  10. #include "..\lib\lib.obj\box_lib.h"
  11. #include "..\lib\file_system.h"
  12. #include "..\lib\figures.h"
  13. #include "..\lib\encoding.h"
  14. #include "..\lib\list_box.h"
  15. #include "..\lib\copyf.h"
  16. //images
  17. #include "imgs\toolbar.txt"
  18. #include "imgs\left_p.txt"
  19.  
  20. #ifndef AUTOBUILD
  21. #include "lang.h--"
  22. #endif
  23.  
  24. #ifdef LANG_RUS
  25.         ?define T_FILE "” ©«"
  26.         ?define T_TYPE "’¨¯"
  27.         ?define T_SIZE " §¬¥à"
  28.         ?define T_NEW_FOLDER "®¢ ï ¯ ¯ª "
  29.         ?define T_NEW_FILE "®¢ë© ä ©«"
  30.         ?define T_DELETE_FILE "‚ë ¤¥©á⢨⥫쭮 å®â¨â¥ 㤠«¨âì"
  31.         ?define T_YES "„ "
  32.         ?define T_NO "¥â"
  33.         ?define T_DEL_ERROR_1 "Žè¨¡ª .  ¯ª  ­¥ ¯ãáâ ï."
  34.         ?define T_DEL_ERROR_2 "Žè¨¡ª . ” ©«®¢ ï á¨á⥬  ⮫쪮 ¤«ï ç⥭¨ï."
  35.         ?define NOT_CREATE_FOLDER "¥ 㤠«®áì ᮧ¤ âì ¯ ¯ªã."
  36.         ?define NOT_CREATE_FILE "¥ 㤠«®áì ᮧ¤ âì ä ©«."
  37.         ?define ERROR_1 "Žè¨¡ª  ¯à¨ § £à㧪¥ ¡¨¡«¨®â¥ª¨ /rd/1/lib/box_lib.obj"
  38.         ?define T_PASTE_WINDOW "Š®¯¨àãî..."
  39.         ?define T_PASTE_WINDOW_TEXT "Š®¯¨àã¥âáï ä ©«:"
  40. #else
  41.         ?define T_FILE "File"
  42.         ?define T_TYPE "Type"
  43.         ?define T_SIZE "Size"
  44.         ?define T_NEW_FOLDER "New folder"
  45.         ?define T_NEW_FILE "New file"
  46.         ?define T_DELETE_FILE "Do you really want to delete"
  47.         ?define T_YES "Yes"
  48.         ?define T_NO "No"
  49.         ?define T_DEL_ERROR_1 "Error. Folder isn't empty."
  50.         ?define T_DEL_ERROR_2 "Error. Filesystem read-only."
  51.         ?define NOT_CREATE_FOLDER "Folder can not be created."
  52.         ?define NOT_CREATE_FILE "File can not be created."
  53.         ?define ERROR_1 "Error while loading library /rd/1/lib/box_lib.obj"
  54.         ?define T_PASTE_WINDOW "Copying..."
  55.         ?define T_PASTE_WINDOW_TEXT "Copying file:"
  56. #endif
  57.  
  58. enum {ONLY_SHOW, WITH_REDRAW, ONLY_OPEN}; //OpenDir
  59.  
  60. #define TITLE "Eolite File Manager v1.95"
  61. #define ABOUT_TITLE "Eolite v1.95"
  62. dword col_work    = 0xE4DFE1;
  63. dword col_border  = 0x9098B0; //A0A0B8; //0x819FC5;
  64. dword col_padding = 0xC8C9C9;
  65. dword col_selec   = 0x94AECE;
  66. dword col_lpanel  = 0x00699C;
  67.  
  68. int toolbar_buttons_x[7]={9,46,85,134,167,203};
  69. char tmp_disk_del_param[3]="d0";
  70. struct path_string { char Item[4096]; };
  71.  
  72. llist files;
  73.  
  74. byte
  75.         path[4096],
  76.         file_path[4096],
  77.         file_name[256],
  78.         temp[4096];      
  79. byte
  80.         rename_active=0,
  81.         del_active=0,
  82.         show_dev_name=1,
  83.         sort_num=2,
  84.         itdir;
  85.  
  86. proc_info Form;
  87. mouse m;
  88. int mouse_dd, scroll_used, scroll_size;
  89. dword buf, off;
  90. dword file_mas[6898];
  91. int j, i;
  92.  
  93. edit_box edit2= {250,213,80,0xFFFFCC,0x94AECE,0xFFFFCC,0xffffff,0,248,#file_name,#mouse_dd,64,6,6};
  94. PathShow_data PathShow = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, #path, #temp, 0};
  95. PathShow_data FileShow = {0, 56,215, 6, 100, 0, 0, 0x0, 0xFFFfff, #file_name, #temp, 0};
  96.  
  97. #include "include\copypaste.h"
  98. #include "include\some_code.h"
  99. #include "include\sorting.h"
  100. #include "include\icons_f.h"
  101. #include "include\ini.h"
  102. #include "include\left_panel.h"
  103. #include "include\history.h"
  104. #include "include\file_menu.h"
  105. #include "include\about_dialog.h"
  106.  
  107. void main()
  108. {
  109.         word key, id, can_show, can_select, m_selected;
  110.  
  111.         files.line_h=18;
  112.         mem_Init();
  113.         if (load_dll2(boxlib, #box_lib_init,0)!=0) notify(ERROR_1);
  114.         SystemDiscsGet();
  115.         GetIni(1);     
  116.         if (param)
  117.         {
  118.                 strcpy(#path, #param);
  119.                 if (path[strlen(#path)-1]!='/') chrcat(#path, '/'); //add "/" to the end of the string
  120.         }
  121.         else
  122.         {
  123.                 strcpy(#path, "/rd/1/");               
  124.         }
  125.         Open_Dir(#path,ONLY_OPEN);
  126.         SetEventMask(0x27);
  127.         loop() switch(WaitEvent())
  128.         {
  129.                 case evMouse:
  130.                         IF (del_active) break;         
  131.                         id=GetProcessSlot(Form.ID);
  132.                         IF (id!=GetActiveProcess()) || (Form.status_window>2) break;
  133.                         IF (rename_active) { edit_box_mouse stdcall(#edit2); break; }
  134.                        
  135.                         m.get();
  136.  
  137.                         if (m.x > files.x) && (m.x < files.x + files.w) && (m.y > files.y) && (m.y < files.y+files.h) && (!can_select)
  138.                         {
  139.                                 m_selected = m.y - 57 / files.line_h;
  140.                                 if (m.lkm) can_select = 1;
  141.                                 if (m.pkm)
  142.                                 {
  143.                                         can_show = 1;
  144.                                         if (m.y - 57 / files.line_h != files.current) can_select = 1;
  145.                                 }
  146.                         }
  147.  
  148.                         //select/open file {
  149.                         if (!m.lkm) && (!m.pkm) && (can_select)
  150.                         {
  151.                                 can_select = 0;
  152.                                 if (m.y>=57)
  153.                                 {
  154.                                         id = m.y - 57 / files.line_h;
  155.                                         if (id!=m_selected)
  156.                                         {
  157.                                                 can_show=0;
  158.                                                 break;
  159.                                         }
  160.                                         if (files.current!=id)
  161.                                         {
  162.                                                 if (id<files.visible) List_Current(id-files.current);
  163.                                         }
  164.                                         else
  165.                                                 Open();
  166.                                 }
  167.                         };
  168.                         // } select/open file
  169.  
  170.                         //file menu {
  171.                         if (!m.pkm) && (!m.lkm) && (can_show)
  172.                         {
  173.                                 can_show = 0;
  174.                                 if (m.y>=57)
  175.                                 {
  176.                                         SwitchToAnotherThread();
  177.                                         CreateThread(#FileMenu,#menu_stak);
  178.                                 }
  179.                                 break;
  180.                         }
  181.                         // } file menu
  182.  
  183.                         if (m.vert)
  184.                         {
  185.                                 files.MouseScroll(m.vert);
  186.                                 List_ReDraw();
  187.                                 break;
  188.                         }
  189.  
  190.                         if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>40) && (m.y<57)
  191.                         {
  192.                                 IF (m.lkm==1) DrawRectangle3D(onLeft(26,0),41,14,14,0xC7C7C7,0xFFFFFF);
  193.                                 WHILE (m.lkm==1) && (files.first>0)
  194.                                 {
  195.                                         pause(8);
  196.                                         files.first--;
  197.                                         List_ReDraw();
  198.                                         m.get();
  199.                                 }
  200.                                 DrawRectangle3D(onLeft(26,0),41,14,14,0xFFFFFF,0xC7C7C7);
  201.                         }
  202.  
  203.                         if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>onTop(22,0)+1) && (m.y<onTop(22,0)+16)
  204.                         {
  205.                                 IF (m.lkm==1) DrawRectangle3D(onLeft(26,0),onTop(21,0),14,14,0xC7C7C7,0xFFFFFF);
  206.                                 while (m.lkm==1) && (files.first<files.count-files.visible)
  207.                                 {
  208.                                         pause(8);
  209.                                         files.first++;
  210.                                         List_ReDraw();
  211.                                         m.get();
  212.                                 }
  213.                                 DrawRectangle3D(onLeft(26,0),onTop(21,0),14,14,0xFFFFFF,0xC7C7C7);
  214.                         }
  215.  
  216.                         //Scrooll
  217.                         if (!m.lkm) && (scroll_used) { scroll_used=NULL; Scroll(); }
  218.                         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();}
  219.                        
  220.                         if (scroll_used)
  221.                         {
  222.                                 IF (scroll_size/2+57>m.y) || (m.y<0) || (m.y>4000) m.y=scroll_size/2+57; //anee eo?ni? iaa ieiii
  223.                                 id=files.first;
  224.                                 j= scroll_size/2;
  225.                                 files.first = m.y -j -57 * files.count;
  226.                                 files.first /= onTop(22,57);
  227.                                 IF (files.visible+files.first>files.count) files.first=files.count-files.visible;
  228.                                 IF (id!=files.first) List_ReDraw();
  229.                         }
  230.                         break;  
  231. //Button pressed-----------------------------------------------------------------------------
  232.                 case evButton:
  233.                         id=GetButtonID();
  234.                         if (id==1) ExitProcess();
  235.                         if (rename_active) break;
  236.                         if (del_active)
  237.                         {
  238.                                 IF (id==301) || (id==302) Del_File(302-id);
  239.                                 break;
  240.                         }
  241.                        
  242.                         switch(id)
  243.                         {
  244.                                 case 21: //Back
  245.                                                 GoBack();
  246.                                                 break;
  247.                                 case 22: //Forward
  248.                                                 if (HistoryPath(GO_FORWARD))
  249.                                                 {
  250.                                                         files.first=files.current=NULL; //aaa?o nienea
  251.                                                         Open_Dir(#path,WITH_REDRAW);
  252.                                                 }
  253.                                                 break;
  254.                                 case 23: //up!
  255.                                                 Dir_Up();
  256.                                                 break;
  257.                                 case 24: //cut
  258.                                                 Copy(#file_path, CUT);
  259.                                                 break;
  260.                                 case 25: //copy
  261.                                                 Copy(#file_path, NOCUT);
  262.                                                 break;
  263.                                 case 26: //paste
  264.                                                 CreateThread(#Paste,#copy_stak);
  265.                                                 break;
  266.                                 case 31...33: //sort
  267.                                                 IF(sort_num==1) DrawFilledBar(onLeft(192,168)/2+210,42,6,10);
  268.                                                 IF(sort_num==2) DrawFilledBar(onLeft(115,0),42,6,10);
  269.                                                 IF(sort_num==3) DrawFilledBar(onLeft(44,0),42,6,10);
  270.                                                 sort_num=id-30;
  271.                                                 Open_Dir(#path,WITH_REDRAW);
  272.                                                 break;
  273.                                 case 50...60: //Actions
  274.                                                 FnProcess(id-50);
  275.                                                 break;
  276.                                 case 100...120:
  277.                                         DEVICE_MARK:
  278.                                                 DrawRectangle(17,id-100*16+74,159,16, 0); //auaaeaiea
  279.                                                 strcpy(#path, #disk_list[id-100].Item);
  280.                                                 files.first=files.current=0;
  281.                                                 Open_Dir(#path,WITH_REDRAW);
  282.                                                 pause(5);
  283.                                                 DrawRectangle(17,id-100*16+74,159,16, 0xFFFFFF);
  284.                                                 break;
  285.                                 case 130...160:
  286.                                                 tmp_disk_del_param[1]=disk_list[id-130].Item[4];
  287.                                                 RunProgram("/sys/tmpdisk", #tmp_disk_del_param);
  288.                                                 pause(10);
  289.                                                 SystemDiscsGet();
  290.                                                 Open_Dir(#path,WITH_REDRAW);
  291.                                                 DrawLeftPanel();
  292.                                                 break;
  293.                         }
  294.                         break;
  295. //Key pressed-----------------------------------------------------------------------------
  296.                 case evKey:
  297.                         key = GetKey();
  298.                         if (Form.status_window>2) break;
  299.                         IF (del_active)
  300.                         {
  301.                                 IF (key==013) Del_File(true);
  302.                                 IF (key==027) Del_File(false);
  303.                                 break;
  304.                         }
  305.                         IF (edit2.flags!=64) && (key!=13) && (key!=27)
  306.                         {
  307.                                 EAX=key<<8;
  308.                                 edit_box_key stdcall (#edit2);
  309.                                 break;
  310.                         }
  311.                         switch (key)
  312.                         {
  313.                                         case 209...217:
  314.                                                         id=key-110;
  315.                                                         IF (id-100>=disc_num) break;
  316.                                                         GOTO DEVICE_MARK;
  317.                                         case 008:
  318.                                                         //GoBack();
  319.                                                         Dir_Up();
  320.                                                         break;
  321.                                         case 004: //Ctrl+D set as bg
  322.                                                         strcpy(#temp, "\\S__");
  323.                                                         strcat(#temp, #file_path);
  324.                                                         RunProgram("/sys/media/kiv", #temp);
  325.                                                         break;
  326.                                         case 014: //Ctrl+N new window
  327.                                                         IF (Form.left==98) MoveSize(Form.left-20,Form.top-20,OLD,OLD);
  328.                                                         RunProgram("/sys/File Managers/Eolite", #path);
  329.                                                         break;
  330.                                         case 024: //Ctrl+X
  331.                                                         Copy(#file_path, CUT);
  332.                                                         break;
  333.                                         case 003: //Ctrl+C
  334.                                                         Copy(#file_path, NOCUT);
  335.                                                         break;
  336.                                         case 022: //Ctrl+V
  337.                                                         CreateThread(#Paste,#copy_stak);
  338.                                                         break;
  339.                                         case 027: //Esc
  340.                                                         IF (rename_active==1) ReName(false);
  341.                                                         break;
  342.                                         case 013: //Enter
  343.                                                         IF (rename_active==1) {ReName(true); break;}
  344.                                                         Open();
  345.                                                         break;
  346.                                         case 178: //up
  347.                                                         List_Current(-1);
  348.                                                         break;
  349.                                         case 177: //down
  350.                                                         List_Current(1);
  351.                                                         break;
  352.                                         case 180: //home
  353.                                                         files.first=0;
  354.                                                         files.current=0;
  355.                                                         List_ReDraw();
  356.                                                         break;
  357.                                         case 181: //end
  358.                                                         files.first = files.count - files.visible;
  359.                                                         files.current = files.visible - 1;
  360.                                                         List_ReDraw();
  361.                                                         break;
  362.                                         case 183: //Page Down
  363.                                                         List_Current(files.visible-1);
  364.                                                         break;
  365.                                         case 184: //Page Up
  366.                                                         List_Current(-files.visible+1);
  367.                                                         break;
  368.                                         case 182: //del
  369.                                                         Del_Form();
  370.                                                         break;
  371.                                         case 050...059: //F1-F10
  372.                                                         FnProcess(key-49);
  373.                                                         break;
  374.                                         default:    
  375.                                                         for (i=files.current+files.first+1; i<files.count; i++)
  376.                                                         {
  377.                                                                 strcpy(#temp, file_mas[i]*304+buf+72);
  378.                                                                 IF (temp[0]==key) || (temp[0]==key-32)
  379.                                                                 {
  380.                                                                         List_Current(i-files.current-files.first);
  381.                                                                         break;
  382.                                                                 }
  383.                                                         }
  384.                         }                        
  385.                         break;
  386.                 case evReDraw:
  387.                         draw_window();
  388.         }
  389. }
  390.  
  391.  
  392. void draw_window()
  393. {
  394.         DefineAndDrawWindow(40,20,550,500,0x73,col_work,TITLE);
  395.         GetProcessInfo(#Form, SelfInfo);
  396.         if (Form.status_window>2) return;
  397.         files.SetSizes(192, 57, onLeft(192,27), onTop(57,6), disc_num*16+195,files.line_h);
  398.         if (Form.height < files.min_h) MoveSize(OLD,OLD,OLD,files.min_h);
  399.         if (Form.width<480) MoveSize(OLD,OLD,480,OLD);
  400.         GetProcessInfo(#Form, SelfInfo); //if win_size changed
  401.  
  402.         PutPaletteImage(#toolbar,246,34,0,0,8,#toolbar_pal);
  403.         DrawBar(127, 8, 1, 25, col_border);
  404.         for (j=0; j<3; j++) DefineButton(toolbar_buttons_x[j]+2,5+2,31-5,29-5,21+j+BT_HIDE,col_work);
  405.         for (j=3; j<6; j++) DefineButton(toolbar_buttons_x[j],5,31,29,21+j+BT_HIDE,col_work);
  406.         DrawBar(246,0,onLeft(246,60),12, col_work); //upper editbox
  407.         DrawBar(246,29,onLeft(246,60),5,col_work);  //under editbox
  408.         DrawRectangle(246,12,onLeft(66,246),16,col_border);
  409.         DefineButton(onLeft(34,0),6,27,28,51+BT_HIDE+BT_NOFRAME,0); //about
  410.         PutPaletteImage(#goto_about,56,34,Form.width-65,0,8,#goto_about_pal);
  411.         //main rectangles
  412.         DrawRectangle(1,40,Form.cwidth-3,onTop(46,0),col_border);
  413.         DrawRectangle(0,39,Form.cwidth-1,onTop(44,0),col_palette[4]); //bg
  414.         for (i=0; i<5; i++) DrawBar(0, 34+i, Form.cwidth, 1, col_palette[8-i]);
  415.         DrawLeftPanel();
  416.         //ListBox
  417.         DrawFlatButton(files.x,40,onLeft(files.x,168),16,31,col_work,T_FILE);
  418.         DrawFlatButton(onLeft(168,0),40,73,16,32,col_work,T_TYPE);
  419.         DrawFlatButton(onLeft(95,0),40,68,16,33,col_work,T_SIZE);
  420.         DrawBar(onLeft(27,0),57,1,onTop(22,57),col_border); //line to the left from the scroll
  421.         DrawFlatButton(onLeft(27,0),40,16,16,0,col_work,"\x18");
  422.         DrawFlatButton(onLeft(27,0),onTop(22,0),16,16,0,col_work,"\x19");
  423.         Open_Dir(#path,ONLY_SHOW);
  424.         if (del_active) Del_Form();
  425.         if (rename_active) FnProcess(2);
  426. }
  427.  
  428.  
  429. void KEdit()
  430. {
  431.         if (Form.width<480) return;
  432.         PathShow.area_size_x = Form.cwidth-306;
  433.         DrawBar(PathShow.start_x-3, PathShow.start_y-4, PathShow.area_size_x+2, 15, 0xFFFfff);
  434.         PathShow_prepare stdcall(#PathShow);
  435.         PathShow_draw stdcall(#PathShow);
  436. }
  437.  
  438.  
  439. void List_Current(int cur)
  440. {
  441.         if (cur<=0) //up
  442.         {
  443.                 IF (files.first==0) && (files.current<=0) return;
  444.                 IF (-cur-1<files.current)
  445.                 {
  446.                         Line_ReDraw(0xFFFFFF, files.current);
  447.                         files.current+=cur;
  448.                         Line_ReDraw(col_selec, files.current);
  449.                         return;
  450.                 }
  451.                 ELSE
  452.                 {
  453.                         IF (-cur<files.first) files.first+=cur; ELSE files.first=0;
  454.                         files.current=0;
  455.                         List_ReDraw();
  456.                         return;
  457.                 }
  458.         }
  459.         else  //down
  460.         {
  461.                 IF (files.first==files.count-files.visible) && (files.current==files.visible-1) return;
  462.                 IF (files.visible-files.current>cur)
  463.                 {
  464.                         Line_ReDraw(0xFFFFFF, files.current);
  465.                         files.current+=cur;
  466.                         Line_ReDraw(col_selec, files.current);
  467.                         return;
  468.                 }
  469.                 else
  470.                 {
  471.                         IF(files.first+files.current+cur>=files.count)
  472.                         {
  473.                                 files.first=files.count-files.visible;
  474.                                 files.current=cur-files.first+files.current;
  475.                                 }
  476.                         ELSE
  477.                         {
  478.                                 files.first+=cur+files.current-files.visible+1;
  479.                                 files.current=files.visible-1;
  480.                         }
  481.                        
  482.                         IF (files.current<0) || (files.current>files.visible)
  483.                         {
  484.                                 files.current=files.visible-1;
  485.                         }
  486.                         List_ReDraw();
  487.                 }
  488.         }
  489. }
  490.  
  491.  
  492. void List_ReDraw()
  493. {
  494.         int paint_y;
  495.         //we are in the end of the list => maximize window => there will be white lines after the last element
  496.         if (files.count-files.first<files.visible) || (files.current>files.visible-1)
  497.         { files.first=files.count-files.visible; files.current=files.visible-1; }
  498.         for (j=0; j<files.visible; j++) if (files.current!=j) Line_ReDraw(0xFFFFFF, j); else Line_ReDraw(col_selec, files.current);
  499.         //in the bottom
  500.         paint_y = j * files.line_h + files.y;
  501.         DrawBar(files.x,paint_y,files.w,onTop(paint_y,6),0xFFFFFF);
  502.         DrawBar(Form.cwidth-159,paint_y,1,onTop(paint_y,6),col_work);
  503.         DrawBar(Form.cwidth-86,paint_y,1,onTop(paint_y,6),col_work);
  504.         Scroll();
  505. }
  506.  
  507.  
  508. void Line_ReDraw(dword color, filenum){
  509.         dword text_col=0,
  510.               name_len=0,
  511.               attr,
  512.               y=filenum*files.line_h+57;
  513.         DrawBar(files.x,y,3,files.line_h,color);
  514.         DrawBar(files.x+19,y,files.w-19,files.line_h,color);
  515.         DrawBar(files.x+3,y+17,16,1,color);
  516.         if (files.line_h>18) DrawBar(files.x+3,y+18,16,files.line_h-18,color);
  517.         if (files.line_h>15) DrawBar(files.x+3,y,16,files.line_h-15,color);
  518.  
  519.         off=file_mas[filenum+files.first]*304 + buf+72;
  520.         attr = ESDWORD[off - 40];
  521.  
  522.         if (! TestBit(attr, 4) ) //file or folder?
  523.         {      
  524.                 Put_icon(off+_strrchr(off,'.'), files.line_h/2-7+y, color);
  525.                 WriteText(7-strlen(ConvertMemSize(ESDWORD[off-8]))*6+onLeft(75,0),files.line_h-6/2+y,0x80,0,ConvertMemSize(ESDWORD[off-8])); //size
  526.         }
  527.         else
  528.                 if (!strcmp("..",off))
  529.                         Put_icon("..", files.line_h/2-7+y, color);
  530.                 else
  531.                         Put_icon("<DIR>", files.line_h/2-7+y, color);
  532.         if ( TestBit(attr, 1) ) || ( TestBit(attr, 2) ) text_col=0xA6A6B7; //system or hiden?
  533.         if (color!=0xFFFfff)
  534.         {
  535.                 itdir = TestBit(attr, 4);
  536.                 strcpy(#file_name, off);
  537.                 strcpy(#file_path, #path);
  538.                 strcat(#file_path, #file_name);
  539.                 if (text_col==0xA6A6B7) text_col=0xFFFFFF;
  540.         }
  541.         if (Form.width>=480)
  542.         {
  543.                 FileShow.start_x = files.x + 23;
  544.                 FileShow.font_color = text_col;
  545.                 FileShow.area_size_x = Form.width - 380;
  546.                 FileShow.text_pointer = off;
  547.                 FileShow.start_y = files.line_h/2-3+y;
  548.                 PathShow_prepare stdcall(#FileShow);
  549.                 PathShow_draw stdcall(#FileShow);
  550.         }
  551.         DrawBar(Form.cwidth-159,y,1,files.line_h,col_work); //gray line 1
  552.         DrawBar(Form.cwidth-86,y,1,files.line_h,col_work); //gray line 2
  553. }
  554.  
  555.  
  556. void Open_Dir(dword dir_path, redraw){
  557.         int errornum, maxcount;
  558.  
  559.         if (redraw!=ONLY_SHOW)
  560.         {
  561.                 if (ESBYTE[dir_path+1]!='\0') ESBYTE[dir_path+strlen(dir_path)-1] = '\0';
  562.                 if (buf) free(buf);
  563.                 errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT);
  564.                 if (ESBYTE[dir_path+1]!='\0') chrcat(dir_path, '/');
  565.                 if (errornum)
  566.                 {
  567.                         HistoryPath(ADD_NEW_PATH);
  568.                         GoBack();
  569.                         Write_Error(errornum);
  570.                         return;
  571.                 }
  572.                 maxcount = sizeof(file_mas)/sizeof(dword)-1;
  573.                 if (files.count>maxcount) files.count = maxcount;              
  574.         }
  575.         if (files.count!=-1)
  576.         {
  577.                 KEdit();
  578.                 HistoryPath(ADD_NEW_PATH);
  579.                 files.visible = files.h / files.line_h;
  580.                 IF (files.count < files.visible) files.visible = files.count;
  581.                 IF (sort_num==1) WriteText(Form.width+60/2,45,0x80,col_border,"\x19");
  582.                 IF (sort_num==2) WriteText(Form.width-115,45,0x80,col_border,"\x19");
  583.                 IF (sort_num==3) WriteText(Form.width-44,45,0x80,col_border,"\x19");
  584.                 IF (redraw!=ONLY_SHOW) Sorting();
  585.                 IF (redraw!=ONLY_OPEN) List_ReDraw();
  586.         }
  587.         IF (files.count==-1) && (redraw!=ONLY_OPEN) {files.visible=files.count=0; List_ReDraw();}
  588. }
  589.  
  590.  
  591. inline Sorting()
  592. {
  593.         dword k=0, l=1;
  594.         int i;
  595.         if (!strcmp(#path,"/")) //do not sort
  596.         {
  597.                 FOR(k=1;k<files.count;k++;) file_mas[k]=k;
  598.                 return;
  599.         }
  600.         FOR (j=files.count-1, off=files.count-1*304+buf+32; j>=0; j--, off-=304;)  //files | folders
  601.         {
  602.                 strttl(off+40);
  603.                 if (TestBit(ESDWORD[off],4)) //directory?
  604.                 {
  605.                         file_mas[k]=j;
  606.                         k++;
  607.                 }
  608.                 else
  609.                 {
  610.                         file_mas[files.count-l]=j;
  611.                         l++;
  612.                 }
  613.         }
  614.         //sorting: files first, then folders
  615.         Sort_by_Name(0,k-1);
  616.         IF (sort_num==1) Sort_by_Name(k,files.count-1);
  617.         IF (sort_num==2) Sort_by_Type(k,files.count-1);
  618.         IF (sort_num==3) Sort_by_Size(k,files.count-1);
  619.         //".." should be first
  620.         IF (k>0) && (strcmp(file_mas[0]*304+buf+72,"..")!=0)
  621.                 FOR(k--; k>0; k--;) IF (!strcmp(file_mas[k]*304+buf+72,"..")) {file_mas[k]><file_mas[0]; break;}
  622. }
  623.  
  624.  
  625. void Del_Form()
  626. {
  627.         int dform_x = files.w - 200 / 2 + files.x;
  628.         //oeia ieii
  629.         if (!files.count) return;
  630.         #ifdef LANG_RUS
  631.         DrawFlatButton(dform_x,160,215,80,0,col_work, ""); //oi?ia
  632.         #else
  633.         DrawFlatButton(dform_x,160,200,80,0,col_work, ""); //oi?ia
  634.         #endif
  635.         WriteText(dform_x+19,175,0x80,0,T_DELETE_FILE);
  636.         IF (strlen(#file_name)<28)
  637.                 {
  638.                         WriteText(strlen(#file_name)*6+dform_x+20,190,0x80,0,"?");
  639.                         WriteText(dform_x+20,190,0x80,0,#file_name); //ieoai eiy
  640.                 }
  641.         ELSE
  642.                 {
  643.                         WriteText(164+dform_x,190,0x80,0,"...?");
  644.                         ESI = 24;
  645.                         WriteText(dform_x+20,190,0,0,#file_name); //ieoai eiy
  646.                 }
  647.         DrawFlatButton(dform_x+20,208,70,20,301,0xFFB6B5,T_YES);
  648.         DrawFlatButton(dform_x+111,208,70,20,302,0xC6DFC6,T_NO);
  649.         del_active=1;
  650. }
  651.  
  652.        
  653. void Del_File(byte dodel)
  654. {    
  655.         int del_rezult;
  656.         IF (dodel==true)
  657.         {
  658.                 del_rezult = DeleteFile(#file_path);
  659.                 IF (del_rezult)
  660.                 {
  661.                         Write_Error(del_rezult);
  662.                         IF ( itdir) ShowMessage(T_DEL_ERROR_1);
  663.                         IF (!itdir) ShowMessage(T_DEL_ERROR_2);
  664.                 }
  665.         }
  666.         del_active=0;
  667.         DeleteButton(301); DeleteButton(302);
  668.         Open_Dir(#path,WITH_REDRAW);
  669. }
  670.  
  671.  
  672. void ReName(byte rename)
  673. {
  674.         int del_rezult, copy_rezult;
  675.         char edit_name[256];
  676.         rename_active=0;
  677.         edit2.flags=64;
  678.         if (rename==true)
  679.         {
  680.                 strcpy(#temp, #path);
  681.                 strcpy(#edit_name, #file_name); //save edit name to select it later
  682.                 strcat(#temp, #file_name);
  683.                 if (strcmp(#file_path,#temp)!=0) && (file_name)
  684.                 if (itdir)
  685.                 {
  686.                         del_rezult = DeleteFile(#file_path);
  687.                         if (del_rezult!=0)
  688.                         {
  689.                                 Write_Error(del_rezult);
  690.                                 ShowMessage(T_DEL_ERROR_1);
  691.                                 return;
  692.                         }
  693.                         ELSE CreateDir(#temp);
  694.                         Open_Dir(#path,WITH_REDRAW);
  695.                 }
  696.                 else
  697.                 {
  698.                         copy_rezult = CopyFile(#file_path,#temp);
  699.                         if (copy_rezult!=0) Write_Error(copy_rezult); else Del_File(true);
  700.                 }
  701.                 SelectFile(#edit_name);
  702.         }
  703.         Line_ReDraw(col_selec,files.current);
  704. }
  705.  
  706.  
  707. void SelectFile(dword that_file)
  708. {
  709.         files.first=files.current=0;
  710.         Open_Dir(#path,ONLY_OPEN);
  711.         strttl(that_file);
  712.         for (i=files.count-1; i>=0; i--;)
  713.                 if (!strcmp(file_mas[i]*304+buf+72,that_file)) break;
  714.         List_Current(i);
  715.         List_ReDraw();
  716. }
  717.  
  718.  
  719. void Dir_Up()
  720. {
  721.         char cur_folder[4096];
  722.         i=strlen(#path)-1;
  723.         if (i==0) return;
  724.         path[i]=0x00;
  725.         i = strrchr(#path, '/');
  726.         strcpy(#cur_folder, #path+i);
  727.         path[i]=0x00;
  728.         SelectFile(#cur_folder);
  729. }
  730.  
  731. void Open()
  732. {
  733.         if (!files.count) return;
  734.         if (!itdir)
  735.         {
  736.                 GetIni(0);
  737.         }
  738.         else
  739.         {
  740.                 if (!strcmp(#file_name,"..")) { Dir_Up(); return; }
  741.                 strcpy(#path, #file_path);
  742.                 if (path[strlen(#path)-1]!='/') chrcat(#path, '/'); //need "/" in the end
  743.                 files.first=files.current=0;
  744.                 Open_Dir(#path,WITH_REDRAW);
  745.         }
  746. }
  747.  
  748.  
  749. inline fastcall void GoBack()
  750. {
  751.         char cur_folder[4096];
  752.         strcpy(#cur_folder, GetCurrentFolder());
  753.         if (HistoryPath(GO_BACK)) SelectFile(#cur_folder);
  754. }
  755.  
  756. void FnProcess(char N)
  757. {
  758.         switch(N)
  759.         {
  760.                 case 1:
  761.                         SwitchToAnotherThread();
  762.                         CreateThread(#about_dialog,#about_stak);
  763.                         break;
  764.                 case 2:
  765.                         if (!files.count) break;
  766.                         edit2.flags = 100000000000010b; //set active
  767.                         edit2.left = files.x + 21;
  768.                         edit2.width = files.w - 26;
  769.                         edit2.top=files.current*files.line_h+59;
  770.                         edit2.size=edit2.pos=strlen(#file_name);
  771.                         edit_box_draw  stdcall (#edit2);
  772.                         DrawBar(edit2.left,files.current*files.line_h+58,edit2.width+1,1,0xFFFFCC); //bg
  773.                         rename_active=1;
  774.                         break;
  775.                 case 3:
  776.                         IF (!itdir) RunProgram("/sys/tinypad", #file_path);
  777.                         break;
  778.                 case 4:
  779.                         IF (!itdir) RunProgram("/sys/develop/heed", #file_path);
  780.                         break;
  781.                 case 5: //refresh cur dir & devs
  782.                         Tip(56, T_DEVICES, 55, "-");
  783.                         Open_Dir(#path,WITH_REDRAW);
  784.                         pause(10);
  785.                         GetIni(1);
  786.                         SystemDiscsGet();
  787.                         Open_Dir(#path,WITH_REDRAW);
  788.                         DrawLeftPanel();
  789.                         break;
  790.                 case 6:
  791.                         strcpy(#temp, #path);
  792.                         strcat(#temp, T_NEW_FOLDER);
  793.                         CreateDir(#temp);
  794.                         if (!EAX){
  795.                                 SelectFile(T_NEW_FOLDER);
  796.                                 FnProcess(2);
  797.                         }
  798.                         else
  799.                         {
  800.                                 Write_Error(EAX);
  801.                                 ShowMessage(NOT_CREATE_FOLDER);
  802.                         }
  803.                         break;
  804.                 case 7:
  805.                         strcpy(#temp, #path);
  806.                         strcat(#temp, T_NEW_FILE);
  807.                         WriteFile(0, 0, #temp);
  808.                         if (!EAX){
  809.                                 SelectFile(T_NEW_FILE);
  810.                                 FnProcess(2);
  811.                         }
  812.                         else
  813.                         {
  814.                                 Write_Error(EAX);
  815.                                 ShowMessage(NOT_CREATE_FILE);
  816.                         }
  817.                         break;
  818.                 case 10: //F10
  819.                         RunProgram(EDITOR_PATH, abspath("Eolite.ini"));
  820.                         break;
  821.         }
  822. }
  823.  
  824.  
  825. stop:
  826.  
  827. char about_stak[512];
  828. char menu_stak[512];
  829. char copy_stak[4096];
  830.