Subversion Repositories Kolibri OS

Rev

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