Subversion Repositories Kolibri OS

Rev

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