コード例 #1
0
ファイル: VValueBag.cpp プロジェクト: StephaneH/core-XToolbox
/*
	static
*/
void VValueBag::GetKeysFromPath( const VString& inPath, StKeyPath& outKeys)
{
	VFromUnicodeConverter_UTF8 converter;

	char buffer[256];
	VIndex charsConsumed;
	VSize bytesProduced;
	const UniChar *begin = inPath.GetCPointer();
	const UniChar *end = begin + inPath.GetLength();
	for( const UniChar *pos = begin ; pos != end ; ++pos)
	{
		if (*pos == '/')
		{
			bool ok = converter.Convert( begin, (VIndex) (pos - begin), &charsConsumed, buffer, sizeof( buffer), &bytesProduced);
			if (ok)
			{
				outKeys.push_back( StKey( buffer, bytesProduced));
			}
			begin = pos + 1;
		}
	}
	if (begin != end)
	{
		bool ok = converter.Convert( begin, (VIndex) (end - begin), &charsConsumed, buffer, sizeof( buffer), &bytesProduced);
		if (ok)
		{
			outKeys.push_back( StKey( buffer, bytesProduced));
		}
	}
}
コード例 #2
0
void VXMLSyntax::parseOneLineByLex(ICodeEditorDocument *&inDocument, sLONG inLineNumber,struct xmlLexStyleInfo *&inputstruct)
{
	VString xstr;
	inDocument->GetLine(inLineNumber,xstr);
	const UniChar * unistring  = xstr.GetCPointer();
	char *lexinput;
	sLONG len = xstr.GetLength();
	lexinput = new char[len+1];
	lexinput[len] = '\0';

	for(int i = 0 ; i < len ; i++)     //to change unicode to char
	{
		if ( unistring[i] == 9 )
		{
			lexinput[i] = ' ';
		}
		else if (unistring[i] > 127)
		{	
			lexinput[i] = 'X';
		}
		else
		{	
			lexinput[i] = (char)unistring[i];
		}			
	}
	inputstruct = startxmlParse(lexinput);  
	delete lexinput;
}
コード例 #3
0
JS4D::ValueRef JS4D::VStringToValue( ContextRef inContext, const VString& inString)
{
	if (inString.IsNull())
		return JSValueMakeNull( inContext);

	JSStringRef jsString = JSStringCreateWithCharacters( inString.GetCPointer(), inString.GetLength());
	ValueRef value = JSValueMakeString( inContext, jsString);
	JSStringRelease( jsString);
	return value;
}
コード例 #4
0
bool VXMLParser::Parse( const VString& inText, IXMLHandler *inHandler, XMLParsingOptions inOptions)
{
	xercesc::MemBufInputSource source( (const XMLByte *) inText.GetCPointer(), inText.GetLength() * sizeof( UniChar), "frommem");
	#if BIGENDIAN
	source.setEncoding( xercesc::XMLUni::fgUTF16BEncodingString);
	#else
	source.setEncoding( xercesc::XMLUni::fgUTF16LEncodingString);
	#endif

	return SAXParse( this, source, inHandler, inOptions);
}
コード例 #5
0
ファイル: VValueBag.cpp プロジェクト: StephaneH/core-XToolbox
bool VValueBag::NeedsEscapeSequence( const VString& inText, const UniChar* inEscapeFirst, const UniChar* inEscapeLast)
{
	bool found = false;
	for( const UniChar *ptr = inText.GetCPointer() ; *ptr && !found ; ++ptr)
	{
		for (const UniChar* pEscape = inEscapeFirst ; (pEscape != inEscapeLast) && !found ; ++pEscape)
		{
			found = (*ptr == *pEscape);
		}
	}
	return found;
}
コード例 #6
0
int VXMLSyntax::findStopLoc(ICodeEditorDocument* inDocument,int inLineNumber,int commenttype)
{
	VString xstr;
	inDocument->GetLine(inLineNumber,xstr);
	const UniChar * unistringtemp  = xstr.GetCPointer();
	int stoploc = 0;


	if ( commenttype == ordinarycomment)
	{
		for (int i = 0;i < xstr.GetLength()-1;i++)
		{
			if (unistringtemp[i] == '*' && unistringtemp[i+1] == '/')
			{  
				stoploc = i+1;
				break;
			}
			if (unistringtemp[i] == '/' && unistringtemp[i+1] == '*')
			{
				stoploc = i +1;
				break;
			}
		}
	}
	else if ( commenttype == htmlsytlecomment )
	{
		for (int i = 0;i < xstr.GetLength()-3;i++)
		{ 
			//		char c = unistringtemp[i];
			if (unistringtemp[i+1] == '-' && unistringtemp[i+2] == '-' && unistringtemp[i+3] == '>')
			{  
				stoploc = i+2;
				break;
			}
			if (unistringtemp[i] == '<' && unistringtemp[i+1] == '!' && unistringtemp[i+2] == '-'&& unistringtemp[i+3] == '-')
			{
				stoploc = i + 3;
				break;
			}
		}

	}

	return stoploc;
}
コード例 #7
0
VError XWinFileSystemNotification::StartWatchingForChanges( const VFolder &inFolder, VFileSystemNotifier::EventKind inKindFilter, VFileSystemNotifier::IEventHandler *inHandler, sLONG inLatency )
{
	VString path;
	inFolder.GetPath( path );

	VError err = VE_OK;

	// Now that we know we need to care about this folder, let's see if we can create an entry for it.  First,
	// we will try to open a handle to the folder.
	HANDLE hFolder = ::CreateFileW( path.GetCPointer(), FILE_LIST_DIRECTORY | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 
						NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, NULL );
	if (hFolder == INVALID_HANDLE_VALUE)
	{
		// We were unable to open the folder, so we need to bail out
		return MAKE_NATIVE_VERROR( ::GetLastError() );
	}

	// launch our task if not already there
	LaunchTaskIfNecessary();

	// Now that we've opened the folder handle, we can add an entry to our watch list
	XWinChangeData *data = new XWinChangeData( inFolder.GetPath(), inKindFilter, VTask::GetCurrent(), inHandler, this);
	data->fFolderHandle = hFolder;
	data->fLatency = inLatency;
	data->fOverlapped.hEvent = ::CreateEvent( NULL, true, false, NULL );
	data->fTimer = NULL;
	if (inLatency)
		data->fTimer = ::CreateWaitableTimer( NULL, FALSE, NULL );

	// Add the new data to our list of things to watch for
	fOwner->PushChangeData( data );

	WatchForChanges( data );

	ReleaseRefCountable( &data);

	return VE_OK;
}
コード例 #8
0
/** parse span text element or XHTML fragment 
@param inTaggedText
	tagged text to parse (span element text only if inParseSpanOnly == true, XHTML fragment otherwise)
@param outStyles
	parsed styles
@param outPlainText
	parsed plain text
@param inParseSpanOnly
	true (default): only <span> element(s) with CSS styles are parsed
	false: all XHTML text fragment is parsed (parse also mandatory HTML text styles)
*/
void VSpanTextParser::ParseSpanText( const VString& inTaggedText, VTreeTextStyle*& outStyles, VString& outPlainText, bool inParseSpanOnly)
{
	outPlainText = "";
	if(outStyles)
		outStyles->Release();
	outStyles = NULL;
	if (inTaggedText.IsEmpty())
		return;
	//fixed ACI0076343: for compatibility with older bases which do not have support for multistyle var or field
	//					we need to convert to xml text the text which is not bracketed with SPAN 
	//					otherwise parser would fail
	VString vtext;
	sLONG posStartSPAN = 1; //pos of first SPAN tag
	sLONG posEndSPAN = inTaggedText.GetLength()+1; //pos of character following ending SPAN tag
	if (inParseSpanOnly)
	{
		//search for opening SPAN tag
		posStartSPAN = inTaggedText.Find("<SPAN", 1, false);
		if (!posStartSPAN)
		{
			//convert full text to xml
			inTaggedText.GetXMLString( vtext, XSO_Default); 
			vtext = VString("<SPAN>")+vtext+"</SPAN>";
		}
		else 
		{
			VString before, after;
			if (posStartSPAN > 1)
			{
				//convert to XML text preceeding first SPAN 
				VString temp;
				inTaggedText.GetSubString( 1, posStartSPAN-1, temp);
				temp.GetXMLString( before, XSO_Default);
			}
			//search for ending SPAN tag
			const UniChar *c = inTaggedText.GetCPointer()+inTaggedText.GetLength()-1;
			sLONG pos = inTaggedText.GetLength()-1;
			VString spanEndTag = "</SPAN>";
			VString spanEndTag2 = "</span>";
			do
			{
				while (pos >= 0 && *c != '>')
				{
					pos--;
					if (pos >= 0)
						c--;
				}
				if (pos >= 0)
				{
					if (memcmp( (void*)(c+1-spanEndTag.GetLength()), spanEndTag.GetCPointer(), spanEndTag.GetLength()*sizeof(UniChar)) == 0
						||
						memcmp( (void*)(c+1-spanEndTag2.GetLength()), spanEndTag2.GetCPointer(), spanEndTag2.GetLength()*sizeof(UniChar)) == 0)
					{
						posEndSPAN = pos+2;
						break;
					}	
					else
					{
						pos--;
						if (pos >= 0)
							c--;
					}
				}
			} while (pos >= 0);
			if (posEndSPAN <= inTaggedText.GetLength())
			{
				//convert to XML text following ending SPAN tag
				VString temp;
				inTaggedText.GetSubString( posEndSPAN, inTaggedText.GetLength()-posEndSPAN+1, temp);
				temp.GetXMLString( after, XSO_Default);
			}
			if (!before.IsEmpty() || !after.IsEmpty())
			{
				inTaggedText.GetSubString( posStartSPAN, posEndSPAN-posStartSPAN, vtext);
				vtext = VString("<SPAN>")+before+vtext+after+"</SPAN>";
			}
			else
				vtext = VString("<SPAN>")+inTaggedText+"</SPAN>";
		}
	}
	else
		vtext = inTaggedText;

	vtext.ExchangeAll(0x0B,0x0D);//[MI] le 28/12/2010 ACI0069253
#if VERSIONWIN
	vtext.ConvertCarriageReturns(eCRM_CR); //important here on Windows before parsing because styles are assumed to use one character size for line ending on any platform 
										   //and so pair of 0x0D 0x0A should be treated as a single 0x0D character
#endif											
	VTaggedTextSAXHandler vsaxhandler(outStyles, &outPlainText, inParseSpanOnly);
	VXMLParser vSAXParser;

	vSAXParser.Parse(vtext, &vsaxhandler, XML_ValidateNever);

#if VERSIONWIN
	outPlainText.ConvertCarriageReturns(eCRM_CR); //we need to convert to CR (on any platform but Linux here) because xerces parser has converted all line endings to LF (cf W3C XML line ending uniformization while parsing)
#elif VERSIONMAC
	outPlainText.ConvertCarriageReturns(eCRM_CR); //we need to convert to CR (on any platform but Linux here) because xerces parser has converted all line endings to LF (cf W3C XML line ending uniformization while parsing)
#endif
}
コード例 #9
0
void XWinIntlMgr::FormatDate( const VTime& inDate, VString& outDate, EOSFormats inFormat, bool inUseGMTTimeZoneForDisplay)
{
	// Prepare SYSTEMTIME for windows.
	sWORD YY = 0;
	sWORD MM = 0;
	sWORD DD = 0;
	sWORD hh = 0;
	sWORD mm = 0;
	sWORD ss = 0;
	sWORD ms = 0;
	if (inUseGMTTimeZoneForDisplay)
		inDate.GetUTCTime (YY,MM,DD,hh,mm,ss,ms);
	else
		inDate.GetLocalTime (YY,MM,DD,hh,mm,ss,ms);

	// Verify if date >1st Jan 1601 (GetDateFormat doesn't support earlier dates.
	if (YY>=1601)
	{
		// Let the OS do it's job.
		UniChar acBuffer[256];

		SYSTEMTIME osDate={0};
		osDate.wYear=YY;
		osDate.wMonth=MM;
		osDate.wDay=DD;
		osDate.wHour=hh;
		osDate.wMinute=mm;
		osDate.wSecond=ss;
		osDate.wMilliseconds=ms;

		if (inFormat == eOS_MEDIUM_FORMAT)
		{
			VString pattern;
			if (GetLocaleInfo( LOCALE_SLONGDATE, pattern))
			{
				// replace long month and date by medium ones
				pattern.ExchangeRawString( CVSTR( "MMMM"), CVSTR( "MMM"));
				pattern.ExchangeRawString( CVSTR( "dddd"), CVSTR( "ddd"));
				if (::GetDateFormatW( fDialect, 0, &osDate, pattern.GetCPointer(), acBuffer, sizeof(acBuffer)))
					outDate = acBuffer;
			}
		}
		else
		{
			// Let the OS do the stuff.
			DWORD dateFormat = (inFormat == eOS_SHORT_FORMAT) ? DATE_SHORTDATE : DATE_LONGDATE;
			if (::GetDateFormatW(fDialect,dateFormat,&osDate,NULL,acBuffer,sizeof(acBuffer)))
				outDate = acBuffer;
		}
	}
	else
	{
		// Get the date pattern
		VString pattern;
		if (GetLocaleInfo( (inFormat == eOS_LONG_FORMAT) ? LOCALE_SLONGDATE : LOCALE_SSHORTDATE, pattern))
		{
			XBOX::VString tokens="gyMd";
			UniChar oldToken=0;
			sLONG count=0;
			pattern.AppendChar(' ');
			sLONG YY2=YY%100;
			XBOX::VString oneName;
			for (int pos=0;pos<pattern.GetLength();pos++)
			{
				UniChar token=pattern[pos];
				if (tokens.FindUniChar(token)>=1)
				{
					if (token==oldToken)
						count++;
					else
					{
						if (!count)
						{
							count=1;
							oldToken=token;
						}
					}
				}

				if (count && token!=oldToken)
				{
					switch(oldToken)
					{
					case 'g':
						if (count==2)
						{
							// TODO: ERA will be added if really wanted.
						}
						else
						{
							for (int i=0;i<count;i++)
								outDate.AppendUniChar(oldToken);
						}
						break;

					case 'y':	// YEAR
						switch(count)
						{
						case 5:
						case 4:		// 4 or more digits date
							outDate.AppendLong(YY);
							break;

						case 2:		// 2 digits with starting 0.
							if (YY2<=9)
								outDate.AppendLong(0);
						case 1:		// 1 or 2 digits
							outDate.AppendLong(YY2);
							break;

						default:
							for (int i=0;i<count;i++)
								outDate.AppendUniChar(oldToken);
							break;
						}
						break;

					case 'M':	// MONTH
						switch(count)
						{
						case 4:	// Long name
						case 3:	// Abbreviated name
							if (GetLocaleInfo( ((count==4) ? LOCALE_SMONTHNAME1 : LOCALE_SABBREVMONTHNAME1) + MM - 1, oneName))
								outDate += oneName;
							break;

						case 2:	// 2 digits number (leading 0)
							if (MM<=9)
								outDate.AppendLong(0);
						case 1:	// 1 or 2 digits number
							outDate.AppendLong(MM);
							break;

						default:
							for (int i=0;i<count;i++)
								outDate.AppendUniChar(oldToken);
							break;
						}
						break;

					case 'd':	// DAY
						switch(count)
						{
						case 4:	// Weekday long name
						case 3:	// Weekday abbreviated name
							if (GetLocaleInfo( ((count==4) ? LOCALE_SDAYNAME1 : LOCALE_SABBREVDAYNAME1) + (inDate.GetWeekDay() + 6) % 7, oneName))
								outDate += oneName;
							break;

						case 2:	// Month day on 2 digits (leading 0)
							if (DD<=9)
								outDate.AppendLong(0);
						case 1:	// Month day on 1 or 2 digits.
							outDate.AppendLong(DD);
							break;

						default:
							for (int i=0;i<count;i++)
								outDate.AppendUniChar(oldToken);
							break;
						}
						break;

					}
					count=0;
				}

				if (!count)
					outDate.AppendUniChar(token);
				oldToken=token;
			}

			// Remove the extra space at end of pattern.
			if (outDate.GetLength()>1)
				outDate.SubString(1,outDate.GetLength()-1);
		}
	}
}
コード例 #10
0
ファイル: VFont.cpp プロジェクト: sanyaade-iot/core-XToolbox
/** return true if font with the specified font family name, style and size exists on the current system */
bool VFont::FontExists(const VString& inFontFamilyName, const VFontFace& inFace, GReal inSize, const GReal inDPI, const VGraphicContext *inGC)
{
#if VERSIONWIN
	bool exists = false;
	//JQ 21/06/2010: fixed and optimized FontExists (was not coherent with font creation)
	VFont *font = RetainFont( inFontFamilyName, inFace, inSize, inDPI, true);
	if (font)
	{
		if (!font->IsTrueTypeFont())
		{
			//not TrueType fonts are drawed with GDI
			//so return true if a valid HFONT is set

			HFONT hFont = font->GetFontRef();
			exists = hFont != NULL;
			font->Release();
			return exists;
		}
#if ENABLE_D2D
		if (inGC && inGC->IsD2DImpl())
		{
			//if DWrite font family name is not equal to inFontFamilyName
			//DWrite has returned a compatible font 
			//so return true only if DWrite font family name matches inFontFamilyName

			VTaskLock lock(&VWinD2DGraphicContext::GetMutexDWriteFactory());
			exists = false;
			if (font->GetImpl().GetDWriteTextFormat() != NULL)
			{
				UINT32 nameLength = font->GetImpl().GetDWriteTextFormat()->GetFontFamilyNameLength();
				if (nameLength+1 <= 80)
				{
					WCHAR familyName[80];
					HRESULT hr = font->GetImpl().GetDWriteTextFormat()->GetFontFamilyName( familyName, nameLength+1);
					exists = wcscmp( inFontFamilyName.GetCPointer(), familyName) == 0;
				}
				else
				{
					WCHAR *familyName = new WCHAR[nameLength+1];
					font->GetImpl().GetDWriteTextFormat()->GetFontFamilyName( familyName, nameLength+1);
					exists = wcscmp( inFontFamilyName.GetCPointer(), familyName) == 0;
					delete [] familyName;
				}
			}
			font->Release();
			return exists;
		}
#endif
		//if gdiplus font family name is not equal to inFontFamilyName
		//gdiplus has returned a compatible font 
		//so return true only if gdiplus font family name matches inFontFamilyName
		Gdiplus::FontFamily *family = new Gdiplus::FontFamily();
		Gdiplus::Status status = font->GetImpl().GetGDIPlusFont()->GetFamily(family);
		WCHAR familyName[LF_FACESIZE];
		family->GetFamilyName( familyName);
		exists = wcscmp( inFontFamilyName.GetCPointer(), familyName) == 0;
		delete family;

		font->Release();
	}
	return exists;
#else
	bool exists = false;
	VFont *font = RetainFont( inFontFamilyName, inFace, inSize, inDPI, true);
	if (font)
	{
		//ensure returned font has the requested family name (here we check only the family name but not the full name)
		//otherwise it is a font substitute
		CTFontRef ctfont = font->GetFontRef();
		CFStringRef name = CTFontCopyFamilyName(ctfont);
		VString xname;
		xname.MAC_FromCFString( name);
		CFRelease(name);
		VString inname( inFontFamilyName);
		inname.Truncate( xname.GetLength());
		return inname.EqualToString( xname);
	}
	return exists;
#endif
}
コード例 #11
0
JS4D::StringRef JS4D::VStringToString( const VString& inString)
{
	JSStringRef jsString = JSStringCreateWithCharacters( inString.GetCPointer(), inString.GetLength());
	return jsString;
}
コード例 #12
0
void VXMLSyntax::SetLine( ICodeEditorDocument* inDocument, sLONG inLineNumber, bool inLoading )
{

	int linekind_comment_aboveline      = 0;
	int linekind_comment_curline_cur    = 0;
	int linekind_comment_curline_former = 0;


	bool NeedTocheckCommet  = false;	//use as a flag whether we should check scommet 
	int checkType	        = 0;                  //check in which situation of the scomment



	if ( inLineNumber > 0 )
	{
		linekind_comment_aboveline = getFullLindKind_Comment(inDocument,inLineNumber-1);
	}
	linekind_comment_curline_former = getFullLindKind_Comment(inDocument,inLineNumber);





	//begin parsing
	struct xmlLexStyleInfo * lexstrptr = 0;
	VString xstr;
	inDocument->GetLine(inLineNumber,xstr);
	const UniChar * unistring  = xstr.GetCPointer();
	char *lexinput;
	sLONG len = xstr.GetLength();
	lexinput = new char[len+1];
	lexinput[len] = '\0';
	for(int i = 0 ; i < len; i++)     //to change unicode to char
	{
		if (unistring[i] == 9)
			lexinput[i] = ' ';
		else if (unistring[i] > 127)
			lexinput[i] = 'X';
		else
			lexinput[i] = (char)unistring[i];			
	}
	lexstrptr = startxmlParse(lexinput); 

	linekind_comment_curline_cur = getxmlLinetype();
	setLineKind_Lex(inDocument,inLineNumber,linekind_comment_curline_cur);
	linekind_comment_curline_cur = linekind_comment_curline_cur%100;






	if ( (inDocument->GetLineKind(inLineNumber)%1000)/100 > common )       //if the line tag begin or tagend
	{

		if ( getLindKind_Tagnameloc(inDocument,inLineNumber) == 0 )
		{
			allxmltags.Push(getxmlTagName());

			setLindKind_Tagnameloc(inDocument,inLineNumber,allxmltags.GetCount());	
		}
		else
		{
			int line_i_tag_loc = getLindKind_Tagnameloc(inDocument,inLineNumber);		
			allxmltags[line_i_tag_loc-1] = getxmlTagName();
		}

	}




	inDocument->SetLineStyle(inLineNumber,0,len,0);		//initiate the line
	for (int j = 0; j < getxmlKeywordNum(); j++ )						//set the keywords color	
	{      
		inDocument->SetLineStyle(inLineNumber,lexstrptr->indent,(lexstrptr->indent)+(lexstrptr->length),xmlcolorShadow[lexstrptr->style]);							
		lexstrptr++;
	}	




	/************************************************************************/
	/* the following code to                                                                     */
	/************************************************************************/



	for (int commenttypei = 0; commenttypei <= htmlsytlecomment ; commenttypei++  )
	{	

		int linekind_comment_specific_cur    = 0;
		int linekind_comment_specific_fomer  = 0;

		int	linkkind_comment_specific_above  = 0; 


		if ( commenttypei == ordinarycomment )
		{
			linekind_comment_specific_cur   = linekind_comment_curline_cur%10;                     //both ..cur and ..former >= 0
			linekind_comment_specific_fomer = linekind_comment_curline_former%10;
			linkkind_comment_specific_above = linekind_comment_aboveline%10;
		}
		else if ( commenttypei == htmlsytlecomment )
		{
			linekind_comment_specific_cur   = linekind_comment_curline_cur/10;                     //both ..cur and ..former >= 0
			linekind_comment_specific_fomer = linekind_comment_curline_former/10;
			linkkind_comment_specific_above = linekind_comment_aboveline/10;
		}



		if ( linekind_comment_curline_former != linekind_comment_curline_cur)		    //if current linekind is changed, we need to check comment folding
		{  

			NeedTocheckCommet = true;

			linekind_comment_specific_fomer = linekind_comment_specific_fomer*10 + linekind_comment_specific_cur;     //getLineKind_Comment(inDocument,inLineNumber);		

			switch(linekind_comment_specific_fomer)
			{

			case 1:  checkType = enterCreateCommon;break;
			case 2:  checkType = enterCreateOnlyStart;break;
			case 3:  checkType = enterCreateOnlyEnd;break;
			case 4:  checkType = enterCreateBoth;break;
			case 12: checkType = commonAddStart;break;                     
			case 21: checkType = onlyStartDeleteStart;break;
			case 23: checkType = endStartDeleteStart;break;
			case 24: checkType = onlyStartAddEnd;	break;
			case 31: checkType = onlyEndDeleteEnd; break;
			case 32: checkType = onlyEndRightAddStart;break;
			case 34: checkType = onlyEndAddStart;break; 
			case 41: checkType = bothToCommon;break;
			case 42: checkType = bothDeleteEnd;break;
			case 43: checkType = bothDeleteStart;break;
			case 51: checkType = insideType;break;
			case 52: checkType = insideAddStart;break;
			case 53: checkType = insideAddEnd;break;
			case 54: checkType = insideCommentToBoth;break;

			default: checkType = 99;

			}
		}
		else																			  // the line kind comment is unchanged
		{
			if (inLineNumber > 0)
			{      
				if ( linkkind_comment_specific_above == insideComment || linkkind_comment_specific_above == startWithoutEnd )
				{	  	
					switch (linekind_comment_specific_cur)
					{
					case common:           inDocument->SetLineStyle(inLineNumber,0,len,0);setLineKind_Comment(inDocument,inLineNumber,insideComment,commenttypei);linekind_comment_specific_cur = insideComment;break;
					case insideComment:    inDocument->SetLineStyle(inLineNumber,0,len,4);break;
					case startWithoutEnd : inDocument->SetLineStyle(inLineNumber,0,findStopLoc(inDocument,inLineNumber,commenttypei),4);
					default:               inDocument->SetLineStyle(inLineNumber,0,findStopLoc(inDocument,inLineNumber,commenttypei),4);
					}
				}	  
			}
		}



		if (NeedTocheckCommet)				 //need to handle comment 
		{
			int line_i_type = 0;         
			int totallinenum = 0;

			totallinenum = inDocument->GetNbLines();


			//----------------------------------------------------------------------------------------------------------------


			if (checkType == enterCreateCommon || checkType == bothToCommon)
			{
				if (inLineNumber > 0 &&  (linkkind_comment_specific_above == insideComment || linkkind_comment_specific_above == startWithoutEnd ))
				{
					inDocument->SetLineStyle(inLineNumber,0,len,4);	
					setLineKind_Comment(inDocument,inLineNumber,insideComment,commenttypei);
				}
			}


			//-----------------------------------------------------------------------------------------------------------------


			else if (checkType == commonAddStart || checkType == onlyEndRightAddStart  || checkType == bothDeleteEnd || checkType == enterCreateOnlyStart)     //case 12,42:  comment add a start     AAAAA  ->  AAA /* AAA
			{      
				if (checkType != commonAddStart)
				{	
					if (inLineNumber > 0 &&  (linkkind_comment_specific_above == insideComment || linkkind_comment_specific_above == startWithoutEnd ))
					{	
						inDocument->SetLineStyle(inLineNumber,0,findStopLoc(inDocument,inLineNumber,commenttypei),4);
					}

				}

				for (int i = inLineNumber+1; i < totallinenum; i++)
				{
					line_i_type = getLineKind_Comment(inDocument,i,commenttypei);
					inDocument->GetLine(i,xstr);
					if (line_i_type == endWithoutStart || line_i_type == startWithEnd ||line_i_type == startWithoutEnd)
					{			
						inDocument->SetLineStyle(i,0, findStopLoc(inDocument,i,commenttypei),4);						
						break;
					}
					else
					{
						inDocument->SetLineStyle(i,0,xstr.GetLength(),4);
						if (line_i_type == common)
						{
							setLineKind_Comment(inDocument,i,insideComment,commenttypei);
						}
					}
				}
			}



			//-----------------------------------------------------------------------------------------------------------------


			else if (checkType == onlyStartDeleteStart )   //case 21:       AAA /*  AA  ->  AAAAAA
			{
				if (inLineNumber > 0 && (linkkind_comment_specific_above == insideComment || linkkind_comment_specific_above ==startWithoutEnd))
				{
					inDocument->SetLineStyle(inLineNumber,0,len,4);
					setLineKind_Comment(inDocument,inLineNumber,insideComment,commenttypei);
				}
				else
				{
					for (int i = inLineNumber+1;i < inDocument->GetNbLines();i++)
					{
						line_i_type = getLineKind_Comment(inDocument,i,commenttypei);
						inDocument->GetLine(i,xstr);					
						const UniChar * unistringtemp = xstr.GetCPointer();
						sLONG len = xstr.GetLength();
						lexinput = new char[len+1];
						lexinput[len] = '\0';
						for(int j = 0 ; j < len ; j++)     //to change unicode to char
						{
							if (unistringtemp[j] == 9)
								lexinput[j] = ' ';
							else if (unistringtemp[j] > 127)
								lexinput[j] = 'X';
							else
								lexinput[j] = (char)unistringtemp[j];			
						}
						lexstrptr = startxmlParse(lexinput);  
						setLineKind_Lex(inDocument,i,getxmlLinetype());
						inDocument->SetLineStyle(i,0,len,4);  //initate the line
						for (int j = 0; j < getxmlKeywordNum(); j++ )
						{      
							inDocument->SetLineStyle(i,lexstrptr->indent,(lexstrptr->indent)+(lexstrptr->length),xmlcolorShadow[lexstrptr->style]);				
							lexstrptr++;
						}	

						if (line_i_type == startWithEnd || line_i_type == startWithoutEnd || line_i_type == endWithoutStart)
						{

							break;
						}

					}
				}
			}



			//--------------------------------------------------------------------------------------------------------------------------------------------



			else if (checkType == endStartDeleteStart || checkType == onlyStartAddEnd || checkType == insideAddEnd || checkType == enterCreateOnlyEnd || checkType == enterCreateBoth)    //23  24
			{

				if (inLineNumber > 0 && (linkkind_comment_specific_above == startWithoutEnd || linkkind_comment_specific_above == insideComment))
				{ 
					inDocument->SetLineStyle(inLineNumber,0,findStopLoc(inDocument,inLineNumber,commenttypei),4);
				}

				for (int i = inLineNumber +1; i < totallinenum; i++)
				{
					line_i_type = getLineKind_Comment(inDocument,i,commenttypei);

					inDocument->GetLine(i,xstr);					
					const UniChar * unistringtemp = xstr.GetCPointer();
					sLONG len = xstr.GetLength();
					lexinput = new char[len+1];
					lexinput[len] = '\0';
					for(int j = 0 ; j < len ; j++)     //to change unicode to char
					{
						if (unistringtemp[j] == 9)
							lexinput[j] = ' ';
						else if (unistringtemp[j] > 127)
							lexinput[j] = 'X';
						else
							lexinput[j] = (char)unistringtemp[j];				
					}
					lexstrptr = startxmlParse(lexinput);  
					setLineKind_Lex(inDocument,i,getxmlLinetype());
					inDocument->SetLineStyle(i,0,len,0);  //initate the line
					for (int j = 0; j < getxmlKeywordNum(); j++ )
					{      
						inDocument->SetLineStyle(i,lexstrptr->indent,(lexstrptr->indent)+(lexstrptr->length),xmlcolorShadow[lexstrptr->style]);						
						lexstrptr++;
					}	

					if (line_i_type == startWithEnd || line_i_type == startWithoutEnd || line_i_type == endWithoutStart)
					{
						break;
					}			 
				}		
			}



			//---------------------------------------------------------------------------------------------------------------------------------------------


			else if (checkType == onlyEndDeleteEnd)      //31
			{
				if (inLineNumber > 0 &&  (linkkind_comment_specific_above == insideComment || linkkind_comment_specific_above == startWithoutEnd ))
				{
					for (int i =inLineNumber; i < totallinenum ;i++)
					{
						line_i_type = getLineKind_Comment(inDocument,i,commenttypei);
						inDocument->GetLine(i,xstr);
						if (line_i_type == startWithEnd || line_i_type == endWithoutStart)
						{							
							inDocument->SetLineStyle(i,0,findStopLoc(inDocument,i,commenttypei),4);
							break;
						}
						else
						{
							inDocument->SetLineStyle(i,0,xstr.GetLength(),4);
							if (line_i_type == common)
							{
								setLineKind_Comment(inDocument,i,insideComment,commenttypei);
							}
						}
					}
				}
			}



			//---------------------------------------------------------------------------------------------------------------------------------------------



			else if (checkType == insideType || checkType == insideAddStart || checkType == bothDeleteStart)     //51
			{
				if (checkType == insideType)
				{
					inDocument->SetLineStyle(inLineNumber,0,len,4);
				}
				else
				{
					if (inLineNumber > 0 &&  (linkkind_comment_specific_above == insideComment || linkkind_comment_specific_above == startWithoutEnd ))
					{		
						inDocument->SetLineStyle(inLineNumber,0,findStopLoc(inDocument,inLineNumber,commenttypei),4);
					}
				}

				if (checkType == insideType)
				{	
					setLineKind_Comment(inDocument,inLineNumber,insideComment,commenttypei);
				}

			}

			//---------------------------------------------------------------------------------------------------------------------------------------------
		}
	}

	delete lexinput;



	
}
コード例 #13
0
bool XWinSystem::DisplayNotification( const VString& inTitle, const VString& inMessage, EDisplayNotificationOptions inOptions, ENotificationResponse *outResponse)
{
	bool ok;
	
	UINT flags = MB_TASKMODAL | MB_SERVICE_NOTIFICATION;
	flags |= (inOptions & EDN_StyleCritical) ? MB_ICONWARNING : MB_ICONINFORMATION;

	switch( inOptions & EDN_LayoutMask)
	{
		case EDN_OK:
			flags |= MB_OK;
			break;
		
		case EDN_OK_Cancel:
			flags |= MB_OKCANCEL;
			break;
		
		case EDN_Yes_No:
			flags |= MB_YESNO;
			break;
		
		case EDN_Yes_No_Cancel:
			flags |= MB_YESNOCANCEL;
			break;
		
		case EDN_Abort_Retry_Ignore:
			flags |= MB_ABORTRETRYIGNORE;
			break;
	}

	switch( inOptions & EDN_DefaultMask)
	{
		case EDN_Default1:
			flags |= MB_DEFBUTTON1;
			break;

		case EDN_Default2:
			flags |= MB_DEFBUTTON2;
			break;

		case EDN_Default3:
			flags |= MB_DEFBUTTON3;
			break;
	}
	
	if (outResponse == NULL)
	{
		/*
			we need a modeless asynchronous message.
			so we create a thread.
		*/

		// MB_SERVICE_NOTIFICATION est adapte a notre cas (face-less app) mais donne un look Win95 tres moche, et surtout ca serialise les messages !!


		VDisplayNotificationParam *param = new VDisplayNotificationParam( inTitle, inMessage, flags, NULL);
		
		DWORD threadID;
		HANDLE thread = ::CreateThread( NULL, 0, DisplayNotificationProc, param, 0, &threadID);

		ok = (thread != NULL);

		if (thread != NULL)
			CloseHandle( thread);
	}
	else
	{
		int r = ::MessageBoxExW( NULL, inMessage.GetCPointer(), inTitle.GetCPointer(), flags, 0);
		ok = r != 0;
		switch( r)
		{
			case IDYES:			*outResponse = ERN_Yes; break;
			case IDNO:			*outResponse = ERN_No; break;
			case IDRETRY:		*outResponse = ERN_Retry; break;
			case IDIGNORE:		*outResponse = ERN_Ignore; break;
			case IDABORT:		*outResponse = ERN_Abort; break;
			case IDOK:			*outResponse = ERN_OK; break;
			case IDCANCEL:
			default:			*outResponse = ERN_Cancel; break;
		}
	}

	return ok;
}