Subversion Repositories Kolibri OS

Rev

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