Subversion Repositories Kolibri OS

Rev

Rev 7462 | Rev 7506 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7462 Rev 7490
Line 1... Line 1...
1
//Leency, Veliant, Punk_Joker, PavelYakov & KolibriOS Team 2008-2018
1
//Leency, Veliant, Punk_Joker, PavelYakov & KolibriOS Team 2008-2018
2
//GNU GPL licence.
2
//GNU GPL license.
Line 3... Line 3...
3
 
3
 
Line 4... Line 4...
4
// 70.5 - get volume info and label
4
// 70.5 - get volume info and label
5
 
5
 
Line 94... Line 94...
94
proc_info Form;
94
proc_info Form;
95
int sc_slider_h;
95
int sc_slider_h;
96
int action_buf;
96
int action_buf;
97
int rand_n;
97
int rand_n;
Line 98... Line 98...
98
 
98
 
-
 
99
char sort_type=2;
99
char sort_num=2;
100
bool sort_desc=false;
Line 100... Line 101...
100
int active_panel=1;
101
int active_panel=1;
101
 
102
 
Line 129... Line 130...
129
#include "include\properties.h"
130
#include "include\properties.h"
130
#include "include\breadcrumbs.h"
131
#include "include\breadcrumbs.h"
Line 131... Line 132...
131
 
132
 
132
void main() 
133
void main() 
-
 
