⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c_rtrndr.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
		    else		    {			if('<'!=ch2)			{			    bNonSpaceTabNewlineCharWasLastFound = TRUE;			}			break;		    }		}		indx--;	 //back up one for outer for loop.		if(bSomeCharsFoundSinceLastBreakTag)		{//XXXXXEH-is fix for bug 4881 here?!?  If UNIX uses '\n' instead of "\r\n",// and we don't handle that count==1 here, what in the Wide Wide World Of// Sports happens??  (Needs checking in same code in textlib/textprsr.cpp)		    //Doesn't follow a new line, so just reduce to 1 space:		    if(newLineCharCount >= 2L)		    {			indexOfRightBracket =				firstNewlineIndex + newLineCharCount - 1L;			indexOfLeftBracket = firstNewlineIndex + 1L;			bIgnoringNewlineChars = TRUE;			bSomeCharsFoundSinceLastBreakTag = TRUE;			break; //indexOf[Left&Right]Bracket vars are set				// to act as a fake tag after the first one.		    }		}		else 		//we want to ignore all newline characters found		// because they were preceded by a line break tag, so		// pretend we've found the start and end of a tag so a new		// TC will be created ending just before this char and the		// next will start just after this char.		{		    indexOfLeftBracket = firstNewlineIndex;		    indexOfRightBracket =			    firstNewlineIndex + newLineCharCount - 1L;		    bIgnoringNewlineChars = TRUE;		    bSomeCharsFoundSinceLastBreakTag =			    bSomeCharsFoundSinceLastPosTag =			    bNonSpaceTabNewlineCharWasLastFound;		    break; //indexOf[Left&Right]Bracket vars are set.			    // to act as a fake tag where newlines are..		}	    }	}	if(-1L != indexOfLeftBracket  &&  -1L == indexOfRightBracket)	{	    //Check if we're inside an HTML-style ("<!-- ... -->") comment,	    // and then ignore all '>'s until we see one preceeded by "--",	    // i.e., only "-->" ends a comment:	    if(len-indexOfLeftBracket >= 4)	    {		if(!stringCompare(&pData_CHAR[indexOfLeftBracket], 4,			"<!--", 4))		{		    m_pTextWindow->incrementCommentTagNestCount();		}	    }	     //find the closing '>':	    for(indx++; indx<len; indx++)	    {		_CHAR ch = pData_CHAR[indx];/*XXXEH- for now, we have to assume that the text encountered is not  DBCS text; all text inside tags must be us-ascii charset:		//added the following to handle DBCS chars:		if((UCHAR)ch >= DBCS_MIN_LEAD_BYTE_VAL)		{		    indx++; //skip this and the following trail byte.		    continue;		}*/		if('>' == ch)		{		    //Check if we're inside an HTML-style ("<!-- ... -->")		    // comment, which could contain a '>' (which should be		    // ignored) before the closing "-->":		    if(m_pTextWindow->getCommentTagNestCount())		    {			if(indx-startIndex >= 2)			{			    if(!stringCompare(&pData_CHAR[indx-2], 3,				    "-->", 3))			    {				if(m_pTextWindow->					decrementCommentTagNestCount() > 0L)				{				    continue; //we're still inside a nested						// comment.				}			    }			    else			    {				continue;			    }			}		    }		    indexOfRightBracket = indx;		    //Added this to make this XML-compatible:		    if(indexOfRightBracket>0)		    {			if(pData_CHAR[indexOfRightBracket-1] == '/')			{			    bSlashFoundAtEndOfTag = TRUE;			    pData_CHAR[indexOfRightBracket-1] = ' ';			}		    }		    break;		}		else if('<' == ch  &&			m_pTextWindow->getCommentTagNestCount())		{		    //Check if we're a comment nested inside another		    // ("<!-- ... -->") comment:		    if(len-indx >= 4)		    {			if(!stringCompare(&pData_CHAR[indx], 4,				"<!--", 4))			{			    m_pTextWindow->incrementCommentTagNestCount();			}		    }		}		//Convert any newline or tab chars inside tag to spaces:		if('\n' == ch  ||  '\r' == ch  ||				'\t' == ch  ||  '\v' == ch				||  '\0' == ch)		{		    pData_CHAR[indx] = ' ';	 		    //Note: don't need to track #of conversions inside tag		}	    }	    if(-1 == indexOfRightBracket)	    {	//No valid end-of-tag found, so ignore all text from		//  indexOfLeftBracket on; this is done by putting a '\0'		//  at pData_CHAR[indexOfLeftBracket]:		pData_CHAR[indexOfLeftBracket] = '\0';		len = indexOfLeftBracket - startIndex;	    }	}		LONG32 tempLen;	BOOL bPreTabOrNewlineCharOnly = FALSE;	if(indexOfLeftBracket != -1)	{	    tempLen = indexOfLeftBracket - startIndex;	    pData_CHAR[indexOfLeftBracket] = '\0';	    if(!tempLen)	    {		//Special case where a tab char was the only text found		// between tags, and, since we're faking like a PRE tab		// is a tag, tempLen ended up 0 and the while loop, below,		// was not getting entered:		if(bDealingWithTabCharWithPre)		{		    bPreTabOrNewlineCharOnly = TRUE;		}	    }	}	else	{	    tempLen = len - startIndex;	}	ulCurCharset = m_pTextWindow->peekAtCharsetStack();	//Added the following to allow for	// word wrap; break the text up wherever there is a	// space char.  (Also, Changed "if(tempLen.." to	// "while(tempLen.."	ULONG32 tmpStartIndex = startIndex;	while(tempLen > 0  ||		bPreTabOrNewlineCharOnly)	{	    ULONG32 theFollowingSpaceCharIndex = tempLen;	    char savedChar = '\0';	    _CHAR* pCurText = &pData_CHAR[tmpStartIndex];	    if(m_pTextWindow->usingWordwrap()  &&		    !m_pTextWindow->peekAtIsPreStack())	    {		//Allow wordwrap to happen in DBCS/UNICODE between chars, not		// just where spaces are, because each character represents		// a "word" and they are rarely separated by spaces:		//XXXEH- NOTE: I assume that UNICODE characters that have a		// zero-valued first byte are really SBCS characters and		// should not get wordwrapped (because they may be in the		// middle of a SB word):		if(ulCurCharset & HX_UNICODE_CHARSET  ||			ulCurCharset & HX_DBCS_CHARSET)		{		    UINT16 sCharWidthInPixels = 0;		    UINT16 sChar = '\0';		    LONG32 lNumBytesOfChar = 1L;		    if(ulCurCharset & HX_UNICODE_CHARSET  ||			    (ulCurCharset & HX_DBCS_CHARSET  &&			    (UCHAR)(*pCurText)>= DBCS_MIN_LEAD_BYTE_VAL) )		    {			//Is a 2-byte character, so deal with it,			// making sure there's a trail byte			lNumBytesOfChar++;			HX_ASSERT(tempLen>=lNumBytesOfChar);			UCHAR tmp = *pCurText;			sChar = (((UINT16)tmp)<<8 | (UCHAR)pCurText[1]);		    }		    else		    {			sChar = (INT16)((UCHAR)(*pCurText));		    }/*  XXXEH-need while loop on each char until we find which character    exceeds the window's right edge and only then end the text blob...:		    sCharWidthInPixels = GetCharacterWidth(			    sChar,			    m_pTextWindow->peekAtFontFaceStack(),			    m_pTextWindow->peekAtPointSizeStack(),			    //XXXEH- isBold and isItalicized need peek..()			    // functions written for them; assuming they are			    // TRUE only means wordwrap will happen a few			    // pixels early, if that:			    TRUE, TRUE,			    ulCurCharset);		    BOOL windowWidthExceeded = 			    m_pTextWindow->getCurrentTextLineEndX() +			    sCharWidthInPixels >			    m_pTextWindow->getWidth();    XXXEH- ...but for now, just make each (2-byte)DBCS/UNICODE character be in its    own TextContainer, although this can be less efficient:*/		    //If we are going from DB char to DB char or from DB char		    // to SB char, or from SB char to DB char, or SB char is		    // a space, newline, or tab, or is a UNICODE character		    // with a non-zero first byte, or is a UNICODE space, tab,		    // or newline, then we can do a wordwrap		    // after this char, otherwise we should not:		    BOOL bNextCharExists = tempLen>lNumBytesOfChar;		    //Initialize to opposite of what cur character is:		    BOOL bNextCharIsTwoByte = (lNumBytesOfChar==1);		    if(bNextCharExists)		    {			bNextCharIsTwoByte =				(ulCurCharset & HX_UNICODE_CHARSET  &&				((UCHAR)(pCurText[lNumBytesOfChar])!=0))  ||			    (ulCurCharset & HX_DBCS_CHARSET  &&			    (UCHAR)(pCurText[lNumBytesOfChar])>=			    DBCS_MIN_LEAD_BYTE_VAL);		    }		    BOOL bIsUNICODEcharThatCanBeWordwrapped = FALSE;		    if(ulCurCharset & HX_UNICODE_CHARSET)		    {			if(*pCurText!=0)			{			    bIsUNICODEcharThatCanBeWordwrapped = TRUE;			}			else			{			    UCHAR ch = pCurText[1]; 			    if(' '==ch  ||  '\n'==ch  ||				    '\r'==ch  ||  '\t'==ch)			    {				bIsUNICODEcharThatCanBeWordwrapped = TRUE;			    }			}		    }		    if((!(1==lNumBytesOfChar)  ||  bNextCharIsTwoByte)  ||			    (1==lNumBytesOfChar  &&  (' '==*pCurText  ||			    '\n'==*pCurText  ||  '\r'==*pCurText  ||			    '\t'==*pCurText))  ||			    bIsUNICODEcharThatCanBeWordwrapped )		    {			//End the text blob here so that wordwrap can occur			// if this character extends off the right edge			// of the window:			theFollowingSpaceCharIndex = lNumBytesOfChar-1;			savedChar = pCurText[theFollowingSpaceCharIndex+1];			pCurText[theFollowingSpaceCharIndex+1] = '\0';		    }		    //If we're in a bunch of single-byte DBCS chars, then we		    // need to find the end of them (or the first space, tab,		    // newline therein), and allow for wordwrap there:		    else if(1==lNumBytesOfChar  &&  tempLen)		    {			_CHAR* pTmpText = pCurText;			LONG32 lTmpTextLen = tempLen;			BOOL bSpaceTabOrNewlineFound=FALSE;			do			{			    lNumBytesOfChar = (UCHAR)(*pTmpText)>=				    DBCS_MIN_LEAD_BYTE_VAL? 2:1;			    if(1==lNumBytesOfChar)			    {				if(' '==*pTmpText  ||  '\n'==*pTmpText  ||					'\r'==*pTmpText  ||  '\t'==*pTmpText)				{				    bSpaceTabOrNewlineFound = TRUE;				    break;				}			    }			    else			    {				lTmpTextLen++;				pTmpText--;				break;			    }			    pTmpText++;			    lTmpTextLen--;			}while(lTmpTextLen);			if(lTmpTextLen)			{			    //then we encountered a double-byte char or a			    // space, tab, or newline char, so ok to wordwrap			    // here:			    theFollowingSpaceCharIndex = tempLen-lTmpTextLen;			    savedChar=pCurText[theFollowingSpaceCharIndex+1];			    pCurText[theFollowingSpaceCharIndex+1] = '\0';			}		    }		}		else //This is SBCS:		{		    ULONG32 firstNonSpaceCharIndex =			    skipSpacesTabsAndNewlineChars(			    pCurText, tempLen, 0);		    ULONG32 dummyVar;		    if(firstNonSpaceCharIndex < (ULONG32)tempLen)		    {			theFollowingSpaceCharIndex =				findNextSpaceTabOrNewLineChar(				pCurText, tempLen,				firstNonSpaceCharIndex, dummyVar, ulCurCharset);			if(theFollowingSpaceCharIndex+1 < (ULONG32)tempLen)			{			    savedChar = pCurText[theFollowingSpaceCharIndex+1];			    if (lIndexOfTabTag >				    (LONG32)theFollowingSpaceCharIndex  &&				    isPlainText())			    {				bNextTabInPlainTextIsAfterNextWhitespaceChar = TRUE;			    }			    pCurText[theFollowingSpaceCharIndex+1] = '\0';			}			else			{			    lIndexOfTabTag = -1;			    bNextTabInPlainTextIsAfterNextWhitespaceChar = FALSE;			}		    }		}	    }	    if(!bPreTabOrNewlineCharOnly)	    {		//Now, look for "&lt;" or "&gt;" and, if found, end the		// TextContainer at the end of the "&lt;" or "&gt;" and replace		// it with '<' or '>'; also, look for "&#n;"		// (where n>8 && n<=255) and translate into the ASCII char		// with that value, and look for "&nbsp;" for ' ' and "&amp;"		// for '&':		ULONG32 ulIndexOfAmpersand = findNextChar('&',			pCurText,			theFollowingSpaceCharIndex,			0L,			ulCurCharset);		ULONG32 ulIndexOfLastCharInTCsBuf=theFollowingSpaceCharIndex;		ULONG32 theOriginalFollowingSpaceCharIndex =			theFollowingSpaceCharIndex;		if(theFollowingSpaceCharIndex > ulIndexOfAmpersand  &&			theFollowingSpaceCharIndex - ulIndexOfAmpersand >= 4  &&			// /Leave "&amp;"...etc. alone for plain text:			!isPlainText())		{		    FindEscapeSequenceChar(pCurText,			    ulIndexOfLastCharInTCsBuf, 			    theFollowingSpaceCharIndex, ulIndexOfAmpersand,			    ulCurCharset);		}		//Create a new one and add it to the list:		pTC = new TextContainer(pCurText,			ulIndexOfLastCharInTCsBuf+1>(ULONG32)tempLen?			(ULONG32)tempLen:ulIndexOfLastCharInTCsBuf+1);		//First, restore pData_CHAR:		if(theOriginalFollowingSpaceCharIndex+1 < (ULONG32)tempLen)		{		    pCurText[theOriginalFollowingSpaceCharIndex+1] =			    savedChar;		}		//then, reset tempLen and tmpStartIndex:		{		    tempLen -= theFollowingSpaceCharIndex+1;		    tmpStartIndex += theFollowingSpaceCharIndex+1;		}	    }	    else //is a tab char inside PRE so send a space char:	    {		//Create a new one and add it to the list:		pTC = new TextContainer(" ", 1);		bPreTabOrNewlineCharOnly = FALSE; //so while loop will quit.	    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -