JBoolean
JDirInfo::BuildRegexFromWildcardFilter
	(
	const JCharacter*	origFilterStr,
	JString*			regexStr
	)
{
	regexStr->Clear();

	JString filterStr = origFilterStr;
	filterStr.TrimWhitespace();

	if (filterStr.IsEmpty())
		{
		return kJFalse;
		}

	JIndex index;
	while (filterStr.LocateSubstring(" ", &index))
		{
		assert( index > 1 );
		const JString str = filterStr.GetSubstring(1, index-1);

		AppendRegex(str, regexStr);

		filterStr.RemoveSubstring(1, index);
		filterStr.TrimWhitespace();
		}

	assert( !filterStr.IsEmpty() );
	AppendRegex(filterStr, regexStr);
	return kJTrue;
}
Ejemplo n.º 2
0
JFontStyle
CBHTMLStyler::GetTagStyle
	(
	const JIndexRange&	tokenRange,
	const JIndex		typeIndex
	)
{
	const JString& text = GetText();

	JFontStyle style;
	JArray<JIndexRange> matchList;
	if (tagNamePattern.MatchWithin(text, tokenRange, &matchList))
		{
		itsLatestTagName = text.GetSubstring(matchList.GetElement(2));
		itsLatestTagName.ToLower();

		JString openTag;
		if (itsLatestTagName.GetFirstCharacter() == '/' &&
			itsLatestTagName.GetLength() > 1)
			{
			openTag = itsLatestTagName.GetSubstring(2, itsLatestTagName.GetLength());
			}

		JBoolean found = GetWordStyle(itsLatestTagName, &style);
		if (!found && !openTag.IsEmpty())
			{
			found = GetWordStyle(openTag, &style);
			}

		if (!found)
			{
			found = GetXMLStyle(itsLatestTagName, &style);
			}

		if (!found && !openTag.IsEmpty())
			{
			found = GetXMLStyle(openTag, &style);
			}

		if (!found)
			{
			style = GetTypeStyle(typeIndex);
			}
		}
	else if (text.GetCharacter(tokenRange.first) == '<')
		{
		itsLatestTagName.Clear();
		style = GetTypeStyle(typeIndex);
		}
	else
		{
		style = GetStyle(typeIndex, itsLatestTagName);
		}

	return style;
}
Ejemplo n.º 3
0
JString
JXPathInput::GetTextForChoosePath()
	const
{
	JString text = GetText();
	if (text.IsEmpty() && HasBasePath())
		{
		text = itsBasePath;
		}
	else if (!text.IsEmpty() && JIsRelativePath(text) && HasBasePath())
		{
		text = JCombinePathAndName(itsBasePath, text);
		}
	return text;
}
Ejemplo n.º 4
0
void
GMMIMEParser::WriteAttachment
	(
	const JString&		data,
	const GMIMEHeader&	header
	)
{
	JString filename = header.GetFileName();
	if (filename.IsEmpty())
		{
		const JError err = JCreateTempFile(itsAttachDir, NULL, &filename);
		if (!err.OK())
			{
			err.ReportIfError();
			return;
			}
		}
	else
		{
		filename = JCombinePathAndName(itsAttachDir, filename);
		}

	AdjustAttachmentName(header, &filename);
	std::ofstream os(filename);
	if (header.GetEncoding() == kBase64Encoding)
		{
		std::istrstream is(data.GetCString(), data.GetLength());
		JDecodeBase64(is, os);
		}
	else
		{
		data.Print(os);
		}
}
Ejemplo n.º 5
0
void
JXTextMenu::AdjustPopupChoiceTitle
	(
	const JIndex index
	)
{
	const JString& origTitle = GetTitleText();
	if (origTitle.IsEmpty())
		{
		return;
		}

	JString newTitle;
	JIndex colonIndex;
	const JBoolean foundColon = origTitle.LocateSubstring(":", &colonIndex);
	if (foundColon && colonIndex > 1)
		{
		newTitle = origTitle.GetSubstring(1, colonIndex-1);
		}
	// not empty but no colon => title was empty originally, so replace it

	if (!newTitle.IsEmpty())
		{
		newTitle += ":  ";
		}
	newTitle += GetItemText(index);

	const JXImage* image = NULL;
	GetItemImage(index, &image);

	SetTitle(newTitle, const_cast<JXImage*>(image), kJFalse);
}
Ejemplo n.º 6
0
void
SVNTabBase::Compare
	(
	const JString&	rev,
	const JBoolean	isPrev
	)
{
	SVNPrefsManager::Integration type;
	JString cmd;
	const JBoolean hasCmd =
		(SVNGetPrefsManager())->GetCommand(SVNPrefsManager::kDiffCmd, &type, &cmd);

	if (type == SVNPrefsManager::kCodeCrusader)
		{
		ExecuteJCCDiff(rev, isPrev);
		}
	else if (hasCmd)
		{
		JString r = rev;
		if (!r.IsEmpty())
			{
			r.Prepend("-r ");
			}
		ExecuteDiff(cmd, r, isPrev);
		}
}
JString
GPrefsMgr::GetSMTPUser()
{
	if (IDValid(kSMTPUserID))
		{
		std::string data;
		const JBoolean ok = GetData(kSMTPUserID, &data);
		assert( ok );

		std::istringstream dataStream(data);

		JString user;
		dataStream >> user;
		if (!user.IsEmpty())
			{
			return user;
			}
		}
	JCharacter* name = getenv("LOGNAME");
	if (name == NULL)
		{
		return JString();
		}
	return JString(name);
}
void
CBSymbolList::PrepareContextNamespace
	(
	const JString&		contextNamespace,
	const CBLanguage	lang,
	JString*			ns1,
	JString*			ns2
	)
	const
{
	if (!contextNamespace.IsEmpty() &&
		(lang == kCBJavaLang       ||
		 lang == kCBJavaScriptLang ||
		 lang == kCBEiffelLang     ||
		 lang == kCBCSharpLang))
		{
		*ns1  = contextNamespace;	// name.
		*ns1 += ".";

		*ns2 = *ns1;				// .name.
		ns2->Prepend(".");
		}
	else
		{
		ns1->Clear();
		ns2->Clear();
		}
}
Ejemplo n.º 9
0
JBoolean
GMApp::NewMailbox
	(
	const JCharacter*	filename,
	const JBoolean		openFile
	)
{
	JString path;
	JString name;
	JSplitPathAndName(filename, &path, &name);
	if (path.IsEmpty())
		{
		path = JGetCurrentDirectory();
		}
	if (!(JDirectoryExists(path) && JDirectoryReadable(path)))
		{
		JString notice = "You do not have write permissions in directory \"" + path + "\"";
		JGetUserNotification()->ReportError(notice);
		return kJFalse;
		}
	ofstream os(filename);
	if (!os.good())
		{
		JString notice = "Unable to create file \"" + path + name + "\"";
		JGetUserNotification()->ReportError(notice);
		return kJFalse;
		}
	os.close();
	if (openFile)
		{
		OpenMailbox(filename);
		}
	return kJTrue;
}
void
CBCommandPathInput::AdjustStylesBeforeRecalc
	(
	const JString&		buffer,
	JRunArray<JFont>*	styles,
	JIndexRange*		recalcRange,
	JIndexRange*		redrawRange,
	const JBoolean		deletion
	)
{
	if (!buffer.IsEmpty() && buffer.GetFirstCharacter() == '@')
		{
		const JColormap* colormap = GetColormap();
		const JSize totalLength   = buffer.GetLength();
		JFont f                   = styles->GetFirstElement();
		styles->RemoveAll();
		f.SetColor(colormap->GetBlackColor());
		styles->AppendElements(f, totalLength);
		*redrawRange += JIndexRange(1, totalLength);
		}
	else
		{
		return JXPathInput::AdjustStylesBeforeRecalc(buffer, styles, recalcRange,
													 redrawRange, deletion);
		}
}
Ejemplo n.º 11
0
void
CBCommand::ReportInfiniteLoop
	(
	const CBFunctionStack&	fnStack,
	const JIndex			startIndex
	)
{
	const JSize cmdCount = fnStack.GetElementCount();
	JString loop;
	for (JIndex i=startIndex; i>=1; i--)
		{
		if (!loop.IsEmpty())
			{
			loop += " -> ";
			}
		loop += fnStack.Peek(i);
		}
	loop += " -> ";
	loop += fnStack.Peek(startIndex);

	const JCharacter* map[] =
		{
		"loop", loop.GetCString()
		};
	const JString msg = JGetString("InfiniteLoop::CBCommand", map, sizeof(map));
	(JGetUserNotification())->ReportError(msg);
}
Ejemplo n.º 12
0
void
JUpdateCVSIgnore
	(
	const JCharacter* ignoreFullName
	)
{
	JString path, name;
	JSplitPathAndName(ignoreFullName, &path, &name);
	const JString cvsFile = JCombinePathAndName(path, ".cvsignore");

	if (!JFileExists(cvsFile) && JGetVCSType(path) != kJCVSType)
		{
		return;
		}

	JString cvsData;
	JReadFile(cvsFile, &cvsData);
	if (!cvsData.IsEmpty() && !cvsData.EndsWith("\n"))
		{
		cvsData += "\n";
		}

	name += "\n";
	if (!cvsData.Contains(name))
		{
		JEditVCS(cvsFile);
		cvsData += name;

		ofstream output(cvsFile);
		cvsData.Print(output);
		}
}
Ejemplo n.º 13
0
int
main
	(
	int		argc,
	char*	argv[]
	)
{
	ParseTextOptions(argc, argv);

	SymcirApp* app = new SymcirApp(&argc, argv);
	assert( app != NULL );

	JString inputFileName;
	ParseXOptions(argc, argv, &inputFileName);

	if (!inputFileName.IsEmpty() ||
		(JGetChooseSaveFile())->ChooseFile("Netlist to analyze:", NULL, &inputFileName))
		{
		SCCircuitDocument* mainDir = new SCCircuitDocument(app, inputFileName);
		assert( mainDir != NULL );

		mainDir->Activate();
		app->Run();
		}

	return 0;
}
void
GLPolyFitDialog::Receive
	(
	JBroadcaster* 	sender, 
	const Message&	message
	)
{
	if (sender == itsHelpButton && message.Is(JXButton::kPushed))
		{
		}
	else if (message.Is(JXCheckbox::kPushed))
		{
		JString fStr;
		JBoolean started	= kJFalse;
		const JSize count	= 10;
		for (JIndex i = 1; i <= count; i++)
			{
			if (itsCB[i-1]->IsChecked())
				{
				if (started)
					{
					fStr += " + ";
					}
				else
					{
					started	= kJTrue;
					}
				JString parm	= "a" + JString(i - 1, JString::kBase10);
				JString xTerm	= " * x";
				if (i > 2)
					{
					xTerm += "^" + JString(i - 1, JString::kBase10);
					}
				fStr += parm;
				if (i > 1)
					{
					fStr += xTerm;
					}
				}
			}
		if (fStr.IsEmpty())
			{
			itsFn->Hide();
			}
		else
			{
			itsFn->Show();
			JFunction* f;
			if (JParseFunction(fStr, itsVarList, &f))
				{
				itsFn->SetFunction(itsVarList, f);
				}
			}
		}
	else
		{
		JXDialogDirector::Receive(sender, message);
		}
}
JBoolean
GAddressBookMgr::NameIsAlias
	(
	const JCharacter*	name,
	JString&			alias,
	JString&			fcc
	)
{
	GAddressBookEntry* entry;
	if (!itsAddresses->GetElement(name, &entry))
		{
		return kJFalse;
		}

	alias = entry->address;
	if (alias.IsEmpty())
		{
		return kJFalse;
		}

	if (alias.GetFirstCharacter() == '(' &&
		alias.GetLastCharacter() == ')')
		{
		if (entry->address.GetLength() > 2)
			{
			alias = entry->address.GetSubstring(2, entry->address.GetLength() - 1);
			}			
		}

	fcc = entry->fcc;
	if (!fcc.IsEmpty() && 
		fcc.GetFirstCharacter() == '(' &&
		fcc.GetLastCharacter() == ')')
		{
		if (entry->fcc.GetLength() > 2)
			{
			fcc = entry->fcc.GetSubstring(2, entry->fcc.GetLength() - 1);
			}
		}

	return kJTrue;
}
Ejemplo n.º 16
0
JString
JXFileInput::GetTextForChooseFile()
	const
{
	JString text = GetText();
	if (text.IsEmpty() && HasBasePath())
		{
		text = itsBasePath;
		JAppendDirSeparator(&text);
		}
	if (text.EndsWith(ACE_DIRECTORY_SEPARATOR_STR))
		{
		text.AppendCharacter('*');
		}
	if (!text.IsEmpty() && JIsRelativePath(text) && HasBasePath())
		{
		text = JCombinePathAndName(itsBasePath, text);
		}
	return text;
}
JBoolean
GAddressBookMgr::GetNextRecord
	(
	JString& line,
	JString& record,
	std::istream& is
	)
{
	if (line.IsEmpty())
		{
		return kJFalse;
		}
	JIndex index;
	if (line.LocateSubstring("\t", &index))
		{
		if (index > 1)
			{
			record = line.GetSubstring(1, index - 1);
			line.RemoveSubstring(1, index);
			return kJTrue;
			}
		line.RemoveSubstring(1, 1);
		return kJFalse;
		}
	record = line;
	if (record.Contains("(") && !record.Contains(")"))
		{
		JString temp = JReadUntil(is, ')');
		record += temp + ")";
		line = JReadLine(is);
		if (!line.IsEmpty() && (line.GetFirstCharacter() == '\t'))
			{
			line.RemoveSubstring(1, 1);
			}
		}
	else
		{
		line.Clear();
		}
	return kJTrue;
}
JBoolean
JXStringCompletionMenu::AddString
	(
	const JCharacter* str
	)
{
	const JIndex i = GetItemCount()+1;
	if (i <= kMaxItemCount)
		{
		if (IsEmpty())
			{
			JFontID id;
			JSize size;
			JFontStyle style;
			itsTE->GetDefaultFont(&id, &size, &style);
			SetDefaultFont(id, size, style, kJFalse);
			}

		JString shortcut;
		if (i <= 10)
			{
			shortcut = JString(i%10, JString::kBase10);
			}
		else if (i <= 36)
			{
			shortcut = " ";
			shortcut.SetCharacter(1, 'a' + i - 11);
			}

		JString s = kItemPrefixStr;
		s += str;
		if (!shortcut.IsEmpty())
			{
			s.SetCharacter(1, shortcut.GetFirstCharacter());
			s.SetCharacter(3, '-');
			}

		AppendItem(s, kPlainType, shortcut);
		return kJTrue;
		}
	else if (i == kMaxItemCount+1)
		{
		AppendItem(kTruncationStr);
		SetItemFont(i, JGetDefaultFontName(), kJDefaultFontSize,
					JFontStyle(kJFalse, kJTrue, 0, kJFalse));
		return kJFalse;
		}
	else
		{
		return kJFalse;
		}
}
Ejemplo n.º 19
0
JBoolean
SyGGetTrashDirectory
	(
	JString*		path,
	const JBoolean	reportErrors
	)
{
	if (!theTrashDir.IsEmpty())
		{
		*path = theTrashDir;
		return kJTrue;
		}

	if (!JGetPrefsDirectory(path))
		{
		if (reportErrors)
			{
			(JGetUserNotification())->ReportError(JGetString(kNoPrefsDirID));
			}
		return kJFalse;
		}

	*path = JCombinePathAndName(*path, kTrashDirName);

	JError err = JNoError();
	if (!JDirectoryExists(*path))
		{
		err = JCreateDirectory(*path, kTrashCanPerms);
		}
	else
		{
		err = JSetPermissions(*path, kTrashCanPerms);
		}

	if (err.OK())
		{
		theTrashDir       = *path;
		const JBoolean ok = JDirInfo::Create(theTrashDir, &theTrashDirInfo);
		assert( ok );
		return kJTrue;
		}
	else
		{
		path->Clear();
		if (reportErrors)
			{
			(JGetStringManager())->ReportError(kCreateTrashErrorID, err);
			}
		return kJFalse;
		}
}
void
CBSymbolTable::DisplaySelectedSymbols()
	const
{
	itsKeyBuffer.Clear();

	const JTableSelection& s = GetTableSelection();
	if (s.HasSelection())
		{
		JString missingFiles;

		JTableSelectionIterator iter(&s);
		JPoint cell;
		while (iter.Next(&cell))
			{
			const JIndex symbolIndex = CellToSymbolIndex(cell);
			JIndex lineIndex;
			const JString& fileName =
				itsSymbolList->GetFile(symbolIndex, &lineIndex);

			CBTextDocument* doc;
			if ((CBGetDocumentManager())->OpenTextDocument(fileName, lineIndex, &doc))
				{
				CBLanguage lang;
				CBSymbolList::Type type;
				itsSymbolList->GetSymbol(symbolIndex, &lang, &type);

				if (CBSymbolList::ShouldSmartScroll(type))
					{
					(doc->GetTextEditor())->ScrollForDefinition(lang);
					}
				}
			else
				{
				missingFiles += fileName;
				missingFiles += "\n";
				}
			}

		if (!missingFiles.IsEmpty())
			{
			const JCharacter* map[] =
				{
				"list", missingFiles
				};
			const JString msg = JGetString(kMissingFilesID, map, sizeof(map));
			(JGetUserNotification())->ReportError(msg);
			}
		}
}
Ejemplo n.º 21
0
JBoolean
SyGGetRecentFileDirectory
	(
	JString*		path,
	const JBoolean	reportErrors
	)
{
	if (!theRecentFileDir.IsEmpty())
		{
		*path = theRecentFileDir;
		return kJTrue;
		}

	if (!JGetPrefsDirectory(path))
		{
		if (reportErrors)
			{
			(JGetUserNotification())->ReportError(JGetString(kNoPrefsDirID));
			}
		return kJFalse;
		}

	*path = JCombinePathAndName(*path, kRecentFileDirName);

	JError err = JNoError();
	if (!JDirectoryExists(*path))
		{
		err = JCreateDirectory(*path, kRecentFileDirPerms);
		}
	else
		{
		err = JSetPermissions(*path, kRecentFileDirPerms);
		}

	if (err.OK())
		{
		theRecentFileDir = *path;
		return kJTrue;
		}
	else
		{
		path->Clear();
		if (reportErrors)
			{
			(JGetStringManager())->ReportError(kCreateRecentFileDirErrorID, err);
			}
		return kJFalse;
		}
}
void
JXTipOfTheDayDialog::AddTip
	(
	JString tip
	)
{
	tip.TrimWhitespace();
	if (tip.IsEmpty())
		{
		return;
		}

	JString* s = new JString(tip);
	assert( s != NULL );
	itsTipList->Append(s);
}
void
GMessageHeader::DecodeMIMEHeader
	(
	JString* header
	)
{
	JArray<JIndexRange> subList;
	JSize count	= encodedMIMEQRegex.MatchAll(*header, &subList);
	JBoolean qType	= kJTrue;
	if (count == 0)
		{
		count	= encodedMIMEBRegex.MatchAll(*header, &subList);
		qType	= kJFalse;
		}
	if (count > 0)
		{
		JString temp;
		JIndex mIndex		= 1;
		const JSize count	= subList.GetElementCount();
		for (JIndex i = 1; i <= count; i++)
			{
			JIndexRange range	= subList.GetElement(i);
//			if ((range.first != mIndex) &&
//				RangeContainsNWS(*header, mIndex, range.first))
//				{
//				temp += header->GetSubstring(mIndex, range.first - 1);
//				}
			if (range.first != mIndex)
				{
				JString trimmed = header->GetSubstring(mIndex, range.first - 1);
				trimmed.TrimWhitespace();
				if (!trimmed.IsEmpty())
					{
					temp += header->GetSubstring(mIndex, range.first - 1);
					}
				}
			temp   += DecodeMIMEWord(qType, header, range);
			mIndex	= range.last + 1;
			}
		if (mIndex < header->GetLength())
			{
			temp   += header->GetSubstring(mIndex, header->GetLength());
			}
		*header = temp;
		}
}
void
CBSearchTextDialog::SaveFileForSearch
	(
	const JString&		fullName,
	JPtrArray<JString>*	fileList,
	JPtrArray<JString>*	nameList
	)
	const
{
	JBoolean exists;
	const JIndex index =
		nameList->GetInsertionSortIndex(const_cast<JString*>(&fullName), &exists);
	if (!exists)
		{
		JString* file = jnew JString(fullName);
		assert( file != NULL );

		JXFileDocument* doc;
		if ((CBGetDocumentManager())->FileDocumentIsOpen(*file, &doc) &&
			doc->NeedsSave())
			{
			CBTextDocument* textDoc = dynamic_cast<CBTextDocument*>(doc);
			if (textDoc != NULL &&
				(JCreateTempFile(file)).OK())
				{
				std::ofstream output(*file);
				((textDoc->GetTextEditor())->GetText()).Print(output);
				}
			}

		if (!file->IsEmpty())
			{
			JString* name = jnew JString(fullName);
			assert( name != NULL );
			nameList->InsertAtIndex(index, name);

			fileList->InsertAtIndex(index, file);
			}
		else
			{
			jdelete file;
			}
		}
}
void
CBFileNameDisplay::HandleUnfocusEvent()
{
	JXFileInput::HandleUnfocusEvent();

	JBoolean saved = kJFalse;

	JString fullName;
	if (itsUnfocusAction != kCancel &&
		JExpandHomeDirShortcut(GetText(), &fullName))
		{
		if (JIsRelativePath(fullName) &&
			!(JGetChooseSaveFile())->SaveFile("Save file as:", "", fullName, &fullName))
			{
			fullName.Clear();
			}

		if (!fullName.IsEmpty() &&
			!JSameDirEntry(fullName, itsOrigFile) &&
			itsDoc->SaveInNewFile(fullName))
			{
			saved = kJTrue;

			JBoolean onDisk;
			fullName = itsDoc->GetFullName(&onDisk);
			SetText(fullName);

			if (itsUnfocusAction == kRename)
				{
				CBCleanUpAfterRename(itsOrigFile, fullName);
				}
			}
		}

	if (!saved)
		{
		SetText(itsOrigFile);
		}

	UpdateDisplay(kJFalse);			// take control of text style
	itsDragSource->ProvideDirectSave(NULL);
}
void
JFunctionWithVar::DrawString
	(
	const JExprRenderer&	renderer,
	const JCoordinate		left,
	const JCoordinate		midline,
	const JSize				fontSize,
	const JString&			str
	)
	const
{
	JCoordinate x = left;

	const JCharacter* greekPrefix = JPGetGreekCharPrefixString();
	const JSize greekPrefixLength = JPGetGreekCharPrefixLength();

	JString s = str;
	JIndex greekIndex;
	while (s.LocateSubstring(greekPrefix, &greekIndex) &&
		   greekIndex < s.GetLength() - greekPrefixLength + 1)
		{
		if (greekIndex > 1)
			{
			const JString s1 = s.GetSubstring(1, greekIndex-1);
			renderer.DrawString(x, midline, fontSize, s1);
			x += renderer.GetStringWidth(fontSize, s1);
			}

		const JCharacter c = s.GetCharacter(greekIndex + greekPrefixLength);
		renderer.DrawGreekCharacter(x, midline, fontSize, c);
		x += renderer.GetGreekCharWidth(fontSize, c);

		s.RemoveSubstring(1, greekIndex + greekPrefixLength);
		}

	if (!s.IsEmpty())
		{
		renderer.DrawString(x, midline, fontSize, s);
		}
}
JSize
JFunctionWithVar::GetStringWidth
	(
	const JExprRenderer&	renderer,
	const JSize				fontSize,
	const JString&			str
	)
	const
{
	JSize w = 0;

	const JCharacter* greekPrefix = JPGetGreekCharPrefixString();
	const JSize greekPrefixLength = JPGetGreekCharPrefixLength();

	JString s = str;
	JIndex greekIndex;
	while (s.LocateSubstring(greekPrefix, &greekIndex) &&
		   greekIndex < s.GetLength() - greekPrefixLength + 1)
		{
		if (greekIndex > 1)
			{
			const JString s1 = s.GetSubstring(1, greekIndex-1);
			w += renderer.GetStringWidth(fontSize, s1);
			}

		const JCharacter c = s.GetCharacter(greekIndex + greekPrefixLength);
		w += renderer.GetGreekCharWidth(fontSize, c);

		s.RemoveSubstring(1, greekIndex + greekPrefixLength);
		}

	if (!s.IsEmpty())
		{
		w += renderer.GetStringWidth(fontSize, s);
		}

	return w;
}
JBoolean
GLPolyFitDialog::OKToDeactivate()
{
	if (!JXDialogDirector::OKToDeactivate())
		{
		return kJFalse;
		}
	if (Cancelled())
		{
		return kJTrue;
		}
	JString name	= itsNameInput->GetText();
	name.TrimWhitespace();
	if (name.IsEmpty())
		{
		JGetUserNotification()->ReportError("You must specify a name for this fit.");
		itsNameInput->Focus();
		return kJFalse;
		}

	JBoolean checked	= kJFalse;
	const JSize count	= 10;
	for (JIndex i = 1; i <= count; i++)
		{
		if (itsCB[i-1]->IsChecked())
			{
			checked		= kJTrue;
			break;
			}
		}

	if (!checked)
		{
		JGetUserNotification()->ReportError("You must add at least one power.");
		}

	return checked;
}
Ejemplo n.º 29
0
void
CBApp::GetSystemIncludeDirectories()
{
	int pid, fd, inFD;
	const JError err = JExecute("gcc -Wp,-v -x c++ -fsyntax-only -", &pid,
								kJCreatePipe, &inFD,
								kJCreatePipe, &fd,
								kJAttachToFromFD);
	if (!err.OK())
		{
		for (const JCharacter* s : kSysIncludeDir)
			{
			itsSystemIncludeDirs->Append(s);
			}
		return;
		}

	close(inFD);

	JString s;
	while (1)
		{
		s = JReadUntil(fd, '\n');
		if (s.IsEmpty())
			{
			break;
			}

		if (s.GetFirstCharacter() == ' ')
			{
			s.RemoveSubstring(1,1);
			if (!s.Contains(" "))
				{
				itsSystemIncludeDirs->Append(s);
				}
			}
		}
}
JString
GPrefsMgr::GetSMTPHost()
{
	if (IDValid(kGSMTPHostID))
		{
		std::string data;
		const JBoolean ok = GetData(kGSMTPHostID, &data);
		assert( ok );

		std::istringstream dataStream(data);

		JString host;
		dataStream >> host;
		if (!host.IsEmpty())
			{
			return host;
			}
		}
	JCharacter hostname[255];
	gethostname(hostname, 255);
	JString host(hostname);
	return host;
}