void JAbout::paint(JGraphics g) { JCanvas::paint(g); int delta = 20; JRect rect(0, 0, width, height); g.draw3DJRect(rect.shrink(delta, delta), -depth); JString text = getText(); if (text.length()) { JFontMetrics fm(g); int dx, dy; JColor c[14] = { JColor::red, JColor::white, JColor::magenta.darker(), JColor::yellow, JColor::orange, JColor::blue, JColor::pink, JColor::magenta, JColor::orange, JColor::green.darker(), JColor::blue, JColor::magenta.darker(), JColor::blue, JColor::yellow }; dy = (height-fm.getHeight())/2; dx = (width-fm.stringWidth(text))/2; g.setJColor(getBackground().brighter()); g.drawJString(text, dx+1, dy+1); g.setJColor(getBackground().darker()); g.drawJString(text, dx-1, dy-1); for (int i=0; i<14; i++) { JString ch = text(i, i+1); g.setJColor(c[i]); g.drawJString(ch, dx, dy); dx += fm.stringWidth(ch); } } }
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); } }
void XDLink::SendRaw ( const JCharacter* text ) { if (itsLink != NULL) { JString s = text; s.TrimWhitespace(); JIndex i; while (s.LocateSubstring(" ", &i)) { s.ReplaceSubstring(i, i+1, " "); } itsLink->SendMessage(s); itsLink->StartTimer(); if (!itsDebuggerBusyFlag) { itsDebuggerBusyFlag = kJTrue; Broadcast(DebuggerBusy()); } Broadcast(DebugOutput(s, kCommandType)); } }
inline JBoolean JXFontManager::IsPostscript ( const JString& name ) const { #if ONLY_STD_PS_FONTS return JI2B(name == "Arial" || // Helvetica sucks on OS X name.BeginsWith("Courier") || name.BeginsWith("Helvetica") || name == "Symbol" || name == "Times" || name.Contains("Bookman") || name.Contains("Century Schoolbook") || name.Contains("Chancery") || name.Contains("Palatino")); #else return kJTrue; #endif }
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); } }
JXPSPrintSetupDialog* CBPSPrinter::CreatePrintSetupDialog ( const Destination destination, const JCharacter* printCmd, const JCharacter* fileName, const JBoolean collate, const JBoolean bw ) { assert( itsCBPrintSetupDialog == NULL ); if (itsFontSize == kUnsetFontSize) { JString fontName; CBGetPrefsManager()->GetDefaultFont(&fontName, &itsFontSize); JArray<JIndexRange> matchList; if (nxmRegex.Match(fontName, &matchList)) { const JString hStr = fontName.GetSubstring(matchList.GetElement(2)); const JBoolean ok = hStr.ConvertToUInt(&itsFontSize); assert( ok ); itsFontSize--; } } itsCBPrintSetupDialog = CBPSPrintSetupDialog::Create(destination, printCmd, fileName, collate, bw, itsFontSize, (CBGetPTTextPrinter())->WillPrintHeader()); return itsCBPrintSetupDialog; }
void JCheckSiteName ( const JCharacter* encSiteSuffix, const JCharacter siteCode, const JCharacter* map[], const JSize size ) { JString siteSuffix = encSiteSuffix; const JSize len = siteSuffix.GetLength(); for (JIndex i=1; i<=len; i++) { siteSuffix.SetCharacter(i, siteSuffix.GetCharacter(i) ^ siteCode); } map[1] = siteSuffix.GetCString(); if (!(JGetHostName()).EndsWith(siteSuffix, kJFalse)) { const JString msg = JGetString(kWrongSiteID, map, size); (JGetUserNotification())->DisplayMessage(msg); exit(0); } }
JBoolean JConvertToStream ( const int input, ifstream* input2, JString* tempFullName, const JBoolean closeInput ) { JString data; if (!JReadAll(input, &data, closeInput)) { return kJFalse; } if (!(JCreateTempFile(tempFullName)).OK()) { return kJFalse; } ofstream output(*tempFullName); data.Print(output); output.close(); input2->open(*tempFullName); return JI2B(input2->good()); }
void CBFileNode::OpenComplementFile() const { JString fullName; if (GetFullName(&fullName)) { const CBTextFileType type = (CBGetPrefsManager())->GetFileType(fullName); if (type == kCBHTMLFT || type == kCBXMLFT) { (JXGetWebBrowser())->ShowFileContent(fullName); } else { (CBGetDocumentManager())->OpenComplementFile(fullName, type); } } else { JString msg = "Unable to find complement of \""; msg += GetFileName(); msg.AppendCharacter('"'); (JGetUserNotification())->ReportError(msg); } }
void JWebBrowser::ShowFileLocation ( const JCharacter* fileName ) { if (!JStringEmpty(itsShowFileLocationCmd)) { JString fullName = fileName; JStripTrailingDirSeparator(&fullName); JString path, name; JSplitPathAndName(fullName, &path, &name); const JCharacter* map[] = { kFileVarName, fullName, kPathVarName, path }; JString s = itsShowFileLocationCmd; if (!s.Contains("$")) { s += " '$"; s += kFileVarName; s += "'"; } (JGetStringManager())->Replace(&s, map, sizeof(map)); JSimpleProcess::Create(s, kJTrue); } }
JBoolean JSearchFile ( const JCharacter* fileName, const JCharacter* searchStr, const JBoolean caseSensitive, JIndex* lineIndex ) { ifstream input(fileName); *lineIndex = 0; while (!input.eof()) { (*lineIndex)++; const JString line = JReadLine(input); if (input.fail()) { break; } if (line.Contains(searchStr, caseSensitive)) { return kJTrue; } } return kJFalse; }
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 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); } }
void JXButton::SetShortcuts ( const JCharacter* list ) { JXWindow* w = GetWindow(); w->ClearShortcuts(this); w->InstallShortcuts(this, list); const JBoolean wasReturnButton = itsIsReturnButtonFlag; itsIsReturnButtonFlag = kJFalse; if (list != NULL) { JString shortcuts = list; if (shortcuts.Contains("^M") || shortcuts.Contains("^m")) { itsIsReturnButtonFlag = kJTrue; } } const JSize borderWidth = GetBorderWidth(); if (!wasReturnButton && itsIsReturnButtonFlag) { SetBorderWidth(borderWidth+1); } else if (wasReturnButton && !itsIsReturnButtonFlag && borderWidth > 0) { SetBorderWidth(borderWidth-1); } Refresh(); }
void JMemoryManager::HandleDebugRequest() const { assert( itsLink != NULL ); JString text; const JBoolean ok = itsLink->GetNextMessage(&text); assert( ok ); std::string s(text, text.GetLength()); std::istringstream input(s); JFileVersion vers; input >> vers; if (vers != kJMemoryManagerDebugVersion) { cerr << "JMemoryManager::HandleDebugRequest received version (" << vers; cerr << ") different than expected (" << kJMemoryManagerDebugVersion << ")" << endl; return; } long type; input >> type; if (type == kRunningStatsMessage) { SendRunningStats(); } else if (type == kRecordsMessage) { SendRecords(input); } }
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); }
void GLFitDirector::AddHistoryText ( const JBoolean refit ) { JString str; if (refit) { str = "Refit\n"; } else { str = "Fit\n"; } itsHistory->AppendText(str, kJFalse); JIndex index; JBoolean ok = itsCurveList->GetCurrentCurveIndex(&index); assert(ok); str = "Curve: " + itsPlot->GetCurveName(index) + "\n"; itsHistory->AppendText(str, kJFalse); ok = itsFitList->GetCurrentFitIndex(&index); assert(ok); const GLFitDescription& fd = GetFitManager()->GetFitDescription(index); str = "Fit type: " + fd.GetFnName() + "\n"; itsHistory->AppendText(str, kJFalse); str.Clear(); itsParameterTable->GetValueString(&str); itsHistory->AppendText(str, kJFalse); str = "Reduced Chi^2: " + itsChiSq->GetText() + "\n"; itsHistory->AppendText(str, kJFalse); itsHistory->AppendText("\n\n", kJFalse); }
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 JSUpperObj::engine(int n, JLinkObj& link) { JString iv; link.access(JStringData(iv)); JString ov = value; value = iv.toUpperCase(); if (value != ov) broadcast(0); }
void CBExecOutputDocument::ReceiveRecord() { assert( itsRecordLink != NULL ); JString text; const JBoolean ok = itsRecordLink->GetNextMessage(&text); assert( ok ); // remove text that has already been printed if (!itsLastPrompt.IsEmpty() && text.BeginsWith(itsLastPrompt)) { text.RemoveSubstring(1, itsLastPrompt.GetLength()); } itsLastPrompt.Clear(); const JXTEBase::DisplayState state = GetTextEditor()->SaveDisplayState(); AppendText(text); GetTextEditor()->ClearUndo(); if (!itsReceivedDataFlag) { itsReceivedDataFlag = kJTrue; if (!IsActive()) { Activate(); } } GetTextEditor()->RestoreDisplayState(state); }
JError JCreateDirectory ( const JCharacter* dirName, const mode_t mode ) { if (JDirectoryExists(dirName)) { return JSetPermissions(dirName, mode); } JString path = dirName; JCleanPath(&path); JAppendDirSeparator(&path); JString dir; JIndex slashIndex = 2; while (path.LocateNextSubstring("/", &slashIndex)) { dir = path.GetSubstring(1, slashIndex); if (!JDirectoryExists(dir)) { const JError err = JMkDir(dir, mode); if (!err.OK()) { return err; } } slashIndex++; // move past the slash we found } return JNoError(); }
CMChooseProcessDialog::CMChooseProcessDialog ( JXDirector* supervisor, const JBoolean attachToSelection, const JBoolean stopProgram ) : JXDialogDirector(supervisor, kJTrue), itsAttachToSelectionFlag(attachToSelection), itsStopProgramFlag(stopProgram) { BuildWindow(); int inFD; const JError err = JExecute(kCmdStr, NULL, kJIgnoreConnection, NULL, kJCreatePipe, &inFD); if (err.OK()) { JString text; JReadAll(inFD, &text); text.TrimWhitespace(); itsText->SetText(text); } ListenTo(this); }
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 CBPTPrinter::PrintHeader ( ostream& output, const JIndex pageIndex ) { if (itsPrintHeaderFlag) { const JString dateStr = JGetTimeStamp(); JString pageStr(pageIndex, 0); pageStr.Prepend("Page "); itsHeaderName.Print(output); output << '\n'; dateStr.Print(output); const JInteger spaceCount = GetPageWidth() - dateStr.GetLength() - pageStr.GetLength(); for (JInteger i=1; i<=spaceCount; i++) { output << ' '; } pageStr.Print(output); output << "\n\n\n"; } }
void SVNTabBase::ComparePrev ( const JCharacter* revStr ) { JString r = "PREV"; if (!JStringEmpty(revStr)) { JString s = revStr; JUInt rev; if (s.ConvertToUInt(&rev) && rev > 0) { r = JString(rev-1, JString::kBase10); r += ":"; r += JString(rev, JString::kBase10); } else { r += ":"; r += revStr; } } Compare(r, kJTrue); }
void JXFSBindingManager::Exec ( const JCharacter* fullProgramName, const JBoolean askForArgs ) { JXFSBindingManager* me = Instance(); JString cmd; JSplitPathAndName(fullProgramName, &(me->itsScriptPath), &cmd); #ifdef _J_UNIX cmd.Prepend("./"); #endif if (askForArgs && me->itsRunScriptDialog == NULL) { me->itsRunScriptDialog = new JXFSRunScriptDialog(cmd); assert( me->itsRunScriptDialog != NULL ); me->ListenTo(me->itsRunScriptDialog); me->itsRunScriptDialog->BeginDialog(); } else if (!askForArgs) { (JXGetApplication())->DisplayBusyCursor(); Exec(me->itsScriptPath, cmd, JFSBinding::kRunPlain); } }
void XDLink::Send ( const JCharacter* text ) { if (itsLink != NULL) { if (ProgramIsRunning()) { StopProgram(); } JString arg = " -i not_command"; JString s = text; JIndex i; if (s.LocateSubstring("@i", &i)) { s.ReplaceSubstring(i, i+1, arg); } else { s += arg; } SendRaw(s); } }
JString CMLink::Build1DArrayExpressionForCFamilyLanguage ( const JCharacter* origExpr, const JInteger index ) { JString expr = origExpr; const JString indexStr(index, 0); // must use floating point conversion if (expr.Contains("$i")) { const JCharacter* map[] = { "i", indexStr.GetCString() }; (JGetStringManager())->Replace(&expr, map, sizeof(map)); } else { if (expr.GetFirstCharacter() != '(' || expr.GetLastCharacter() != ')') { expr.PrependCharacter('('); expr.AppendCharacter(')'); } expr.AppendCharacter('['); expr += indexStr; expr.AppendCharacter(']'); } return expr; }
void XDLink::SwitchToFrame ( const JUInt64 id ) { if (id != itsStackFrameIndex) { itsStackFrameIndex = id; Broadcast(FrameChanged()); } const CMStackFrameNode* frame; JString fileName; JIndex lineIndex; if (CMGetCommandDirector()->GetStackDir()->GetStackWidget()->GetStackFrame(id, &frame) && frame->GetFile(&fileName, &lineIndex)) { if (fileName.BeginsWith("file://")) { fileName.RemoveSubstring(1, 7); } Broadcast(ProgramStopped(CMLocation(fileName, lineIndex))); } }
const JCharacter* JXMenu::GetDefaultFont ( JSize* size ) { if (!theDefaultMenuFontInitFlag) { theDefaultMenuFontInitFlag = kJTrue; theDefaultFontName = JGetDefaultFontName(); theDefaultFontSize = kJDefaultFontSize; JString fileName; if (JExpandHomeDirShortcut(kMenuFontFileName, &fileName)) { ifstream input(fileName); input >> ws; JString name = JReadLine(input); name.TrimWhitespace(); JSize size; input >> size; if (input.good()) { theDefaultFontName = name; theDefaultFontSize = size; } }