Subversion Repositories Kolibri OS

Rev

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