Example #1
0
void FileList::FileListToPluginItem(FileListItem *fi,PluginPanelItem *pi)
{
	pi->FileName = xf_wcsdup(fi->strName);
	pi->AlternateFileName = xf_wcsdup(fi->strShortName);
	pi->FileSize=fi->FileSize;
	pi->AllocationSize=fi->AllocationSize;
	pi->FileAttributes=fi->FileAttr;
	pi->LastWriteTime=fi->WriteTime;
	pi->CreationTime=fi->CreationTime;
	pi->LastAccessTime=fi->AccessTime;
	pi->NumberOfLinks=fi->NumberOfLinks;
	pi->Flags=fi->UserFlags;

	if (fi->Selected)
		pi->Flags|=PPIF_SELECTED;

	pi->CustomColumnData=fi->CustomColumnData;
	pi->CustomColumnNumber=fi->CustomColumnNumber;
	pi->Description=fi->DizText; //BUGBUG???

	pi->UserData.Data=fi->UserData;
	pi->UserData.FreeData=fi->Callback;

	pi->CRC32=fi->CRC32;
	pi->Reserved[0]=pi->Reserved[1]=0;
	pi->Owner=fi->strOwner.IsEmpty()?nullptr:(wchar_t*)fi->strOwner.CPtr();
}
Example #2
0
void FileList::FileListToPluginItem(FileListItem *fi,PluginPanelItem *pi)
{
	pi->FileName = xf_wcsdup(fi->strName);
	pi->AlternateFileName = xf_wcsdup(fi->strShortName);
	pi->FileSize=fi->FileSize;
	pi->AllocationSize=fi->AllocationSize;
	pi->FileAttributes=fi->FileAttr;
	pi->LastWriteTime=fi->WriteTime;
	pi->CreationTime=fi->CreationTime;
	pi->LastAccessTime=fi->AccessTime;
	pi->NumberOfLinks=fi->NumberOfLinks;
	pi->Flags=fi->UserFlags;

	if (fi->Selected)
		pi->Flags|=PPIF_SELECTED;

	pi->CustomColumnData=fi->CustomColumnData;
	pi->CustomColumnNumber=fi->CustomColumnNumber;
	pi->Description=fi->DizText; //BUGBUG???

	if (fi->UserData && (fi->UserFlags & PPIF_USERDATA))
	{
		DWORD Size=*(DWORD *)fi->UserData;
		pi->UserData=(DWORD_PTR)xf_malloc(Size);
		memcpy((void *)pi->UserData,(void *)fi->UserData,Size);
	}
	else
		pi->UserData=fi->UserData;

	pi->CRC32=fi->CRC32;
	pi->Reserved[0]=pi->Reserved[1]=0;
	pi->Owner=fi->strOwner.IsEmpty()?nullptr:(wchar_t*)fi->strOwner.CPtr();
}
Example #3
0
void FindDataExToPluginPanelItem(const FAR_FIND_DATA_EX *pSrc, PluginPanelItem *pDest)
{
	pDest->FileAttributes = pSrc->dwFileAttributes;
	pDest->CreationTime = pSrc->ftCreationTime;
	pDest->LastAccessTime = pSrc->ftLastAccessTime;
	pDest->LastWriteTime = pSrc->ftLastWriteTime;
	pDest->ChangeTime = pSrc->ftChangeTime;
	pDest->FileSize = pSrc->nFileSize;
	pDest->AllocationSize = pSrc->nAllocationSize;
	pDest->FileName = xf_wcsdup(pSrc->strFileName);
	pDest->AlternateFileName = xf_wcsdup(pSrc->strAlternateFileName);
}
Example #4
0
// Изменение любого Label
void KeyBar::Change(int Group,const wchar_t *NewStr,int Pos)
{
	if (NewStr)
	{
		if (KeyTitles[Group][Pos]) xf_free(KeyTitles[Group][Pos]);
		KeyTitles[Group][Pos]=xf_wcsdup(NewStr);
	}
}
Example #5
0
		const HelpRecord& operator=(const HelpRecord &rhs)
		{
			if (this != &rhs)
			{
				HelpStr = xf_wcsdup(rhs.HelpStr);
			}

			return *this;
		};
