Subversion Repositories Kolibri OS

Rev

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

  1. //Leency, Veliant, Punk_Joker, PavelYakov & KolibriOS Team 2008-2021
  2. //GNU GPL license.
  3.  
  4. /*
  5. BUGS:
  6. - F1 in KFM (move Properties to an external app)
  7. TODO:
  8. - 70.5 - get volume info and label
  9. */
  10.  
  11. #define ABOUT_TITLE "EOLITE 5.04 Gold"
  12. #define TITLE_EOLITE "Eolite File Manager 5.04 Gold"
  13. #define TITLE_KFM "Kolibri File Manager 2.04 Gold";
  14.  
  15. #define MEMSIZE 1024 * 250
  16. #include "../lib/clipboard.h"
  17. #include "../lib/strings.h"
  18. #include "../lib/mem.h"
  19. #include "../lib/fs.h"
  20. #include "../lib/gui.h"
  21. #include "../lib/list_box.h"
  22. #include "../lib/random.h"
  23. #include "../lib/kfont.h"
  24. #include "../lib/collection.h"
  25. #include "../lib/copyf.h"
  26.  
  27. #include "../lib/obj/libini.h"
  28. #include "../lib/obj/box_lib.h"
  29. #include "../lib/obj/libimg.h"
  30.  
  31. #include "../lib/patterns/history.h"
  32.  
  33. #include "imgs/images.h"
  34. #include "include/const.h"
  35.  
  36. struct Eolite_colors
  37. {
  38.         bool  skin_is_dark;
  39.         dword lpanel;
  40.         dword list_vert_line; //vertical line between columns in list
  41.         dword selec;
  42.         dword selec_active;
  43.         dword selec_inactive;
  44.         dword selec_text;
  45.         dword list_bg;
  46.         dword list_gb_text;
  47.         dword list_text_hidden;
  48.         dword work_gradient[24];
  49.         dword slider_bg_big;
  50.         dword slider_bg_left;
  51.         dword odd_line;
  52. } col;
  53. dword waves_pal[256];
  54.  
  55. //Global data
  56.         bool efm = false;
  57.         _history history;
  58.  
  59. //Folder data
  60.         dword buf, buf_inactive;
  61.         collection_int items=0;
  62.         int folder_count;
  63.         dword path;
  64.         bool dir_at_fat16 = NULL;
  65.  
  66. //Selected element data
  67.         byte file_path[4096];
  68.         byte file_name[256];
  69.         byte temp[4096];
  70.         bool itdir;
  71.  
  72. //Window data
  73.         proc_info Form;
  74.         int sc_slider_h;
  75.         bool scroll_used=false;
  76.         char sort_type=2;
  77.         bool sort_desc=false;
  78.         int status_bar_h;
  79.         int icon_size = 18;
  80.         char active_popin = NULL;
  81.         bool list_full_redraw;
  82.  
  83. //Threads data
  84.         dword about_thread_id;
  85.         dword settings_window;
  86.         bool active_about = false;
  87.         bool active_settings = false;
  88.         dword about_stak=0,properties_stak=0,settings_stak=0;
  89.         byte cmd_free=0;
  90.  
  91. //Multipanes
  92.         int active_panel=0;
  93.         #define PANES_COUNT 2
  94.         dword location[PANES_COUNT];
  95.         llist files, files_active, files_inactive;
  96.         collection_int selected0, selected1;
  97.         dword selected_count[PANES_COUNT]=0;
  98.  
  99. libimg_image icons16_default;
  100. libimg_image icons16_selected;
  101. libimg_image icons32_default;
  102. libimg_image icons32_selected;
  103.  
  104. byte popin_string[4096];
  105. edit_box popin_text = {200,213,180,0xFFFFFF,0x94AECE,0xFFFFFF,0xFFFFFF,0x10000000,
  106.         248,#popin_string,0,ed_focus+ed_always_focus,6,0};
  107.  
  108. PathShow_data FileShow = {0, 56,215, 8, 100, 1, 0, 0x0, 0xFFFfff, #file_name, #temp, 0};
  109.  
  110. #include "include\settings.h"
  111. #include "include\gui.h"
  112. #include "include\progress_dialog.h"
  113. #include "include\copy_and_delete.h"
  114. #include "include\sorting.h"
  115. #include "include\icons.h"
  116. #include "include\left_panel.h"
  117. #include "include\menu.h"
  118. #include "include\about.h"
  119. #include "include\properties.h"
  120.  
  121. void handle_param()
  122. {
  123.         //-p <path> : just show file/folder properties dialog
  124.         //-d <path> : delete file/folder
  125.         //-v : paste files/folder from clipboard
  126.         int i;
  127.         dword p = #param;
  128.         if (streq(#program_path+strrchr(#program_path,'/'), "KFM")) {
  129.                 efm = true;
  130.                 //now we need to restore the original app name
  131.                 //without this external operations down won't work
  132.                 strcpy(#program_path+strrchr(#program_path,'/'), "EOLITE");
  133.         }
  134.  
  135.         LoadIniSettings();
  136.  
  137.         for (i=0; i<PANES_COUNT; i++) {
  138.                 location[i] = malloc(4096);
  139.                 strcpy(location[i], #path_start);
  140.         }
  141.         path = location[0];
  142.  
  143.         if (ESBYTE[p]=='\0') return;
  144.  
  145.         if (ESBYTE[p]=='-') switch (ESBYTE[p+1])
  146.         {
  147.                 case 'p':
  148.                         strcpy(#file_path, p + 3);
  149.                         itdir = dir_exists(#file_path);
  150.                         strcpy(#file_name, p + strrchr(p, '/'));
  151.                         ESBYTE[strrchr(p, '/')+p-1] = '\0';
  152.                         strcpy(path, p + 3);
  153.                         properties_dialog();
  154.                         ExitProcess();
  155.                 case 'd':
  156.                         strcpy(path, p + 3);
  157.                         DeleteThread();
  158.                         ExitProcess();
  159.                 case 'v':
  160.                         cut_active = ESBYTE[p+2] - '0';
  161.                         strcpy(path, p + 4);
  162.                         PasteThread();
  163.                         ExitProcess();
  164.         }
  165.  
  166.         if (param[strlen(#param)-1]=='/') ESBYTE[strlen(#param)-1]=NULL; //no "/" at the end
  167.  
  168.         if (dir_exists(p)) {
  169.                 strcpy(path, p);
  170.         } else {
  171.                 if (file_exists(p)) {
  172.                         ESBYTE[strrchr(p, '/')+p-1] = '\0';
  173.                         strcpy(path, p);
  174.                         SelectFileByName(p+strlen(path)+1);
  175.                 } else {
  176.                         notify(T_NOTIFY_APP_PARAM_WRONG);
  177.                 }
  178.         }      
  179. }
  180.  
  181. void main()
  182. {
  183.         dword id;
  184.         int old_cur_y;
  185.  
  186.         load_dll(boxlib, #box_lib_init,0);
  187.         load_dll(libini, #lib_init,1);
  188.         load_dll(libimg, #libimg_init,1);
  189.  
  190.         SetAppColors();
  191.         handle_param();
  192.  
  193.         SystemDiscs.Get();
  194.         OpenDir(ONLY_OPEN);
  195.         llist_copy(#files_inactive, #files);
  196.         SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
  197.         loop() switch(@WaitEventTimeout(100))
  198.         {
  199.                 case evMouse:
  200.                         if (Form.status_window&ROLLED_UP) break;
  201.  
  202.                         if (active_popin) {
  203.                                 if (popin_string[0]!=-1) edit_box_mouse stdcall(#popin_text);
  204.                                 break;
  205.                         }
  206.                        
  207.                         mouse.get();
  208.  
  209.                         ProceedMouseGestures();
  210.  
  211.                         if (mouse.vert)
  212.                         {
  213.                                 if (files.MouseScroll(mouse.vert)) List_ReDraw();
  214.                                 break;
  215.                         }
  216.  
  217.                         if (files.MouseOver(mouse.x, mouse.y))
  218.                         {
  219.                                 //select file
  220.                                 if (mouse.key&MOUSE_LEFT) && (mouse.up)
  221.                                 {
  222.                                         GetKeyModifier();
  223.                                         old_cur_y = files.cur_y;
  224.                                         if (files.ProcessMouse(mouse.x, mouse.y)) && (!key_modifier) {
  225.                                                 List_ReDraw();
  226.                                                 break;
  227.                                         }
  228.                                         if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
  229.                                                 EventChooseFilesRange(old_cur_y, files.cur_y);
  230.                                         } else if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) {
  231.                                                 EventChooseFile(files.cur_y);
  232.                                                 DrawStatusBar();
  233.                                                 List_ReDraw();
  234.                                         } else {
  235.                                                 if (mouse.y - files.y / files.item_h + files.first == files.cur_y) EventOpen(0);
  236.                                         }
  237.                                 }
  238.                                 //file menu
  239.                                 if (mouse.key&MOUSE_RIGHT) && (mouse.up)
  240.                                 {
  241.                                         if (files.ProcessMouse(mouse.x, mouse.y)) List_ReDraw();
  242.                                         if (getElementSelectedFlag(files.cur_y) == false) unselectAll(); //on redraw selection would be flashed, see [L001]
  243.                                         EventShowListMenu();
  244.                                 }
  245.                         }
  246.  
  247.                         if (mouse.x>=files.x+files.w) && (mouse.x<=files.x+files.w+16) && (mouse.y>files.y-17) && (mouse.y<files.y)
  248.                         {
  249.                                 if (mouse.lkm) DrawRectangle3D(files.x+files.w+1,files.y-16,14,14,sc.work_dark,sc.work_light);
  250.                                 WHILE (mouse.lkm) && (files.first>0)
  251.                                 {
  252.                                         pause(8);
  253.                                         files.first--;
  254.                                         List_ReDraw();
  255.                                         mouse.get();
  256.                                 }
  257.                                 DrawRectangle3D(files.x+files.w+1,files.y-16,14,14,sc.work_light,sc.work_dark);
  258.                         }
  259.  
  260.                         if (mouse.x>=files.x+files.w) && (mouse.x<=files.x+files.w+16) && (mouse.y>files.y+files.h-16) && (mouse.y<files.y+files.h)
  261.                         {
  262.                                 if (mouse.lkm) DrawRectangle3D(files.x+files.w+1,files.y+files.h-15,14,14,sc.work_dark,sc.work_light);
  263.                                 while (mouse.lkm) && (files.first<files.count-files.visible)
  264.                                 {
  265.                                         pause(8);
  266.                                         files.first++;
  267.                                         List_ReDraw();
  268.                                         mouse.get();
  269.                                 }
  270.                                 DrawRectangle3D(files.x+files.w+1,files.y+files.h-15,14,14,sc.work_light,sc.work_dark);
  271.                         }
  272.  
  273.                         //Scrooll
  274.                         if (mouse.x>=files.x+files.w) && (mouse.x<=files.x+files.w+18) && (mouse.y>files.y)
  275.                                 && (mouse.y<files.y+files.h-18) && (mouse.lkm) && (!scroll_used) {scroll_used=true; DrawScroll(scroll_used);}
  276.                         if (scroll_used) && (!mouse.key&MOUSE_LEFT) { scroll_used=false; DrawScroll(scroll_used); }
  277.                        
  278.                         if (scroll_used)
  279.                         {
  280.                                 if (sc_slider_h/2+files.y>mouse.y) || (mouse.y<0) || (mouse.y>4000) mouse.y=sc_slider_h/2+files.y; //anee eo?ni? iaa ieiii
  281.                                 id = files.first;
  282.                                 files.first = -sc_slider_h / 2 + mouse.y -files.y * files.count;
  283.                                 files.first /= files.h - 18;
  284.                                 if (files.visible+files.first>files.count) files.first=files.count-files.visible;
  285.                                 if (files.first<0) files.first=0;
  286.                                 if (id!=files.first) List_ReDraw();
  287.                                 break;
  288.                         }
  289.  
  290.                         if (efm) && (mouse.y < files.y + files.h) && (mouse.down) {
  291.                                 if (mouse.x<Form.cwidth/2) {
  292.                                         SetActivePanel(0);
  293.                                 } else {
  294.                                         SetActivePanel(1);
  295.                                 }
  296.                         }
  297.                         break;  
  298. //Button pressed-----------------------------------------------------------------------------
  299.                 case evButton:
  300.                         id = GetButtonID();
  301.  
  302.                         if (CLOSE_BTN == id) {
  303.                                 KillProcess(about_thread_id);
  304.                                 SaveIniSettings();
  305.                                 ExitProcess();
  306.                         }
  307.  
  308.                         if (active_popin) {
  309.                                 if (POPUP_BTN2==id) { EventClosePopinForm(); break; }
  310.                                 if (POPUP_BTN1==id) { EventPopinClickOkay(); break; }
  311.  
  312.                                 if (POPIN_DISK==active_popin) {
  313.                                         active_popin = NULL;
  314.                                         EventDriveClick(id-100);
  315.                                 }
  316.  
  317.                                 if (POPIN_BREADCR==active_popin) {
  318.                                         EventClosePopinForm();
  319.                                         ClickOnBreadCrumb(id-BREADCRUMB_ID);
  320.                                 }
  321.  
  322.                                 break;                                 
  323.                         }
  324.  
  325.                         switch(id)
  326.                         {
  327.                                 case KFM_DEV_DROPDOWN_1:
  328.                                 case KFM_DEV_DROPDOWN_2:
  329.                                                 ShowPopinForm(POPIN_DISK);
  330.                                                 break;
  331.                                 case BACK_BTN...PASTE_BTN:
  332.                                                 EventToolbarButtonClick(id);
  333.                                                 break;
  334.                                 case BTN_PATH:
  335.                                 case BTN_PATH+1:
  336.                                                 ShowPopinForm(POPIN_PATH);
  337.                                                 break;
  338.                                 case BTN_BREADCRUMB:
  339.                                 case BTN_BREADCRUMB+1:
  340.                                                 ShowPopinForm(POPIN_BREADCR);
  341.                                                 break;
  342.                                 case 31...33:
  343.                                                 EventSort(id-30);
  344.                                                 break;
  345.                                 case 51:
  346.                                                 EventShowBurgerMenu();
  347.                                                 break;
  348.                                 case 52...60: //Actions
  349.                                                 FnProcess(id-50);
  350.                                                 break;
  351.                                 case 100...120:
  352.                                                 EventDriveClick(id-100);
  353.                                                 break;
  354.                                 case KFM_FUNC_ID...KFM_FUNC_ID+10:
  355.                                                 FnProcess(id-KFM_FUNC_ID);
  356.                                                 break;
  357.                         }
  358.                         break;
  359.                        
  360. //Key pressed-----------------------------------------------------------------------------
  361.                 case evKey:
  362.                         GetKeys();
  363.  
  364.                         if (Form.status_window&ROLLED_UP) break;
  365.  
  366.                         if (active_popin)
  367.                         {
  368.                                 if (key_scancode == SCAN_CODE_ESC) EventClosePopinForm();
  369.  
  370.                                 if (POPIN_DISK == active_popin) {
  371.                                         if (key_scancode >= SCAN_CODE_1)
  372.                                                 && (key_scancode <= SCAN_CODE_10) {
  373.                                                         EventDriveClick(key_scancode-2);
  374.                                                 }
  375.                                 } else {
  376.                                         if (key_scancode == SCAN_CODE_ENTER) EventPopinClickOkay();
  377.                                         if (popin_string[0] != -1) {
  378.                                                 EAX = key_editbox;
  379.                                                 edit_box_key stdcall (#popin_text);
  380.                                         }                                      
  381.                                 }
  382.                                 break;
  383.                         }
  384.  
  385.                         if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
  386.  
  387.                                 if (key_scancode == SCAN_CODE_ENTER) {
  388.                                         EventOpenSelected();
  389.                                         break;
  390.                                 }
  391.  
  392.                                 old_cur_y = files.cur_y;
  393.                                 files.ProcessKey(key_scancode);
  394.                                 EventChooseFilesRange(old_cur_y, files.cur_y);
  395.                                 break;
  396.                         }
  397.  
  398.                         if (files.ProcessKey(key_scancode))
  399.                         {
  400.                                 List_ReDraw();
  401.                                 break;
  402.                         }
  403.  
  404.                         if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL)
  405.                         {
  406.                                 switch(key_scancode)
  407.                                 {
  408.                                         case SCAN_CODE_F1...SCAN_CODE_F3:
  409.                                                         EventSort(key_scancode - 58);
  410.                                                         break;
  411.                                         case SCAN_CODE_1...SCAN_CODE_2:
  412.                                                         if (efm) {
  413.                                                                 active_panel = key_scancode - SCAN_CODE_1;
  414.                                                                 ShowPopinForm(POPIN_DISK);
  415.                                                                 break;
  416.                                                         }
  417.                                         case SCAN_CODE_3...SCAN_CODE_10:
  418.                                                         key_scancode-=2;
  419.                                                         if (key_scancode >= SystemDiscs.list.count) break;
  420.                                                         if (!efm) {
  421.                                                                 DrawRectangle(17,key_scancode*17+74,159,17, 0); //display click
  422.                                                                 pause(7);                                                                              
  423.                                                         }
  424.                                                         EventDriveClick(key_scancode);
  425.                                                         break;
  426.                                         case SCAN_CODE_KEY_X:
  427.                                                         CopyFilesListToClipboard(CUT);
  428.                                                         break;                                         
  429.                                         case SCAN_CODE_KEY_C:
  430.                                                         CopyFilesListToClipboard(COPY);
  431.                                                         break;
  432.                                         case SCAN_CODE_KEY_G:
  433.                                                         EventOpenConsoleHere();
  434.                                                         break;
  435.                                         case SCAN_CODE_KEY_V:
  436.                                                         EventPaste(path);
  437.                                                         break;
  438.                                         case SCAN_CODE_KEY_D: //set image as bg
  439.                                                         strlcpy(#temp, "\\S__",4);
  440.                                                         strcat(#temp, #file_path);
  441.                                                         RunProgram("/sys/media/kiv", #temp);
  442.                                                         break;
  443.                                         case SCAN_CODE_KEY_N:
  444.                                                         EventOpenNewEolite();
  445.                                                         break;
  446.                                         case SCAN_CODE_KEY_R:
  447.                                                         EventManualFolderRefresh();
  448.                                                         break;
  449.                                         case SCAN_CODE_ENTER:
  450.                                                         if (!itdir) ShowOpenWithDialog();
  451.                                                         else EventOpen(1);
  452.                                                         break;
  453.                                         case SCAN_CODE_KEY_A:
  454.                                                         EventChooseAllFiles(true);
  455.                                                         break;
  456.                                         case SCAN_CODE_KEY_U: //unselect all files
  457.                                                         EventChooseAllFiles(false);
  458.                                                         break;
  459.                                 }
  460.                                 break;
  461.                         }
  462.  
  463.                         switch (key_scancode)
  464.                         {
  465.                                         case SCAN_CODE_BS:
  466.                                                         Dir_Up();
  467.                                                         break;
  468.                                         case SCAN_CODE_ENTER:
  469.                                                         EventOpen(0);
  470.                                                         break;
  471.                                         case SCAN_CODE_TAB:
  472.                                                         if (!efm) break;
  473.                                                         SetActivePanel(active_panel^1);
  474.                                                         break;
  475.                                         case SCAN_CODE_MENU:
  476.                                                         mouse.x = files.x+15;
  477.                                                         mouse.y = files.cur_y - files.first * files.item_h + files.y + 5;
  478.                                                         EventShowListMenu();
  479.                                                         break;
  480.                                         case SCAN_CODE_DEL:
  481.                                                         ShowPopinForm(POPIN_DELETE);
  482.                                                         break;
  483.                                         case SCAN_CODE_SPACE:
  484.                                                         EventChooseFile(files.cur_y);
  485.                                                         DrawStatusBar();
  486.                                                         Line_ReDraw(col.selec, files.cur_y);
  487.                                                         break;
  488.                                         case SCAN_CODE_INS:
  489.                                                         EventChooseFile(files.cur_y);
  490.                                                         files.KeyDown();
  491.                                                         DrawStatusBar();
  492.                                                         List_ReDraw();
  493.                                                         break;
  494.                                         case SCAN_CODE_F1...SCAN_CODE_F10:
  495.                                                         FnProcess(key_scancode-58);
  496.                                                         break;
  497.                                         default:
  498.                                                         EventSelectFileByKeyPress();
  499.                         }                        
  500.                         break;
  501.                 case evIPC:
  502.                 case evReDraw:
  503.                         draw_window();
  504.                         if (CheckActiveProcess(Form.ID)) && (GetMenuClick()) break;
  505.                         break;
  506.                 default:
  507.                         if (!Form.status_window&ROLLED_UP) EventRefreshDisksAndFolders();
  508.         }
  509.        
  510.         if(cmd_free)
  511.         {
  512.                 if(cmd_free==2) about_stak=free(about_stak);
  513.                 else if(cmd_free==3) properties_stak=free(properties_stak);
  514.                 else if(cmd_free==4) settings_stak=free(settings_stak);
  515.                 cmd_free = false;
  516.         }
  517. }
  518.  
  519. void draw_window()
  520. {
  521.         dword i=0;
  522.         incn x;
  523.         dword title;
  524.         static int rand_n;
  525.         if (rand_n) rand_n = random(80);
  526.  
  527.         if (show_status_bar.checked) {
  528.                 #define STBAR_EOLITE_H 16
  529.                 #define STBAR_KFM_H 21
  530.                 if (efm) status_bar_h = STBAR_KFM_H;
  531.                 else status_bar_h = STBAR_EOLITE_H;
  532.         } else {
  533.                 status_bar_h = 0;
  534.         }
  535.         if (efm) title = TITLE_KFM; else title = TITLE_EOLITE;
  536.         DefineAndDrawWindow(Form.left+rand_n,Form.top+rand_n,Form.width,Form.height,0x73,NULL,title,0);
  537.         GetProcessInfo(#Form, SelfInfo);
  538.         if (Form.status_window&ROLLED_UP) return;
  539.         if (Form.height < 356) { MoveSize(OLD,OLD,OLD,356); return; }
  540.         GetProcessInfo(#Form, SelfInfo);
  541.         SetAppColors();
  542.         if (efm) {
  543.                 if (screen.width > 693) && (Form.width < 693) { MoveSize(OLD,OLD,693,OLD); return; }
  544.                 DrawBar(0, 4, Form.cwidth, SELECTY-5, sc.work);
  545.                 DrawBar(0, SELECTY+KFM2_DEVH+1, Form.cwidth, 3, sc.work);
  546.                 DrawBar(0, SELECTY-1, 1, KFM2_DEVH+2, sc.work);
  547.                 DrawBar(Form.cwidth-1, SELECTY-1, 1, KFM2_DEVH+2, sc.work);
  548.                 DrawBar(Form.cwidth/2-16, SELECTY-1, 15, KFM2_DEVH+2, sc.work);
  549.                 /*
  550.                 #define PAD 7
  551.                 #define GAP_S 26+5
  552.                 #define GAP_B 26+14
  553.                 x.set(Form.cwidth/2-DDW-203/2-GAP_S);
  554.                 while (i<200) {
  555.                         DrawTopPanelButton(i+BACK_BTN, x.inc(GAP_S), PAD, 30, false);
  556.                         DrawTopPanelButton(i+FWRD_BTN, x.inc(GAP_S), PAD, 31, false);
  557.                         DrawTopPanelButton(i+GOUP_BTN, x.inc(GAP_B), PAD, 01, false);
  558.                         DrawTopPanelButton(i+COPY_BTN, x.inc(GAP_B), PAD, 55, false);
  559.                         DrawTopPanelButton(i+CUT_BTN,  x.inc(GAP_S), PAD, 20, false);
  560.                         DrawTopPanelButton(i+PASTE_BTN,x.inc(GAP_S), PAD, 56, false);
  561.                         x.set(Form.cwidth/2-DDW-203/2-GAP_S+calc(Form.cwidth/2));
  562.                         i+=100;
  563.                 }
  564.                 //DrawTopPanelButton(51, Form.cwidth-GAP_S-PAD, PAD, -1, false); //burger menu
  565.                 */
  566.         } else {
  567.                 if (Form.width < 480) { MoveSize(OLD,OLD,480,OLD); return; }
  568.                 ESDWORD[#toolbar_pal] = sc.work;
  569.                 ESDWORD[#toolbar_pal+4] = MixColors(0, sc.work, 35);
  570.                 PutPaletteImage(#toolbar, 246, 34, 0, 0, 8, #toolbar_pal);             
  571.                 for (i=0; i<3; i++) DefineHiddenButton(toolbar_buttons_x[i]+2,7,31-5,29-5,BACK_BTN+i);
  572.                 for (i=3; i<6; i++) DefineHiddenButton(toolbar_buttons_x[i],  5,31,  29,  BACK_BTN+i);
  573.                 DrawBar(127, 8, 1, 25, sc.work_graph);
  574.                 DrawBar(246,0, Form.cwidth - 246, 34, sc.work);
  575.                 DrawDot(Form.cwidth-17,12);
  576.                 DrawDot(Form.cwidth-17,12+6);
  577.                 DrawDot(Form.cwidth-17,12+12);
  578.                 DefineHiddenButton(Form.cwidth-24,7,20,25,51+BT_NOFRAME); //dots
  579.         }
  580.         //main rectangles
  581.         DrawRectangle(1,40,Form.cwidth-3,Form.cheight - 42-status_bar_h,sc.work_graph);
  582.         DrawRectangle(0,39,Form.cwidth-1,-show_status_bar.checked*status_bar_h + Form.cheight - 40,col.work_gradient[4]); //bg
  583.         for (i=0; i<6; i++) DrawBar(0, 34+i, Form.cwidth, 1, MixColors(sc.work_dark, sc.work, i*10));
  584.         for (i=0; i<6; i++) DrawBar(0, 5-i, Form.cwidth, 1, MixColors(sc.work_light, sc.work, i*10));
  585.         llist_copy(#files_active, #files);
  586.         DrawStatusBar();
  587.         if (!getSelectedCount()) {
  588.                 OpenDir(ONLY_OPEN); //if there are no selected files -> refresh folder [L001]
  589.         }
  590.         DrawFilePanels();
  591.  
  592.         if (files.x!=files_inactive.x) {
  593.                 if (active_popin) ShowPopinForm(active_popin);
  594.         }
  595. }
  596.  
  597. void DrawButtonsAroundList()
  598. {
  599.         word sorting_arrow_x;
  600.         dword sorting_arrow_t = "\x19";
  601.         if (sort_desc) sorting_arrow_t = "\x18";
  602.         DrawFlatButtonSmall(files.x - efm,           files.y-17,files.w-141+efm,16,31,T_FILE);
  603.         DrawFlatButtonSmall(files.x + files.w - 141, files.y-17,73,16,32,T_TYPE);
  604.         DrawFlatButtonSmall(files.x + files.w -  68, files.y-17,68,16,33,T_SIZE);
  605.         DrawFlatButtonSmall(files.x + files.w,       files.y-17,16,16, 0,"\x18");
  606.         DrawFlatButtonSmall(files.x + files.w,files.y+files.h-16,16,16,0,"\x19");
  607.         if (sort_type==1) sorting_arrow_x = files.w - 141 / 2 + files.x + 18;
  608.         if (sort_type==2) sorting_arrow_x = files.x + files.w - 90;
  609.         if (sort_type==3) sorting_arrow_x = strlen(T_SIZE)*3-30+files.x+files.w;
  610.         WriteText(sorting_arrow_x,files.y-12,0x80, sc.work_text, sorting_arrow_t);
  611.         DrawBar(files.x+files.w,files.y,1,files.h,sc.work_graph);
  612.         if (efm) && (files.x<5) {
  613.                 DrawBar(files.x+files.w+16,files.y,1,files.h,EDX); //line between panel
  614.         }
  615. }
  616.  
  617. void DrawFuncButtonsInKfm()
  618. {
  619.         int i, x=0, len, min_w=0, padding;
  620.         for (i=0; i<10; i++) min_w += strlen(kfm_func[i])+2*6 + 2;
  621.         padding = Form.cwidth - min_w + 4 / 10;
  622.         for (i=0; i<10; i++) {
  623.                 len = strlen(kfm_func[i])+2*6 + padding;
  624.                 if (i==9) len = Form.cwidth - x - 3;
  625.                 DrawBar(x, Form.cheight - 19, 1, 17, sc.work);
  626.                 DrawFuncButton(x+1, Form.cheight - 19, len, i+KFM_FUNC_ID+1, i+1, kfm_func[i]);
  627.                 x += len + 2;
  628.         }
  629. }
  630.  
  631. void DrawStatusBar()
  632. {
  633.         char status_bar_str[80];
  634.         int go_up_folder_exists=0;
  635.  
  636.         if (efm) {
  637.                 DrawBar(0, Form.cheight - status_bar_h, Form.cwidth, 2, sc.work);
  638.                 DrawBar(0, Form.cheight - 2, Form.cwidth,  2, sc.work);
  639.                 DrawBar(Form.cwidth-1, Form.cheight - 19, 1,  17, sc.work);
  640.                 DrawFuncButtonsInKfm();
  641.         } else {
  642.                 if (!show_status_bar.checked) return;
  643.                 if (files.count>0) && (streq(items.get(0)*304+buf+72,"..")) go_up_folder_exists=1;
  644.                 DrawBar(0, Form.cheight - status_bar_h, Form.cwidth,  status_bar_h, sc.work);
  645.                 sprintf(#status_bar_str, T_STATUS_EVEMENTS, folder_count-go_up_folder_exists, files.count-folder_count);
  646.                 WriteText(6,Form.cheight - 13,0x80,sc.work_text,#status_bar_str);
  647.                 if (getSelectedCount()) {
  648.                         sprintf(#status_bar_str, T_STATUS_SELECTED, getSelectedCount());
  649.                         WriteText(Form.cwidth - calc(strlen(#status_bar_str)*6)-6,Form.cheight - 13,
  650.                                 0x80,sc.work_text,#status_bar_str);
  651.                 }
  652.         }
  653. }
  654.  
  655. void DrawFilePanels()
  656. {
  657.         int files_y = files.y;
  658.         int w2 = -Form.cwidth-1/2+Form.cwidth;
  659.         int h2 = Form.cheight-files_y-2 - status_bar_h;
  660.         if (!efm)
  661.         {
  662.                 SystemDiscs.Draw();
  663.                 files.SetSizes(192, 57, Form.cwidth - 210, Form.cheight - 59 - status_bar_h, files.item_h);
  664.                 DrawButtonsAroundList();
  665.                 List_ReDraw();
  666.                 DrawPathBar();
  667.         }
  668.         else
  669.         {
  670.                 llist_copy(#files_active, #files);
  671.                 llist_copy(#files, #files_inactive);
  672.  
  673.                 if (!active_panel) {
  674.                         files.SetSizes(Form.cwidth/2, files_y, w2-17, h2, files.item_h);
  675.                 } else {
  676.                         files.SetSizes(2, files_y, Form.cwidth/2-2-17, h2, files.item_h);
  677.                 }
  678.  
  679.                 files_inactive.x = files.x;
  680.                 DrawButtonsAroundList();
  681.                 path = location[active_panel^1];
  682.                 active_panel ^= 1;
  683.                 OpenDir2(WITH_REDRAW);
  684.                 active_panel ^= 1;
  685.                 if (!getSelectedCount()) files_inactive.count = files.count;
  686.                 llist_copy(#files, #files_active);
  687.  
  688.                 if (!active_panel) {
  689.                         files.SetSizes(2, files_y, Form.cwidth/2-2-17, h2, files.item_h);
  690.                 } else {
  691.                         files.SetSizes(Form.cwidth/2, files_y, w2 -17, h2, files.item_h);
  692.                 }
  693.  
  694.                 DrawButtonsAroundList();
  695.                 path = location[active_panel];
  696.                 OpenDir2(WITH_REDRAW);
  697.         }
  698. }
  699.  
  700. void OpenDir2(char redraw){
  701.         if (buf) free(buf);
  702.         if (GetDir(#buf, #files.count, path, DIRS_NOROOT)) {
  703.                 Write_Error(EAX);
  704.                 history.add(path);
  705.                 EventHistoryGoBack();
  706.                 return;
  707.         }
  708.         SetCurDir(path);
  709.         if (files.count>0) && (files.cur_y-files.first==-1) files.cur_y=0;
  710.         files.visible = math.min(files.h / files.item_h, files.count);
  711.         if (!strncmp(path, "/rd/1",5)) || (!strncmp(path, "/sys/",4))
  712.                 dir_at_fat16 = true; else dir_at_fat16 = false;
  713.         Sorting();
  714.         SystemDiscs.Draw();
  715.         list_full_redraw = true;
  716.         List_ReDraw();
  717.         DrawPathBar();
  718. }
  719.  
  720.  
  721. void OpenDir(char redraw){
  722.         int errornum;
  723.         unselectAll();
  724.         if (buf) free(buf);
  725.         if (errornum = GetDir(#buf, #files.count, path, DIRS_NOROOT)) {
  726.                 history.add(path);
  727.                 EventHistoryGoBack();
  728.                 Write_Error(errornum);
  729.                 return;
  730.         }
  731.         if (files.count>0) && (files.cur_y-files.first==-1) files.cur_y=0;
  732.         history.add(path);
  733.         SystemDiscs.Draw();
  734.         files.visible = math.min(files.h / files.item_h, files.count);
  735.         if (!strncmp(path, "/rd/1",5)) || (!strncmp(path, "/sys/",4))
  736.                 dir_at_fat16 = true; else dir_at_fat16 = false;
  737.         Sorting();
  738.         list_full_redraw = true;
  739.         SetCurDir(path);
  740.         if (redraw!=ONLY_OPEN) {
  741.                 List_ReDraw();
  742.                 DrawStatusBar();
  743.                 DrawPathBar();
  744.         }
  745. }
  746.  
  747.  
  748. void List_ReDraw()
  749. {
  750.         int all_lines_h;
  751.         dword j;
  752.         static int old_cur_y, old_first;
  753.         dword separator_color;
  754.  
  755.         files.CheckDoesValuesOkey(); //prevent some shit
  756.         if (files.count < files.visible) files.visible = files.count;
  757.  
  758.         if (list_full_redraw) || (old_first != files.first)
  759.         {
  760.                 old_cur_y = files.cur_y;
  761.                 old_first = files.first;
  762.                 list_full_redraw = false;
  763.                 goto _ALL_LIST_REDRAW;
  764.         }
  765.         if (old_cur_y != files.cur_y)
  766.         {
  767.                 if (old_cur_y-files.first<files.visible) Line_ReDraw(col.list_bg, old_cur_y-files.first);
  768.                 Line_ReDraw(col.selec, files.cur_y-files.first);
  769.                 old_cur_y = files.cur_y;
  770.                 return;
  771.         }
  772.  
  773.         _ALL_LIST_REDRAW:
  774.  
  775.         for (j=0; j<files.visible; j++) {
  776.                 if (files.cur_y-files.first!=j) Line_ReDraw(col.list_bg, j);
  777.                 else Line_ReDraw(col.selec, files.cur_y-files.first);          
  778.         }
  779.         //in the bottom
  780.         all_lines_h = j * files.item_h;
  781.         DrawBar(files.x,all_lines_h + files.y,files.w,files.h - all_lines_h, col.list_bg);
  782.         if (colored_lines.checked) separator_color = col.list_bg; else separator_color = col.list_vert_line;
  783.         DrawBar(files.x+files.w-141,all_lines_h + files.y,1,files.h - all_lines_h, separator_color);
  784.         DrawBar(files.x+files.w-68,all_lines_h + files.y,1,files.h - all_lines_h, separator_color);
  785.         DrawScroll(scroll_used);
  786. }
  787.  
  788. void Line_ReDraw(dword bgcol, filenum){
  789.         dword text_col=col.list_gb_text,
  790.                   ext1, attr,
  791.                   file_name_off,
  792.                   file_size=0,
  793.                   y=filenum*files.item_h+files.y,
  794.                   icon_y = files.item_h-icon_size/2+y;
  795.                   BDVK file;
  796.                   char full_path[4096];
  797.                   dword separator_color;
  798.                   bool current_inactive = false;
  799.         char label_file_name[4096];
  800.         if (filenum==-1) return;
  801.  
  802.         if (bgcol==col.selec) && (files.x==files_inactive.x) {
  803.                 bgcol = col.list_bg;
  804.                 current_inactive = true;
  805.         }
  806.  
  807.         DrawBar(files.x,y,4,files.item_h,bgcol);
  808.         DrawBar(files.x+4,y,icon_size,icon_y-y,bgcol);
  809.         if (files.item_h>icon_size) DrawBar(files.x+4,icon_y+icon_size,icon_size,y+files.item_h-icon_y-icon_size,bgcol);
  810.         if (colored_lines.checked) {
  811.                 if (bgcol!=col.selec) && (filenum%2) bgcol=col.odd_line;
  812.                 separator_color = bgcol;
  813.         } else {
  814.                 separator_color = col.list_vert_line;
  815.         }
  816.         DrawBar(files.x+icon_size+4,y,files.w-icon_size-4,files.item_h,bgcol);
  817.         DrawBar(files.x+files.w-141,y,1,files.item_h, separator_color);
  818.         DrawBar(files.x+files.w-68,y,1,files.item_h, separator_color);
  819.  
  820.         ESI = items.get(filenum+files.first)*304 + buf+32;
  821.         attr = ESDWORD[ESI];
  822.         file.sizelo   = ESDWORD[ESI+32];
  823.         file.sizehi   = ESDWORD[ESI+36];
  824.         file_name_off = ESI+40;
  825.         sprintf(#full_path,"%s/%s",path,file_name_off);
  826.  
  827.         if (attr&ATR_FOLDER)
  828.         {      
  829.                 if (!strcmp(file_name_off,"..")) ext1="<up>"; else {
  830.                         ext1="<DIR>";
  831.                         WriteTextCenter(files.x+files.w-140, files.text_y+y+1, 72, col.list_gb_text, ext1);
  832.                 }
  833.                 if (chrnum(path, '/')==1) && (streq(path, "/kolibrios")==false)
  834.                 && (streq(path, "/sys")==false) file_size = GetDeviceSize(#full_path);
  835.         }
  836.         else
  837.         {
  838.                 ext1 = strrchr(file_name_off,'.') + file_name_off;
  839.                 if (ext1==file_name_off) ext1 = NULL; //if no extension then show nothing
  840.                 file_size = ConvertSize64(file.sizelo, file.sizehi);
  841.                 if (ext1) && (strlen(ext1)<9) WriteTextCenter(files.x+files.w-140, files.text_y+y+1, 72, col.list_gb_text, ext1);
  842.         }
  843.         if (file_size) WriteText(7-strlen(file_size)*6+files.x+files.w-58,
  844.                         files.text_y+y+1, files.font_type, col.list_gb_text, file_size);
  845.  
  846.         if (attr&ATR_HIDDEN) || (attr&ATR_SYSTEM) text_col=col.list_text_hidden;
  847.         if (bgcol==col.selec)
  848.         {
  849.                 file_name_is_8_3(file_name_off);
  850.                 itdir = attr & ATR_FOLDER;
  851.                 strcpy(#file_name, file_name_off);
  852.                 if (streq(path,"/")) sprintf(#file_path,"%s%s",path,file_name_off);
  853.                         else sprintf(#file_path,"%s/%s",path,file_name_off);
  854.                 if (text_col==col.list_text_hidden) {
  855.                         text_col=MixColors(col.selec_text, col.list_text_hidden, 65);
  856.                 } else text_col=col.selec_text;
  857.         }
  858.         if (getElementSelectedFlag(filenum+files.first)) text_col=0xFF0000;
  859.         if (kfont.size.pt==9) || (!kfont.font)
  860.         {
  861.                 if (Form.width>=480)
  862.                 {
  863.                         FileShow.start_x = files.x + icon_size + 7;
  864.                         FileShow.font_color = text_col;
  865.                         FileShow.area_size_x = files.w - 164;
  866.                         FileShow.text_pointer = file_name_off;
  867.                         FileShow.start_y = files.text_y + y - 3;
  868.                         PathShow_prepare stdcall(#FileShow);
  869.                         PathShow_draw stdcall(#FileShow);
  870.                 }              
  871.         }
  872.         else
  873.         {
  874.                 //that shit must be it a library
  875.                 strcpy(#label_file_name, file_name_off);
  876.                 if (kfont.getsize(kfont.size.pt, #label_file_name) + 141 + 26 > files.w)
  877.                 {
  878.                         while (kfont.getsize(kfont.size.pt, #label_file_name) + 141 + 26 > files.w) {
  879.                                 ESBYTE[#label_file_name+strlen(#label_file_name)-1] = NULL;
  880.                         }
  881.                         strcpy(#label_file_name+strlen(#label_file_name)-2, "...");                    
  882.                 }
  883.                 kfont.WriteIntoWindow(files.x + icon_size+7, files.item_h - kfont.height / 2 + y,
  884.                         bgcol, text_col, kfont.size.pt, #label_file_name);
  885.         }
  886.         DrawIconByExtension(#full_path, ext1, files.x+4, icon_y, bgcol);
  887.         if (current_inactive) DrawWideRectangle(files.x+2, y, files.w-4, files.item_h, 2, col.selec);
  888. }
  889.  
  890. inline Sorting()
  891. {
  892.         dword d=0, f=1;
  893.         int j=0;
  894.         dword file_off;
  895.  
  896.         items.drop();
  897.  
  898.         if (streq(path,"/")) //do not sort root folder
  899.         {
  900.                 for(d=1;d<files.count;d++;) items.set(d, d);
  901.                 folder_count = d;
  902.                 return;
  903.         }
  904.         for (j=files.count-1, file_off=files.count-1*304+buf+32; j>=0; j--, file_off-=304;)  //files | folders
  905.         {
  906.                 if (dir_at_fat16) && (file_name_is_8_3(file_off+40)) strttl(file_off+40);
  907.                 if (ESDWORD[file_off] & ATR_FOLDER) {
  908.                         items.set(d, j);
  909.                         d++;
  910.                 } else {
  911.                         items.set(files.count-f, j);
  912.                         f++;
  913.                 }
  914.         }
  915.         folder_count = d;
  916.         //sorting: files first, then folders
  917.         Sort_by_Name(0,d-1);
  918.         if (sort_type==1) Sort_by_Name(d,files.count-1);
  919.         else if (sort_type==2) Sort_by_Type(d,files.count-1);
  920.         else if (sort_type==3) Sort_by_Size(d,files.count-1);
  921.         //reversed sorting
  922.         if (sort_desc) {
  923.                 for (j=0; j<f/2; j++) {
  924.                         items.swap(files.count-j-1, d+j);
  925.                 }
  926.                 //if (sort_type==1) for (j=0; j<d/2; j++) items[d-j]><items[j];
  927.         }
  928.         //make ".." first item in list
  929.         if (d>0) && (strncmp(items.get(0)*304+buf+72,"..",2)!=0)
  930.                 for(d--; d>0; d--;) if (!strncmp(items.get(d)*304+buf+72,"..",2)) {items.swap(d,0); break;}
  931. }
  932.  
  933.  
  934. void SelectFileByName(dword that_file)
  935. {
  936.         int ind;
  937.         files.KeyHome();
  938.         OpenDir(ONLY_OPEN);
  939.         if (dir_at_fat16) && (file_name_is_8_3(that_file)) strttl(that_file);
  940.         for (ind=files.count-1; ind>=0; ind--;) { if (!strcmpi(items.get(ind)*304+buf+72,that_file)) break; }
  941.         files.cur_y = ind - 1;
  942.         files.KeyDown();
  943.         DrawStatusBar();
  944.         List_ReDraw();
  945. }
  946.  
  947.  
  948. void Dir_Up()
  949. {
  950.         int iii;
  951.         char old_folder_name[4096];
  952.         iii=strlen(path)-1;
  953.         if (iii==0) return;
  954.         iii = strrchr(path, '/');
  955.         strcpy(#old_folder_name, path+iii);
  956.         if (iii>1) ESBYTE[path+iii-1]=NULL; else ESBYTE[path+iii]=NULL;
  957.         SelectFileByName(#old_folder_name);
  958.         DrawPathBar();
  959. }
  960.  
  961. void EventOpenSelected()
  962. {
  963.         int i;
  964.         for (i=0; i<files.count; i++) if (getElementSelectedFlag(i)) {
  965.                 EDX = items.get(i)*304 + buf+32;
  966.                 if (ESDWORD[EDX]&ATR_FOLDER) continue; //is foder
  967.                 sprintf(#param,"%s/%s",path, EDX+40);
  968.                 RunProgram("/sys/@open", #param);
  969.         }
  970. }
  971.  
  972. void EventOpen(byte _new_window)
  973. {
  974.         if (getSelectedCount()) && (!itdir) notify(T_USE_SHIFT_ENTER);
  975.         if (_new_window)
  976.         {
  977.                 if (streq(#file_name,"..")) return;
  978.                 RunProgram(I_Path, #file_path);
  979.                 return;
  980.         }
  981.         if (!files.count) return;
  982.         if (!itdir)
  983.         {
  984.                 if (strrchr(#file_name, '.')==0) RunProgram(#file_path, ""); else RunProgram("/sys/@open", #file_path);
  985.         }
  986.         else
  987.         {
  988.                 if (!strncmp(#file_name,"..",3)) { Dir_Up(); return; }
  989.                 strcpy(path, #file_path);
  990.                 files.first=files.cur_y=0;
  991.                 OpenDir(WITH_REDRAW);
  992.         }
  993. }
  994.  
  995. void EventHistoryGoBack()
  996. {
  997.         char cur_folder[4096];
  998.         strcpy(#cur_folder, path);
  999.         if (history.back()) {
  1000.                 strcpy(path, history.current());
  1001.                 SelectFileByName(#cur_folder+strrchr(#cur_folder,'/'));
  1002.                 DrawPathBar();
  1003.         }
  1004. }
  1005.  
  1006. void EventHistoryGoForward()
  1007. {
  1008.         if (history.forward()) {
  1009.                 strcpy(path, history.current());
  1010.                 files.KeyHome();
  1011.                 OpenDir(WITH_REDRAW);
  1012.                 DrawPathBar();
  1013.         }
  1014. }
  1015.  
  1016.  
  1017. void ShowOpenWithDialog()
  1018. {
  1019.         byte open_param[4097];
  1020.         sprintf(#open_param,"~%s",#file_path);
  1021.         RunProgram("/sys/@open", #open_param);
  1022. }
  1023.  
  1024. bool EventCreateAndRename()
  1025. {
  1026.         sprintf(#temp,"%s/%s",path,popin_text.text);
  1027.         if (file_exists(#temp)) {
  1028.                 notify(FS_ITEM_ALREADY_EXISTS);
  1029.                 return false;
  1030.         }
  1031.         switch(active_popin)
  1032.         {
  1033.                 case POPIN_NEW_FILE:
  1034.                                 if (CreateFile(0, 0, #temp)) goto __FAIL;
  1035.                                 break;
  1036.                 case POPIN_NEW_FOLDER:
  1037.                                 if (CreateDir(#temp)) goto __FAIL;
  1038.                                 break;
  1039.                 case POPIN_RENAME:
  1040.                                 if (RenameMove(popin_text.text, #file_path))
  1041.                                 {
  1042.                                         if (itdir) {
  1043.                                                 goto __FAIL;
  1044.                                         } else {
  1045.                                                 if (CopyFile(#file_path,#temp)) {
  1046.                                                         goto __FAIL;
  1047.                                                 } else {
  1048.                                                         DeleteFile(#file_path);
  1049.                                                 }
  1050.                                         }
  1051.                                 }
  1052.         }
  1053.         SelectFileByName(popin_text.text);
  1054.         return true;
  1055.         __FAIL:
  1056.         Write_Error(EAX);
  1057.         return false;  
  1058. }
  1059.  
  1060. void EventPopinClickOkay()
  1061. {
  1062.         switch(active_popin) {
  1063.                 case POPIN_PATH:
  1064.                         strcpy(path, #popin_string);
  1065.                         OpenDir(WITH_REDRAW);
  1066.                         break;
  1067.                 case POPIN_DELETE:
  1068.                         CopyFilesListToClipboard(DELETE);
  1069.                         EventChooseAllFiles(false);
  1070.                         sprintf(#param, "-d %s", #file_path);
  1071.                         RunProgram(#program_path, #param);
  1072.                         break; 
  1073.                 case POPIN_RENAME:
  1074.                 case POPIN_NEW_FILE:
  1075.                 case POPIN_NEW_FOLDER:
  1076.                         if (!EventCreateAndRename()) return;
  1077.         }
  1078.         EventClosePopinForm();
  1079. }
  1080.  
  1081. void EventClosePopinForm()
  1082. {
  1083.         active_popin = NULL;
  1084.         draw_window();
  1085. }
  1086.  
  1087. void ShowPopinForm(byte _popin_type)
  1088. {
  1089.         int popinx;
  1090.         popin_string[0] = -1;
  1091.         switch(_popin_type) {
  1092.                 case POPIN_PATH:
  1093.                                 edit_box_set_text stdcall (#popin_text, path);
  1094.                                 DrawEolitePopup(T_GOPATH, T_CANCEL);
  1095.                                 break;
  1096.                 case POPIN_NEW_FILE:
  1097.                                 edit_box_set_text stdcall (#popin_text, T_NEW_FILE);
  1098.                                 DrawEolitePopup(T_CREATE, T_CANCEL);
  1099.                                 break;
  1100.                 case POPIN_NEW_FOLDER:
  1101.                                 edit_box_set_text stdcall (#popin_text, T_NEW_FOLDER);
  1102.                                 DrawEolitePopup(T_CREATE, T_CANCEL);
  1103.                                 break;
  1104.                 case POPIN_RENAME:
  1105.                                 edit_box_set_text stdcall (#popin_text, #file_name);
  1106.                                 DrawEolitePopup(T_RENAME, T_CANCEL);
  1107.                                 break;
  1108.                 case POPIN_DELETE:
  1109.                                 if (!files.count) return;
  1110.                                 if (!getSelectedCount()) && (!strncmp(#file_name,"..",2)) return;
  1111.                                 popinx = DrawEolitePopup(T_YES, T_NO);
  1112.                                 WriteTextCenter(popinx, 178, POPIN_W, sc.work_text, T_DELETE_FILE);
  1113.                                 if (getSelectedCount()) {
  1114.                                         sprintf(#param,"%s%d%s",DEL_MORE_FILES_1,getSelectedCount(),DEL_MORE_FILES_2);
  1115.                                 } else {
  1116.                                         if (strlen(#file_name)<28) {
  1117.                                                 sprintf(#param,"%s ?",#file_name);
  1118.                                         } else {
  1119.                                                 strncpy(#param, #file_name, POPIN_W-20/6-4);
  1120.                                                 strcat(#param, "...?");
  1121.                                         }
  1122.                                 }
  1123.                                 WriteTextCenter(popinx, 192, POPIN_W, sc.work_text, #param);
  1124.                                 break;
  1125.                 case POPIN_DISK:
  1126.                                 DefineHiddenButton(0,0,5000,3000,POPUP_BTN2+BT_NOFRAME);
  1127.                                 if (active_panel==0) {
  1128.                                         SystemDiscs.DrawOptions(1);
  1129.                                 } else {
  1130.                                         SystemDiscs.DrawOptions(Form.cwidth/2-1);
  1131.                                 }
  1132.                                 break;
  1133.                 case POPIN_BREADCR:
  1134.                                 DefineHiddenButton(0,0,5000,3000,POPUP_BTN2+BT_NOFRAME);
  1135.                                 DrawBreadCrumbs();
  1136.                                 break;
  1137.         }
  1138.         active_popin = _popin_type;
  1139. }
  1140.  
  1141. void EventShowAbout()
  1142. {
  1143.         if (!active_about) {
  1144.                 about_stak = malloc(4096);
  1145.                 about_thread_id = CreateThread(#about_dialog,about_stak+4092);
  1146.         } else {
  1147.                 ActivateWindow(GetProcessSlot(about_thread_id));
  1148.         }
  1149. }
  1150.  
  1151. void FnProcess(byte N)
  1152. {
  1153.         switch(N)
  1154.         {
  1155.                 case 1:
  1156.                         EventShowProperties();
  1157.                         break;
  1158.                 case 2:
  1159.                         if (files.count) ShowPopinForm(POPIN_RENAME);
  1160.                         break;
  1161.                 case 3:
  1162.                         if (files.count) && (!itdir) RunProgram("/sys/quark", #file_path);
  1163.                         break;
  1164.                 case 4:
  1165.                         if (files.count) && (!itdir) RunProgram("/sys/develop/cedit", #file_path);
  1166.                         break;
  1167.                 case 5:
  1168.                         if (efm) {
  1169.                                 CopyFilesListToClipboard(COPY);
  1170.                                 EventPaste(location[active_panel^1]);
  1171.                         } else {
  1172.                                 EventManualFolderRefresh();
  1173.                         }
  1174.                         break;
  1175.                 case 6:
  1176.                         if (efm) {
  1177.                                 CopyFilesListToClipboard(CUT);
  1178.                                 EventChooseAllFiles(false);
  1179.                                 EventPaste(location[active_panel^1]);
  1180.                         }
  1181.                         break;
  1182.                 case 7:
  1183.                         ShowPopinForm(POPIN_NEW_FOLDER);
  1184.                         break;
  1185.                 case 8:
  1186.                         ShowPopinForm(POPIN_DELETE);
  1187.                         break;
  1188.                 case 9:
  1189.                         ShowPopinForm(POPIN_NEW_FILE);
  1190.                         break;
  1191.                 case 10: //F10
  1192.                         if (active_settings) {
  1193.                                 ActivateWindow(GetProcessSlot(settings_window));
  1194.                         } else {
  1195.                                 settings_stak = malloc(4096);
  1196.                                 settings_window = CreateThread(#settings_dialog, settings_stak+4092);
  1197.                         }
  1198.                         break;
  1199.         }
  1200. }
  1201.  
  1202. void SetActivePanel(int _active)
  1203. {
  1204.         if (active_panel != _active) { 
  1205.                 active_panel = _active;
  1206.                 llist_copy(#files_active, #files_inactive);
  1207.                 llist_copy(#files_inactive, #files);
  1208.                 llist_copy(#files, #files_active);
  1209.                 path = location[active_panel];
  1210.                 DrawFilePanels();
  1211.         }
  1212. }
  1213.  
  1214. void EventSelectFileByKeyPress()
  1215. {
  1216.         int i;
  1217.         for (i=files.cur_y+1; i<files.count; i++)
  1218.         {
  1219.                 strcpy(#temp, items.get(i)*304+buf+72);
  1220.                 if (temp[0]==key_ascii) || (temp[0]==key_ascii-32)
  1221.                 {
  1222.                         files.cur_y = i - 1;
  1223.                         files.KeyDown();
  1224.                         List_ReDraw();
  1225.                         return;
  1226.                 }
  1227.         }
  1228. }
  1229.  
  1230. dword GetDeviceSize(dword p)
  1231. {
  1232.         BDVK bdvk;
  1233.         if (ESBYTE[p+1] == '/') p++;
  1234.         if (ESBYTE[p+1] == 'c') && (ESBYTE[p+2] == 'd')
  1235.                 && (ESBYTE[p+4] == 0) return 0;
  1236.         if (GetFileInfo(p, #bdvk)) {
  1237.                 return 0;
  1238.         } else {
  1239.                 ConvertSize64(bdvk.sizelo, bdvk.sizehi);
  1240.         }
  1241. }
  1242.  
  1243. int GetRealFileCountInFolder(dword folder_path)
  1244. {
  1245.         int fcount;
  1246.         dword countbuf;
  1247.  
  1248.         GetDir(#countbuf, #fcount, folder_path, DIRS_NOROOT);
  1249.         if (countbuf) free(countbuf);
  1250.  
  1251.         return fcount;
  1252. }
  1253.  
  1254. void EventRefreshDisksAndFolders()
  1255. {
  1256.         if(efm) {
  1257.                 if (GetRealFileCountInFolder(location[active_panel^1]) != files_inactive.count) {
  1258.                         DrawFilePanels();
  1259.                         return;
  1260.                 }
  1261.         } else {
  1262.                 if (GetRealFileCountInFolder("/")+dir_exists("/kolibrios") != SystemDiscs.dev_num) {
  1263.                         SystemDiscs.Get();
  1264.                         SystemDiscs.Draw();
  1265.                 }
  1266.         }
  1267.         if(GetRealFileCountInFolder(path) != files.count) OpenDir(WITH_REDRAW);
  1268. }
  1269.  
  1270. void EventManualFolderRefresh()
  1271. {
  1272.         Tip(56, T_DEVICES, 55, "-");
  1273.         pause(10);
  1274.         DrawFilePanels();
  1275. }
  1276.  
  1277. void EventSort(dword id)
  1278. {
  1279.         char selected_filename[256];
  1280.         if (sort_type == id) sort_desc ^= 1;
  1281.         else sort_type = id;
  1282.         strcpy(#selected_filename, #file_name);
  1283.         DrawButtonsAroundList();
  1284.         OpenDir(WITH_REDRAW);
  1285.         SelectFileByName(#selected_filename);
  1286. }
  1287.  
  1288. void EventOpenNewEolite()
  1289. {
  1290.         RunProgram(I_Path, path);
  1291. }
  1292.  
  1293. void EventOpenConsoleHere()
  1294. {
  1295.         sprintf(#param, "pwd cd %s", path);
  1296.         RunProgram("/sys/shell", #param);
  1297. }
  1298.  
  1299. void ProceedMouseGestures()
  1300. {
  1301.         char stats;
  1302.         signed x_old, y_old, dif_x, dif_y, adif_x, adif_y;
  1303.         if (!mouse.mkm) && (stats>0) stats = 0;
  1304.         if (mouse.mkm) && (!stats)
  1305.         {
  1306.                 x_old = mouse.x;
  1307.                 y_old = mouse.y;
  1308.                 stats = 1;
  1309.         }
  1310.         if (mouse.mkm) && (stats==1)
  1311.         {
  1312.                 dif_x = mouse.x-x_old;
  1313.                 dif_y = mouse.y-y_old;
  1314.                 adif_x = fabs(dif_x);
  1315.                 adif_y = fabs(dif_y);
  1316.                
  1317.                 if (adif_x>adif_y) {
  1318.                         if (dif_x > 150) {
  1319.                                 EventHistoryGoForward();
  1320.                                 stats = 0;
  1321.                         }
  1322.                         if (dif_x < -150) {
  1323.                                 EventHistoryGoBack();
  1324.                                 stats = 0;
  1325.                         }
  1326.                 } else {
  1327.                         if (dif_y < -100) {
  1328.                                 Dir_Up();
  1329.                                 stats = 0;
  1330.                         }
  1331.                 }
  1332.         }
  1333. }
  1334.  
  1335. void EventPaste(dword _into_path) {
  1336.         char paste_line[4096+6];
  1337.         sprintf(#paste_line, "-v%i %s", cut_active, _into_path);
  1338.         RunProgram(#program_path, #paste_line);
  1339.         EventClosePopinForm();
  1340. }
  1341.  
  1342. void EventShowProperties()
  1343. char line_param[4096+5];
  1344. {
  1345.         if (!getSelectedCount()) {
  1346.                 sprintf(#line_param, "-p %s", #file_path);
  1347.                 RunProgram(#program_path, #line_param);
  1348.         } else {
  1349.                 properties_stak = malloc(8096);
  1350.                 CreateThread(#properties_dialog, properties_stak+8092);
  1351.         }
  1352. }
  1353.  
  1354. void EventChooseFile(int _id)
  1355. {
  1356.         if (getElementSelectedFlag(_id) == true) {
  1357.                 setElementSelectedFlag(_id, false);
  1358.         } else {
  1359.                 setElementSelectedFlag(_id, true);
  1360.         }
  1361. }
  1362.  
  1363. void EventChooseFilesRange(int _start, _end)
  1364. {
  1365.         if (_start > _end) _start >< _end;
  1366.         if (_end - _start > 1) list_full_redraw = true;
  1367.         while (_start < _end) {
  1368.                 EventChooseFile(_start);
  1369.                 _start++;
  1370.         }
  1371.         DrawStatusBar();
  1372.         List_ReDraw();
  1373. }
  1374.  
  1375. void EventChooseAllFiles(dword state)
  1376. {
  1377.         int i;
  1378.         for (i=0; i<files.count; i++) setElementSelectedFlag(i, state);
  1379.         List_ReDraw();
  1380.         DrawStatusBar();
  1381. }
  1382.  
  1383. void EventToolbarButtonClick(int _btid)
  1384. {
  1385.         switch(_btid) {
  1386.                 case BACK_BTN: EventHistoryGoBack(); break;
  1387.                 case FWRD_BTN: EventHistoryGoForward(); break;
  1388.                 case GOUP_BTN: Dir_Up(); break;
  1389.                 case COPY_BTN: CopyFilesListToClipboard(CUT); break;
  1390.                 case CUT_BTN:  CopyFilesListToClipboard(COPY); break;
  1391.                 case PASTE_BTN:EventPaste(path); break;        
  1392.         }
  1393. }
  1394.  
  1395. void EventDriveClick(int __id)
  1396. {
  1397.         if (__id >= SystemDiscs.list.count) return;
  1398.         if (efm) {
  1399.                 EventClosePopinForm();
  1400.                 draw_window();
  1401.         }
  1402.         strcpy(path, SystemDiscs.list.get(__id));
  1403.         files.KeyHome();
  1404.         OpenDir(WITH_REDRAW);  
  1405. }
  1406.  
  1407. stop:
  1408.