Subversion Repositories Kolibri OS

Rev

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

Rev 8953 Rev 8956
Line 2... Line 2...
2
//GNU GPL license.
2
//GNU GPL license.
Line 3... Line 3...
3
 
3
 
4
/*
4
/*
5
BUGS:
5
BUGS:
6
- fix a kfm2 bug with selected files on window deactivation
-
 
7
- back button broken
-
 
8
- bug with going to wrong path (related to prior issue?)
6
- fix a kfm2 bug with selected files on window deactivation
9
TODO:
7
TODO:
10
- 70.5 - get volume info and label
-
 
11
- click on a path bar dropdown opens breadcrumbs
8
- 70.5 - get volume info and label
Line 12... Line 9...
12
*/
9
*/
13
 
10
 
14
#define ABOUT_TITLE "EOLITE 5 Beta12"
11
#define ABOUT_TITLE "EOLITE 5 RC6"
Line 15... Line 12...
15
#define TITLE_EOLITE "Eolite File Manager 5 Beta12"
12
#define TITLE_EOLITE "Eolite File Manager 5 RC6"
16
#define TITLE_KFM "Kolibri File Manager 2 Beta12";
13
#define TITLE_KFM "Kolibri File Manager 2 RC6";
17
 
14
 
18
#define MEMSIZE 1024 * 250
15
#define MEMSIZE 1024 * 250
Line 58... Line 55...
58
//Global data
55
//Global data
59
	bool efm = false;
56
	bool efm = false;
60
	_history history;
57
	_history history;
Line 61... Line 58...
61
 
58
 
62
//Folder data
59
//Folder data
63
	dword buf;
60
	dword buf, buf_inactive;
64
	collection_int items=0;
61
	collection_int items=0;
65
	int selected_count;
62
	int selected_count;
66
	int folder_count;
63
	int folder_count;
67
	dword path;
64
	dword path;
Line 92... Line 89...
92
	dword about_stak=0,properties_stak=0,settings_stak=0;
89
	dword about_stak=0,properties_stak=0,settings_stak=0;
93
	byte cmd_free=0;
90
	byte cmd_free=0;
Line 94... Line 91...
94
 
91
 
95
//Multipanes
92
//Multipanes
96
	int active_panel=0;
-
 
97
	int disk_popin_active_on_panel=0;
93
	int active_panel=0;
98
	#define PANES_COUNT 2
94
	#define PANES_COUNT 2
99
	dword location[PANES_COUNT];
95
	dword location[PANES_COUNT];
Line 100... Line 96...
100
	llist files, files_active, files_inactive;
96
	llist files, files_active, files_inactive;
Line 187... Line 183...
187
 
183
 
188
	SetAppColors();
184
	SetAppColors();
Line 189... Line 185...
189
	handle_param();
185
	handle_param();
190
 
186
 
191
	SystemDiscs.Get();
187
	SystemDiscs.Get();
192
	Open_Dir(path,ONLY_OPEN);
188
	OpenDir(ONLY_OPEN);
193
	llist_copy(#files_inactive, #files);
189
	llist_copy(#files_inactive, #files);
194
	SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
190
	SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
195
	loop() switch(@WaitEventTimeout(100))
191
	loop() switch(@WaitEventTimeout(100))
Line 302... Line 298...
302
				SaveIniSettings();
298
				SaveIniSettings();
303
				ExitProcess();
299
				ExitProcess();
304
			}
300
			}
Line 305... Line 301...
305
 
301
 
-
 
