void
CBCtagsUser::ReadExtensionFlags
	(
	istream&				input,
	JStringPtrMap<JString>*	flags
	)
	const
{
	flags->DeleteAll();

	JIgnoreUntil(input, ";\"\t");			// fluff

	JString data, key;
	JCharacter delimiter = '\t';
	while (delimiter != '\n')
		{
		if (!JReadUntil(input, 2, "\t\n", &data, &delimiter))
			{
			delimiter = '\n';
			}

		JString* value = new JString;
		assert( value != NULL );

		JIndex colonIndex;
		if (data.LocateSubstring(":", &colonIndex))
			{
			if (colonIndex > 1)
				{
				key = data.GetSubstring(1, colonIndex-1);
				}
			else
				{
				key.Clear();
				}

			if (colonIndex < data.GetLength())
				{
				*value = data.GetSubstring(colonIndex+1, data.GetLength());
				}
			}
		else
			{
			key    = "kind";
			*value = data;
			}

		flags->SetElement(key, value, JPtrArrayT::kDelete);
		}
}
void
JPartition::ReadGeometry
	(
	istream& input
	)
{
JIndex i;

	JFileVersion vers;
	input >> vers;
	if (vers > kCurrentGeometryDataVersion)
		{
		JIgnoreUntil(input, kGeometryDataEndDelimiter);
		return;
		}

	JSize count;
	JCoordinate totalSize;
	input >> count >> totalSize;
	if (count != GetCompartmentCount() || totalSize != GetTotalSize())
		{
		JIgnoreUntil(input, kGeometryDataEndDelimiter);
		return;
		}

	if (vers == 0)
		{
		JIndex elasticIndex;
		input >> elasticIndex;

		for (i=1; i<=count; i++)
			{
			JCoordinate minSize;
			input >> minSize;
			}
		}
예제 #3
0
JBoolean
JIsManagedByVCS
	(
	const JCharacter*	fullName,
	JVCSType*			returnType
	)
{
	const JVCSType type = JGetVCSType(fullName);

	JBoolean isManaged = kJFalse;
	if (type == kJSVNType)
		{
		JString path, name, entriesFileName, data, pattern;
		JSplitPathAndName(fullName, &path, &name);
		entriesFileName = JCombinePathAndName(path, kSubversionDirName);
		entriesFileName = JCombinePathAndName(entriesFileName, kSubversionFileName);
		JReadFile(entriesFileName, &data);

		if (data.BeginsWith("<?xml"))
			{
			pattern = "<entry[^>]+name=\"" + JRegex::BackslashForLiteral(name) + "\"(.|\n)*?>";
			const JRegex r(pattern);
			isManaged = r.Match(data);
			}
		else
			{
			std::istrstream input(data, data.GetLength());

			const JString version = JReadLine(input);
			if (version == "8" || version == "9" || version == "10")
				{
				pattern = "\n\f\n" + name + "\n";
				JIgnoreUntil(input, pattern, &isManaged);
				}
			}
		}
	else if (type == kJGitType)
		{
		isManaged = kJTrue;	// TODO: ask git (until then, better safe than sorry)
		}

	if (returnType != NULL)
		{
		*returnType = (isManaged ? type : kJUnknownVCSType);
		}
	return isManaged;
}
void
CBPTPrinter::ReadPrefs
	(
	istream& input
	)
{
	JFileVersion vers;
	input >> vers;
	if (vers == 0)
		{
		JString printCmd;
		JSize pageHeight;
		input >> printCmd >> pageHeight;
		JIgnoreUntil(input, '\1');

		SetPrintCmd(printCmd);
		SetPageHeight(pageHeight);
		}
예제 #5
0
void
CBTextEditor::ReadSetup
	(
	istream& input
	)
{
	JFileVersion vers;
	input >> vers;

	if (vers <= kCurrentSetupVersion)
		{
		if (vers == 0)
			{
			JIgnoreUntil(input, '\1');
			input >> vers;
			assert( vers == 0 );
			}

		JSize tabCharCount;
		JBoolean autoIndent;
		input >> tabCharCount >> autoIndent;
		SetTabCharCount(tabCharCount);
		ShouldAutoIndent(autoIndent);

		if (vers >= 2)
			{
			JBoolean allowDND, moveFrontOfText;
			JSize undoDepth;
			input >> allowDND >> moveFrontOfText >> undoDepth;

			if (vers == 2)
				{
				// It actually read first digit of font name,
				// so we reset it.
				undoDepth = 100;
				}

			CBShouldAllowDragAndDrop(allowDND);
			ShouldMoveToFrontOfText(moveFrontOfText);
			SetUndoDepth(undoDepth);
			}
예제 #6
0
void
JXFontManager::GetFontNames
	(
	JPtrArray<JString>* fontNames
	)
	const
{
	if (itsAllFontNames != NULL)
		{
		fontNames->CopyObjects(*itsAllFontNames, fontNames->GetCleanUpAction(), kJFalse);
		}
	else
		{
		fontNames->CleanOut();
		fontNames->SetCompareFunction(JCompareStringsCaseInsensitive);
		fontNames->SetSortOrder(JOrderedSetT::kSortAscending);

#ifdef _J_USE_XFT
		FcBool scalable = 1;
		XftFontSet* fs = XftListFonts(*itsDisplay, DefaultScreen((Display*)*itsDisplay), XFT_SCALABLE, XftTypeBool, scalable, 0, XFT_FAMILY, 0);

		for (int i=0; i<fs->nfont; i++)
		{
			char* raw_name;
			if (XftPatternGetString(fs->fonts[i], XFT_FAMILY, 0, &raw_name) == XftResultMatch)
			{
				JString name(raw_name);
				JBoolean isDuplicate;
				const JIndex index = fontNames->GetInsertionSortIndex(&name, &isDuplicate);
				if (!isDuplicate)
				{
					fontNames->InsertAtIndex(index, name);
				}
			}
		}
		
		XftFontSetDestroy(fs);		
#else
		int nameCount;
		char** nameList = XListFonts(*itsDisplay, "-*-*-*-*-*-*-*-*-75-75-*-*-*-*",
									 INT_MAX, &nameCount);
		if (nameList == NULL)
			{
			return;
			}

		JString name, charSet;
		for (int i=0; i<nameCount; i++)
			{
			const std::string s(nameList[i], strlen(nameList[i]));
			std::istringstream input(s);
			input.ignore();						// initial dash
			JIgnoreUntil(input, '-');			// foundry name
			name = JReadUntil(input, '-');		// font name
			JIgnoreUntil(input, "-75-75-");		// ignore specs
			JIgnoreUntil(input, '-');
			JIgnoreUntil(input, '-');
			JReadAll(input, &charSet);			// char set

			if (name.IsEmpty() || name == "nil")
				{
				continue;
				}

			ConvertToPSFontName(&name);

			// Until JPSPrinter can embed fonts in a Postscript file, we are limited
			// to only the standard Postscript fonts.

			if (name == JXGetCourierFontName()   ||
				name == JXGetHelveticaFontName() ||
				name == JXGetSymbolFontName()    ||
				name == JXGetTimesFontName())
				{
//				if (name != JXGetSymbolFontName())
//					{
//					name = CombineNameAndCharacterSet(name, charSet);
//					}

				JBoolean isDuplicate;
				const JIndex index =
					fontNames->GetInsertionSortIndex(&name, &isDuplicate);
				if (!isDuplicate)
					{
					fontNames->InsertAtIndex(index, name);
					}
				}
			}

		XFreeFontNames(nameList);
#endif

		// save names for next time

		JXFontManager* me = const_cast<JXFontManager*>(this);

		me->itsAllFontNames =
			new JPtrArray<JString>(*fontNames, JPtrArrayT::kDeleteAll, kJTrue);
		assert( me->itsAllFontNames != NULL );
		}
}
예제 #7
0
JBoolean
JXFontManager::GetFontCharSets
	(
	const JCharacter*	name,
	const JSize			size,
	JPtrArray<JString>*	charSetList
	)
	const
{
	charSetList->CleanOut();
	charSetList->SetCompareFunction(JCompareStringsCaseInsensitive);
	charSetList->SetSortOrder(JOrderedSetT::kSortAscending);

	JString xFontName, charSet;
	ConvertToXFontName(name, &xFontName, &charSet);		// strip charSet

	const JString regexStr =
		"-*-" + xFontName + "-*-*-*-*-*-" +
		JString(10*size, 0, JString::kForceNoExponent) +
		"-75-75-*-*-*-*";

	int nameCount;
	char** nameList = XListFonts(*itsDisplay, regexStr, INT_MAX, &nameCount);
	if (nameList == NULL)
		{
		return kJFalse;
		}

	for (int i=0; i<nameCount; i++)
		{
		const std::string s(nameList[i], strlen(nameList[i]));
		std::istringstream input(s);
		input.ignore();							// initial dash
		JIgnoreUntil(input, '-');				// foundry name
		JIgnoreUntil(input, '-');				// font name
		JIgnoreUntil(input, '-');				// medium/bold
		JIgnoreUntil(input, '-');				// roman/oblique/italic
		JIgnoreUntil(input, '-');				// character spacing
		input.ignore();							// extra dash
		JIgnoreUntil(input, '-');				// pixel height
		JIgnoreUntil(input, '-');				// 10*(point size)
		JIgnoreUntil(input, '-');				// x resolution
		JIgnoreUntil(input, '-');				// y resolution
		JIgnoreUntil(input, '-');				// ?
		JIgnoreUntil(input, '-');				// ?
		JReadAll(input, &charSet);

		JBoolean isDuplicate;
		const JIndex index =
			charSetList->GetInsertionSortIndex(&charSet, &isDuplicate);
		if (!isDuplicate)
			{
			JString* s = new JString(charSet);
			assert( s != NULL );
			charSetList->InsertElementAtIndex(index, s);
			}
		}

	XFreeFontNames(nameList);
	return JNegate( charSetList->IsEmpty() );
}
예제 #8
0
JFontStyle
JXFontManager::GetFontStyles
	(
	const JCharacter*	name,
	const JSize			size
	)
	const
{
	JFontStyle style(kJFalse, kJFalse, 0, kJTrue);

#ifdef _J_USE_XFT
	double raw_size = size;
	XftFontSet* fs = XftListFonts(*itsDisplay, DefaultScreen((Display*)*itsDisplay), XFT_FAMILY, XftTypeString, name, XFT_SIZE, XftTypeDouble, raw_size, 0, XFT_SLANT, XFT_WEIGHT, 0);

	if (fs->nfont == 0)
	{
		return style;
	}

	for (int i=0; i<fs->nfont; i++)
	{
		int raw_slant;
		if (XftPatternGetInteger(fs->fonts[i], XFT_SLANT, 0, &raw_slant) == XftResultMatch)
		{
			if (raw_slant == XFT_SLANT_ITALIC)
				style.italic = kJTrue;
		}

		int raw_weight;
		if (XftPatternGetInteger(fs->fonts[i], XFT_WEIGHT, 0, &raw_weight) == XftResultMatch)
		{
			if (raw_weight == XFT_WEIGHT_BOLD)
				style.bold = kJTrue;
		}
	}
	
	XftFontSetDestroy(fs);		
#else
	JString xFontName, charSet;
	if (!ConvertToXFontName(name, &xFontName, &charSet))
		{
		charSet = "*-*";
		}

	const JString regexStr =
		"-*-" + xFontName + "-*-*-*-*-*-" +
		JString(10*size, 0, JString::kForceNoExponent) +
		"-75-75-*-*-" + charSet;

	int nameCount;
	char** nameList = XListFonts(*itsDisplay, regexStr, INT_MAX, &nameCount);
	if (nameList == NULL)
		{
		return style;
		}

	JString weight, slant;
	for (int i=0; i<nameCount; i++)
		{
		const std::string s(nameList[i], strlen(nameList[i]));
		std::istringstream input(s);
		input.ignore();							// initial dash
		JIgnoreUntil(input, '-');				// foundry name
		JIgnoreUntil(input, '-');				// font name
		weight = JReadUntil(input, '-');		// medium/bold
		slant  = JReadUntil(input, '-');		// roman/oblique/italic

		if (weight == "bold")
			{
			style.bold = kJTrue;
			}
		if (slant == "o" || slant == "i")
			{
			style.italic = kJTrue;
			}
		}

	XFreeFontNames(nameList);
#endif

	return style;
}
예제 #9
0
JBoolean
JXFontManager::GetFontSizes
	(
	const JCharacter*	name,
	JSize*				minSize,
	JSize*				maxSize,
	JArray<JSize>*		sizeList
	)
	const
{
	*minSize = *maxSize = 0;
	sizeList->RemoveAll();
	sizeList->SetCompareFunction(JCompareSizes);
	sizeList->SetSortOrder(JOrderedSetT::kSortAscending);

#ifdef _J_USE_XFT
	XftFontSet* fs = XftListFonts(*itsDisplay, DefaultScreen((Display*)*itsDisplay), XFT_FAMILY, XftTypeString, name, 0, XFT_SIZE, 0);

	if (fs->nfont == 0)
	{
		*minSize = 8;
		*maxSize = 24;
		XftFontSetDestroy(fs);		
		return kJTrue;
	}

	for (int i=0; i<fs->nfont; i++)
	{
		double raw_size;
		if (XftPatternGetDouble(fs->fonts[i], XFT_SIZE, 0, &raw_size) == XftResultMatch)
		{
			JSize fontSize = static_cast<JSize>(raw_size);
			if (sizeList->IsEmpty())
			{
				*minSize = *maxSize = fontSize;
			}

			JBoolean isDuplicate;
			const JIndex index =
				sizeList->GetInsertionSortIndex(fontSize, &isDuplicate);
			if (!isDuplicate)
			{
				sizeList->InsertElementAtIndex(index, fontSize);

				if (fontSize < *minSize)
				{
					*minSize = fontSize;
				}
				else if (fontSize > *maxSize)
				{
					*maxSize = fontSize;
				}
			}
		}
	}
	
	// Look for scalable
	if ((*minSize == 0) && (*maxSize == 0))
	{
		*minSize = 8;
		*maxSize = 24;
		XftFontSetDestroy(fs);		
		return kJTrue;
	}
	
	XftFontSetDestroy(fs);		
#else
	JString xFontName, charSet;
	if (!ConvertToXFontName(name, &xFontName, &charSet))
		{
		charSet = "*-*";
		}

	// check for rescalable font

	JString regexStr = "-*-" + xFontName + "-*-*-*-*-*-0-75-75-*-*-" + charSet;

	int nameCount;
	char** nameList = XListFonts(*itsDisplay, regexStr, INT_MAX, &nameCount);
	if (nameList != NULL)
		{
		*minSize = 8;
		*maxSize = 24;
		XFreeFontNames(nameList);
		return kJTrue;
		}

	// get list of available sizes

	regexStr = "-*-" + xFontName + "-*-*-*-*-*-*-75-75-*-*-" + charSet;

	nameList = XListFonts(*itsDisplay, regexStr, INT_MAX, &nameCount);
	if (nameList == NULL)
		{
		return kJFalse;
		}

	JSize fontSize;
	for (int i=0; i<nameCount; i++)
		{
		const std::string s(nameList[i], strlen(nameList[i]));
		std::istringstream input(s);
		input.ignore();							// initial dash
		JIgnoreUntil(input, '-');				// foundry name
		JIgnoreUntil(input, '-');				// font name
		JIgnoreUntil(input, '-');				// medium/bold
		JIgnoreUntil(input, '-');				// roman/oblique/italic
		JIgnoreUntil(input, '-');				// character spacing
		input.ignore();							// extra dash
		JIgnoreUntil(input, '-');				// pixel height
		input >> fontSize;						// 10*(point size)

		if (fontSize < 10)
			{
			continue;		// we already checked for rescalable version
			}

		fontSize /= 10;
		if (sizeList->IsEmpty())
			{
			*minSize = *maxSize = fontSize;
			}

		JBoolean isDuplicate;
		const JIndex index =
			sizeList->GetInsertionSortIndex(fontSize, &isDuplicate);
		if (!isDuplicate)
			{
			sizeList->InsertElementAtIndex(index, fontSize);

			if (fontSize < *minSize)
				{
				*minSize = fontSize;
				}
			else if (fontSize > *maxSize)
				{
				*maxSize = fontSize;
				}
			}
		}

	XFreeFontNames(nameList);
#endif

	return JNegate( sizeList->IsEmpty() );
}
예제 #10
0
void
JXFontManager::GetMonospaceFontNames
	(
	JPtrArray<JString>* fontNames
	)
	const
{
	if (itsMonoFontNames != NULL)
		{
		fontNames->CopyObjects(*itsMonoFontNames, fontNames->GetCleanUpAction(), kJFalse);
		}
	else
		{
		(JXGetApplication())->DisplayBusyCursor();

		fontNames->CleanOut();
		fontNames->SetCompareFunction(JCompareStringsCaseInsensitive);
		fontNames->SetSortOrder(JOrderedSetT::kSortAscending);

#ifdef _J_USE_XFT
		FcBool scalable = 1;
		XftFontSet* fs = XftListFonts(*itsDisplay, DefaultScreen((Display*)*itsDisplay), XFT_SPACING, XftTypeInteger, XFT_MONO,
																			XFT_SCALABLE, XftTypeBool, scalable, 0, XFT_FAMILY, 0);

		for (int i=0; i<fs->nfont; i++)
		{
			char* raw_name;
			if (XftPatternGetString(fs->fonts[i], XFT_FAMILY, 0, &raw_name) == XftResultMatch)
			{
				JString name(raw_name);
				JBoolean isDuplicate;
				const JIndex index = fontNames->GetInsertionSortIndex(&name, &isDuplicate);
				if (!isDuplicate)
				{
					fontNames->InsertAtIndex(index, name);
				}
			}
		}
		
		XftFontSetDestroy(fs);		
#else
		JPtrArray<JString> allFontNames(JPtrArrayT::kDeleteAll);
		allFontNames.SetCompareFunction(JCompareStringsCaseInsensitive);
		allFontNames.SetSortOrder(JOrderedSetT::kSortAscending);

		for (int j=0; j<kMonospaceFontPatternCount; j++)
			{
			int nameCount;
			char** nameList = XListFonts(*itsDisplay, kMonospaceFontPattern[j],
										 INT_MAX, &nameCount);
			if (nameList == NULL)
				{
				return;
				}

			JString name, charSet;
			for (int i=0; i<nameCount; i++)
				{
				const std::string s(nameList[i], strlen(nameList[i]));
				std::istringstream input(s);
				input.ignore();						// initial dash
				JIgnoreUntil(input, '-');			// foundry name
				name = JReadUntil(input, '-');		// font name
				JIgnoreUntil(input, "-iso");		// ignore specs
				JReadAll(input, &charSet);			// char set

				if (name.IsEmpty() || name == "nil")
					{
					continue;
					}

				ConvertToPSFontName(&name);

#if ! QUERY_FOR_MONOSPACE
				if (name == "Clean" || name == "Courier" || name == "Fixed" ||
					name == "Terminal" || name == "Lucidatypewriter" ||
					name == "Profontwindows")
					{
#endif

//				charSet.Prepend("iso");
//				name = CombineNameAndCharacterSet(name, charSet);

				JBoolean isDuplicate;
				const JIndex index =
					allFontNames.GetInsertionSortIndex(&name, &isDuplicate);
				if (!isDuplicate)
					{
					allFontNames.InsertAtIndex(index, name);

//					cout << nameList[i] << endl;

					XFontStruct* xfont = XLoadQueryFont(*itsDisplay, nameList[i]);
					if (xfont != NULL)
						{
						if (IsMonospace(*xfont))
							{
							JString* n = new JString(name);
							assert( n != NULL );
							const JBoolean ok = fontNames->InsertSorted(n, kJFalse);
							assert( ok );
							}
						XFreeFont(*itsDisplay, xfont);
						}
					}
#if ! QUERY_FOR_MONOSPACE
					}
#endif
				}

			XFreeFontNames(nameList);
			}
#endif

		// save names for next time

		JXFontManager* me = const_cast<JXFontManager*>(this);

		me->itsMonoFontNames =
			new JPtrArray<JString>(*fontNames, JPtrArrayT::kDeleteAll, kJTrue);
		assert( me->itsMonoFontNames != NULL );
		}
}
예제 #11
0
JBoolean
JXFontManager::GetFontSizes
	(
	const JCharacter*	name,
	JSize*				minSize,
	JSize*				maxSize,
	JArray<JSize>*		sizeList
	)
	const
{
	sizeList->RemoveAll();

#if ENABLE_TRUE_TYPE

	*minSize = 8;
	*maxSize = 24;
	return kJTrue;

#else

	*minSize = *maxSize = 0;
	sizeList->SetCompareFunction(JCompareSizes);
	sizeList->SetSortOrder(JOrderedSetT::kSortAscending);

	const JString xFontName = ConvertToXFontName(name)

	// check for rescalable font

	JString regexStr = "-*-" + xFontName + "-medium-r-normal-*-*-0-75-75-*-*-*";

	int nameCount;
	char** nameList = XListFonts(*itsDisplay, regexStr, INT_MAX, &nameCount);
	if (nameList != NULL)
		{
		*minSize = 8;
		*maxSize = 24;
		XFreeFontNames(nameList);
		return kJTrue;
		}

	// get list of available sizes

	regexStr = "-*-" + xFontName + "-medium-r-normal-*-*-*-75-75-*-*-*";

	nameList = XListFonts(*itsDisplay, regexStr, INT_MAX, &nameCount);
	if (nameList == NULL)
		{
		return kJFalse;
		}

	JSize fontSize;
	for (int i=0; i<nameCount; i++)
		{
		const std::string s(nameList[i], strlen(nameList[i]));
		std::istringstream input(s);
		input.ignore();							// initial dash
		JIgnoreUntil(input, '-');				// foundry name
		JIgnoreUntil(input, '-');				// font name
		JIgnoreUntil(input, '-');				// medium/bold
		JIgnoreUntil(input, '-');				// roman/oblique/italic
		JIgnoreUntil(input, '-');				// character spacing
		JIgnoreUntil(input, '-');				// sans
		JIgnoreUntil(input, '-');				// pixel height
		input >> fontSize;						// 10*(point size)

		if (fontSize < 10)
			{
			continue;		// we already checked for rescalable version
			}

		fontSize /= 10;
		if (sizeList->IsEmpty())
			{
			*minSize = *maxSize = fontSize;
			}

		JBoolean isDuplicate;
		const JIndex index =
			sizeList->GetInsertionSortIndex(fontSize, &isDuplicate);
		if (!isDuplicate)
			{
			sizeList->InsertElementAtIndex(index, fontSize);

			if (fontSize < *minSize)
				{
				*minSize = fontSize;
				}
			else if (fontSize > *maxSize)
				{
				*maxSize = fontSize;
				}
			}
		}

	XFreeFontNames(nameList);

#endif

	return !sizeList->IsEmpty();
}
예제 #12
0
void
JXFontManager::GetMonospaceFontNames
	(
	JPtrArray<JString>* fontNames
	)
	const
{
	if (itsMonoFontNames != NULL)
		{
		fontNames->CopyObjects(*itsMonoFontNames, fontNames->GetCleanUpAction(), kJFalse);
		}
	else
		{
		(JXGetApplication())->DisplayBusyCursor();

		fontNames->CleanOut();
		fontNames->SetCompareFunction(JCompareStringsCaseInsensitive);
		fontNames->SetSortOrder(JOrderedSetT::kSortAscending);

		JPtrArray<JString> allFontNames(JPtrArrayT::kDeleteAll);
		allFontNames.SetCompareFunction(JCompareStringsCaseInsensitive);
		allFontNames.SetSortOrder(JOrderedSetT::kSortAscending);

		JString name;

#if ENABLE_TRUE_TYPE

		FcFontSet* set =
			XftListFonts(*itsDisplay, itsDisplay->GetScreen(),
						 FC_SPACING, FcTypeInteger, FC_MONO, NULL,
						 FC_FAMILY, NULL);
		for (int i=0; i < set->nfont; i++)
			{
			FcChar8* s = FcNameUnparse(set->fonts[i]);
			name.Set((JCharacter*) s);
//			cout << "tt  mono: " << name << endl;

#if ONLY_STD_MONOSPACE

			if (!name.BeginsWith("Courier") &&
				!name.BeginsWith("Consolas") &&
				!name.Contains(" Mono")     &&
				name != "LucidaTypewriter")
				{
				FcStrFree(s);
				continue;
				}

#endif

			if (IsUseless(name))
				{
				FcStrFree(s);
				continue;
				}

			JBoolean isDuplicate;
			const JIndex index =
				allFontNames.GetInsertionSortIndex(&name, &isDuplicate);
			if (!isDuplicate)
				{
				allFontNames.InsertAtIndex(index, name);

				JString* n = new JString(name);
				assert( n != NULL );
				const JBoolean ok = fontNames->InsertSorted(n, kJFalse);
				assert( ok );
				}

			FcStrFree(s);
			}
		FcFontSetDestroy(set);

#else

		for (int j=0; j<kMonospaceFontPatternCount; j++)
			{
			int nameCount;
			char** nameList = XListFonts(*itsDisplay, kMonospaceFontPattern[j],
										 INT_MAX, &nameCount);
			if (nameList == NULL)
				{
				return;
				}

			for (int i=0; i<nameCount; i++)
				{
				const std::string s(nameList[i], strlen(nameList[i]));
				std::istringstream input(s);
				input.ignore();						// initial dash
				JIgnoreUntil(input, '-');			// foundry name
				name = JReadUntil(input, '-');		// font name

				if (name.IsEmpty() || name == "nil")
					{
					continue;
					}

				ConvertToPSFontName(&name);
//				cout << "std mono: " << name << endl;

#if ONLY_STD_MONOSPACE

				if (name != "Clean" && name != "Fixed" && name != "Terminal" &&
					name != "Courier" && name != "Lucidatypewriter" &&
					name != "Profontwindows")
					{
					continue;
					}

#endif

				if (IsUseless(name))
					{
					continue;
					}

				JBoolean isDuplicate;
				const JIndex index =
					allFontNames.GetInsertionSortIndex(&name, &isDuplicate);
				if (!isDuplicate)
					{
					allFontNames.InsertAtIndex(index, name);

					XFontStruct* xfont = XLoadQueryFont(*itsDisplay, nameList[i]);
					if (xfont != NULL)
						{
						if (xfont->min_bounds.width == xfont->max_bounds.width)
							{
							JString* n = new JString(name);
							assert( n != NULL );
							const JBoolean ok = fontNames->InsertSorted(n, kJFalse);
							assert( ok );
							}
						XFreeFont(*itsDisplay, xfont);
						}
					}
				}

			XFreeFontNames(nameList);
			}

#endif

		// save names for next time

		itsMonoFontNames = new JDCCPtrArray<JString>(*fontNames, JPtrArrayT::kDeleteAll);
		assert( itsMonoFontNames != NULL );
		}
}
예제 #13
0
void
JXFontManager::GetFontNames
	(
	JPtrArray<JString>* fontNames
	)
	const
{
	if (itsAllFontNames != NULL)
		{
		fontNames->CopyObjects(*itsAllFontNames, fontNames->GetCleanUpAction(), kJFalse);
		}
	else
		{
		fontNames->CleanOut();
		fontNames->SetCompareFunction(JCompareStringsCaseInsensitive);
		fontNames->SetSortOrder(JOrderedSetT::kSortAscending);

		JString name;

#if ENABLE_TRUE_TYPE

		FcFontSet* set = XftListFonts(*itsDisplay, itsDisplay->GetScreen(), NULL, FC_FAMILY, NULL);
		for (int i=0; i < set->nfont; i++)
			{
			FcChar8* s = FcNameUnparse(set->fonts[i]);
			name.Set((JCharacter*) s);
//			cout << "tt  font: " << name << endl;

			if (!IsPostscript(name) || IsUseless(name))
				{
				FcStrFree(s);
				continue;
				}

			JBoolean isDuplicate;
			const JIndex index = fontNames->GetInsertionSortIndex(&name, &isDuplicate);
			if (!isDuplicate)
				{
				fontNames->InsertAtIndex(index, name);
				}

			FcStrFree(s);
			}
		FcFontSetDestroy(set);

#endif

		int nameCount;
		char** nameList = XListFonts(*itsDisplay, "-*-*-medium-r-normal-*-*-*-75-75-*-*-*-*",
									 INT_MAX, &nameCount);
		if (nameList == NULL)
			{
			return;
			}

		for (int i=0; i<nameCount; i++)
			{
			const std::string s(nameList[i], strlen(nameList[i]));
			std::istringstream input(s);
			input.ignore();						// initial dash
			JIgnoreUntil(input, '-');			// foundry name
			name = JReadUntil(input, '-');		// font name

			if (name.IsEmpty() || name == "nil")
				{
				continue;
				}

			ConvertToPSFontName(&name);
//			cout << "std font: " << name << endl;

			if (!IsPostscript(name) || IsUseless(name))
				{
				continue;
				}

			JBoolean isDuplicate;
			const JIndex index = fontNames->GetInsertionSortIndex(&name, &isDuplicate);
			if (!isDuplicate)
				{
				fontNames->InsertAtIndex(index, name);
				}
			}

		XFreeFontNames(nameList);

		// save names for next time

		itsAllFontNames = new JDCCPtrArray<JString>(*fontNames, JPtrArrayT::kDeleteAll);
		assert( itsAllFontNames != NULL );
		}
}
void
CBSymbolList::ReadSymbolList
	(
	istream&			input,
	const CBLanguage	lang,
	const JCharacter*	fullName,
	const JFAID_t		fileID
	)
{
	JString path, fileName;
	JSplitPathAndName(fullName, &path, &fileName);

	input >> ws;
	while (input.peek() == '!')
		{
		JIgnoreLine(input);
		input >> ws;
		}

	JStringPtrMap<JString> flags(JPtrArrayT::kDeleteAll);
	while (1)
		{
		JString* name = new JString;
		assert( name != NULL );

		input >> ws;
		*name = JReadUntil(input, '\t');		// symbol name
		if (input.eof() || input.fail())
			{
			delete name;
			break;
			}

		JIgnoreUntil(input, '\t');				// file name

		JIndex lineIndex;
		input >> lineIndex;						// line index

		ReadExtensionFlags(input, &flags);

		JCharacter typeChar = ' ';
		JString* value;
		if (flags.GetElement("kind", &value) && !value->IsEmpty())
			{
			typeChar = value->GetFirstCharacter();
			}

		JString* signature = NULL;
		if (flags.GetElement("signature", &value) && !value->IsEmpty())
			{
			signature = new JString(*value);
			assert( signature != NULL );
			signature->PrependCharacter(' ');
			}

		if (IgnoreSymbol(*name))
			{
			delete name;
			}
		else
			{
			const Type type = DecodeSymbolType(lang, typeChar);
			if (signature == NULL &&
				(IsFunction(type) || IsPrototype(type)))
				{
				signature = new JString(" ( )");
				assert( signature != NULL );
				}

			const SymbolInfo info(name, signature, lang, type,
								  kJFalse, fileID, lineIndex);
			itsSymbolList->InsertSorted(info);

			// add file:name

			if (IsFileScope(type))
				{
				JString* name1 = new JString(fileName);
				assert( name1 != NULL );
				*name1 += ":";
				*name1 += *name;

				JString* sig1 = NULL;
				if (signature != NULL)
					{
					sig1 = new JString(*signature);
					assert( sig1 != NULL );
					}

				const SymbolInfo info1(name1, sig1, lang, type,
									   kJTrue, fileID, lineIndex);
				itsSymbolList->InsertSorted(info1);
				}
			}
		}
}
void
CBFnMenuUpdater::ReadFunctionList
	(
	std::istream&	input,
	CBLanguage		lang,
	const JBoolean	sort,
	const JBoolean	includeNS,
	JXTextMenu*		menu,
	JArray<JIndex>*	lineIndexList
	)
{
	JPtrArray<JString> fnNameList(JPtrArrayT::kDeleteAll);
	fnNameList.SetCompareFunction(JCompareStringsCaseInsensitive);
	fnNameList.SetSortOrder(JOrderedSetT::kSortAscending);

	lineIndexList->SetCompareFunction(JCompareIndices);
	lineIndexList->SetSortOrder(JOrderedSetT::kSortAscending);

	// build symbol list

	const JBoolean hasNS = CBHasNamespace(lang);
	JString fnName;
	while (1)
		{
		input >> std::ws;
		fnName = JReadUntil(input, '\t');	// fn name
		if (input.eof() || input.fail())
			{
			break;
			}

		JIgnoreUntil(input, '\t');			// file name

		JIndex lineIndex;
		input >> lineIndex;					// line index

		if (IgnoreSymbol(fnName))
			{
			continue;
			}

		// toss qualified or unqualified version

		if (hasNS && !includeNS && cbIsQualified(fnName))
			{
			continue;
			}

		// save symbol

		JIndex i;
		if (sort)
			{
			i = fnNameList.GetInsertionSortIndex(&fnName);
			}
		else
			{
			i = lineIndexList->GetInsertionSortIndex(lineIndex);
			}
		fnNameList.InsertAtIndex(i, fnName);
		lineIndexList->InsertElementAtIndex(i, lineIndex);
		}

	if (hasNS && includeNS)
		{
		JSize count = fnNameList.GetElementCount();
		for (JIndex i=1; i<=count; i++)
			{
			const JString* fnName  = fnNameList.NthElement(i);
			const JIndex lineIndex = lineIndexList->GetElement(i);
			if (cbIsQualified(*fnName))
				{
				for (JIndex j=1; j<=count; j++)
					{
					if (j != i && lineIndexList->GetElement(j) == lineIndex)
						{
						fnNameList.DeleteElement(j);
						lineIndexList->RemoveElement(j);
						count--;
						if (j < i)
							{
							i--;
							}
						break;
						}
					}
				}
			}
		}

	// build menu

	const JSize count = fnNameList.GetElementCount();
	for (JIndex i=1; i<=count; i++)
		{
		menu->AppendItem(*(fnNameList.NthElement(i)));
		}
}
예제 #16
0
JBoolean
JGetCurrentSVNRevision
	(
	const JCharacter*	fullName,
	JString*			rev
	)
{
	JString path, name, entriesFileName, data, pattern;
	JSplitPathAndName(fullName, &path, &name);
	entriesFileName = JCombinePathAndName(path, kSubversionDirName);
	entriesFileName = JCombinePathAndName(entriesFileName, kSubversionFileName);
	JReadFile(entriesFileName, &data);

	if (data.BeginsWith("<?xml"))
		{
		pattern = "<entry[^>]+name=\"" + JRegex::BackslashForLiteral(name) + "\"(.|\n)*?>";
		JRegex r(pattern);
		JIndexRange range;
		JArray<JIndexRange> matchList;
		if (r.Match(data, &range) &&
			svn4RevisionPattern.MatchWithin(data, range, &matchList))
			{
			*rev = data.GetSubstring(matchList.GetElement(2));
			return kJTrue;
			}
		}
	else
		{
		std::istrstream input(data, data.GetLength());

		const JString version = JReadLine(input);
		if (version == "8" || version == "9" || version == "10")
			{
			pattern = "\n\f\n" + name + "\n";

			JBoolean found;
			JIgnoreUntil(input, pattern, &found);
			if (found)
				{
				const JString data2 = JReadUntil(input, '\f');
				std::istrstream input2(data2, data2.GetLength());

				JIgnoreLine(input2);		// file
				JIgnoreLine(input2);		// ???
				JIgnoreLine(input2);		// ???
				JIgnoreLine(input2);		// ???
				JIgnoreLine(input2);		// ???
				JIgnoreLine(input2);		// timestamp
				JIgnoreLine(input2);		// hash
				JIgnoreLine(input2);		// timestamp

				*rev = JReadLine(input2);
				if (input2.good())
					{
					return kJTrue;
					}
				}
			}
		}

	rev->Clear();
	return kJFalse;
}