22#include "RConfigure.h"
47#include "TApplicationCommandLineOptionsHelp.h"
89 gROOT->EndOfProcessCleanups();
119 void * ,
Int_t numOptions) :
146 Error(
"TApplication",
"only one instance of TApplication allowed");
152 ::Fatal(
"TApplication::TApplication",
"ROOT system not initialized");
155 ::Fatal(
"TApplication::TApplication",
"gSystem not initialized");
158 if (!hasRegisterAtExit) {
161 hasRegisterAtExit =
kTRUE;
163 gROOT->SetName(appClassName);
166 if (argc && *argc > 0) {
171 for (
int i = 0; i <
fArgc; i++)
181 if (
gSystem->Getenv(
"ROOT_BATCH"))
185 gSystem->NotifyApplicationCreated();
201 gROOT->SetLineHasBeenProcessed();
205 gROOT->SetApplication(
this);
214 for (
int i = 0; i <
fArgc; i++)
258 const char *ttpath =
gEnv->GetValue(
"Root.TTFontPath",
259 TROOT::GetTTFFontDir());
265 #if !defined(R__WIN32)
267 ttfont &&
gEnv->GetValue(
"Root.UseTTFonts", 1)) {
275 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TVirtualX",
"x11ttf")))
276 if (
h->LoadPlugin() == -1)
277 Info(
"InitializeGraphics",
"no TTF support");
304 if (!only_web &&
gEnv->GetValue(
"Canvas.UseScreenFactor", 1)) {
310 gStyle->SetScreenFactor(0.001 *
h);
334 if (index >=
fArgc) {
335 Error(
"Argv",
"index (%d) >= number of arguments (%d)", index,
fArgc);
349 static char null[1] = {
"" };
361 for (i = 1; i < *argc; i++) {
362 if (!strcmp(argv[i],
"-?") || !strncmp(argv[i],
"-h", 2) ||
363 !strncmp(argv[i],
"--help", 6)) {
366 }
else if (!strncmp(argv[i],
"--version", 9)) {
367 fprintf(stderr,
"ROOT Version: %s\n",
gROOT->GetVersion());
368 fprintf(stderr,
"Built for %s on %s\n",
370 gROOT->GetGitDate());
372 fprintf(stderr,
"From %s@%s\n",
373 gROOT->GetGitBranch(),
374 gROOT->GetGitCommit());
377 }
else if (!strcmp(argv[i],
"-config")) {
378 fprintf(stderr,
"ROOT ./configure options:\n%s\n",
gROOT->GetConfigOptions());
380 }
else if (!strcmp(argv[i],
"-a")) {
381 fprintf(stderr,
"ROOT splash screen is not visible with root.exe, use root instead.\n");
383 }
else if (!strcmp(argv[i],
"-b")) {
386 }
else if (!strcmp(argv[i],
"-n")) {
389 }
else if (!strcmp(argv[i],
"-t")) {
395 }
else if (!strcmp(argv[i],
"-q")) {
398 }
else if (!strcmp(argv[i],
"-l")) {
402 }
else if (!strcmp(argv[i],
"-x")) {
405 }
else if (!strcmp(argv[i],
"-splash")) {
409 }
else if (strncmp(argv[i],
"--web", 5) == 0) {
411 const char *opt = argv[i] + 5;
413 gROOT->SetWebDisplay((*opt ==
'=') ? opt + 1 :
"");
414 }
else if (!strcmp(argv[i],
"-e")) {
425 Warning(
"GetOptions",
"-e must be followed by an expression.");
427 }
else if (!strcmp(argv[i],
"--")) {
429 bool warnShown =
false;
435 if (!
dynamic_cast<TNamed*
>(
f)) {
436 Error(
"GetOptions()",
"Inconsistent file entry (not a TObjString)!");
450 if (macro && !warnShown && (warnShown =
true))
451 Warning(
"GetOptions",
"-- is used with several macros. "
452 "The arguments will be passed to the last one.");
464 for (; i < *argc; i++) {
469 str.
EndsWith(
",") ? str[str.Length() - 1] =
')' : str +=
')';
471 Warning(
"GetOptions",
"no macro to pass arguments to was provided. "
472 "Everything after the -- will be ignored.");
473 for (; i < *argc; i++)
476 }
else if (argv[i][0] !=
'-' && argv[i][0] !=
'+') {
479 char *arg = strchr(argv[i],
'(');
480 if (arg) *arg =
'\0';
482 if (
gSystem->ExpandPathName(expandedDir)) {
498 if (!arg && !
gSystem->GetPathInfo(path.
Data(), &
id, &
size, &flags, &modtime)) {
502 pwd =
gSystem->WorkingDirectory();
504 gSystem->ChangeDirectory(expandedDir);
506 }
else if (!strcmp(
gROOT->GetName(),
"Rint")) {
507 Warning(
"GetOptions",
"only one directory argument can be specified (%s)", expandedDir.
Data());
509 }
else if (
size > 0) {
515 Warning(
"GetOptions",
"file %s has size 0, skipping", expandedDir.
Data());
522 if (!strcmp(
gROOT->GetName(),
"Rint"))
523 Warning(
"GetOptions",
"file %s not found", expandedDir.
Data());
532 TString fname =
gSystem->SplitAclicMode(expandedDir,mode,fargs,io);
546 if (!strcmp(
gROOT->GetName(),
"Rint")) {
547 Error(
"GetOptions",
"macro %s not found", fname.
Data());
565 for (i = 0; i < *argc; i++) {
566 if (strcmp(argv[i],
"")) {
584 Emit(
"HandleIdleTimer()");
640#elif defined(R__WIN32)
642 TString cWindows(
"start \"\" ");
649 if (
gSystem->Getenv(
"DISPLAY")) {
655 Warning(
"OpenInBrowser",
"The $DISPLAY is not set! Please open (e.g. Ctrl-click) %s\n", url.
Data());
659 Info(
"OpenInBrowser",
"A new tab should have opened in your browser.");
663enum EUrl { kURLforClass, kURLforNameSpace, kURLforStruct };
676 TString url =
"https://root.cern/doc/";
678 TPRegexp re4(R
"(.*/(v\d)-(\d\d)-00-patches)");
680 TObjArray *objarr = re4.MatchS(branchName);
698 if (scopeType == kURLforClass) {
700 }
else if (scopeType == kURLforStruct) {
735 methodArguments.
ReplaceAll(
"ostream",
"std::ostream");
736 methodArguments.
ReplaceAll(
"istream",
"std::istream");
737 methodArguments.
ReplaceAll(
"map",
"std::map");
738 methodArguments.
ReplaceAll(
"vector",
"std::vector");
742 scopeNameRE.Append(scopeName);
743 scopeNameRE.Append(
"::\\b");
745 argFix.Substitute(methodArguments,
"");
746 return methodArguments;
760 text.ReplaceAll(
"\n",
"%0A");
761 text.ReplaceAll(
"#",
"%23");
762 text.ReplaceAll(
";",
"%3B");
763 text.ReplaceAll(
"\"",
"%22");
764 text.ReplaceAll(
"`",
"%60");
765 text.ReplaceAll(
"+",
"%2B");
766 text.ReplaceAll(
"/",
"%2F");
789 scopeNameRE.Append(scopeName);
790 scopeNameRE.Append(
"::\\b");
792 returnFix.Substitute(returnType,
"");
798 returnType.
Prepend(
"virtual ");
808 returnType.
ReplaceAll(
"istream",
"std::istream");
809 returnType.
ReplaceAll(
"ostream",
"std::ostream");
811 returnType.
ReplaceAll(
"vector",
"std::vector");
835 if (!dataMember->
IsEnum()) {
840 md5DataMember.Append(
" ");
842 md5DataMember.Append(scopeName);
843 md5DataMember.Append(
"::");
845 md5DataMember.Append(dataMemberName);
846 md5DataMember.Append(dataMemberName);
848 TString urlForDataMember = UrlGenerator(scopeName, scopeType);
850 urlForDataMember.
Append(
"#a");
851 urlForDataMember.
Append(md5DataMember.MD5());
852 return urlForDataMember;
859 if (scopeEnumeration.
Contains(
"(unnamed)")) {
861 md5EnumClass.
Append(scopeName);
862 md5EnumClass.
Append(
"::@1@1");
866 md5EnumClass.
Append(scopeEnumeration);
870 md5EnumClass.
Append(enumOnlyName);
874 md5Enumerator.Append(scopeName);
875 md5Enumerator.Append(
"::");
876 md5Enumerator.Append(dataMemberName);
877 md5Enumerator.Append(dataMemberName);
879 TString url = UrlGenerator(scopeName, scopeType);
885 url.
Append(md5Enumerator.MD5());
903 TString md5Enumeration(scopeName);
904 md5Enumeration.Append(
"::");
905 md5Enumeration.Append(enumeration);
906 md5Enumeration.Append(enumeration);
908 TString url(UrlGenerator(scopeName, scopeType));
911 url.
Append(md5Enumeration.MD5());
917enum EMethodKind { kURLforMethod, kURLforStructor };
933 EMethodKind methodType, EUrl scopeType)
936 if (methodType == kURLforMethod) {
939 md5Text.
Append((FormatReturnTypeForDoxygen(scopeName, func)));
940 if (scopeType == kURLforNameSpace) {
949 md5Text.
Append(scopeName);
951 md5Text.
Append(methodName);
952 md5Text.
Append(methodName);
954 md5Text.
Append(FormatMethodArgsForDoxygen(scopeName, func));
956 TString url = UrlGenerator(scopeName, scopeType);
971 std::vector<TString> lines;
972 lines.emplace_back(
"```");
974 gROOT->GetVersion()));
976 if (!strcmp(
gROOT->GetGitBranch(),
gROOT->GetGitCommit())) {
977 static const char *months[] = {
"January",
"February",
"March",
"April",
"May",
978 "June",
"July",
"August",
"September",
"October",
979 "November",
"December"};
981 Int_t iday = idatqq%100;
982 Int_t imonth = (idatqq/100)%100;
983 Int_t iyear = (idatqq/10000);
986 gROOT->GetGitBranch(),
987 iday,months[imonth-1],iyear));
992 gROOT->GetGitBranch(),
993 gROOT->GetGitCommit()));
996 gSystem->GetBuildCompilerVersionStr(), __cplusplus));
997 lines.emplace_back(
"Binary directory: "+
gROOT->GetBinDir());
998 lines.emplace_back(
"```");
1000 for (
auto&
line : lines) {
1017 if (type ==
"bug") {
1021_Please read [tips for efficient and successful posting](https://root-forum.cern.ch/t/tips-for-efficient-and-successful-posting/28292) and [posting code](https://root-forum.cern.ch/t/posting-code-read-this-first/28293)_
1025A clear and concise description of what the wrong behavior is.
1027### Expected behavior
1029A clear and concise description of what you expected to happen.
1034Steps to reproduce the behavior:
10351. Your code that triggers the issue: at least a part; ideally something we can run ourselves.
10362. Don't forget to attach the required input files!
10373. How to run your code and / or build it, e.g. `root myMacro.C`, ...
1044Please specify also how you obtained ROOT, such as `dnf install` / binary download / you built it yourself.
1047### Additional context
1049Add any other context about the problem here.
1051 report_template = FormatHttpUrl(report_template);
1053 OpenInBrowser("\"https://root-forum.cern.ch/new-topic?category=ROOT&tags=bug&body="+report_template+
"&\"");
1055 Warning(
"OpenForumTopic",
"cannot find \"%s\" as type for a Forum topic\n"
1056 "Available types are 'bug'.", type.
Data());
1069 if (type ==
"bug") {
1071 "\"https://github.com/root-project/root/issues/new?labels=bug&template=bug_report.yml&root-version=" +
1073 }
else if (type ==
"improvement") {
1074 OpenInBrowser(
"\"https://github.com/root-project/root/issues/"
1075 "new?labels=improvement&template=improvement_report.yml&root-version=" +
1077 }
else if (type ==
"feature") {
1079 "\"https://github.com/root-project/root/issues/new?labels=new+feature&template=feature_request.yml\"");
1082 "Cannot find GitHub issue type \"%s\".\n"
1083 "Available types are 'bug', 'feature' and 'improvement'.",
1104 scopeType = kURLforNameSpace;
1105 }
else if (clas->Property() &
kIsStruct) {
1106 scopeType = kURLforStruct;
1108 scopeType = kURLforClass;
1118 if (strippedClass == memberName) {
1119 Error(
"OpenReferenceGuideFor",
"Unknown entity \"%s\" - global variables / functions not supported yet!",
1120 strippedClass.
Data());
1124 TString scopeName = strippedClass(0, strippedClass.
Length() - memberName.
Length() - 2);
1129 Warning(
"OpenReferenceGuideFor",
"\"%s\" does not exist in ROOT!", scopeName.
Data());
1135 scopeType = kURLforNameSpace;
1137 scopeType = kURLforStruct;
1139 scopeType = kURLforClass;
1144 int bracket = memberName.
First(
"(");
1146 memberName.
Remove(bracket);
1151 TString baseClName = ((TMethod *)func)->GetClass()->GetName();
1153 EMethodKind methodType;
1155 if (baseClName == memberName) {
1156 methodType = kURLforStructor;
1158 }
else if (memberName[0] ==
'~') {
1159 methodType = kURLforStructor;
1162 methodType = kURLforMethod;
1165 OpenInBrowser(GetUrlForMethod(baseClName, memberName, func, methodType, scopeType));
1172 OpenInBrowser(GetUrlForEnumeration(scopeName, memberName, scopeType));
1179 TString baseClName = ((TMethod *)enumerator->GetClass())->GetName();
1180 OpenInBrowser(GetUrlForDataMember(baseClName, memberName, enumerator, scopeType));
1186 Warning(
"OpenReferenceGuideFor",
"cannot find \"%s\" as member of %s or its base classes! Check %s\n", memberName.
Data(),
1187 scopeName.
Data(), UrlGenerator(scopeName, scopeType).Data());
1200 if (!strippedCommand.
BeginsWith(
".forum ")) {
1201 Error(
"Forum",
"Unknown command! Use 'bug' after '.forum '");
1205 strippedCommand.
Remove(0, 7);
1222 Error(
"GitHub",
"Unknown command! Use 'bug', 'feature' or 'improvement' after '.gh '");
1226 strippedCommand.
Remove(0, 4);
1244 if ((strippedCommand ==
".help") || (strippedCommand ==
".?")) {
1246 Printf(
"\n ROOT special commands.");
1247 Printf(
" ==============================================================================");
1248 Printf(
" .L <filename>[flags]: load the given file with optional flags like\n"
1249 " + to compile or ++ to force recompile.\n"
1250 " Type .? TSystem::CompileMacro for a list of all flags.\n"
1251 " <filename> can also be a shared library; skip flags.");
1252 Printf(
" .(x|X) <filename>[flags](args) :\n"
1253 " same as .L <filename>[flags] and runs then a function\n"
1254 " with signature: ret_type filename(args).");
1255 Printf(
" .credits : show credits");
1256 Printf(
" .demo : launch GUI demo");
1257 Printf(
" .forum bug : ask for help with a bug or crash at the ROOT forum.");
1258 Printf(
" .gh [bug|feature|improvement]\n"
1259 " : submit a bug report, feature or improvement suggestion");
1260 Printf(
" .help Class::Member : open reference guide for that class member (or .?).\n"
1261 " Specifying '::Member' is optional.");
1262 Printf(
" .help edit : show line editing shortcuts (or .?)");
1263 Printf(
" .license : show license");
1264 Printf(
" .libraries : show loaded libraries");
1265 Printf(
" .ls : list contents of current TDirectory");
1266 Printf(
" .pwd : show current TDirectory, pad and style");
1267 Printf(
" .quit (or .exit) : quit ROOT (long form of .q)");
1268 Printf(
" .R [user@]host[:dir] [-l user] [-d dbg] [script] :\n"
1269 " launch process in a remote host");
1270 Printf(
" .qqq : quit ROOT - mandatory");
1271 Printf(
" .qqqqq : exit process immediately");
1272 Printf(
" .qqqqqqq : abort process");
1273 Printf(
" .which [file] : show path of macro file");
1274 Printf(
" .![OS_command] : execute OS-specific shell command");
1275 Printf(
" .!root -? : print ROOT usage (CLI options)");
1281 Error(
"Help",
"Unknown command!");
1286 strippedCommand.
Remove(0, 3);
1288 strippedCommand.
Remove(0, 5);
1293 if (strippedCommand ==
"edit") {
1294 Printf(
"\n ROOT terminal keyboard shortcuts (GNU-readline style).");
1296 #define FOOTNOTE " *"
1297 Printf(
"* Some of these commands might be intercepted by macOS predefined system shortcuts.");
1302 Printf(
" ==============================================================================");
1303 Printf(
" Arrow_Left : move cursor left [Ctrl+B]");
1304 Printf(
" Arrow_Right : move cursor right [Ctrl+F] [Ctrl+G]");
1306 Printf(
" Fn+Arrow_Left : move cursor to beginning of line [Ctrl+A]");
1308 Printf(
" Home : move cursor to beginning of line [Ctrl+A]");
1311 Printf(
" Fn+Arrow_Right : move cursor to end of line [Ctrl+E]");
1313 Printf(
" End : move cursor to end of line [Ctrl+E]");
1315 Printf(
" Ctrl+Arrow_Left : jump to previous word [Esc,B] [Alt,B]" FOOTNOTE);
1316 Printf(
" Ctrl+Arrow_Right : jump to next word [Esc,F] [Alt,F]" FOOTNOTE);
1318 Printf(
" Backspace : delete previous character [Ctrl+H]");
1319 Printf(
" Del : delete next character [Ctrl+D]");
1320 Printf(
" Esc,Backspace : delete previous word [Ctrl+W] [Esc,Ctrl+H] [Alt+Backspace] [Esc,Del] [Esc,Ctrl+Del]" FOOTNOTE);
1322 Printf(
" Ctrl+U : cut all characters between cursor and start of line");
1323 Printf(
" Ctrl+K : cut all characters between cursor and end of line");
1325 Printf(
" Ctrl+T : transpose characters");
1326 Printf(
" Esc,C : character to upper and jump to next word");
1327 Printf(
" Esc,L : word to lower case and jump to its end");
1328 Printf(
" Esc,U : word to upper case and jump to its end");
1329 Printf(
" Ctrl+Shift+C : copy clipboard content");
1330 Printf(
" Ctrl+Shift+V : paste clipboard content [Ctrl+Y] [Alt+Y]");
1332 Printf(
" Fn+Enter : toggle overwrite mode");
1334 Printf(
" Ins : toggle overwrite mode");
1337 Printf(
" Ctrl+_ : undo last keypress action");
1338 Printf(
" Tab : autocomplete command or print suggestions [Ctrl+I] [Esc,Tab]");
1339 Printf(
" Enter : execute command [Ctrl+J] [Ctrl+M]");
1340 Printf(
" Ctrl+L : clear prompt screen");
1341 Printf(
" Ctrl+D : quit ROOT (if empty line)");
1342 Printf(
" Ctrl+C : send kSigInt interrupt signal");
1343 Printf(
" Ctrl+Z : send kSigStop pause job signal");
1344 Printf(
" Ctrl+\\ : send kSigQuit quit job signal");
1346 Printf(
" Arrow_Down : navigate downwards in command history [Ctrl+N]");
1347 Printf(
" Arrow_Up : navigate upwards in command history [Ctrl+P]");
1348 Printf(
" Ctrl+R ; Ctrl+S : search command in your history by typing a string.\n"
1349 " Use Backspace if you mistyped (but not arrows).\n"
1350 " Press Ctrl+R (Ctrl+S) repeateadly to navigate matches in reverse (forward) order");
1351 Printf(
" Arrow_Right : after Ctrl+R (Ctrl+S), select current match of the history search\n"
1352 " [Ctrl+O] [Enter] [Ctrl+J] [Ctrl+M] [Arrow_Left] [Esc,Esc].\n"
1353 " Use Ctrl+F or Ctrl+G to cancel search and revert original line");
1367 if (
gROOT->IsBatch())
1370 if (
auto h =
gROOT->GetPluginManager()->FindHandler(
"TVirtualPad"))
1371 if (
h->LoadPlugin() == -1)
1375 TString title1 =
"ROOT interface to ";
1376 TString nativex, title;
1379 nativex =
"win32gdk";
1381 title = title1 +
"Win32gdk";
1382#elif defined(R__HAS_COCOA)
1385 title = title1 +
"Quartz";
1389 title = title1 +
"X11";
1392 TString guiBackend =
gEnv->GetValue(
"Gui.Backend",
"native");
1394 if (guiBackend ==
"native") {
1395 guiBackend = nativex;
1398 title = title1 + guiBackend;
1401 if (
auto h =
gROOT->GetPluginManager()->FindHandler(
"TVirtualX", guiBackend)) {
1402 if (
h->LoadPlugin() == -1) {
1406 gVirtualX = (TVirtualX *)
h->ExecPlugin(2,
name.Data(), title.Data());
1410 TString guiFactory =
gEnv->GetValue(
"Gui.Factory",
"native");
1412 if (guiFactory ==
"native")
1413 guiFactory =
"root";
1415 if (
auto h =
gROOT->GetPluginManager()->FindHandler(
"TGuiFactory", guiFactory)) {
1416 if (
h->LoadPlugin() == -1) {
1455 if (!ln || strlen(ln) <= 0)
1467 while (
line.Tokenize(tkn, from,
" ")) {
1471 }
else if (tkn ==
"-d") {
1473 }
else if (tkn ==
"-close") {
1476 ::Warning(
"TApplication::ParseRemoteLine",
"unknown option: %s", tkn.
Data());
1484 }
else if (isHostDir) {
1489 }
else if (isScript) {
1519 if (!
line)
return 0;
1521 if (!strncmp(
line,
"-?", 2) || !strncmp(
line,
"-h", 2) ||
1522 !strncmp(
line,
"--help", 6)) {
1523 Info(
"ProcessRemote",
"remote session help:");
1524 Printf(
".R [user@]host[:dir] [-l user] [-d dbg] [[<]script] | [host] -close");
1525 Printf(
"Create a ROOT session on the specified remote host.");
1526 Printf(
"The variable \"dir\" is the remote directory to be used as working dir.");
1527 Printf(
"The username can be specified in two ways, \"-l\" having the priority");
1528 Printf(
"(as in ssh). A \"dbg\" value > 0 gives increasing verbosity.");
1529 Printf(
"The last argument \"script\" allows to specify an alternative script to");
1530 Printf(
"be executed remotely to startup the session, \"roots\" being");
1531 Printf(
"the default. If the script is preceded by a \"<\" the script will be");
1532 Printf(
"sourced, after which \"roots\" is executed. The sourced script can be ");
1533 Printf(
"used to change the PATH and other variables, allowing an alternative");
1534 Printf(
"\"roots\" script to be found.");
1535 Printf(
"To close down a session do \".R host -close\".");
1536 Printf(
"To switch between sessions do \".R host\", to switch to the local");
1537 Printf(
"session do \".R\".");
1538 Printf(
"To list all open sessions do \"gApplication->GetApplications()->Print()\".");
1542 TString hostdir, user, script;
1545 if (hostdir.
Length() <= 0) {
1555 }
else if (rc == 1) {
1566 const char *sc = (script.
Length() > 0) ? script.
Data() :
nullptr;
1577 static int PrintFile(
const char* filename) {
1579 gSystem->ExpandPathName(sFileName);
1580 if (
gSystem->AccessPathName(sFileName)) {
1581 Error(
"ProcessLine()",
"Cannot find file %s", filename);
1584 std::ifstream instr(sFileName);
1602 if (!strncmp(
line,
".R", 2)) {
1604 while (*(
line+
n) ==
' ')
1615 if (!strncasecmp(
line,
".qqqqqqq", 7)) {
1617 }
else if (!strncasecmp(
line,
".qqqqq", 5)) {
1618 Info(
"ProcessLine",
"Bye... (try '.qqqqqqq' if still running)");
1620 }
else if (!strncasecmp(
line,
".exit", 4) || !strncasecmp(
line,
".quit", 2)) {
1625 if (!strncmp(
line,
".gh", 3)) {
1630 if (!strncmp(
line,
".forum", 6)) {
1635 if (!strncmp(
line,
".?", 2) || !strncmp(
line,
".help", 5)) {
1640 if (!strncmp(
line,
".demo", 5)) {
1641 if (
gROOT->IsBatch()) {
1642 Error(
"ProcessLine",
"Cannot show demos in batch mode!");
1649 if (!strncmp(
line,
".license", 8)) {
1653 if (!strncmp(
line,
".credits", 8)) {
1657 return PrintFile(credits);
1660 if (!strncmp(
line,
".pwd", 4)) {
1670 if (!strncmp(
line,
".ls", 3)) {
1671 const char *opt =
nullptr;
1677 if (!strncmp(
line,
".which", 6)) {
1679 char *s = strtok(fn,
"+(");
1690 if (!strncmp(
line,
".L", 2) || !strncmp(
line,
".U", 2)) {
1691 TString aclicMode, arguments, io;
1692 TString fname =
gSystem->SplitAclicMode(
line+3, aclicMode, arguments, io);
1696 Warning(
"ProcessLine",
"argument(s) \"%s\" ignored with .%c", arguments.
Data(),
line[1]);
1701 TString cmd(
line + 1);
1702 Ssiz_t posSpace = cmd.Index(
' ');
1703 if (posSpace ==
kNPOS)
1706 cmd.Remove(posSpace);
1720 if (!strncmp(
line,
".X", 2) || !strncmp(
line,
".x", 2)) {
1724 if (!strcmp(
line,
".reset")) {
1726 Printf(
"*** .reset not allowed, please use gROOT->Reset() ***");
1737 if (!strcmp(
line,
".libraries")) {
1763 static const Int_t kBufSize = 1024;
1765 if (!file || !*file)
return 0;
1770 TString fname =
gSystem->SplitAclicMode(file, aclicMode, arguments, io);
1774 ::Error(
"TApplication::ExecuteFile",
"macro %s not found in path %s", fname.
Data(),
1782 ::std::ifstream macro(exnam, std::ios::in);
1783 if (!macro.good()) {
1784 ::Error(
"TApplication::ExecuteFile",
"%s no such file", exnam);
1791 char currentline[kBufSize];
1792 char dummyline[kBufSize];
1802 bool res = (bool)macro.getline(currentline, kBufSize);
1803 if (macro.eof())
break;
1808 while (!macro.getline(dummyline, kBufSize) && !macro.eof()) {
1813 while (s && (*s ==
' ' || *s ==
'\t')) s++;
1820 if (strstr(cs,
"#ifndef__CLING__") || strstr(cs,
"#ifndef__CINT__") ||
1821 strstr(cs,
"#if!defined(__CLING__)") || strstr(cs,
"#if!defined(__CINT__)"))
1823 else if (ifndefc && (strstr(cs,
"#ifdef") || strstr(cs,
"#ifndef") ||
1824 strstr(cs,
"#ifdefined") || strstr(cs,
"#if!defined")))
1826 else if (ifndefc && strstr(cs,
"#endif")) {
1831 }
else if (ifndefc && !ifdef && strstr(cs,
"#else"))
1835 if (!*s || *s ==
'#' || ifndefc || !strncmp(s,
"//", 2))
continue;
1837 if (!comment && (!strncmp(s,
".X", 2) || !strncmp(s,
".x", 2))) {
1843 if (!strncmp(s,
"/*", 2)) comment = 1;
1847 s = strstr(s,
"*/");
1852 while (s && (*s ==
' ' || *s ==
'\t')) s++;
1854 if (!strncmp(s,
"//", 2))
continue;
1855 if (!strncmp(s,
"/*", 2)) {
1861 if (!comment && *s ==
'{') tempfile = 1;
1862 if (!comment)
break;
1871 exname += aclicMode;
1873 exname += arguments;
1878 tempbuf.
Form(
".x %s", exname.
Data());
1880 tempbuf.
Form(
".X%s %s", keep ?
"k" :
" ", exname.
Data());
1961 Emit(
"Terminate(Int_t)", status);
1975 Emit(
"LineProcessed(const char*)",
line);
1983 Emit(
"KeyPressed(Int_t)", key);
1991 Emit(
"ReturnPressed(char*)",
text);
2020 Printf(
"<TApplication::CreateApplication>: "
2021 "created default TApplication");
2022 delete []
a;
delete []
b;
2032 Int_t debug,
const char *script)
2049 if (strlen(au.GetUser()) > 0 && strlen(nu.GetUser()) > 0 &&
2050 !strcmp(au.GetUser(), nu.GetUser())) {
2051 if (!strncmp(au.GetHost(), nu.GetHost(), strlen(nu.GetHost())))
2058 ::Error(
"TApplication::Open",
"list of applications undefined - protocol error");
2069 TPluginHandler *
h =
nullptr;
2070 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TApplication",
"remote"))) {
2071 if (
h->LoadPlugin() == 0) {
2072 ap = (
TApplication *)
h->ExecPlugin(3, nu.GetUrl(), debug, script);
2074 ::Error(
"TApplication::Open",
"failed to load plugin for TApplicationRemote");
2077 ::Error(
"TApplication::Open",
"failed to find plugin for TApplicationRemote");
2084 TIter next(
gROOT->GetListOfBrowsers());
2086 while ((
b = (TBrowser*) next()))
2088 gROOT->RefreshBrowsers();
2092 "TApplicationRemote for %s could not be instantiated", url);
2107 gROOT->GetListOfBrowsables()->RecursiveRemove(app);
2111 b->RecursiveRemove(app);
2112 gROOT->RefreshBrowsers();
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int).
long Longptr_t
Integer large enough to hold a pointer (platform-dependent).
int Ssiz_t
String size (currently int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
bool Bool_t
Boolean (0=false, 1=true) (bool).
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
long long Long64_t
Portable signed long integer 8 bytes.
const char Option_t
Option string (const char).
static void CallEndOfProcessCleanups()
TApplication * gApplication
externTApplication * gApplication
externTClassTable * gClassTable
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
R__EXTERN ExceptionContext_t * gException
R__EXTERN void Throw(int code)
If an exception context has been set (using the TRY and RETRY macros) jump back to where it was set.
externTGuiFactory * gGuiFactory
externTGuiFactory * gBatchGuiFactory
externTVirtualMutex * gInterpreterMutex
externTVirtualMutex * gROOTMutex
char * Compress(const char *str)
Remove all blanks from the string str.
char * Strip(const char *str, char c=' ')
Strip leading and trailing c (blanks by default) from a string.
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
char * StrDup(const char *str)
Duplicate the string str.
#define R__LOCKGUARD(mutex)
externTVirtualX * gGXBatch
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
EExitOnException ExitOnException(EExitOnException opt=kExit)
Set the exit on exception option.
virtual void KeyPressed(Int_t key)
Emit signal when console keyboard key was pressed.
virtual Longptr_t ProcessLine(const char *line, Bool_t sync=kFALSE, Int_t *error=nullptr)
Process a single command line, either a C++ statement or an interpreter command starting with a "....
static TList * fgApplications
static void Close(TApplication *app)
Static function used to close a remote application.
virtual void SetEchoMode(Bool_t mode)
Set console echo mode:
virtual void Help(const char *line)
The function lists useful commands (".help") or opens the online reference guide, generated with Doxy...
virtual void LineProcessed(const char *line)
Emit signal when a line has been processed.
void ClearInputFiles()
Clear list containing macro files passed as program arguments.
TApplicationImp * fAppImp
!Window system specific application implementation
TApplication(const TApplication &)=delete
static Longptr_t ExecuteFile(const char *file, Int_t *error=nullptr, Bool_t keep=kFALSE)
Execute a file containing a C++ macro (static method).
void InitializeGraphics(Bool_t only_web=kFALSE)
Initialize the graphics environment.
virtual void LoadGraphicsLibs()
Load shared libs necessary for graphics.
virtual void StopIdleing()
Called when system stops idleing.
virtual void StartIdleing()
Called when system starts idleing.
virtual void Run(Bool_t retrn=kFALSE)
Main application eventloop. Calls system dependent eventloop via gSystem.
virtual ~TApplication()
TApplication dtor.
void OpenReferenceGuideFor(const TString &strippedClass)
It opens the online reference guide, generated with Doxygen, for the chosen scope (class/namespace/st...
virtual void HandleException(Int_t sig)
Handle exceptions (kSigBus, kSigSegmentationViolation, kSigIllegalInstruction and kSigFloatingExcepti...
virtual void MakeBatch()
Switch to batch mode.
void OpenGitHubIssue(const TString &type)
It opens a GitHub issue in a web browser with prefilled ROOT version.
static Bool_t fgGraphNeeded
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
void OpenInBrowser(const TString &url)
The function generates and executes a command that loads the Doxygen URL in a browser.
virtual const char * ApplicationName() const
virtual void Forum(const char *line)
The function (".forum <type>") submits a new post on the ROOT forum via web browser.
void SetReturnFromRun(Bool_t ret)
virtual Int_t TabCompletionHook(char *buf, int *pLoc, std::ostream &out)
What to do when tab is pressed.
EExitOnException fExitOnException
const char * GetIdleCommand() const
TApplication()
Default ctor. Can be used by classes deriving from TApplication.
virtual Longptr_t ProcessFile(const char *file, Int_t *error=nullptr, Bool_t keep=kFALSE)
Process a file containing a C++ macro.
void OpenForumTopic(const TString &type)
It opens a Forum topic in a web browser with prefilled ROOT version.
virtual void ReturnPressed(char *text)
Emit signal when return key was pressed.
static Bool_t fgGraphInit
virtual void RemoveIdleTimer()
Remove idle timer. Normally called via TROOT::Idle(0).
virtual void SetIdleTimer(UInt_t idleTimeInSec, const char *command)
Set the command to be executed after the system has been idle for idleTimeInSec seconds.
virtual void GitHub(const char *line)
The function (".gh <type>") submits a new issue on GitHub via web browser.
static void CreateApplication()
Static function used to create a default application environment.
virtual void GetOptions(Int_t *argc, char **argv)
Get and handle command line options.
static TList * GetApplications()
Static method returning the list of available applications.
std::atomic< bool > fIsRunning
static void NeedGraphicsLibs()
Static method.
static Int_t ParseRemoteLine(const char *ln, TString &hostdir, TString &user, Int_t &dbg, TString &script)
Parse the content of a line starting with ".R" (already stripped-off) The format is.
void ls(Option_t *option="") const override
Show available sessions.
TString GetSetup()
It gets the ROOT installation setup as TString.
virtual void HandleIdleTimer()
Handle idle timeout.
TSignalHandler * fSigHandler
virtual Longptr_t ProcessRemote(const char *line, Int_t *error=nullptr)
Process the content of a line starting with ".R" (already stripped-off) The format is.
TApplication * fAppRemote
Using a TBrowser one can browse all ROOT objects.
TList * GetListOfAllPublicDataMembers(Bool_t load=kTRUE)
Returns a list of all public data members of this class and its base classes.
TList * GetListOfEnums(Bool_t load=kTRUE)
Return a list containing the TEnums of a class.
Long_t Property() const override
Returns the properties of the TClass as a bit field stored as a Long_t value.
TMethod * GetMethodAllAny(const char *method)
Return pointer to method without looking at parameters.
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
static void InitializeColors()
All ROOT classes may have RTTI (run time type identification) support added.
const char * GetTrueTypeName() const
Get the desugared type name of this data member, including const and volatile qualifiers.
Bool_t IsEnum() const
Return true if data member is an enum.
const char * GetFullTypeName() const
Get the concrete type name of this data member, including const and volatile qualifiers.
Global functions class (global functions are obtained from CINT).
Long_t Property() const override
Get property description word. For meaning of bits see EProperty.
const char * GetSignature()
Return signature of function.
Long_t ExtraProperty() const
Get property description word. For meaning of bits see EProperty.
const char * GetReturnTypeName() const
Get full type description of function return type, e,g.: "class TDirectory*".
Bool_t Notify() override
Notify handler.
void ls(Option_t *option="") const override
List this line with its attributes.
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
The TNamed class is the base class for all named ROOT classes.
Int_t GetEntries() const override
Return the number of objects in array (i.e.
TObject * At(Int_t idx) const override
Collectable string class.
Bool_t TestBit(UInt_t f) const
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
@ kInvalidObject
if object ctor succeeded but object should not be used
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
static const char * GetMacroPath()
Get macro search path. Static utility function.
static Bool_t Initialized()
Return kTRUE if the TROOT object has been initialized.
static const TString & GetTutorialDir()
Get the tutorials directory in the installation. Static utility function.
static const TString & GetDocDir()
Get the documentation directory in the installation. Static utility function.
void ToLower()
Change string to lower-case.
TString & Insert(Ssiz_t pos, const char *s)
Int_t Atoi() const
Return integer value of string.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
Ssiz_t First(char c) const
Find first occurrence of a character c.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
TString MD5() const
Return the MD5 digest for this string, in a string representation.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
TString & Prepend(const char *cs)
std::istream & ReadFile(std::istream &str)
Replace string with the contents of strm, stopping at an EOF.
TString & Remove(Ssiz_t pos)
TString & Append(const char *cs)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
void Reset()
Reset the timer.
TTimer(const TTimer &)=delete
This class represents a WWW compatible URL.
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
const char * GetFileAndOptions() const
Return the file and its options (the string specified behind the ?).
const char * GetFile() const
const char * GetProtocol() const
static constexpr const char kCommandLineOptionsHelp[]
void EnableImplicitMT(UInt_t numthreads=0)
Enable ROOT's implicit multi-threading for all objects and methods that provide an internal paralleli...
void EnableThreadSafety()
Enable support for multi-threading within the ROOT code in particular, enables the global mutex to ma...
const char * GetUnqualifiedName(const char *name)
Return the start of the unqualified name include in 'original'.