Example #6
0
void KeyBar::SetRegGroup(int Group)
{
	for (int I=0; I < KEY_COUNT; I++)
		if (KeyTitlesCustom[Group][I] && *KeyTitlesCustom[Group][I])
		{
			if (KeyTitles[Group][I]) xf_free(KeyTitles[Group][I]);
			KeyTitles[Group][I]=xf_wcsdup(KeyTitlesCustom[Group][I]);
		}
}
Example #7
0
void KeyBar::ReadRegGroup(const wchar_t *RegGroup, const wchar_t *Language)
{
	if (!RegReaded || StrCmpI(strLanguage,Language) || StrCmpI(strRegGroupName,RegGroup))
	{
		DWORD Index=0;
		string strRegName;
		string strValue;
		string strValueName;

		strLanguage=Language;
		strRegGroupName=RegGroup;
		strRegName=L"KeyBarLabels.";
		strRegName+=strLanguage;
		strRegName+=L".";
		strRegName+=RegGroup;

		ClearKeyTitles(true);

		while (GeneralCfg->EnumValues(strRegName,Index++,strValueName,strValue))
		{
			DWORD Key=KeyNameToKey(strValueName);
			DWORD Key0=Key&(~KEY_CTRLMASK);
			DWORD Ctrl=Key&KEY_CTRLMASK;

			if (Key0 >= KEY_F1 && Key0 <= KEY_F24)
			{
				size_t J;
				static DWORD Area[][2]=
				{
					{ KBL_MAIN,         0 },
					{ KBL_SHIFT,        KEY_SHIFT },
					{ KBL_CTRL,         KEY_CTRL },
					{ KBL_ALT,          KEY_ALT },
					{ KBL_CTRLSHIFT,    KEY_CTRL|KEY_SHIFT },
					{ KBL_ALTSHIFT,     KEY_ALT|KEY_SHIFT },
					{ KBL_CTRLALT,      KEY_CTRL|KEY_ALT },
					{ KBL_CTRLALTSHIFT, KEY_CTRL|KEY_ALT|KEY_SHIFT },
				};

				for (J=0; J < ARRAYSIZE(Area); ++J)
					if (Area[J][1] == Ctrl)
						break;

				if (J <= ARRAYSIZE(Area))
				{
					KeyTitlesCustom[Area[J][0]][Key0-KEY_F1]=xf_wcsdup(strValue.CPtr());
				}
			}
		}

		RegReaded=TRUE;
	}
}
Example #8
0
// Групповая установка идущих подряд строк LNG для указанной группы
void KeyBar::SetAllGroup(int Group, LNGID StartIndex, int Count)
{
	if (Count > KEY_COUNT)
		Count = KEY_COUNT;

	for (int i=0; i<Count; i++)
	{
		if (KeyTitles[Group][i]) xf_free(KeyTitles[Group][i]);
		KeyTitles[Group][i]=xf_wcsdup(MSG(StartIndex+i));
	}

	KeyCounts [Group] = Count;
}
Example #9
0
void KeyBar::SetGroup(int Group,const wchar_t * const *Key,int KeyCount)
{
	if (!Key) return;

	for (int i=0; i<KeyCount && i<KEY_COUNT; i++)
		if (Key[i])
		{
			if (KeyTitles[Group][i]) xf_free(KeyTitles[Group][i]);
			KeyTitles[Group][i]=xf_wcsdup(Key[i]);
		}

	KeyCounts [Group]=KeyCount;
}
Example #10
0
		HelpRecord(const wchar_t *HStr=nullptr)
		{
			HelpStr = nullptr;
			if (HStr )
				HelpStr = xf_wcsdup(HStr);
		};
