Subversion Repositories Kolibri OS

Rev

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