Example #1
0
bool isCharNonWord(ucs32 inChar)
{
	if (isCharSpace(inChar)
		|| isCharSeparate(inChar)
		|| isCharPseudographics(inChar)
		)
		return true;
	return false;
}
Example #2
0
		static bool isChar(ucs32 inChar)
		{
			return (isCharSpace(inChar) || isCharSeparate(inChar));
		}
Example #3
0
bool CVConLine::ParseLine(bool abForce, unsigned anTextWidth, unsigned anFontWidth, unsigned anRow, wchar_t* apConCharLine, CharAttr* apConAttrLine, const wchar_t* const ConCharLine2, const CharAttr* const ConAttrLine2)
{
	const bool bNeedAlloc = (MaxBufferSize < anTextWidth);
	TextWidth = anTextWidth;
	FontWidth = anFontWidth;
	row = anRow;
	ConCharLine = apConCharLine;
	ConAttrLine = apConAttrLine;
	PartsCount = 0;

	NextDialog = true;
	NextDialogX = 0;
	CurDialogX1 = CurDialogX2 = CurDialogI = 0;
	CurDialogFlags = 0;

	isFilePanel = (mn_DialogAllFlags & (FR_LEFTPANEL|FR_RIGHTPANEL|FR_FULLPANEL)) != 0;

	//TODO: Extend to other old-scool managers?
	isFixFrameCoord = mp_RCon->isFar();

	if (bNeedAlloc && !AllocateMemory())
		return false;

	const bool bEnhanceGraphics = gpSet->isEnhanceGraphics;
	const bool bUseAlternativeFont = _bool(gpSet->isFixFarBorders);

	for (unsigned j = 0; j < TextWidth;)
	{
		bool bPair = ((j+1) < TextWidth);
		ucs32 wc = ucs32_from_wchar(ConCharLine+j, bPair);
		unsigned j2 = j + (bPair ? 2 : 1);

		const CharAttr attr = ConAttrLine[j];

		VConTextPart* p = TextParts+(PartsCount++);

		//TODO: DBCS cell number, it may differ from j
		p->Init(j, j, this);

		// Process Far Dialogs to justify rectangles and frames
		TextPartFlags dlgBorder = j ? isDialogBorderCoord(j) : TRF_None;

		/* *** Now we split our text line into parts with characters one "family" *** */

		_ASSERTE(p->Flags == TRF_None);

		if (dlgBorder)
		{
			p->Flags = dlgBorder | TRF_SizeFixed
				| (isCharBorderVertical(wc) ? TRF_TextPseudograph : TRF_None)
				//| (isCharSpaceSingle(wc) ? TRF_TextSpacing : TRF_None)
				| ((bUseAlternativeFont && isCharAltFont(wc)) ? TRF_TextAlternative : TRF_None)
				| ((bEnhanceGraphics && isCharProgress(wc)) ? TRF_TextProgress : TRF_None)
				;
		}
		else if (isCharSpaceSingle(wc))
		{
			// CJK Double-width space will be processed under isCharCJK
			p->Flags = TRF_TextSpacing;
			if (!bPair)
			while ((j2 < TextWidth) && (ConAttrLine[j2] == attr) && isCharSpaceSingle(ConCharLine[j2]))
				j2++;
		}
		else if (isCharSeparate(wc))
		{
			p->Flags = TRF_TextSeparate;
			if (!bPair)
			while ((j2 < TextWidth) && (ConAttrLine[j2] == attr) && isCharSeparate(ConCharLine[j2]))
				j2++;
		}
		// isCharProgress must be checked before isCharScroll!
		else if (bEnhanceGraphics && isCharProgress(wc))
		{
			p->Flags = TRF_TextProgress
				| ((bUseAlternativeFont && isCharAltFont(wc)) ? TRF_TextAlternative : TRF_None)
				;
			if (!bPair)
			while ((j2 < TextWidth) && (ConAttrLine[j2] == attr) && isCharProgress(ConCharLine[j2]))
				j2++;
		}
		// isCharScroll has wider range than isCharProgress, and comes after it
		else if (bEnhanceGraphics && isCharScroll(wc))
		{
			p->Flags = TRF_TextScroll
				| ((bUseAlternativeFont && isCharAltFont(wc)) ? TRF_TextAlternative : TRF_None)
				;
			if (!bPair)
			while ((j2 < TextWidth) && (ConAttrLine[j2] == attr) && isCharScroll(ConCharLine[j2]))
				j2++;
		}
		else if (bEnhanceGraphics && isCharTriangles(wc))
		{
			p->Flags = TRF_TextTriangles;
		}
		// Miscellaneous borders
		else if (isCharPseudographics(wc))
		{
			// Processed separately from isCharAltFont, because last may cover larger range
			p->Flags = TRF_TextPseudograph;
			if (bUseAlternativeFont && isCharAltFont(wc))
			{
				p->Flags |= TRF_TextAlternative;
				wchar_t wc2;
				if (!bPair)
				while ((j2 < TextWidth) && (ConAttrLine[j2] == attr)
					&& isCharPseudographics((wc2=ConCharLine[j2]))
					&& (!bEnhanceGraphics || !isCharScroll(wc2))
					&& !isCharBorderVertical(wc2)
					&& isCharAltFont(wc2))
					j2++;
			}
			else
			{
				wchar_t wc2;
				if (!bPair)
				while ((j2 < TextWidth) && (ConAttrLine[j2] == attr)
					&& isCharPseudographics((wc2=ConCharLine[j2]))
					&& (!bEnhanceGraphics || !isCharScroll(wc2))
					&& !isCharBorderVertical(wc2)
					)
					j2++;
			}
		}
		else if (isCharCJK(wc)) // Double-width characters (CJK, etc.)
		{
			// Processed separately from isCharAltFont, because last may cover larger range
			p->Flags = TRF_TextCJK;
			if (bUseAlternativeFont && isCharAltFont(wc))
			{
				p->Flags |= TRF_TextAlternative;
				wchar_t wc2;
				if (!bPair)
				while ((j2 < TextWidth) && (ConAttrLine[j2] == attr)
					&& isCharCJK((wc2=ConCharLine[j2]))
					&& isCharAltFont(wc2))
					j2++;
			}
			else
			{
				if (!bPair)
				while ((j2 < TextWidth) && (ConAttrLine[j2] == attr) && isCharCJK(ConCharLine[j2]))
					j2++;
			}
		}
		else if (bUseAlternativeFont && isCharAltFont(wc))
		{
			p->Flags = TRF_TextAlternative;
			if (!bPair)
			while ((j2 < TextWidth) && (ConAttrLine[j2] == attr) && isCharScroll(ConCharLine[j2]))
				j2++;
		}
		else
		{
			p->Flags = TRF_TextNormal;
			wchar_t wc2;
			// That's more complicated as previous branches,
			// we must break on all chars mentioned above
			if (!bPair)
			while ((j2 < TextWidth) && (ConAttrLine[j2] == attr)
				&& !isCharSpaceSingle((wc2=ConCharLine[j2]))
				&& !isCharSeparate(wc2)
				&& !isCharProgress(wc2)
				&& !isCharScroll(wc2)
				&& !isCharPseudographics(wc2)
				&& (wc2 != L'}') // Far Manager Panels mark "file name is trimmed"
				&& !(bUseAlternativeFont && isCharAltFont(wc2))
				//TODO: RTL/LTR
				)
				j2++;
		}

		/* *** We shall prepare this token (default/initial widths must be set) *** */
		_ASSERTE(j2>j);
		p->SetLen(j2-j, FontWidth);

		#if 0
		TotalLineWidth += p->TotalWidth;
		MinLineWidth += p->MinWidth;
		#endif

		/* Next part */
		j = j2;
	}

	return true;
}