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

📄 c_rtrndr.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
		    MIN_ACCEPTABLE_PLAINTEXT_HEIGHT) *2 /* *2 for safety*/;	    ULONG32 ulMaxBytesToBeSentByFF =		    m_ulMaxPlainTextBytesToBeSentByFF;	    m_ulMaxAllowedPlainTextCharsOnThisSystem =		    ulMaxCharsOnOneLine * ulMaxRowsOfPlainText;	    if (m_ulMaxAllowedPlainTextCharsOnThisSystem >		    ulMaxBytesToBeSentByFF)	    {		m_ulMaxAllowedPlainTextCharsOnThisSystem = ulMaxBytesToBeSentByFF;	    }	    // /If no wordwrap and CR & LF chars are treated literally (i.e.,	    // not as spaces), then the above calculation may not be correct	    // if there is a really long line followed by a CR or LF followed	    // by another line of text that should be drawn because it's not	    // past the bottom of the window yet.  In all other cases, the	    // above calculation is sufficient for fixing PR 78150 without	    // breaking valid content:	    if (!m_pTextWindow->usingWordwrap()  &&		    !m_pTextWindow->wasVertAlignExplicitlySet() )	    {		if (m_ulNoWrdWrpNoVertAlignPlainTxtCRsAndLFsSoFar >			ulMaxRowsOfPlainText)		{		    goto cleanup; /* [X] tested. */		}		else		{		    _CHAR* pTmp = pData_CHAR;		    ULONG32 ulCount = dataLength;		    _CHAR pPrevChar = '\0';		    BOOL bNewlineFoundInPacket = FALSE;		    do		    {			if ('\n' == *pTmp  &&  '\r' == pPrevChar)			{			    pPrevChar = *pTmp;  // /maintain original '\n'.#if defined(_MACINTOSH)			    // /Fixes PR 81110: replace all "\r\n"s with " \r"; that way,			    // on the Mac, \r\n will display as an unnoticed space plus a			    // single newline without the '\n' displaying as a box.  Also,			    // this is much more efficient than removing the \n since that			    // would require walking the entire buffer and shifting chars:			    *(pTmp-1) = ' ';			    *pTmp     = '\r';#endif /* _MACINTOSH*/			    			    			    continue; // /[\r\n] == 1 newline			}			if ('\r' == *pTmp  ||  '\n' == *pTmp)			{			    bNewlineFoundInPacket = TRUE;			    m_ulNoWrdWrpNoVertAlignPlainTxtCharsSinceLastCRorLF = 0;			    m_ulNoWrdWrpNoVertAlignPlainTxtCRsAndLFsSoFar++;			    			    pPrevChar = *pTmp;  // /maintain original '\n'.			    // /More fix for PR 81110: if we see a '\n' alone, treat it			    // as a '\r':			    if ('\n' == *pTmp)			    {				*pTmp = '\r';			    }			    			}			else			{			    m_ulNoWrdWrpNoVertAlignPlainTxtCharsSinceLastCRorLF++;			    pPrevChar = *pTmp;			}		    } while (ulCount--  &&  *(pTmp++));		    // /We can toss this whole packet if we didn't find a newline		    // char AND if we already have enough in the current line to		    // go past the width of the screen at min reasonable char width:		    if (!bNewlineFoundInPacket  &&			    (m_ulNoWrdWrpNoVertAlignPlainTxtCharsSinceLastCRorLF -			    dataLength) > ulMaxCharsOnOneLine)		    {			goto cleanup; /* [ ] tested. */		    }		}	    }	    else if (!m_pTextWindow->usingWordwrap())	    {		m_ulMaxAllowedPlainTextCharsOnThisSystem = ulMaxCharsOnOneLine;		if (m_ulPlainTextDataLen > ulMaxCharsOnOneLine)		{		    goto cleanup; /* [X] tested. */		}	    }	    else // /Using wordwrap:	    { 		if (m_ulPlainTextDataLen >			m_ulMaxAllowedPlainTextCharsOnThisSystem)		{ 		    goto cleanup; /* [X] tested. */		} #if defined(_MACINTOSH)		_CHAR* pTmp = pData_CHAR;		ULONG32 ulCount = dataLength;		_CHAR pPrevChar = '\0';		do		{ 		    if ('\n' == *pTmp)		    {			// /Fixes PR 81110 wordWrap="true" version (see above for			// description in non-wordwrap version):			if ('\r' == pPrevChar)			{			    *(pTmp-1) = ' '; // / '\r\n' ==> ' \r'			}			pPrevChar = *pTmp; // /maintain original '\n'.						// /Convert '\n' to '\r':			*pTmp = '\r';		    }		    else		    {			pPrevChar = *pTmp;		    }		} while (ulCount--  &&  *(pTmp++));#endif /* _MACINTOSH*/			    	    }	}	BOOL bIsFirstOnPacketData = FALSE;	if (0 == m_ulPlainTextDataLen)	{	    bIsFirstOnPacketData = bFromOnPacket;	    setPlainTextData(pData_CHAR);	}	else if (bFromOnPacket)	{	    // /If this is from an OnPacket() call, tack the data onto what's	    // there so far:	    appendPlainTextData(pData_CHAR);	}	if (0 == m_ulPlainTextDataLen)	{	    HX_ASSERT(m_ulPlainTextDataLen);	    return; // /No text to show.	}	// /Better fix for PR 59981 (+ helps fix PR 58784 & PR58791):	if (!bFromOnPacket  ||  bIsFirstOnPacketData)	{	    // /This is a reformatting call, not new data:	    m_pTextWindow->SetLatestSentTimeToRender(0);	    m_pTextWindow->SetLatestSentTimeToStopRendering(		    (ULONG32)ULONG_MAX);	    m_pTextWindow->m_bClearWasJustSent = TRUE;	    m_pTextWindow->clearNumBreakTagsEncountered();	    pData_CHAR = new _CHAR[m_ulPlainTextDataLen+1];	    HX_ASSERT(pData_CHAR);	    if (pData_CHAR)	    {		bDataCHARwasAllocd = TRUE;		strcpy((char*)pData_CHAR, m_pPlainTextData); /* Flawfinder: ignore */		m_pTextWindow->TextContainerList::flush(); // /Get rid of prior text.	    }	}	pTC = new TextContainer(m_pPlainTextData, m_ulPlainTextDataLen);	if (pTC)	{	    // /This new pTC includes *all* packets' text so far, so remove	    // prior one so we don't 	    ULONG32 ulNumDeleted = m_pTextWindow->TextContainerList::flush();	    HX_ASSERT(ulNumDeleted==(bIsFirstOnPacketData? 0 : 1));	    if (!m_pTextWindow->insertAtEndOfList(pTC, TRUE, FALSE))	    {		delete pTC;	    }	    // /Now, since we've reset the text back to its original encoding	    // (character set), we need to reset that flag to FALSE:	    m_pTextWindow->setCharsetTranslatedForOS(FALSE);	}#if defined(XXXEH_TESTING_DATAURLPLAINTEXT_HANDLING)FILE* f1 = ::fopen("c:\\LogDataURLhandling.txt", "a+"); ::fprintf(f1, "OnData(), pData_CHAR = {{{%s}}}\n", pData_CHAR);::fclose(f1);#endif  }  else // /Not plain text:  {    if(!pData_CHAR  ||  dataLength<1)    {	return; //there's nothing to do.    }    ULONG32 ulOriginalDataLength = dataLength;    if('\0' == pData_CHAR[dataLength-1])    {	dataLength -= 1;    }    BOOL bIsLiveSource = m_pTextWindow->isLiveSource();    //This will be set to FALSE as soon as we see some non-markup-tag text:    SetWeAreInsidePacketOpaqueHeader(TRUE);        //Find the first '<' or end-of-data, whichever comes first, and put    //	any raw text found before it into the TextContainer list:    LONG32 startIndex=0L;    //Changed this to skip newlines only:    //First, skip all newline characters at start of this string only    // if this is the very first packet received (and is not live):    IncrementCurrentPacketNum();    //XXXXXEH- if the first n packets were LOST, we shouldn't do the    // following (if n>=1), right?!?:    if(GetCurrentPacketNum() <= 1L  &&  !bIsLiveSource  &&  !isPlainText())    {	for(startIndex=0L; startIndex<(LONG32)dataLength; startIndex++)	{	    if(pData_CHAR[startIndex] != '\n'  &&		    pData_CHAR[startIndex] != '\r')	    {	        break;	    }	}    }    if((LONG32)dataLength == startIndex)    {	//All that were found were newline chars, so quit:	if (bDataCHARwasAllocd  &&  pData_CHAR)	{	    delete [] pData_CHAR;	}	return;     }    //Reset the ptr and dataLength to where the first    // non-newline is:    dataLength = dataLength-startIndex;    pData_CHAR = &(pData_CHAR[startIndex]);    startIndex = 0L;    //TEXTPRSR_DIFF:    //Added this so wordwrap calculating could be removed    // from the renderer end; the FF now sends "<WR>"s whenever the text    // that follows starts a new line due to wordwrapping (as calculated by    // the file format in a platform-independent way):    BOOL bIsWordWrapNewLine = FALSE;    //TEXTPRSR_DIFF:    //At start of packet,     m_pTextWindow->SetNewPktStartXAtTimeZero(INVALID_LONG32);    m_pTextWindow->SetNewPktStartYAtTimeZero(INVALID_LONG32);    LONG32 len = LONG32(dataLength);    //Got rid of this and replaced with     // m_pTextWindow's functions to keep track of this because there    // was a bug if a <BR> was the last thing in a packet, using just    // the following local variable meant that this info got lost    // when this function was done, so the next packet's data would    // not end up with the proper number of line breaks before it:    ///LONG32 numBreakTagsEncountered = 0L;        BOOL bSomeCharsFoundSinceLastBreakTag = FALSE;    //For bug #6906:    BOOL bSomeCharsFoundSinceLastPosTag = FALSE;    BOOL bUserPosTagFoundSinceLastTextContainer = FALSE;    ULONG32 ulCurCharset;    //TEXTPRSR_DIFF >>    BOOL bStartOfPacketNewlinesIsZero = FALSE;    //<<TEXTPRSR_DIFF.    ULONG32 ulNumPREtagNewlineCharsFound = 0L;    do //Now find the next '<', starting at pData_CHAR[startIndex]:    {	ulCurCharset = m_pTextWindow->peekAtCharsetStack();	LONG32 indexOfLeftBracket = -1;	LONG32 indexOfRightBracket = -1;	BOOL bSlashFoundAtEndOfTag = FALSE;	BOOL bIgnoringNewlineChars = FALSE;	BOOL bDealingWithTabCharWithPre = FALSE;	LONG32 lIndexOfTabTag = -1;	BOOL bNextTabInPlainTextIsAfterNextWhitespaceChar = FALSE;	LONG32 indx;	for(indx=startIndex; indx<len; indx++,		bSomeCharsFoundSinceLastPosTag=TRUE,		bSomeCharsFoundSinceLastBreakTag=TRUE)	{	    _CHAR ch = pData_CHAR[indx];	    //added the following to handle DBCS chars:	    if((ulCurCharset & HX_DBCS_CHARSET)  &&		    (UCHAR)ch >= DBCS_MIN_LEAD_BYTE_VAL)	    {		indx++; //skip this and the following trail byte.		continue;	    }	    if('<' == ch  &&  !isPlainText())	    {		indexOfLeftBracket = indx;		bSomeCharsFoundSinceLastBreakTag=FALSE; //Fixes bug #6903.		bSomeCharsFoundSinceLastPosTag=FALSE; //Helps fix bug #6906.		break;	    }	    //Convert any tab chars outside a tag to spaces if we're not	    // currently between a <PRE> and a </PRE>, else leave '\t' alone	    // and let TextWindow::insertAtEndOfList() calculate where the	    // next tab stop is:	    BOOL bTabCharHandled = FALSE;	    if('\t' == ch  ||  '\v' == ch		    ||  '\0' == ch) //added this for safety.	    {		pData_CHAR[indx] = ' ';		//treat tab char as a tab, not a space, inside PRE text:		if(('\t' == ch)  &&  (m_pTextWindow->peekAtIsPreStack()  ||			isPlainText()) )		{		    // pretend we've found the start and end of a tag so a		    // new TC will be created with this char and the		    // next will start just after this char.		    {			bTabCharHandled = TRUE;			indexOfLeftBracket = indx;			indexOfRightBracket = indexOfLeftBracket;			bDealingWithTabCharWithPre = TRUE;			lIndexOfTabTag = indx;			bSomeCharsFoundSinceLastBreakTag = TRUE;			bSomeCharsFoundSinceLastPosTag = TRUE;			break; //indexOf[Left&Right]Bracket vars are set				// to act as a fake tag just after this '\t'.		    }		}	    }	    //Reduce any string of newlines into either one or zero spaces;	    // one space if !bSomeCharsFoundSinceLastBreakTag, 0 otherwise:	    // UNLESS we're currently between a <PRE> and a </PRE>. in which	    // case leave them alone.	    // If we are ignoring extra spaces, then do this for spaces and	    // tab chars, too:	    else if(('\n' == ch  ||  '\r' == ch)  ||		    (m_pTextWindow->IgnoreExtraSpaces()  &&  		      ((!bTabCharHandled && ('\t' == ch  ||  '\v' == ch))  ||		      ' ' == ch		      )		    )		   )	    {		LONG32 firstNewlineIndex = indx;		pData_CHAR[firstNewlineIndex] = ' ';		indexOfLeftBracket = indx;		if(indexOfLeftBracket+1==len			//TEXTPRSR_DIFF>>			// FF version of this code, in textprsr.cpp, doesn't			// have to make sure that it won't go past the end			// of the buffer because it always has a '\0' beyond			// the dataLength given, whereas here we may have a			// '\0' as the last element:			&&  len<(LONG32)ulOriginalDataLength)			//<<END TEXTPRSR_DIFF.		{		    //If we're at the end of the packet and it ends with a		    // space or tab char and we're ignoring extra spaces,		    // then we want to make sure NOT to ignore this last		    // space if it's solo:		    if('\n' != ch  &&  '\r' != ch  &&			    m_pTextWindow->IgnoreExtraSpaces())		    {			indexOfLeftBracket++;		    }		}		LONG32 newLineCharCount=1L;		BOOL bNonSpaceTabNewlineCharWasLastFound = FALSE;		for(indx++; indx<len; indx++, newLineCharCount++)		{		    _CHAR ch2 = pData_CHAR[indx];		    if('\n' == ch2  ||  '\r'== ch2)		    {			pData_CHAR[indx] = ' ';			if(m_pTextWindow->peekAtIsPreStack()  ||  isPlainText())			// pretend we've found the start and end of a tag so			// a new TC will be created with this char and the			// next will start just after this char:			{			    //See if this is a PC "\r\n" newline:			    if('\r' == pData_CHAR[indx-1]  &&  '\n' == ch2)			    {				indx++;			    }			    ulNumPREtagNewlineCharsFound++;			}		    }		    else if(m_pTextWindow->IgnoreExtraSpaces()  &&			    !m_pTextWindow->peekAtIsPreStack()  &&			    (!bTabCharHandled && ('\t' == ch2  ||				    '\v' == ch2)) )		    {			;		    }		    else if(m_pTextWindow->IgnoreExtraSpaces()  &&			    !m_pTextWindow->peekAtIsPreStack()  &&			    ' ' == ch2)		    {			;		    }

⌨️ 快捷键说明

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