134
{
133
{
135
	char selected_filename[256];
134
	dword id;
136
	dword id;
135
	byte count_sl = 0;
137
	byte count_sl = 0;
136
	signed x_old, y_old, dif_x, dif_y, adif_x, adif_y;
138
	signed x_old, y_old, dif_x, dif_y, adif_x, adif_y;
137
	char stats;
139
	char stats;
Line 368... Line 370...
368
							break;
370
							break;
369
					case 26:
371
					case 26:
370
							Paste();
372
							Paste();
371
							break;
373
							break;
372
					case 31...33: //sorting
374
					case 31...33: //sorting
-
 
375
							id -= 30;
-
 
376
							if (sort_type == id) sort_desc ^= 1;
373
							sort_num = id - 30;
377
							else sort_type = id;
-
 
378
							strcpy(#selected_filename, #file_name);
374
							DrawList();
379
							DrawList();
375
							Open_Dir(#path,WITH_REDRAW);
380
							Open_Dir(#path,WITH_REDRAW);
-
 
381
							SelectFileByName(#selected_filename);
376
							break;
382
							break;
377
					case 50...60: //Actions
383
					case 50...60: //Actions
378
							FnProcess(id-50);
384
							FnProcess(id-50);
379
							break;
385
							break;
380
					case 61: // Set path as default
386
					case 61: // Set path as default
Line 432... Line 438...
432
										pause(7);										
438
										pause(7);										
433
									}
439
									}
434
									SystemDiscs.Click(key_scancode);
440
									SystemDiscs.Click(key_scancode);
435
								}
441
								}
436
								break;
442
								break;
437
						case 45:  //Ctrl+X
443
						case SCAN_CODE_KEY_X:
438
								Copy(#file_path, CUT);
444
								Copy(#file_path, CUT);
439
								break;						
445
								break;						
440
						case 46:  //Ctrl+C
446
						case SCAN_CODE_KEY_C:
441
								Copy(#file_path, NOCUT);
447
								Copy(#file_path, NOCUT);
442
								break;
448
								break;
443
						case 47:  //Ctrl+V
449
						case SCAN_CODE_KEY_V:
444
								Paste();
450
								Paste();
445
								break;
451
								break;
446
						case 032: //Ctrl+D - set as bg
452
						case SCAN_CODE_KEY_D: //set image as bg
447
								strlcpy(#temp, "\\S__",4);
453
								strlcpy(#temp, "\\S__",4);
448
								strcat(#temp, #file_path);
454
								strcat(#temp, #file_path);
449
								RunProgram("/sys/media/kiv", #temp);
455
								RunProgram("/sys/media/kiv", #temp);
450
								break;
456
								break;
451
						case 049: //Ctrl+N - create new window
457
						case SCAN_CODE_KEY_N: //create new window
452
								if (Form.left==98) MoveSize(Form.left-20,Form.top-20,OLD,OLD);
458
								if (Form.left==98) MoveSize(Form.left-20,Form.top-20,OLD,OLD);
453
								RunProgram(I_Path, #path);
459
								RunProgram(I_Path, #path);
454
								break; 
460
								break; 
455
						case 050: //Ctrl+M
461
						case SCAN_CODE_KEY_M:
456
								Open_Dir(#inactive_path,WITH_REDRAW);
462
								Open_Dir(#inactive_path,WITH_REDRAW);
457
								break; 
463
								break; 
458
						case SCAN_CODE_ENTER: //Ctrl+Enter
464
						case SCAN_CODE_ENTER:
459
								if (!itdir) ShowOpenWithDialog();
465
								if (!itdir) ShowOpenWithDialog();
460
								else Open(1);
466
								else Open(1);
461
								break;
467
								break;
462
						case 030: //Ctrl+A - select all files
468
						case SCAN_CODE_KEY_A:
463
								EventSelectAllFiles(true);
469
								EventSelectAllFiles(true);
464
								break;
470
								break;
465
						case 022: //Ctrl+U - unselect all files
471
						case SCAN_CODE_KEY_U: //unselect all files
466
								selected_count = 0;
472
								selected_count = 0;
467
								EventSelectAllFiles(false);
473
								EventSelectAllFiles(false);
468
								break;
474
								break;
469
					}
475
					}
470
					break;
476
					break;
Line 483... Line 489...
483
								if (!two_panels.checked) break;
489
								if (!two_panels.checked) break;
484
								if (active_panel==1) active_panel=2; else active_panel=1;
490
								if (active_panel==1) active_panel=2; else active_panel=1;
485
								ChangeActivePanel();
491
								ChangeActivePanel();
486
								DrawFilePanels();
492
								DrawFilePanels();
487
								break;
493
								break;
488
						case 093: //menu
494
						case SCAN_CODE_MENU:
489
								menu_call_mouse=0;
495
								menu_call_mouse=0;
490
								menu_stak = malloc(4096);
496
								menu_stak = malloc(4096);
491
								CreateThread(#FileMenu,menu_stak+4092);
497
								CreateThread(#FileMenu,menu_stak+4092);
492
								break;
498
								break;
493
						case SCAN_CODE_DEL:
499
						case SCAN_CODE_DEL:
Line 498... Line 504...
498
								else setElementSelectedFlag(files.cur_y, true);
504
								else setElementSelectedFlag(files.cur_y, true);
499
								files.KeyDown();
505
								files.KeyDown();
500
								List_ReDraw();
506
								List_ReDraw();
501
								DrawStatusBar();
507
								DrawStatusBar();
502
								break;
508
								break;
503
						case 059...068: //F1-F10
509
						case SCAN_CODE_F1...SCAN_CODE_F10:
504
								FnProcess(key_scancode-58);
510
								FnProcess(key_scancode-58);
505
								break; 
511
								break; 
506
						default:
512
						default:
507
								EventSelectFileByKeyPress();
513
								EventSelectFileByKeyPress();
508
				}                         
514
				}                         
Line 556... Line 562...
556
	DefineAndDrawWindow(Form.left+rand_n,Form.top+rand_n,Form.width,Form.height,0x73,NULL,TITLE,0);
562
	DefineAndDrawWindow(Form.left+rand_n,Form.top+rand_n,Form.width,Form.height,0x73,NULL,TITLE,0);
557
	GetProcessInfo(#Form, SelfInfo);
563
	GetProcessInfo(#Form, SelfInfo);
558
	if (Form.status_window>2) return;
564
	if (Form.status_window>2) return;
559
	if (Form.height < 350) { MoveSize(OLD,OLD,OLD,350); return; }
565
	if (Form.height < 350) { MoveSize(OLD,OLD,OLD,350); return; }
560
	if (Form.width  < 480) { MoveSize(OLD,OLD,480,OLD); return; }
566
	if (Form.width  < 480) { MoveSize(OLD,OLD,480,OLD); return; }
561
	GetProcessInfo(#Form, SelfInfo); //if win_size changed
567
	GetProcessInfo(#Form, SelfInfo);
562
	ESDWORD[#toolbar_pal] = col_work;
568
	ESDWORD[#toolbar_pal] = col_work;
563
	ESDWORD[#toolbar_pal+4] = MixColors(0, col_work, 35);
569
	ESDWORD[#toolbar_pal+4] = MixColors(0, col_work, 35);
564
	PutPaletteImage(#toolbar, 246, 34, 0, 0, 8, #toolbar_pal);
570
	PutPaletteImage(#toolbar, 246, 34, 0, 0, 8, #toolbar_pal);
565
	DrawBar(127, 8, 1, 25, col_graph);
571
	DrawBar(127, 8, 1, 25, col_graph);
566
	for (i=0; i<3; i++) DefineHiddenButton(toolbar_buttons_x[i]+2,7,31-5,29-5,21+i);
572
	for (i=0; i<3; i++) DefineHiddenButton(toolbar_buttons_x[i]+2,7,31-5,29-5,21+i);
Line 582... Line 588...
582
}
588
}
Line 583... Line 589...
583
 
589
 
584
void DrawList() 
590
void DrawList() 
585
{
591
{
-
 
592
	word sorting_arrow_x;
-
 
593
	dword sorting_arrow_t = "\x19";
586
	word sorting_arrow_x;
594
	if (sort_desc) sorting_arrow_t = "\x18";
587
	DrawFlatButtonSmall(files.x, files.y-17,     files.w - 141,16,31,T_FILE);
595
	DrawFlatButtonSmall(files.x, files.y-17,     files.w - 141,16,31,T_FILE);
588
	DrawFlatButtonSmall(files.x + files.w - 141, files.y-17,73,16,32,T_TYPE);
596
	DrawFlatButtonSmall(files.x + files.w - 141, files.y-17,73,16,32,T_TYPE);
589
	DrawFlatButtonSmall(files.x + files.w -  68, files.y-17,68,16,33,T_SIZE);
597
	DrawFlatButtonSmall(files.x + files.w -  68, files.y-17,68,16,33,T_SIZE);
590
	DrawFlatButtonSmall(files.x + files.w,       files.y-17,16,16, 0,"\x18");
598
	DrawFlatButtonSmall(files.x + files.w,       files.y-17,16,16, 0,"\x18");
591
	DrawFlatButtonSmall(files.x + files.w,files.y+files.h-16,16,16,0,"\x19");
599
	DrawFlatButtonSmall(files.x + files.w,files.y+files.h-16,16,16,0,"\x19");
592
	if (sort_num==1) sorting_arrow_x = files.w - 141 / 2 + files.x + 18;
600
	if (sort_type==1) sorting_arrow_x = files.w - 141 / 2 + files.x + 18;
593
	if (sort_num==2) sorting_arrow_x = files.x + files.w - 90;
601
	if (sort_type==2) sorting_arrow_x = files.x + files.w - 90;
594
	if (sort_num==3) sorting_arrow_x = strlen(T_SIZE)*3-30+files.x+files.w;
602
	if (sort_type==3) sorting_arrow_x = strlen(T_SIZE)*3-30+files.x+files.w;
595
	WriteText(sorting_arrow_x,files.y-12,0x80, system.color.work_text,"\x19");
603
	WriteText(sorting_arrow_x,files.y-12,0x80, system.color.work_text, sorting_arrow_t);
596
	DrawBar(files.x+files.w,files.y,1,files.h,col_graph);
604
	DrawBar(files.x+files.w,files.y,1,files.h,col_graph);
597
	if (two_panels.checked) && (files.x<5) DrawBar(files.x+files.w+16,files.y,1,files.h,col_graph);	
605
	if (two_panels.checked) && (files.x<5) DrawBar(files.x+files.w+16,files.y,1,files.h,col_graph);	
Line 598... Line 606...
598
}
606
}
Line 820... Line 828...
820
	}
828
	}
821
}
829
}
Line 822... Line 830...
822
 
830
 
823
inline Sorting()
831
inline Sorting()
824
{
832
{
825
	dword k=0, l=1;
833
	dword d=0, f=1;
826
	int j=0;
834
	int j=0;
Line 827... Line 835...
827
	dword file_off;
835
	dword file_off;
828
 
836
 
829
	if (!strcmp(#path,"/")) //do not sort root folder
837
	if (!strcmp(#path,"/")) //do not sort root folder
830
	{
838
	{
831
		for(k=1;k
839
		for(d=1;d
832
		count_dir = k;
840
		count_dir = d;
833
		return;
841
		return;
834
	}
842
	}
835
	for (j=files.count-1, file_off=files.count-1*304+buf+32; j>=0; j--, file_off-=304;)  //files | folders
843
	for (j=files.count-1, file_off=files.count-1*304+buf+32; j>=0; j--, file_off-=304;)  //files | folders
836
	{
844
	{
837
		if (!show_real_names.checked) strttl(file_off+40);
845
		if (!show_real_names.checked) strttl(file_off+40);
838
		if (TestBit(ESDWORD[file_off],4)) //directory?
846
		if (TestBit(ESDWORD[file_off],4)) //directory?
839
		{
847
		{
840
			file_mas[k]=j;
848
			file_mas[d]=j;
841
			k++;
849
			d++;
842
		}
850
		}
843
		else
851
		else
844
		{
852
		{
845
			file_mas[files.count-l]=j;
853
			file_mas[files.count-f]=j;
846
			l++;
854
			f++;
847
		}
855
		}
848
	}
856
	}
849
	count_dir = k;
857
	count_dir = d;
850
	//sorting: files first, then folders
858
	//sorting: files first, then folders
851
	Sort_by_Name(0,k-1);
859
	Sort_by_Name(0,d-1);
852
	if (sort_num==1) Sort_by_Name(k,files.count-1);
860
	if (sort_type==1) Sort_by_Name(d,files.count-1);
-
 
861
	else if (sort_type==2) Sort_by_Type(d,files.count-1);
-
 
862
	else if (sort_type==3) Sort_by_Size(d,files.count-1);
-
 
863
	//reversed sorting
-
 
864
	if (sort_desc) {
-
 
865
		for (j=0; j
853
	else if (sort_num==2) Sort_by_Type(k,files.count-1);
866
		//if (sort_type==1) for (j=0; j
854
	else if (sort_num==3) Sort_by_Size(k,files.count-1);
867
	}
855
	//make ".." first item in list
868
	//make ".." first item in list
856
	if (k>0) && (strncmp(file_mas[0]*304+buf+72,"..",2)!=0)
869
	if (d>0) && (strncmp(file_mas[0]*304+buf+72,"..",2)!=0)
Line 857... Line 870...
857
		for(k--; k>0; k--;) if (!strncmp(file_mas[k]*304+buf+72,"..",2)) {file_mas[k]>
870
		for(d--; d>0; d--;) if (!strncmp(file_mas[d]*304+buf+72,"..",2)) {file_mas[d]>
858
}
871
}