302
			if (active_popin) {
-
 
303
				if (POPUP_BTN2==id) { EventClosePopinForm(); break; }
-
 
304
				if (POPUP_BTN1==id) { EventPopinClickOkay(); break; }
306
			if (active_popin) {
305
 
307
				if (POPIN_DISK==active_popin) {
-
 
308
					if (id>=100) && (id<=120) {
306
				if (POPIN_DISK==active_popin) {
309
						active_popin = NULL;
307
					active_popin = NULL;
-
 
308
					EventDriveClick(id-100);
-
 
309
				}
-
 
310
 
-
 
311
				if (POPIN_BREADCR==active_popin) {
-
 
312
					EventClosePopinForm();
310
						EventDriveClick(id);
313
					ClickOnBreadCrumb(id-BREADCRUMB_ID);
311
					}
-
 
312
					EventClosePopinForm();                                //POPIN_DISK create close btn with POPUP_BTN2
314
				}
313
					break; }
-
 
314
				if (POPUP_BTN2==id) EventClosePopinForm();
-
 
315
				if (POPUP_BTN1==id) EventPopinClickOkay();
315
 
316
				break;					
316
				break;					
Line 317... Line 317...
317
			}
317
			}
318
 
318
 
Line 341... Line 341...
341
						break;
341
						break;
342
				case 52...60: //Actions
342
				case 52...60: //Actions
343
						FnProcess(id-50);
343
						FnProcess(id-50);
344
						break;
344
						break;
345
				case 100...120:
345
				case 100...120:
346
						EventDriveClick(id);
346
						EventDriveClick(id-100);
347
						break;
-
 
348
				case BREADCRUMB_ID...360:
-
 
349
						ClickOnBreadCrumb(id-BREADCRUMB_ID);
-
 
350
						break;
347
						break;
351
				case KFM_FUNC_ID...KFM_FUNC_ID+10:
348
				case KFM_FUNC_ID...KFM_FUNC_ID+10:
352
						FnProcess(id-KFM_FUNC_ID);
349
						FnProcess(id-KFM_FUNC_ID);
353
						break;
350
						break;
354
			}
351
			}
