Beispiel #1
0
void HighlightFiles::SaveHiData()
{
	if (!Changed)
		return;

	Changed = false;

	string strRegKey, strGroupName;
	const wchar_t *KeyNames[4]={HighlightKeyName,SortGroupsKeyName,SortGroupsKeyName,HighlightKeyName};
	const wchar_t *GroupNames[4]={fmtFirstGroup,fmtUpperGroup,fmtLowerGroup,fmtLastGroup};
	const int Count[4][2] =
	{
		{0,                               FirstCount},
		{FirstCount,                      FirstCount+UpperCount},
		{FirstCount+UpperCount,           FirstCount+UpperCount+LowerCount},
		{FirstCount+UpperCount+LowerCount,FirstCount+UpperCount+LowerCount+LastCount}
	};

	HierarchicalConfig *cfg = CreateHighlightConfig();

	unsigned __int64 root = cfg->GetKeyID(0, HighlightKeyName);
	if (root)
		cfg->DeleteKeyTree(root);
	root = cfg->GetKeyID(0, SortGroupsKeyName);
	if (root)
		cfg->DeleteKeyTree(root);

	for (int j=0; j<4; j++)
	{
		root = cfg->CreateKey(0, KeyNames[j]);
		if (!root)
			continue;

		for (int i=Count[j][0]; i<Count[j][1]; i++)
		{
			strGroupName.Format(GroupNames[j],i-Count[j][0]);
			unsigned __int64 key = cfg->CreateKey(root,strGroupName);
			if (!key)
				break;

			FileFilterParams *CurHiData=HiData.getItem(i);

			SaveFilter(cfg,key,CurHiData,(!j || j==3)?false:true);
		}
	}

	delete cfg;
}
Beispiel #2
0
void HighlightFiles::InitHighlightFiles(HierarchicalConfig *ExternCfg)
{
	string strGroupName, strMask;
	const int GroupDelta[4]={DEFAULT_SORT_GROUP,0,DEFAULT_SORT_GROUP+1,DEFAULT_SORT_GROUP};
	const wchar_t *KeyNames[4]={HighlightKeyName,SortGroupsKeyName,SortGroupsKeyName,HighlightKeyName};
	const wchar_t *GroupNames[4]={fmtFirstGroup,fmtUpperGroup,fmtLowerGroup,fmtLastGroup};
	int  *Count[4] = {&FirstCount,&UpperCount,&LowerCount,&LastCount};
	HiData.Free();
	FirstCount=UpperCount=LowerCount=LastCount=0;
	HierarchicalConfig *cfg = ExternCfg? ExternCfg : CreateHighlightConfig();

	for (int j=0; j<4; j++)
	{
		unsigned __int64 root = cfg->GetKeyID(0,KeyNames[j]);
		if (!root)
			continue;

		for (int i=0;; i++)
		{
			strGroupName.Format(GroupNames[j],i);
			unsigned __int64 key = cfg->GetKeyID(root,strGroupName);
			if (!key)
				break;

			if (!cfg->GetValue(key,HLS.Mask,strMask))
				break;

			FileFilterParams *HData = HiData.addItem();

			if (HData)
			{
				LoadFilter(cfg,key,HData,strMask,GroupDelta[j]+(GroupDelta[j]==DEFAULT_SORT_GROUP?0:i),(GroupDelta[j]==DEFAULT_SORT_GROUP?false:true));
				(*(Count[j]))++;
			}
			else
				break;
		}
	}

	if(cfg != ExternCfg)
	{
		delete cfg;
	}
}
Beispiel #3
0
void FileList::ReadPanelModes()
{
	HierarchicalConfig *PanelModeCfg = Db->CreatePanelModeConfig();

	for (int I=0; I<10; I++)
	{
		unsigned __int64 id = PanelModeCfg->GetKeyID(0, FormatString() << I);
		if (!id)
			continue;

		string strColumnTitles, strColumnWidths;
		PanelModeCfg->GetValue(id, L"ColumnTitles", strColumnTitles);
		PanelModeCfg->GetValue(id, L"ColumnWidths", strColumnWidths);

		if (strColumnTitles.IsEmpty() || strColumnWidths.IsEmpty())
			continue;

		string strStatusColumnTitles, strStatusColumnWidths;
		PanelModeCfg->GetValue(id, L"StatusColumnTitles", strStatusColumnTitles);
		PanelModeCfg->GetValue(id, L"StatusColumnWidths", strStatusColumnWidths);

		unsigned __int64 Flags=0;
		PanelModeCfg->GetValue(id, L"Flags", &Flags);

		PanelViewSettings NewSettings=ViewSettingsArray[VIEW_0+I];

		if (!strColumnTitles.IsEmpty())
			TextToViewSettings(strColumnTitles,strColumnWidths,NewSettings.ColumnType,
			                   NewSettings.ColumnWidth,NewSettings.ColumnWidthType,NewSettings.ColumnCount);

		if (!strStatusColumnTitles.IsEmpty())
			TextToViewSettings(strStatusColumnTitles,strStatusColumnWidths,NewSettings.StatusColumnType,
			                   NewSettings.StatusColumnWidth,NewSettings.StatusColumnWidthType,NewSettings.StatusColumnCount);

		NewSettings.Flags = (DWORD)Flags;

		ViewSettingsArray[VIEW_0+I] = NewSettings;
	}

	delete PanelModeCfg;
}
Beispiel #4
0
static void SetHighlighting(bool DeleteOld = false, HierarchicalConfig *ExternCfg = nullptr)
{
	unsigned __int64 root;
	HierarchicalConfig *cfg = ExternCfg?ExternCfg:CreateHighlightConfig();

	if (DeleteOld)
	{
		root = cfg->GetKeyID(0, HighlightKeyName);
		if (root)
			cfg->DeleteKeyTree(root);
	}

	if (!cfg->GetKeyID(0, HighlightKeyName))
	{
		root = cfg->CreateKey(0,HighlightKeyName);
		if (root)
		{
			static const wchar_t *Masks[]=
			{
				/* 0 */ L"*.*",
				/* 1 */ L"<arc>",
				/* 2 */ L"<temp>",
				/* $ 25.09.2001  IS
					Эта маска для каталогов: обрабатывать все каталоги, кроме тех, что
					являются родительскими (их имена - две точки).
				*/
				/* 3 */ L"*.*|..", // маска для каталогов
				/* 4 */ L"..",     // такие каталоги окрашивать как простые файлы
				/* 5 */ L"<exec>",
			};
			static struct DefaultData
			{
				const wchar_t *Mask;
				int IgnoreMask;
				DWORD IncludeAttr;
				BYTE InitNC;
				BYTE InitCC;
				FarColor NormalColor;
				FarColor CursorColor;
			}


			StdHighlightData[]=
			{
				/* 0 */{Masks[0], 0, 0x0002, 0x13, 0x38},
				/* 1 */{Masks[0], 0, 0x0004, 0x13, 0x38},
				/* 2 */{Masks[3], 0, 0x0010, 0x1F, 0x3F},
				/* 3 */{Masks[4], 0, 0x0010, 0x00, 0x00},
				/* 4 */{Masks[5], 0, 0x0000, 0x1A, 0x3A},
				/* 5 */{Masks[1], 0, 0x0000, 0x1D, 0x3D},
				/* 6 */{Masks[2], 0, 0x0000, 0x16, 0x36},
				// это настройка для каталогов на тех панелях, которые должны раскрашиваться
				// без учета масок (например, список хостов в "far navigator")
				/* 7 */{Masks[0], 1, 0x0010, 0x1F, 0x3F},
			};

			for (size_t I=0; I < ARRAYSIZE(StdHighlightData); I++)
			{
				Colors::ConsoleColorToFarColor(StdHighlightData[I].InitNC, StdHighlightData[I].NormalColor);
				MAKE_TRANSPARENT(StdHighlightData[I].NormalColor.BackgroundColor);
				Colors::ConsoleColorToFarColor(StdHighlightData[I].InitCC, StdHighlightData[I].CursorColor);
				MAKE_TRANSPARENT(StdHighlightData[I].CursorColor.BackgroundColor);

				unsigned __int64 key = cfg->CreateKey(root, FormatString() << L"Group" << I);
				if (!key)
					break;
				cfg->SetValue(key,HLS.Mask,StdHighlightData[I].Mask);
				cfg->SetValue(key,HLS.IgnoreMask,StdHighlightData[I].IgnoreMask);
				cfg->SetValue(key,HLS.IncludeAttributes,StdHighlightData[I].IncludeAttr);

				cfg->SetValue(key,HLS.NormalColor, &StdHighlightData[I].NormalColor, sizeof(FarColor));
				cfg->SetValue(key,HLS.CursorColor, &StdHighlightData[I].CursorColor, sizeof(FarColor));

				const FarColor DefaultColor = {FCF_FG_4BIT|FCF_BG_4BIT, 0xff000000, 0x00000000};
				cfg->SetValue(key,HLS.SelectedColor, &DefaultColor, sizeof(FarColor));
				cfg->SetValue(key,HLS.SelectedCursorColor, &DefaultColor, sizeof(FarColor));
				cfg->SetValue(key,HLS.MarkCharNormalColor, &DefaultColor, sizeof(FarColor));
				cfg->SetValue(key,HLS.MarkCharSelectedColor, &DefaultColor, sizeof(FarColor));
				cfg->SetValue(key,HLS.MarkCharCursorColor, &DefaultColor, sizeof(FarColor));
				cfg->SetValue(key,HLS.MarkCharSelectedCursorColor, &DefaultColor, sizeof(FarColor));
			}
		}
	}

	if (cfg!=ExternCfg)
	{
		delete cfg;
	}
}