Example #11
0
string& WINAPI FarFormatText(const wchar_t *SrcText,     // источник
                             int Width,               // заданная ширина
                             string &strDestText,          // приемник
                             const wchar_t* Break,       // брик, если = nullptr, то принимается '\n'
                             DWORD Flags)             // один из FFTM_*
{
	const wchar_t *breakchar;
	breakchar = Break?Break:L"\n";

	if (!SrcText || !*SrcText)
	{
		strDestText.Clear();
		return strDestText;
	}

	string strSrc = SrcText; //copy string in case of SrcText == strDestText

	if (!wcspbrk(strSrc,breakchar) && strSrc.GetLength() <= static_cast<size_t>(Width))
	{
		strDestText = strSrc;
		return strDestText;
	}

	long i=0, l=0, pgr=0, last=0;
	wchar_t *newtext;
	const wchar_t *text= strSrc;
	long linelength = Width;
	int breakcharlen = StrLength(breakchar);
	int docut = Flags&FFTM_BREAKLONGWORD?1:0;
	/* Special case for a single-character break as it needs no
	   additional storage space */

	if (breakcharlen == 1 && !docut)
	{
		newtext = xf_wcsdup(text);

		if (!newtext)
		{
			strDestText.Clear();
			return strDestText;
		}

		while (newtext[i] != L'\0')
		{
			/* prescan line to see if it is greater than linelength */
			l = 0;

			while (newtext[i+l] != breakchar[0])
			{
				if (newtext[i+l] == L'\0')
				{
					l--;
					break;
				}

				l++;
			}

			if (l >= linelength)
			{
				pgr = l;
				l = linelength;

				/* needs breaking; work backwards to find previous word */
				while (l >= 0)
				{
					if (newtext[i+l] == L' ')
					{
						newtext[i+l] = breakchar[0];
						break;
					}

					l--;
				}

				if (l == -1)
				{
					/* couldn't break is backwards, try looking forwards */
					l = linelength;

					while (l <= pgr)
					{
						if (newtext[i+l] == L' ')
						{
							newtext[i+l] = breakchar[0];
							break;
						}

						l++;
					}
				}
			}

			i += l+1;
		}
	}
	else
	{
		/* Multiple character line break */
		newtext = (wchar_t*)xf_malloc((strSrc.GetLength() * (breakcharlen+1)+1)*sizeof(wchar_t));

		if (!newtext)
		{
			strDestText.Clear();
			return strDestText;
		}

		newtext[0] = L'\0';
		i = 0;

		while (text[i] != L'\0')
		{
			/* prescan line to see if it is greater than linelength */
			l = 0;

			while (text[i+l] != L'\0')
			{
				if (text[i+l] == breakchar[0])
				{
					if (breakcharlen == 1 || !StrCmpN(text+i+l, breakchar, breakcharlen))
						break;
				}

				l++;
			}

			if (l >= linelength)
			{
				pgr = l;
				l = linelength;

				/* needs breaking; work backwards to find previous word */
				while (l >= 0)
				{
					if (text[i+l] == L' ')
					{
						wcsncat(newtext, text+last, i+l-last);
						wcscat(newtext, breakchar);
						last = i + l + 1;
						break;
					}

					l--;
				}

				if (l == -1)
				{
					/* couldn't break it backwards, try looking forwards */
					l = linelength - 1;

					while (l <= pgr)
					{
						if (!docut)
						{
							if (text[i+l] == L' ')
							{
								wcsncat(newtext, text+last, i+l-last);
								wcscat(newtext, breakchar);
								last = i + l + 1;
								break;
							}
						}

						if (docut == 1)
						{
							if (text[i+l] == L' ' || l > i-last)
							{
								wcsncat(newtext, text+last, i+l-last+1);
								wcscat(newtext, breakchar);
								last = i + l + 1;
								break;
							}
						}

						l++;
					}
				}

				i += l+1;
			}
			else
			{
				i += (l ? l : 1);
			}
		}

		if (i+l > last)
		{
			wcscat(newtext, text+last);
		}
	}

	strDestText = newtext;
	xf_free(newtext);
	return strDestText;
}
Example #12
0
int FileList::PopPlugin(int EnableRestoreViewMode)
{
	OpenPanelInfo Info={};

	if (PluginsList.Empty())
	{
		PanelMode=NORMAL_PANEL;
		return FALSE;
	}

	// указатель на плагин, с которого уходим
	PluginsListItem *PStack=*PluginsList.Last();

	// закрываем текущий плагин.
	PluginsList.Delete(PluginsList.Last());

	--PluginPanelsCount;

	CtrlObject->Plugins->ClosePanel(hPlugin);

	if (!PluginsList.Empty())
	{
		hPlugin=(*PluginsList.Last())->hPlugin;
		strOriginalCurDir=PStack->strPrevOriginalCurDir;

		if (EnableRestoreViewMode)
		{
			SetViewMode(PStack->PrevViewMode);
			SortMode=PStack->PrevSortMode;
			NumericSort=PStack->PrevNumericSort;
			CaseSensitiveSort=PStack->PrevCaseSensitiveSort;
			SortOrder=PStack->PrevSortOrder;
			DirectoriesFirst=PStack->PrevDirectoriesFirst;
		}

		if (PStack->Modified)
		{
			PluginPanelItem PanelItem={};
			string strSaveDir;
			apiGetCurrentDirectory(strSaveDir);

			if (FileNameToPluginItem(PStack->strHostFile,&PanelItem))
			{
				CtrlObject->Plugins->PutFiles(hPlugin,&PanelItem,1,FALSE,0);
			}
			else
			{
				PanelItem.FileName = xf_wcsdup(PointToName(PStack->strHostFile));
				CtrlObject->Plugins->DeleteFiles(hPlugin,&PanelItem,1,0);
				xf_free(PanelItem.FileName);
			}

			FarChDir(strSaveDir);
		}


		CtrlObject->Plugins->GetOpenPanelInfo(hPlugin,&Info);

		if (!(Info.Flags & OPIF_REALNAMES))
		{
			DeleteFileWithFolder(PStack->strHostFile);  // удаление файла от предыдущего плагина
		}
	}
	else
	{
		PanelMode=NORMAL_PANEL;
		hPlugin = nullptr;

		if (EnableRestoreViewMode)
		{
			SetViewMode(PStack->PrevViewMode);
			SortMode=PStack->PrevSortMode;
			NumericSort=PStack->PrevNumericSort;
			CaseSensitiveSort=PStack->PrevCaseSensitiveSort;
			SortOrder=PStack->PrevSortOrder;
			DirectoriesFirst=PStack->PrevDirectoriesFirst;
		}
	}

	delete PStack;

	if (EnableRestoreViewMode)
		CtrlObject->Cp()->RedrawKeyBar();

	return TRUE;
}
Example #13
0
void FileList::PutDizToPlugin(FileList *DestPanel,PluginPanelItem *ItemList,
                              int ItemNumber,int Delete,int Move,DizList *SrcDiz,
                              DizList *DestDiz)
{
	_ALGO(CleverSysLog clv(L"FileList::PutDizToPlugin()"));
	OpenPanelInfo Info;
	CtrlObject->Plugins->GetOpenPanelInfo(DestPanel->hPlugin,&Info);

	if (DestPanel->strPluginDizName.IsEmpty() && Info.DescrFilesNumber>0)
		DestPanel->strPluginDizName = Info.DescrFiles[0];

	if (((Opt.Diz.UpdateMode==DIZ_UPDATE_IF_DISPLAYED && IsDizDisplayed()) ||
	        Opt.Diz.UpdateMode==DIZ_UPDATE_ALWAYS) && !DestPanel->strPluginDizName.IsEmpty() &&
	        (!Info.HostFile || !*Info.HostFile || DestPanel->GetModalMode() ||
	         apiGetFileAttributes(Info.HostFile)!=INVALID_FILE_ATTRIBUTES))
	{
		CtrlObject->Cp()->LeftPanel->ReadDiz();
		CtrlObject->Cp()->RightPanel->ReadDiz();

		if (DestPanel->GetModalMode())
			DestPanel->ReadDiz();

		int DizPresent=FALSE;

		for (int I=0; I<ItemNumber; I++)
			if (ItemList[I].Flags & PPIF_PROCESSDESCR)
			{
				string strName = ItemList[I].FileName;
				string strShortName = ItemList[I].AlternateFileName;
				int Code;

				if (Delete)
					Code=DestDiz->DeleteDiz(strName,strShortName);
				else
				{
					Code=SrcDiz->CopyDiz(strName,strShortName,strName,strShortName,DestDiz);

					if (Code && Move)
						SrcDiz->DeleteDiz(strName,strShortName);
				}

				if (Code)
					DizPresent=TRUE;
			}

		if (DizPresent)
		{
			string strTempDir;

			if (FarMkTempEx(strTempDir) && apiCreateDirectory(strTempDir,nullptr))
			{
				string strSaveDir;
				apiGetCurrentDirectory(strSaveDir);
				string strDizName=strTempDir+L"\\"+DestPanel->strPluginDizName;
				DestDiz->Flush(L"", &strDizName);

				if (Move)
					SrcDiz->Flush(L"");

				PluginPanelItem PanelItem;

				if (FileNameToPluginItem(strDizName,&PanelItem))
					CtrlObject->Plugins->PutFiles(DestPanel->hPlugin,&PanelItem,1,FALSE,OPM_SILENT|OPM_DESCR);
				else if (Delete)
				{
					PluginPanelItem pi={};
					pi.FileName = xf_wcsdup(DestPanel->strPluginDizName);
					CtrlObject->Plugins->DeleteFiles(DestPanel->hPlugin,&pi,1,OPM_SILENT);
					xf_free(pi.FileName);
				}

				FarChDir(strSaveDir);
				DeleteFileWithFolder(strDizName);
			}
		}
	}
}