Line 364... Line 361...
364
			{
361
			{
365
				if (key_scancode == SCAN_CODE_ESC) EventClosePopinForm();
362
				if (key_scancode == SCAN_CODE_ESC) EventClosePopinForm();
Line 366... Line 363...
366
 
363
 
367
				if (POPIN_DISK == active_popin) {
364
				if (POPIN_DISK == active_popin) {
368
					if (key_scancode >= SCAN_CODE_1) 
365
					if (key_scancode >= SCAN_CODE_1) 
369
						&& (key_scancode >= SCAN_CODE_10) {
366
						&& (key_scancode <= SCAN_CODE_10) {
370
							EventDriveClick(key_scancode-1+100);
367
							EventDriveClick(key_scancode-2);
371
						}
368
						}
372
				} else {
369
				} else {
373
					if (key_scancode == SCAN_CODE_ENTER) EventPopinClickOkay();
370
					if (key_scancode == SCAN_CODE_ENTER) EventPopinClickOkay();
374
					if (popin_string[0] != -1) {
371
					if (popin_string[0] != -1) {
Line 413... Line 410...
413
							}
410
							}
414
					case SCAN_CODE_3...SCAN_CODE_10:
411
					case SCAN_CODE_3...SCAN_CODE_10:
415
							key_scancode-=2;
412
							key_scancode-=2;
416
							if (key_scancode >= SystemDiscs.list.count) break;
413
							if (key_scancode >= SystemDiscs.list.count) break;
417
							if (!efm) {
414
							if (!efm) {
418
								DrawRectangle(17,key_scancode*16+74,159,16, 0); //display click
415
								DrawRectangle(17,key_scancode*17+74,159,17, 0); //display click
419
								pause(7);										
416
								pause(7);										
420
							}
417
							}
421
							SystemDiscs.Click(key_scancode);
418
							EventDriveClick(key_scancode);
422
							break;
419
							break;
423
					case SCAN_CODE_KEY_X:
420
					case SCAN_CODE_KEY_X:
424
							CopyFilesListToClipboard(CUT);
421
							CopyFilesListToClipboard(CUT);
425
							break;						
422
							break;						
426
					case SCAN_CODE_KEY_C:
423
					case SCAN_CODE_KEY_C:
Line 580... Line 577...
580
	for (i=0; i<6; i++) DrawBar(0, 34+i, Form.cwidth, 1, MixColors(sc.work_dark, sc.work, i*10));
577
	for (i=0; i<6; i++) DrawBar(0, 34+i, Form.cwidth, 1, MixColors(sc.work_dark, sc.work, i*10));
581
	for (i=0; i<6; i++) DrawBar(0, 5-i, Form.cwidth, 1, MixColors(sc.work_light, sc.work, i*10));
578
	for (i=0; i<6; i++) DrawBar(0, 5-i, Form.cwidth, 1, MixColors(sc.work_light, sc.work, i*10));
582
	llist_copy(#files_active, #files);
579
	llist_copy(#files_active, #files);
583
	DrawStatusBar();
580
	DrawStatusBar();
584
	if (!selected_count) {
581
	if (!selected_count) {
585
		Open_Dir(path,ONLY_OPEN); //if there are no selected files -> refresh folder [L001] 
582
		OpenDir(ONLY_OPEN); //if there are no selected files -> refresh folder [L001] 
586
	}
583
	}
587
	DrawFilePanels();
584
	DrawFilePanels();
-
 
585
 
588
	disk_popin_active_on_panel = 0;
586
	if (files.x!=files_inactive.x) {
-
 
587
		if (active_popin) ShowPopinForm(active_popin);
-
 
588
	}
589
}
589
}
Line 590... Line 590...
590
 
590
 
591
void DrawButtonsAroundList() 
591
void DrawButtonsAroundList() 
592
{
592
{
Line 671... Line 671...
671
		}
671
		}
Line 672... Line 672...
672
 
672
 
673
		files_inactive.x = files.x;
673
		files_inactive.x = files.x;
674
		DrawButtonsAroundList();
674
		DrawButtonsAroundList();
675
		path = location[active_panel^1];
675
		path = location[active_panel^1];
676
		Open_Dir(path,WITH_REDRAW);
676
		OpenDir(WITH_REDRAW);
677
		if (!selected_count) files_inactive.count = files.count;
677
		if (!selected_count) files_inactive.count = files.count;
Line 678... Line 678...
678
		llist_copy(#files, #files_active);
678
		llist_copy(#files, #files_active);
679
 
679
 
Line 683... Line 683...
683
			files.SetSizes(Form.cwidth/2, files_y, w2 -17, h2, files.item_h);
683
			files.SetSizes(Form.cwidth/2, files_y, w2 -17, h2, files.item_h);
684
		}
684
		}
Line 685... Line 685...
685
 
685
 
686
		DrawButtonsAroundList();
686
		DrawButtonsAroundList();
687
		path = location[active_panel];
687
		path = location[active_panel];
688
		Open_Dir(path,WITH_REDRAW);
688
		OpenDir(WITH_REDRAW);
689
	}
689
	}
Line 690... Line 690...
690
}
690
}
691
 
691
 
Line 725... Line 725...
725
	DrawBar(files.x,all_lines_h + files.y,files.w,files.h - all_lines_h, col.list_bg);
725
	DrawBar(files.x,all_lines_h + files.y,files.w,files.h - all_lines_h, col.list_bg);
726
	if (colored_lines.checked) separator_color = col.list_bg; else separator_color = col.list_vert_line;
726
	if (colored_lines.checked) separator_color = col.list_bg; else separator_color = col.list_vert_line;
727
	DrawBar(files.x+files.w-141,all_lines_h + files.y,1,files.h - all_lines_h, separator_color);
727
	DrawBar(files.x+files.w-141,all_lines_h + files.y,1,files.h - all_lines_h, separator_color);
728
	DrawBar(files.x+files.w-68,all_lines_h + files.y,1,files.h - all_lines_h, separator_color);
728
	DrawBar(files.x+files.w-68,all_lines_h + files.y,1,files.h - all_lines_h, separator_color);
729
	DrawScroll(scroll_used);
729
	DrawScroll(scroll_used);
730
 
-
 
731
	if (files.x!=files_inactive.x) {
-
 
732
		if (active_popin) ShowPopinForm(active_popin);
-
 
733
	}
