Subversion Repositories Kolibri OS

Rev

Rev 9727 | 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.26"
  15. #define TITLE_EOLITE "Eolite File Manager 5.26"
  16. #define TITLE_KFM "Kolibri File Manager 2.26";
  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.                                                 edit_box_key_c stdcall (#popin_text, key_editbox);
  384.                                         }
  385.                                 }
  386.                                 break;
  387.                         }
  388.  
  389.                         if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT)
  390.                         {
  391.                                 if (key_scancode == SCAN_CODE_ENTER) {
  392.                                         EventOpenSelected();
  393.                                         break;
  394.                                 }
  395.                                 old_cur_y = files.cur_y;
  396.                                 files.ProcessKey(key_scancode);
  397.                                 EventChooseFilesRange(old_cur_y, files.cur_y);
  398.                                 break;
  399.                         }
  400.  
  401.                         if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL)
  402.                         {
  403.                                 switch(key_scancode)
  404.                                 {
  405.                                         case SCAN_CODE_F1...SCAN_CODE_F3:
  406.                                                         EventSort(key_scancode - 58);
  407.                                                         break;
  408.                                         case SCAN_CODE_1...SCAN_CODE_2:
  409.                                                         if (efm) {
  410.                                                                 active_panel = key_scancode - SCAN_CODE_1;
  411.                                                                 ShowPopinForm(POPIN_DISK);
  412.                                                                 break;
  413.                                                         }
  414.                                         case SCAN_CODE_3...SCAN_CODE_10:
  415.                                                         key_scancode-=2;
  416.                                                         if (key_scancode >= SystemDiscs.list.count) break;
  417.                                                         if (!efm) {
  418.                                                                 DrawRectangle(17,key_scancode*17+74,159,17, 0); //display click
  419.                                                                 pause(7);
  420.                                                         }
  421.                                                         EventDriveClick(key_scancode);
  422.                                                         break;
  423.                                         case SCAN_CODE_KEY_X:
  424.                                                         CopyFilesListToClipboard(CUT);
  425.                                                         break;
  426.                                         case SCAN_CODE_KEY_C:
  427.                                                         CopyFilesListToClipboard(COPY);
  428.                                                         break;
  429.                                         case SCAN_CODE_KEY_G:
  430.                                                         EventOpenConsoleHere();
  431.                                                         break;
  432.                                         case SCAN_CODE_KEY_V:
  433.                                                         EventPaste(path);
  434.                                                         break;
  435.                                         case SCAN_CODE_KEY_S: //set image as bg tile
  436.                                                         sprintf(#temp, "\\S__%s",#file_path);
  437.                                                         RunProgram("/sys/media/kiv", #temp);
  438.                                                         break;
  439.                                         case SCAN_CODE_KEY_T: //set image as bg stretch
  440.                                                         sprintf(#temp, "\\T__%s",#file_path);
  441.                                                         RunProgram("/sys/media/kiv", #temp);
  442.                                                         break;
  443.                                         case SCAN_CODE_KEY_N:
  444.                                                         EventOpenNewEolite();
  445.                                                         break;
  446.                                         case SCAN_CODE_KEY_R:
  447.                                                         EventManualFolderRefresh();
  448.                                                         break;
  449.                                         case SCAN_CODE_ENTER:
  450.                                                         if (!itdir) ShowOpenWithDialog();
  451.                                                         else EventOpen(1);
  452.                                                         break;
  453.                                         case SCAN_CODE_KEY_A:
  454.                                                         EventChooseAllFiles(true);
  455.                                                         break;
  456.                                         case SCAN_CODE_KEY_U: //unselect all files
  457.                                                         EventChooseAllFiles(false);
  458.                                                         break;
  459.                                 }
  460.                                 break;
  461.                         }
  462.  
  463.                         switch (calc(key_scancode))
  464.                         {
  465.                                         case SCAN_CODE_BS:
  466.                                                         Dir_Up();
  467.                                                         break;
  468.                                         case SCAN_CODE_ENTER:
  469.                                                         EventOpen(0);
  470.                                                         break;
  471.                                         case SCAN_CODE_TAB:
  472.                                                         if (!efm) break;
  473.                                                         SetActivePanel(active_panel^1);
  474.                                                         break;
  475.                                         case SCAN_CODE_MENU:
  476.                                                         mouse.x = files.x+15;
  477.                                                         mouse.y = files.cur_y - files.first * files.item_h + files.y + 5;
  478.                                                         EventShowListMenu();
  479.                                                         break;
  480.                                         case SCAN_CODE_DEL:
  481.                                                         ShowPopinForm(POPIN_DELETE);
  482.                                                         break;
  483.                                         case SCAN_CODE_SPACE:
  484.                                                         EventChooseFile(files.cur_y);
  485.                                                         DrawStatusBar();
  486.                                                         Line_ReDraw(col.selec, files.cur_y);
  487.                                                         break;
  488.                                         case SCAN_CODE_INS:
  489.                                                         EventChooseFile(files.cur_y);
  490.                                                         files.KeyDown();
  491.                                                         DrawStatusBar();
  492.                                                         List_ReDraw();
  493.                                                         break;
  494.                                         case SCAN_CODE_F1...SCAN_CODE_F10:
  495.                                                         FnProcess(key_scancode-58);
  496.                                                         break;
  497.                                         case SCAN_CODE_DOWN:
  498.                                         case SCAN_CODE_UP:
  499.                                         case SCAN_CODE_HOME:
  500.                                         case SCAN_CODE_END:
  501.                                         case SCAN_CODE_PGUP:
  502.                                         case SCAN_CODE_PGDN:
  503.                                                         if (files.ProcessKey(key_scancode)) List_ReDraw();
  504.                                                         break;
  505.                                         default:
  506.                                                         EventSelectFileByKeyPress();
  507.                         }
  508.                         break;
  509.                 case evIPC:
  510.                 case evReDraw:
  511.                         draw_window();
  512.                         if (CheckActiveProcess(Form.ID)) && (GetMenuClick()) break;
  513.                         break;
  514.                 default:
  515.                         if (!Form.status_window&ROLLED_UP)
  516.                         && (ESBYTE[path+1]!='f') && (ESBYTE[path+1]!='c') {
  517.                                 EventRefreshDisksAndFolders();
  518.                         }
  519.         }
  520.  
  521.         if(cmd_free)
  522.         {
  523.                 if(cmd_free==2) about_stak=free(about_stak);
  524.                 else if(cmd_free==3) properties_stak=free(properties_stak);
  525.                 else if(cmd_free==4) settings_stak=free(settings_stak);
  526.                 cmd_free = false;
  527.         }
  528. }
  529.  
  530. void draw_window()
  531. {
  532.         dword i=0;
  533.         incn x;
  534.         dword title;
  535.         static int rand_n;
  536.         if (!rand_n) rand_n = random(80);
  537.  
  538.         if (show_status_bar.checked) {
  539.                 #define STBAR_EOLITE_H 16
  540.                 #define STBAR_KFM_H 21
  541.                 if (efm) status_bar_h = STBAR_KFM_H;
  542.                 else status_bar_h = STBAR_EOLITE_H;
  543.         } else {
  544.                 status_bar_h = 0;
  545.         }
  546.         if (efm) title = TITLE_KFM; else title = TITLE_EOLITE;
  547.         DefineAndDrawWindow(Form.left+rand_n,Form.top+rand_n,Form.width,Form.height,0x73,NULL,title,0);
  548.         GetProcessInfo(#Form, SelfInfo);
  549.         if (Form.status_window&ROLLED_UP) return;
  550.         if (Form.height < 356) { MoveSize(OLD,OLD,OLD,356); return; }
  551.         GetProcessInfo(#Form, SelfInfo);
  552.         SetAppColors();
  553.         if (efm) {
  554.                 if (screen.w > 693) && (Form.width < 693) { MoveSize(OLD,OLD,693,OLD); return; }
  555.                 DrawBar(0, 4, Form.cwidth, SELECTY-5, sc.work);
  556.                 DrawBar(0, SELECTY+KFM2_DEVH+1, Form.cwidth, 3, sc.work);
  557.                 DrawBar(0, SELECTY-1, 1, KFM2_DEVH+2, sc.work);
  558.                 DrawBar(Form.cwidth-1, SELECTY-1, 1, KFM2_DEVH+2, sc.work);
  559.                 DrawBar(Form.cwidth/2-16, SELECTY-1, 15, KFM2_DEVH+2, sc.work);
  560.                 /*
  561.                 #define PAD 7
  562.                 #define GAP_S 26+5
  563.                 #define GAP_B 26+14
  564.                 x.set(Form.cwidth/2-DDW-203/2-GAP_S);
  565.                 while (i<200) {
  566.                         DrawTopPanelButton(i+BACK_BTN, x.inc(GAP_S), PAD, 30, false);
  567.                         DrawTopPanelButton(i+FWRD_BTN, x.inc(GAP_S), PAD, 31, false);
  568.                         DrawTopPanelButton(i+GOUP_BTN, x.inc(GAP_B), PAD, 01, false);
  569.                         DrawTopPanelButton(i+COPY_BTN, x.inc(GAP_B), PAD, 55, false);
  570.                         DrawTopPanelButton(i+CUT_BTN,  x.inc(GAP_S), PAD, 20, false);
  571.                         DrawTopPanelButton(i+PASTE_BTN,x.inc(GAP_S), PAD, 56, false);
  572.                         x.set(Form.cwidth/2-DDW-203/2-GAP_S+calc(Form.cwidth/2));
  573.                         i+=100;
  574.                 }
  575.                 //DrawTopPanelButton(51, Form.cwidth-GAP_S-PAD, PAD, -1, false); //burger menu
  576.                 */
  577.         } else {
  578.                 if (Form.width < 480) { MoveSize(OLD,OLD,480,OLD); return; }
  579.                 ESDWORD[#toolbar_pal] = sc.work;
  580.                 ESDWORD[#toolbar_pal+4] = MixColors(0, sc.work, 35);
  581.                 PutPaletteImage(#toolbar, 246, 34, 0, 0, 8, #toolbar_pal);
  582.                 for (i=0; i<3; i++) DefineHiddenButton(toolbar_buttons_x[i]+2,7,31-5,29-5,BACK_BTN+i);
  583.                 for (i=3; i<6; i++) DefineHiddenButton(toolbar_buttons_x[i],  5,31,  29,  BACK_BTN+i);
  584.                 DrawBar(127, 8, 1, 25, sc.line);
  585.                 DrawBar(246,0, Form.cwidth - 246, 34, sc.work);
  586.                 DrawDot(Form.cwidth-17,12);
  587.                 DrawDot(Form.cwidth-17,12+6);
  588.                 DrawDot(Form.cwidth-17,12+12);
  589.                 DefineHiddenButton(Form.cwidth-24,7,20,25,51+BT_NOFRAME); //dots
  590.         }
  591.         //main rectangles
  592.         DrawRectangle(1,40,Form.cwidth-3,Form.cheight - 42-status_bar_h,sc.line);
  593.         DrawBar(0,39,1,-show_status_bar.checked*status_bar_h + Form.cheight - 40, sc.work);
  594.         EBX = Form.cwidth-1 * 65536 + 1;
  595.         $int 64
  596.         for (i=0; i<6; i++) DrawBar(0, 34+i, Form.cwidth, 1, MixColors(sc.dark, sc.work, i*10));
  597.         for (i=0; i<6; i++) DrawBar(0, 5-i, Form.cwidth, 1, MixColors(sc.light, sc.work, i*10));
  598.         llist_copy(#files_active, #files);
  599.         DrawStatusBar();
  600.         if (!getSelectedCount()) {
  601.                 OpenDir(ONLY_OPEN); //if there are no selected files -> refresh folder [L001]
  602.         }
  603.         DrawFilePanels();
  604.  
  605.         if (files.x!=files_inactive.x) {
  606.                 if (active_popin) ShowPopinForm(active_popin);
  607.         }
  608. }
  609.  
  610. void DrawButtonsAroundList()
  611. {
  612.         word sorting_arrow_x;
  613.         dword sorting_arrow_t = "\x19";
  614.         if (sort_desc) sorting_arrow_t = "\x18";
  615.         DrawFlatButtonSmall(files.x - efm,           files.y-17,files.w-141+efm,16,31,T_FILE);
  616.         DrawFlatButtonSmall(files.x + files.w - 141, files.y-17,73,16,32,T_TYPE);
  617.         DrawFlatButtonSmall(files.x + files.w -  68, files.y-17,68,16,33,T_SIZE);
  618.         DrawFlatButtonSmall(files.x + files.w,       files.y-17,16,16, 0,"\x18");
  619.         DrawFlatButtonSmall(files.x + files.w,files.y+files.h-16,16,16,0,"\x19");
  620.         if (sort_type==1) sorting_arrow_x = files.w - 141 / 2 + files.x + 18;
  621.         if (sort_type==2) sorting_arrow_x = files.x + files.w - 90;
  622.         if (sort_type==3) sorting_arrow_x = strlen(T_SIZE)*3-30+files.x+files.w;
  623.         WriteText(sorting_arrow_x,files.y-12,0x80, sc.work_text, sorting_arrow_t);
  624.         DrawBar(files.x+files.w,files.y,1,files.h,sc.line);
  625.         if (efm) && (files.x<5) {
  626.                 DrawBar(files.x+files.w+16,files.y,1,files.h,EDX); //line between panel
  627.         }
  628. }
  629.  
  630. void DrawFuncButtonsInKfm()
  631. {
  632.         int i, x=0, len, min_w=0, padding;
  633.         for (i=0; i<10; i++) min_w += strlen(kfm_func[i])+2*6 + 2;
  634.         padding = Form.cwidth - min_w + 4 / 10;
  635.         for (i=0; i<10; i++) {
  636.                 len = strlen(kfm_func[i])+2*6 + padding;
  637.                 if (i==9) len = Form.cwidth - x - 3;
  638.                 DrawBar(x, Form.cheight - 19, 1, 17, sc.work);
  639.                 DrawFuncButton(x+1, Form.cheight - 19, len, i+KFM_FUNC_ID+1, i+1, kfm_func[i]);
  640.                 x += len + 2;
  641.         }
  642. }
  643.  
  644. void DrawStatusBar()
  645. {
  646.         char status_bar_str[80];
  647.         int go_up_folder_exists=0;
  648.         dword topcolor;
  649.  
  650.         if (show_status_bar.checked) topcolor=sc.light; else topcolor=sc.work;
  651.         DrawBar(0, Form.cheight - status_bar_h-1, Form.cwidth, 1, topcolor);
  652.  
  653.         if (efm) {
  654.                 DrawBar(0, Form.cheight - status_bar_h, Form.cwidth, 2, sc.work);
  655.                 DrawBar(0, Form.cheight - 2, Form.cwidth,  2, EDX);
  656.                 DrawBar(Form.cwidth-1, Form.cheight - 19, 1,  17, EDX);
  657.                 DrawFuncButtonsInKfm();
  658.         } else if (show_status_bar.checked) {
  659.                 if (files.count>0) && (streq(items.get(0)*304+buf+72,"..")) go_up_folder_exists=1;
  660.                 DrawBar(0, Form.cheight - status_bar_h, Form.cwidth,  status_bar_h, sc.work);
  661.                 sprintf(#status_bar_str, T_STATUS_EVEMENTS, folder_count-go_up_folder_exists, files.count-folder_count);
  662.                 WriteText(6,Form.cheight - 13,0x80,sc.work_text,#status_bar_str);
  663.                 if (getSelectedCount()) {
  664.                         sprintf(#status_bar_str, T_STATUS_SELECTED, getSelectedCount());
  665.                         WriteText(Form.cwidth - calc(strlen(#status_bar_str)*6)-6,Form.cheight - 13,
  666.                                 0x80,sc.work_text,#status_bar_str);
  667.                 }
  668.         }
  669. }
  670.  
  671. void DrawFilePanels()
  672. {
  673.         int files_y = files.y;
  674.         int w2 = -Form.cwidth-1/2+Form.cwidth;
  675.         int h2 = Form.cheight-files_y-2 - status_bar_h;
  676.         if (!efm)
  677.         {
  678.                 SystemDiscs.Draw();
  679.                 files.SetSizes(SIDEBAR_W, 57, Form.cwidth - SIDEBAR_W-18, Form.cheight - 59 - status_bar_h, files.item_h);
  680.                 DrawButtonsAroundList();
  681.                 List_ReDraw();
  682.                 DrawPathBar();
  683.         }
  684.         else
  685.         {
  686.                 llist_copy(#files_active, #files);
  687.                 llist_copy(#files, #files_inactive);
  688.  
  689.                 if (!active_panel) {
  690.                         files.SetSizes(Form.cwidth/2, files_y, w2-17, h2, files.item_h);
  691.                 } else {
  692.                         files.SetSizes(2, files_y, Form.cwidth/2-2-17, h2, files.item_h);
  693.                 }
  694.  
  695.                 files_inactive.x = files.x;
  696.                 DrawButtonsAroundList();
  697.                 path = location[active_panel^1];
  698.                 active_panel ^= 1;
  699.                 OpenDir2(WITH_REDRAW);
  700.                 active_panel ^= 1;
  701.                 if (!getSelectedCount()) files_inactive.count = files.count;
  702.                 llist_copy(#files, #files_active);
  703.  
  704.                 if (!active_panel) {
  705.                         files.SetSizes(2, files_y, Form.cwidth/2-2-17, h2, files.item_h);
  706.                 } else {
  707.                         files.SetSizes(Form.cwidth/2, files_y, w2 -17, h2, files.item_h);
  708.                 }
  709.  
  710.                 DrawButtonsAroundList();
  711.                 path = location[active_panel];
  712.                 OpenDir2(WITH_REDRAW);
  713.         }
  714. }
  715.  
  716. void OpenDir2(char redraw){
  717.         if (buf) free(buf);
  718.         if (GetDir(#buf, #files.count, path, DIRS_NOROOT)) {
  719.                 Write_Error(EAX);
  720.                 history.add(path);
  721.                 EventHistoryGoBack();
  722.                 return;
  723.         }
  724.         SetCurDir(path);
  725.         if (files.count>0) && (files.cur_y-files.first==-1) files.cur_y=0;
  726.         files.visible = math.min(files.h / files.item_h, files.count);
  727.         if (!strncmp(path, "/rd/1",5)) || (!strncmp(path, "/sys/",4))
  728.                 dir_at_fat16 = true; else dir_at_fat16 = false;
  729.         Sorting();
  730.         SystemDiscs.Draw();
  731.         list_full_redraw = true;
  732.         List_ReDraw();
  733.         DrawPathBar();
  734. }
  735.  
  736.  
  737. void OpenDir(char redraw){
  738.         int errornum;
  739.         unselectAll();
  740.         if (buf) free(buf);
  741.         if (errornum = GetDir(#buf, #files.count, path, DIRS_NOROOT)) {
  742.                 history.add(path);
  743.                 //EventHistoryGoBack();
  744.                 Dir_Up();
  745.                 Write_Error(errornum);
  746.                 return;
  747.         }
  748.         if (files.count>0) && (files.cur_y-files.first==-1) files.cur_y=0;
  749.         history.add(path);
  750.         SystemDiscs.Draw();
  751.         files.visible = math.min(files.h / files.item_h, files.count);
  752.         if (!strncmp(path, "/rd/1",5)) || (!strncmp(path, "/sys/",4))
  753.                 dir_at_fat16 = true; else dir_at_fat16 = false;
  754.         Sorting();
  755.         list_full_redraw = true;
  756.         SetCurDir(path);
  757.         if (redraw!=ONLY_OPEN) {
  758.                 List_ReDraw();
  759.                 DrawStatusBar();
  760.                 DrawPathBar();
  761.         }
  762. }
  763.  
  764.  
  765. void List_ReDraw()
  766. {
  767.         int all_lines_h;
  768.         dword j;
  769.         static int old_cur_y, old_first;
  770.         dword separator_color;
  771.  
  772.         files.CheckDoesValuesOkey(); //prevent some shit
  773.         if (files.count < files.visible) files.visible = files.count;
  774.  
  775.         if (list_full_redraw) || (old_first != files.first)
  776.         {
  777.                 old_cur_y = files.cur_y;
  778.                 old_first = files.first;
  779.                 list_full_redraw = false;
  780.                 goto _ALL_LIST_REDRAW;
  781.         }
  782.         if (old_cur_y != files.cur_y)
  783.         {
  784.                 if (old_cur_y-files.first<files.visible) Line_ReDraw(col.list_bg, old_cur_y-files.first);
  785.                 Line_ReDraw(col.selec, files.cur_y-files.first);
  786.                 old_cur_y = files.cur_y;
  787.                 return;
  788.         }
  789.  
  790.         _ALL_LIST_REDRAW:
  791.  
  792.         for (j=0; j<files.visible; j++) {
  793.                 if (files.cur_y-files.first!=j) Line_ReDraw(col.list_bg, j);
  794.                 else Line_ReDraw(col.selec, files.cur_y-files.first);
  795.         }
  796.         //in the bottom
  797.         all_lines_h = j * files.item_h;
  798.         DrawBar(files.x,all_lines_h + files.y,files.w,files.h - all_lines_h, col.list_bg);
  799.         if (colored_lines.checked) separator_color = col.list_bg; else separator_color = col.list_vert_line;
  800.         DrawBar(files.x+files.w-141,all_lines_h + files.y,1,files.h - all_lines_h, separator_color);
  801.         DrawBar(files.x+files.w-68,all_lines_h + files.y,1,files.h - all_lines_h, separator_color);
  802.         DrawScroll(scroll_used);
  803. }
  804.  
  805. void Line_ReDraw(dword bgcol, signed filenum){
  806.         dword text_col=col.list_gb_text,
  807.                   ext1, attr,
  808.                   file_name_off,
  809.                   file_size=0,
  810.                   y=filenum*files.item_h+files.y,
  811.                   icon_y = files.item_h-icon_size/2+y;
  812.                   BDVK file;
  813.                   char full_path[4096];
  814.                   dword separator_color;
  815.                   bool current_inactive = false;
  816.                   char volume_label[64] = 0;
  817.         char label_file_name[4096];
  818.         if (filenum<0) return; //if hold lkm and scroll down by mouse wheel this may be the case
  819.  
  820.         if (bgcol==col.selec) && (files.x==files_inactive.x) {
  821.                 bgcol = col.list_bg;
  822.                 current_inactive = true;
  823.         }
  824.  
  825.         DrawBar(files.x,y,4,files.item_h,bgcol);
  826.         DrawBar(files.x+4,y,icon_size,icon_y-y,bgcol);
  827.         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);
  828.         if (colored_lines.checked) {
  829.                 if (bgcol!=col.selec) && (filenum%2) bgcol=col.odd_line;
  830.                 separator_color = bgcol;
  831.         } else {
  832.                 separator_color = col.list_vert_line;
  833.         }
  834.         DrawBar(files.x+icon_size+4,y,files.w-icon_size-4,files.item_h,bgcol);
  835.         DrawBar(files.x+files.w-141,y,1,files.item_h, separator_color);
  836.         DrawBar(files.x+files.w-68,y,1,files.item_h, separator_color);
  837.  
  838.         ESI = items.get(filenum+files.first)*304 + buf+32;
  839.         attr = ESDWORD[ESI];
  840.         file.sizelo   = ESI.BDVK.sizelo;
  841.         file.sizehi   = ESI.BDVK.sizehi;
  842.         file_name_off = #ESI.BDVK.name;
  843.         sprintf(#full_path,"%s/%s",path,file_name_off);
  844.  
  845.         if (attr&ATR_FOLDER)
  846.         {
  847.                 if (!strcmp(file_name_off,"..")) ext1="<up>"; else {
  848.                         ext1="<DIR>";
  849.                         WriteTextCenter(files.x+files.w-140, files.text_y+y+1, 72, col.list_gb_text, ext1);
  850.                 }
  851.                 if (chrnum(path, '/')==1) && (streq(path, "/kolibrios")==false)
  852.                         && (streq(path, "/sys")==false) {
  853.                                 file_size = GetDeviceSize(#full_path);
  854.                                 if (ESBYTE[path+1]) strlcpy(#volume_label, GetVolumeLabel(#full_path), sizeof(volume_label));
  855.                         }
  856.         }
  857.         else
  858.         {
  859.                 ext1 = strrchr(file_name_off,'.') + file_name_off;
  860.                 if (ext1==file_name_off) ext1 = NULL; //if no extension then show nothing
  861.                 file_size = ConvertSize64(file.sizelo, file.sizehi);
  862.                 if (ext1) && (strlen(ext1)<9) WriteTextCenter(files.x+files.w-140, files.text_y+y+1, 72, col.list_gb_text, ext1);
  863.         }
  864.         if (file_size) WriteText(7-strlen(file_size)*6+files.x+files.w-58,
  865.                         files.text_y+y+1, files.font_type, col.list_gb_text, file_size);
  866.  
  867.         if (attr&ATR_HIDDEN) || (attr&ATR_SYSTEM) text_col=col.list_text_hidden;
  868.         if (bgcol==col.selec)
  869.         {
  870.                 file_name_is_8_3(file_name_off);
  871.                 itdir = attr & ATR_FOLDER;
  872.                 strcpy(#file_name, file_name_off);
  873.                 if (streq(path,"/")) sprintf(#file_path,"%s%s",path,file_name_off);
  874.                         else sprintf(#file_path,"%s/%s",path,file_name_off);
  875.                 if (text_col==col.list_text_hidden) {
  876.                         text_col=MixColors(col.selec_text, col.list_text_hidden, 65);
  877.                 } else text_col=col.selec_text;
  878.         }
  879.         if (getElementSelectedFlag(filenum+files.first)) text_col=0xFF0000;
  880.         if (kfont.size.pt==9) || (!kfont.font)
  881.         {
  882.                 // Show default font
  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.         } else {
  894.                 // Show KFONT
  895.                 //that shit must be in a library
  896.                 strcpy(#label_file_name, file_name_off);
  897.                 if (volume_label) sprintf(#label_file_name, "%s [%s]", file_name_off, #volume_label);
  898.                 if (kfont.get_label_width(#label_file_name) + 141 + 26 > files.w)
  899.                 {
  900.                         while (kfont.get_label_width(#label_file_name) + 141 + 26 > files.w) {
  901.                                 ESBYTE[#label_file_name+strlen(#label_file_name)-1] = NULL;
  902.                         }
  903.                         strcpy(#label_file_name+strlen(#label_file_name)-2, "...");
  904.                 }
  905.                 kfont.WriteIntoWindow(files.x + icon_size+7, files.item_h - kfont.height / 2 + y,
  906.                         bgcol, text_col, kfont.size.pt, #label_file_name);
  907.         }
  908.         DrawIconByExtension(#full_path, ext1, files.x+4, icon_y, bgcol);
  909.         if (current_inactive) DrawWideRectangle(files.x+2, y, files.w-4, files.item_h, 2, col.selec);
  910. }
  911.  
  912. inline Sorting()
  913. {
  914.         dword d=0, f=1;
  915.         int j=0;
  916.         dword file_off;
  917.  
  918.         items.drop();
  919.  
  920.         if (streq(path,"/")) //do not sort root folder
  921.         {
  922.                 for(d=1;d<files.count;d++;) items.set(d, d);
  923.                 folder_count = d;
  924.                 return;
  925.         }
  926.         for (j=files.count-1, file_off=files.count-1*304+buf+32; j>=0; j--, file_off-=304;)  //files | folders
  927.         {
  928.                 if (dir_at_fat16) && (file_name_is_8_3(file_off+40)) strttl(file_off+40);
  929.                 if (ESDWORD[file_off] & ATR_FOLDER) {
  930.                         items.set(d, j);
  931.                         d++;
  932.                 } else {
  933.                         items.set(files.count-f, j);
  934.                         f++;
  935.                 }
  936.         }
  937.         folder_count = d;
  938.         //sorting: files first, then folders
  939.         Sort_by_Name(0,d-1);
  940.         if (sort_type==1) Sort_by_Name(d,files.count-1);
  941.         else if (sort_type==2) Sort_by_Type(d,files.count-1);
  942.         else if (sort_type==3) Sort_by_Size(d,files.count-1);
  943.         //reversed sorting
  944.         if (sort_desc) {
  945.                 for (j=0; j<f/2; j++) {
  946.                         items.swap(files.count-j-1, d+j);
  947.                 }
  948.                 //if (sort_type==1) for (j=0; j<d/2; j++) items[d-j]><items[j];
  949.         }
  950.         //make ".." first item in list
  951.         if (d>0) && (strncmp(items.get(0)*304+buf+72,"..",2)!=0)
  952.                 for(d--; d>0; d--;) if (!strncmp(items.get(d)*304+buf+72,"..",2)) {items.swap(d,0); break;}
  953. }
  954.  
  955.  
  956. void SelectFileByName(dword that_file)
  957. {
  958.         int ind;
  959.         files.KeyHome();
  960.         OpenDir(ONLY_OPEN);
  961.         if (dir_at_fat16) && (file_name_is_8_3(that_file)) strttl(that_file);
  962.         for (ind=files.count-1; ind>=0; ind--;) { if (!strcmpi(items.get(ind)*304+buf+72,that_file)) break; }
  963.         files.cur_y = ind - 1;
  964.         files.KeyDown();
  965.         DrawStatusBar();
  966.         List_ReDraw();
  967. }
  968.  
  969.  
  970. void Dir_Up()
  971. {
  972.         int iii;
  973.         char old_folder_name[4096];
  974.         iii=strlen(path)-1;
  975.         if (iii==0) return;
  976.         iii = strrchr(path, '/');
  977.         strcpy(#old_folder_name, path+iii);
  978.         if (iii>1) ESBYTE[path+iii-1]=NULL; else ESBYTE[path+iii]=NULL;
  979.         SelectFileByName(#old_folder_name);
  980.         DrawPathBar();
  981. }
  982.  
  983. void EventOpenSelected()
  984. {
  985.         int i;
  986.         for (i=0; i<files.count; i++) if (getElementSelectedFlag(i)) {
  987.                 EDX = items.get(i)*304 + buf+32;
  988.                 if (ESDWORD[EDX]&ATR_FOLDER) continue; //is foder
  989.                 sprintf(#param,"%s/%s",path, EDX+40);
  990.                 RunProgram("/sys/@open", #param);
  991.         }
  992. }
  993.  
  994. void EventOpen(byte _new_window)
  995. {
  996.         if (getSelectedCount()) && (!itdir) notify(T_USE_SHIFT_ENTER);
  997.         if (_new_window)
  998.         {
  999.                 if (streq(#file_name,"..")) return;
  1000.                 RunProgram(I_Path, #file_path);
  1001.                 return;
  1002.         }
  1003.         if (!files.count) return;
  1004.         if (!itdir)
  1005.         {
  1006.                 if (strrchr(#file_name, '.')==0) RunProgram(#file_path, ""); else RunProgram("/sys/@open", #file_path);
  1007.         }
  1008.         else
  1009.         {
  1010.                 if (!strncmp(#file_name,"..",3)) { Dir_Up(); return; }
  1011.                 strcpy(path, #file_path);
  1012.                 files.first=files.cur_y=0;
  1013.                 OpenDir(WITH_REDRAW);
  1014.         }
  1015. }
  1016.  
  1017. void EventHistoryGoBack()
  1018. {
  1019.         char cur_folder[4096];
  1020.         strcpy(#cur_folder, path);
  1021.         if (history.back()) {
  1022.                 strcpy(path, history.current());
  1023.                 SelectFileByName(#cur_folder+strrchr(#cur_folder,'/'));
  1024.                 DrawPathBar();
  1025.         }
  1026. }
  1027.  
  1028. void EventHistoryGoForward()
  1029. {
  1030.         if (history.forward()) {
  1031.                 strcpy(path, history.current());
  1032.                 files.KeyHome();
  1033.                 OpenDir(WITH_REDRAW);
  1034.                 DrawPathBar();
  1035.         }
  1036. }
  1037.  
  1038.  
  1039. void ShowOpenWithDialog()
  1040. {
  1041.         byte open_param[4097];
  1042.         sprintf(#open_param,"~%s",#file_path);
  1043.         RunProgram("/sys/@open", #open_param);
  1044. }
  1045.  
  1046. bool EventCreateAndRename()
  1047. {
  1048.         sprintf(#temp,"%s/%s",path,popin_text.text);
  1049.         if (file_exists(#temp)) {
  1050.                 notify(FS_ITEM_ALREADY_EXISTS);
  1051.                 return false;
  1052.         }
  1053.         switch(active_popin)
  1054.         {
  1055.                 case POPIN_NEW_FILE:
  1056.                                 if (CreateFile(0, 0, #temp)) goto __FAIL;
  1057.                                 break;
  1058.                 case POPIN_NEW_FOLDER:
  1059.                                 if (CreateDir(#temp)) goto __FAIL;
  1060.                                 break;
  1061.                 case POPIN_RENAME:
  1062.                                 if (RenameMove(popin_text.text, #file_path))
  1063.                                 {
  1064.                                         if (itdir) {
  1065.                                                 goto __FAIL;
  1066.                                         } else {
  1067.                                                 if (CopyFile(#file_path,#temp)) {
  1068.                                                         goto __FAIL;
  1069.                                                 } else {
  1070.                                                         DeleteFile(#file_path);
  1071.                                                 }
  1072.                                         }
  1073.                                 }
  1074.         }
  1075.         SelectFileByName(popin_text.text);
  1076.         return true;
  1077.         __FAIL:
  1078.         Write_Error(EAX);
  1079.         return false;
  1080. }
  1081.  
  1082. void EventPopinClickOkay()
  1083. {
  1084.         switch(active_popin) {
  1085.                 case POPIN_PATH:
  1086.                         strcpy(path, #popin_string);
  1087.                         OpenDir(WITH_REDRAW);
  1088.                         break;
  1089.                 case POPIN_DELETE:
  1090.                         CopyFilesListToClipboard(DELETE);
  1091.                         EventChooseAllFiles(false);
  1092.                         sprintf(#param, "-d %s", #file_path);
  1093.                         RunProgram(#program_path, #param);
  1094.                         break;
  1095.                 case POPIN_RENAME:
  1096.                 case POPIN_NEW_FILE:
  1097.                 case POPIN_NEW_FOLDER:
  1098.                         if (!EventCreateAndRename()) return;
  1099.         }
  1100.         EventClosePopinForm();
  1101. }
  1102.  
  1103. void EventClosePopinForm()
  1104. {
  1105.         active_popin = NULL;
  1106.         draw_window();
  1107. }
  1108.  
  1109. void ShowPopinForm(byte _popin_type)
  1110. {
  1111.         int popinx;
  1112.         popin_string[0] = -1;
  1113.         switch(_popin_type) {
  1114.                 case POPIN_PATH:
  1115.                                 edit_box_set_text stdcall (#popin_text, path);
  1116.                                 DrawEolitePopup(T_GOPATH, T_CANCEL);
  1117.                                 break;
  1118.                 case POPIN_NEW_FILE:
  1119.                                 edit_box_set_text stdcall (#popin_text, T_NEW_FILE);
  1120.                                 DrawEolitePopup(T_CREATE, T_CANCEL);
  1121.                                 break;
  1122.                 case POPIN_NEW_FOLDER:
  1123.                                 edit_box_set_text stdcall (#popin_text, T_NEW_FOLDER);
  1124.                                 DrawEolitePopup(T_CREATE, T_CANCEL);
  1125.                                 break;
  1126.                 case POPIN_RENAME:
  1127.                                 edit_box_set_text stdcall (#popin_text, #file_name);
  1128.                                 DrawEolitePopup(T_RENAME, T_CANCEL);
  1129.                                 break;
  1130.                 case POPIN_DELETE:
  1131.                                 if (!files.count) return;
  1132.                                 if (!getSelectedCount()) && (!strncmp(#file_name,"..",2)) return;
  1133.                                 popinx = DrawEolitePopup(T_YES, T_NO);
  1134.                                 WriteTextCenter(popinx, 178, POPIN_W, sc.work_text, T_DELETE_FILE);
  1135.                                 if (getSelectedCount()) {
  1136.                                         sprintf(#param,"%s%d%s",DEL_MORE_FILES_1,getSelectedCount(),DEL_MORE_FILES_2);
  1137.                                 } else {
  1138.                                         if (strlen(#file_name)<28) {
  1139.                                                 sprintf(#param,"%s ?",#file_name);
  1140.                                         } else {
  1141.                                                 strncpy(#param, #file_name, POPIN_W-20/6-4);
  1142.                                                 strcat(#param, "...?");
  1143.                                         }
  1144.                                 }
  1145.                                 WriteTextCenter(popinx, SIDEBAR_W, POPIN_W, sc.work_text, #param);
  1146.                                 break;
  1147.                 case POPIN_DISK:
  1148.                                 DefineHiddenButton(0,0,5000,3000,POPUP_BTN2+BT_NOFRAME);
  1149.                                 if (active_panel==0) {
  1150.                                         SystemDiscs.DrawOptions(1);
  1151.                                 } else {
  1152.                                         SystemDiscs.DrawOptions(Form.cwidth/2-1);
  1153.                                 }
  1154.                                 break;
  1155.                 case POPIN_BREADCR:
  1156.                                 DefineHiddenButton(0,0,5000,3000,POPUP_BTN2+BT_NOFRAME);
  1157.                                 DrawBreadCrumbs();
  1158.                                 break;
  1159.         }
  1160.         active_popin = _popin_type;
  1161. }
  1162.  
  1163. void EventShowAbout()
  1164. {
  1165.         if (!active_about) {
  1166.                 about_stak = malloc(4096);
  1167.                 about_thread_id = CreateThread(#about_dialog,about_stak+4092);
  1168.         } else {
  1169.                 ActivateWindow(GetProcessSlot(about_thread_id));
  1170.         }
  1171. }
  1172.  
  1173. void FnProcess(byte N)
  1174. {
  1175.         switch(N)
  1176.         {
  1177.                 case 1:
  1178.                         EventShowProperties();
  1179.                         break;
  1180.                 case 2:
  1181.                         if (files.count) ShowPopinForm(POPIN_RENAME);
  1182.                         break;
  1183.                 case 3:
  1184.                         if (files.count) && (!itdir) RunProgram("/kolibrios/utils/quark", #file_path);
  1185.                         break;
  1186.                 case 4:
  1187.                         if (files.count) && (!itdir) RunProgram("/sys/develop/cedit", #file_path);
  1188.                         break;
  1189.                 case 5:
  1190.                         if (efm) {
  1191.                                 CopyFilesListToClipboard(COPY);
  1192.                                 EventPaste(location[active_panel^1]);
  1193.                         } else {
  1194.                                 EventManualFolderRefresh();
  1195.                         }
  1196.                         break;
  1197.                 case 6:
  1198.                         if (efm) {
  1199.                                 CopyFilesListToClipboard(CUT);
  1200.                                 EventChooseAllFiles(false);
  1201.                                 EventPaste(location[active_panel^1]);
  1202.                         }
  1203.                         break;
  1204.                 case 7:
  1205.                         ShowPopinForm(POPIN_NEW_FOLDER);
  1206.                         break;
  1207.                 case 8:
  1208.                         ShowPopinForm(POPIN_DELETE);
  1209.                         break;
  1210.                 case 9:
  1211.                         ShowPopinForm(POPIN_NEW_FILE);
  1212.                         break;
  1213.                 case 10: //F10
  1214.                         if (active_settings) {
  1215.                                 ActivateWindow(GetProcessSlot(settings_window));
  1216.                         } else {
  1217.                                 settings_stak = malloc(4096);
  1218.                                 settings_window = CreateThread(#settings_dialog, settings_stak+4092);
  1219.                         }
  1220.                         break;
  1221.         }
  1222. }
  1223.  
  1224. void SetActivePanel(int _active)
  1225. {
  1226.         if (active_panel != _active) {
  1227.                 active_panel = _active;
  1228.                 llist_copy(#files_active, #files_inactive);
  1229.                 llist_copy(#files_inactive, #files);
  1230.                 llist_copy(#files, #files_active);
  1231.                 path = location[active_panel];
  1232.                 DrawFilePanels();
  1233.         }
  1234. }
  1235.  
  1236. void EventSelectFileByKeyPress()
  1237. {
  1238.         int i;
  1239.         for (i=files.cur_y+1; i<files.count; i++)
  1240.         {
  1241.                 strcpy(#temp, items.get(i)*304+buf+72);
  1242.                 if (temp[0]==key_ascii) || (temp[0]==key_ascii-32)
  1243.                 {
  1244.                         files.cur_y = i - 1;
  1245.                         files.KeyDown();
  1246.                         List_ReDraw();
  1247.                         return;
  1248.                 }
  1249.         }
  1250. }
  1251.  
  1252. dword GetDeviceSize(dword p)
  1253. {
  1254.         BDVK bdvk;
  1255.         if (ESBYTE[p+1] == '/') p++;
  1256.         if (ESBYTE[p+1] == 'c') && (ESBYTE[p+2] == 'd')
  1257.                 && (ESBYTE[p+4] == 0) return 0;
  1258.         if (GetFileInfo(p, #bdvk)) {
  1259.                 return 0;
  1260.         } else {
  1261.                 ConvertSize64(bdvk.sizelo, bdvk.sizehi);
  1262.         }
  1263. }
  1264.  
  1265. int GetRealFileCountInFolder(dword folder_path)
  1266. {
  1267.         int fcount;
  1268.         dword countbuf;
  1269.  
  1270.         GetDir(#countbuf, #fcount, folder_path, DIRS_NOROOT);
  1271.         if (countbuf) free(countbuf);
  1272.  
  1273.         return fcount;
  1274. }
  1275.  
  1276. void EventRefreshDisksAndFolders()
  1277. {
  1278.         if(efm) {
  1279.                 if (GetRealFileCountInFolder(location[active_panel^1]) != files_inactive.count) {
  1280.                         DrawFilePanels();
  1281.                         return;
  1282.                 }
  1283.         } else {
  1284.                 if (GetRealFileCountInFolder("/")+KolibriosMounted() != SystemDiscs.dev_num) {
  1285.                         SystemDiscs.Get();
  1286.                         SystemDiscs.Draw();
  1287.                 }
  1288.         }
  1289.         if(GetRealFileCountInFolder(path) != files.count) {
  1290.                 OpenDir(WITH_REDRAW);
  1291.         }
  1292. }
  1293.  
  1294. void EventManualFolderRefresh()
  1295. {
  1296.         Tip(56, T_DEVICES, 55, "-");
  1297.         pause(10);
  1298.         DrawFilePanels();
  1299. }
  1300.  
  1301. void EventSort(dword id)
  1302. {
  1303.         char selected_filename[256];
  1304.         if (sort_type == id) sort_desc ^= 1;
  1305.         else sort_type = id;
  1306.         strcpy(#selected_filename, #file_name);
  1307.         DrawButtonsAroundList();
  1308.         OpenDir(WITH_REDRAW);
  1309.         SelectFileByName(#selected_filename);
  1310. }
  1311.  
  1312. void EventOpenNewEolite()
  1313. {
  1314.         RunProgram(I_Path, path);
  1315. }
  1316.  
  1317. void EventOpenConsoleHere()
  1318. {
  1319.         sprintf(#param, "pwd cd %s", path);
  1320.         RunProgram("/sys/shell", #param);
  1321. }
  1322.  
  1323. void ProceedMouseGestures()
  1324. {
  1325.         char stats;
  1326.         signed x_old, y_old, dif_x, dif_y, adif_x, adif_y;
  1327.         if (!mouse.mkm) && (stats>0) stats = 0;
  1328.         if (mouse.mkm) && (!stats)
  1329.         {
  1330.                 x_old = mouse.x;
  1331.                 y_old = mouse.y;
  1332.                 stats = 1;
  1333.         }
  1334.         if (mouse.mkm) && (stats==1)
  1335.         {
  1336.                 dif_x = mouse.x-x_old;
  1337.                 dif_y = mouse.y-y_old;
  1338.                 adif_x = fabs(dif_x);
  1339.                 adif_y = fabs(dif_y);
  1340.  
  1341.                 if (adif_x>adif_y) {
  1342.                         if (dif_x > 150) {
  1343.                                 EventHistoryGoForward();
  1344.                                 stats = 0;
  1345.                         }
  1346.                         if (dif_x < -150) {
  1347.                                 EventHistoryGoBack();
  1348.                                 stats = 0;
  1349.                         }
  1350.                 } else {
  1351.                         if (dif_y < -100) {
  1352.                                 Dir_Up();
  1353.                                 stats = 0;
  1354.                         }
  1355.                 }
  1356.         }
  1357. }
  1358.  
  1359. void EventPaste(dword _into_path) {
  1360.         char paste_line[4096+6];
  1361.         sprintf(#paste_line, "-v%i %s", cut_active, _into_path);
  1362.         RunProgram(#program_path, #paste_line);
  1363.         EventClosePopinForm();
  1364. }
  1365.  
  1366. void EventShowProperties()
  1367. char line_param[4096+5];
  1368. {
  1369.         if (!getSelectedCount()) {
  1370.                 sprintf(#line_param, "-p %s", #file_path);
  1371.                 RunProgram(#program_path, #line_param);
  1372.         } else {
  1373.                 properties_stak = malloc(8096);
  1374.                 CreateThread(#properties_dialog, properties_stak+8092);
  1375.         }
  1376. }
  1377.  
  1378. void EventChooseFile(int _id)
  1379. {
  1380.         if (getElementSelectedFlag(_id) == true) {
  1381.                 setElementSelectedFlag(_id, false);
  1382.         } else {
  1383.                 setElementSelectedFlag(_id, true);
  1384.         }
  1385. }
  1386.  
  1387. void EventChooseFilesRange(int _start, _end)
  1388. {
  1389.         if (_start > _end) _start >< _end;
  1390.         if (_end - _start > 1) list_full_redraw = true;
  1391.         while (_start < _end) {
  1392.                 EventChooseFile(_start);
  1393.                 _start++;
  1394.         }
  1395.         DrawStatusBar();
  1396.         List_ReDraw();
  1397. }
  1398.  
  1399. void EventChooseAllFiles(dword state)
  1400. {
  1401.         int i;
  1402.         for (i=0; i<files.count; i++) setElementSelectedFlag(i, state);
  1403.         List_ReDraw();
  1404.         DrawStatusBar();
  1405. }
  1406.  
  1407. void EventToolbarButtonClick(int _btid)
  1408. {
  1409.         switch(_btid) {
  1410.                 case BACK_BTN: EventHistoryGoBack(); break;
  1411.                 case FWRD_BTN: EventHistoryGoForward(); break;
  1412.                 case GOUP_BTN: Dir_Up(); break;
  1413.                 case COPY_BTN: CopyFilesListToClipboard(CUT); break;
  1414.                 case CUT_BTN:  CopyFilesListToClipboard(COPY); break;
  1415.                 case PASTE_BTN:EventPaste(path); break;
  1416.         }
  1417. }
  1418.  
  1419. void EventDriveClick(int __id)
  1420. {
  1421.         if (__id >= SystemDiscs.list.count) return;
  1422.         if (efm) {
  1423.                 EventClosePopinForm();
  1424.                 draw_window();
  1425.         }
  1426.         strcpy(path, SystemDiscs.list.get(__id));
  1427.         files.KeyHome();
  1428.         OpenDir(WITH_REDRAW);
  1429. }
  1430.  
  1431. stop:
  1432.