-
 
734
}
730
}
Line 735... Line 731...
735
 
731
 
736
void Line_ReDraw(dword bgcol, filenum){
732
void Line_ReDraw(dword bgcol, filenum){
737
	dword text_col=col.list_gb_text,
733
	dword text_col=col.list_gb_text,
Line 834... Line 830...
834
	DrawIconByExtension(#full_path, ext1, files.x+4, icon_y, bgcol);
830
	DrawIconByExtension(#full_path, ext1, files.x+4, icon_y, bgcol);
835
	if (current_inactive) DrawWideRectangle(files.x+2, y, files.w-4, files.item_h, 2, col.selec);
831
	if (current_inactive) DrawWideRectangle(files.x+2, y, files.w-4, files.item_h, 2, col.selec);
836
}
832
}
Line 837... Line 833...
837
 
833
 
838
 
834
 
Line 839... Line 835...
839
void Open_Dir(dword dir_path, redraw){
835
void OpenDir(char redraw){
840
	int errornum;
836
	int errornum;
841
 
837
 
842
	selected_count = 0;
838
	selected_count = 0;
843
	if (buf) free(buf);
839
	if (buf) free(buf);
844
	if (errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT))
840
	if (errornum = GetDir(#buf, #files.count, path, DIRS_NOROOT))
845
	{
841
	{
846
		history.add(path);
842
		history.add(path);
847
		EventHistoryGoBack();
843
		EventHistoryGoBack();
848
		Write_Error(errornum);
844
		Write_Error(errornum);
Line -... Line 845...
-
 
845
		return;
849
		return;
846
	}
850
	}
847
	if (files.count>0) && (files.cur_y-files.first==-1) files.cur_y=0;
851
	if (files.count>0) && (files.cur_y-files.first==-1) files.cur_y=0;
-
 
852
 
848
 
853
	SystemDiscs.Draw();
849
	history.add(path);
854
	files.visible = files.h / files.item_h;
850
	SystemDiscs.Draw();
855
	if (files.count < files.visible) files.visible = files.count;
851
	files.visible = math.min(files.h / files.item_h, files.count);
856
	if (!strncmp(dir_path, "/rd/1",5)) || (!strncmp(dir_path, "/sys/",4)) 
852
	if (!strncmp(path, "/rd/1",5)) || (!strncmp(path, "/sys/",4)) 
857
		dir_at_fat16 = true; else dir_at_fat16 = false; 
853
		dir_at_fat16 = true; else dir_at_fat16 = false; 
858
	Sorting();
-
 
859
	list_full_redraw = true;
854
	Sorting();
860
	SetCurDir(dir_path);
855
	list_full_redraw = true;
861
	if (redraw!=ONLY_OPEN) {
856
	SetCurDir(path);
862
		history.add(path);
857
	if (redraw!=ONLY_OPEN) {
863
		List_ReDraw();
858
		List_ReDraw();
Line 912... Line 907...
912
 
907
 
913
void SelectFileByName(dword that_file)
908
void SelectFileByName(dword that_file)
914
{
909
{
915
	int ind;
910
	int ind;
916
	files.KeyHome();
911
	files.KeyHome();
917
	Open_Dir(path,ONLY_OPEN);
912
	OpenDir(ONLY_OPEN);
918
	if (dir_at_fat16) && (file_name_is_8_3(that_file)) strttl(that_file);
913
	if (dir_at_fat16) && (file_name_is_8_3(that_file)) strttl(that_file);
919
	for (ind=files.count-1; ind>=0; ind--;) { if (!strcmpi(items.get(ind)*304+buf+72,that_file)) break; }
914
	for (ind=files.count-1; ind>=0; ind--;) { if (!strcmpi(items.get(ind)*304+buf+72,that_file)) break; }
920
	files.cur_y = ind - 1;
915
	files.cur_y = ind - 1;
921
	files.KeyDown();
916
	files.KeyDown();
Line 965... Line 960...
965
	else
960
	else
966
	{
961
	{
967
		if (!strncmp(#file_name,"..",3)) { Dir_Up(); return; }
962
		if (!strncmp(#file_name,"..",3)) { Dir_Up(); return; }
968
		strcpy(path, #file_path);
963
		strcpy(path, #file_path);
969
		files.first=files.cur_y=0;
964
		files.first=files.cur_y=0;
970
		Open_Dir(path,WITH_REDRAW);
965
		OpenDir(WITH_REDRAW);
971
	}
966
	}
972
}
967
}
Line 973... Line 968...
973
 
968
 
974
inline fastcall void EventHistoryGoBack()
969
void EventHistoryGoBack()
975
{
970
{
976
	char cur_folder[4096];
971
	char cur_folder[4096];
977
	strcpy(#cur_folder, path);
972
	strcpy(#cur_folder, path);
978
	if (history.back()) {
973
	if (history.back()) {
979
		strcpy(path, history.current());
974
		strcpy(path, history.current());
-
 
975
		SelectFileByName(#cur_folder+strrchr(#cur_folder,'/'));
980
		SelectFileByName(#cur_folder+strrchr(#cur_folder,'/'));
976
		DrawPathBar();
981
	}
977
	}
Line -... Line 978...
-
 
978
}
-
 
979
 
-
 
980
void EventHistoryGoForward()
-
 
981
{
-
 
982
	if (history.forward()) {
-
 
983
		strcpy(path, history.current());
-
 
984
		files.KeyHome();
-
 
985
		OpenDir(WITH_REDRAW);
-
 
986
		DrawPathBar();
-
 
987
	}
-
 
988
}
982
}
989
 
983
 
990
 
984
void ShowOpenWithDialog()
991
void ShowOpenWithDialog()
985
{
992
{
986
	byte open_param[4097];
993
	byte open_param[4097];
Line 1015... Line 1022...
1015
							DeleteFile(#file_path);
1022
							DeleteFile(#file_path);
1016
						}
1023
						}
1017
					}
1024
					}
1018
				}
1025
				}
1019
	}
1026
	}
1020
	Open_Dir(path,WITH_REDRAW);
-
 
1021
	SelectFileByName(popin_text.text);
1027
	SelectFileByName(popin_text.text);
1022
	return true;
1028
	return true;
1023
	__FAIL:
1029
	__FAIL:
1024
	Write_Error(EAX);
1030
	Write_Error(EAX);
1025
	return false;	
1031
	return false;	
Line 1028... Line 1034...
1028
void EventPopinClickOkay()
1034
void EventPopinClickOkay()
1029
{
1035
{
1030
	switch(active_popin) {
1036
	switch(active_popin) {
1031
		case POPIN_PATH:
1037
		case POPIN_PATH:
1032
			strcpy(path, #popin_string);
1038
			strcpy(path, #popin_string);
1033
			Open_Dir(path, WITH_REDRAW);
1039
			OpenDir(WITH_REDRAW);
1034
			break;
1040
			break;
1035
		case POPIN_DELETE:
1041
		case POPIN_DELETE:
1036
			CopyFilesListToClipboard(DELETE);
1042
			CopyFilesListToClipboard(DELETE);
1037
			EventClosePopinForm();
1043
			EventClosePopinForm();
1038
			sprintf(#param, "-d %s", #file_path);
1044
			sprintf(#param, "-d %s", #file_path);
Line 1089... Line 1095...
1089
					}
1095
					}
1090
				}
1096
				}
1091
				WriteTextCenter(popinx, 192, POPIN_W, sc.work_text, #param);
1097
				WriteTextCenter(popinx, 192, POPIN_W, sc.work_text, #param);
1092
				break;
1098
				break;
1093
		case POPIN_DISK:
1099
		case POPIN_DISK:
1094
				DefineHiddenButton(0,0,5000,3000,9999+BT_NOFRAME);
1100
				DefineHiddenButton(0,0,5000,3000,POPUP_BTN2+BT_NOFRAME);
1095
				if (active_panel==0) {
1101
				if (active_panel==0) {
1096
					SystemDiscs.DrawOptions(1);
1102
					SystemDiscs.DrawOptions(1);
1097
				} else {
1103
				} else {
1098
					SystemDiscs.DrawOptions(Form.cwidth/2-1);
1104
					SystemDiscs.DrawOptions(Form.cwidth/2-1);
1099
				}
1105
				}
1100
				break;
1106
				break;
1101
		case POPIN_BREADCR:
1107
		case POPIN_BREADCR:
1102
				notify("'Not implemented yet' C");
1108
				DefineHiddenButton(0,0,5000,3000,POPUP_BTN2+BT_NOFRAME);
1103
				return;
-
 
1104
				//DrawBreadCrumbs();
1109
				DrawBreadCrumbs();
1105
				break;
1110
				break;
1106
	}
1111
	}
1107
	active_popin = _popin_type;
1112
	active_popin = _popin_type;
1108
}
1113
}
Line 1227... Line 1232...
1227
		if (GetRealFileCountInFolder("/")+dir_exists("/kolibrios") != SystemDiscs.dev_num) {
1232
		if (GetRealFileCountInFolder("/")+dir_exists("/kolibrios") != SystemDiscs.dev_num) {
1228
			SystemDiscs.Get();
1233
			SystemDiscs.Get();
1229
			SystemDiscs.Draw();
1234
			SystemDiscs.Draw();
1230
		}
1235
		}
1231
	}
1236
	}
1232
	if(GetRealFileCountInFolder(path) != files.count) Open_Dir(path,WITH_REDRAW);
1237
	if(GetRealFileCountInFolder(path) != files.count) OpenDir(WITH_REDRAW);
1233
}
1238
}
Line 1234... Line 1239...
1234
 
1239
 
1235
void EventManualFolderRefresh()
1240
void EventManualFolderRefresh()
1236
{
1241
{
Line 1244... Line 1249...
1244
	char selected_filename[256];
1249
	char selected_filename[256];
1245
	if (sort_type == id) sort_desc ^= 1;
1250
	if (sort_type == id) sort_desc ^= 1;
1246
	else sort_type = id;
1251
	else sort_type = id;
1247
	strcpy(#selected_filename, #file_name);
1252
	strcpy(#selected_filename, #file_name);
1248
	DrawButtonsAroundList();
1253
	DrawButtonsAroundList();
1249
	Open_Dir(path,WITH_REDRAW);
1254
	OpenDir(WITH_REDRAW);
1250
	SelectFileByName(#selected_filename);
1255
	SelectFileByName(#selected_filename);
1251
}
1256
}
Line 1252... Line -...
1252
 
-
 
1253
void EventHistoryGoForward()
-
 
1254
{
-
 
1255
	if (history.forward()) {
-
 
1256
		strcpy(path, history.current());
-
 
1257
		files.KeyHome();
-
 
1258
		Open_Dir(path,WITH_REDRAW);
-
 
1259
	}
-
 
1260
}
-
 
1261
 
1257
 
1262
void EventOpenNewEolite()
1258
void EventOpenNewEolite()
1263
{
1259
{
1264
	RunProgram(I_Path, path);
1260
	RunProgram(I_Path, path);
Line 1366... Line 1362...
1366
	}
1362
	}
1367
}
1363
}
Line 1368... Line 1364...
1368
 
1364
 
1369
void EventDriveClick(int __id)
1365
void EventDriveClick(int __id)
-
 
1366
{
1370
{
1367
	if (__id >= SystemDiscs.list.count) return;
-
 
1368
	if (efm) {
1371
	if (efm) {
1369
		EventClosePopinForm();
1372
		draw_window();
1370
		draw_window();
1373
	}
1371
	}
-
 
1372
	strcpy(path, SystemDiscs.list.get(__id));
-
 
1373
	files.KeyHome();
1374
	SystemDiscs.Click(__id-100);
1374
	OpenDir(WITH_REDRAW);	
Line 1375... Line 1375...
1375
}
1375
}