22#include "RConfigure.h"
47#include "optparse.hxx"
91 gROOT->EndOfProcessCleanups();
99 fArgc(0), fArgv(nullptr), fAppImp(nullptr), fIsRunning(
kFALSE), fReturnFromRun(
kFALSE),
101 fFiles(nullptr), fIdleTimer(nullptr), fSigHandler(nullptr), fExitOnException(kDontExit),
121 void * ,
Int_t numOptions) :
122 fArgc(0), fArgv(nullptr), fAppImp(nullptr), fIsRunning(
kFALSE), fReturnFromRun(
kFALSE),
124 fFiles(nullptr), fIdleTimer(nullptr), fSigHandler(nullptr), fExitOnException(kDontExit),
148 Error(
"TApplication",
"only one instance of TApplication allowed");
154 ::Fatal(
"TApplication::TApplication",
"ROOT system not initialized");
157 ::Fatal(
"TApplication::TApplication",
"gSystem not initialized");
160 if (!hasRegisterAtExit) {
163 hasRegisterAtExit =
kTRUE;
165 gROOT->SetName(appClassName);
168 if (argc && *argc > 0) {
173 for (
int i = 0; i <
fArgc; i++)
203 gROOT->SetLineHasBeenProcessed();
207 gROOT->SetApplication(
this);
216 for (
int i = 0; i <
fArgc; i++)
272 #if !defined(R__WIN32)
281 if (
auto h =
gROOT->GetPluginManager()->FindHandler(
"TVirtualX",
"x11ttf"))
282 if (
h->LoadPlugin() == -1)
283 Info(
"InitializeGraphics",
"no TTF support");
362 for (
int i = 1; i < *argc; ++i) {
363 if (strcmp(argv[i],
"--web") != 0)
366 Warning(
"TApplication",
"Flag `--web` without arguments is deprecated, use `--web=on` instead.");
367 if (argv[i][5] ==
'=') {
368 gROOT->SetWebDisplay(argv[i] + 6);
370 gROOT->SetWebDisplay(
"");
374 for (
int j = i + 1; j < *argc; ++j) {
375 argv[j - 1] = argv[j];
381 ROOT::RCmdLineOpts::RSettings settings;
382 settings.fIgnoreUnknownFlags =
true;
383 ROOT::RCmdLineOpts opts{settings};
384 opts.AddFlag({
"-b",
"--batch"});
385 opts.AddFlag({
"-x",
"--exit-on-exceptions"});
386 opts.AddFlag({
"-e",
"--execute"}, ROOT::RCmdLineOpts::EFlagType::kWithArg,
"",
387 ROOT::RCmdLineOpts::kFlagAllowMultiple);
388 opts.AddFlag({
"-n",
"--no-logon-logoff"});
389 opts.AddFlag({
"-t",
"--enable-threading"});
390 opts.AddFlag({
"-q",
"--quit-after-processing"});
391 opts.AddFlag({
"-l",
"--no-banner"});
392 opts.AddFlag({
"-a"});
393 opts.AddFlag({
"-splash"});
394 opts.AddFlag({
"-config",
"--config"});
395 opts.AddFlag({
"-h",
"-?",
"--help"});
400 opts.AddFlag({
"--web="}, ROOT::RCmdLineOpts::EFlagType::kWithArg,
"", ROOT::RCmdLineOpts::kFlagPrefixArg);
401 opts.AddFlag({
"--version"});
403 opts.Parse(argv + 1, *argc - 1);
404 for (
const auto &err : opts.GetErrors()) {
405 fprintf(stderr,
"%s\n", err.c_str());
407 if (!opts.GetErrors().empty())
410 if (opts.GetSwitch(
"help")) {
414 if (opts.GetSwitch(
"version")) {
415 fprintf(stderr,
"ROOT Version: %s\n",
gROOT->GetVersion());
416 fprintf(stderr,
"Built for %s on %s\n",
418 gROOT->GetGitDate());
419 fprintf(stderr,
"From %s@%s\n",
420 gROOT->GetGitBranch(),
421 gROOT->GetGitCommit());
424 if (opts.GetSwitch(
"config")) {
425 fprintf(stderr,
"ROOT ./configure options:\n%s\n",
gROOT->GetConfigOptions());
428 if (opts.GetSwitch(
"a")) {
429 fprintf(stderr,
"ROOT splash screen is not visible with root.exe, use root instead.\n");
432 if (opts.GetSwitch(
"b")) {
435 if (opts.GetSwitch(
"n")) {
438 if (opts.GetSwitch(
"t")) {
444 if (opts.GetSwitch(
"q")) {
447 if (opts.GetSwitch(
"l")) {
451 if (opts.GetSwitch(
"x")) {
454 if (opts.GetSwitch(
"splash")) {
455 Warning(
"TApplication",
"Flag `-splash` is deprecated and ignored.");
458 if (
auto web = opts.GetFlagValue(
"web="); !web.empty()) {
459 gROOT->SetWebDisplay(std::string(web).c_str());
462 std::vector<std::pair<std::size_t, TObject *>> filesToAdd;
466 for (
const auto &flag : opts.GetFlags()) {
467 if (flag.fName ==
"e" || flag.fName ==
"execute") {
468 auto *expr =
new TObjString(std::string(flag.fValue).c_str());
470 filesToAdd.emplace_back(flag.fIndex, expr);
474 const auto positionalArgsWithIndices = opts.GetArgsWithIndices();
475 const auto lastArgBeforeDashDash = opts.GetFirstPostDashDashArg().value_or(positionalArgsWithIndices.size());
480 for (std::size_t i = 0; i < lastArgBeforeDashDash; ++i) {
481 const auto [argIdx, arg] = positionalArgsWithIndices[i];
485 auto [argPreParens, argPostParens] =
ROOT::SplitAt(arg,
'(');
486 TString expandedDir(argPreParens);
510 }
else if (!strcmp(
gROOT->GetName(),
"Rint")) {
511 Warning(
"GetOptions",
"only one directory argument can be specified (%s)", expandedDir.
Data());
513 }
else if (
size > 0) {
517 Warning(
"GetOptions",
"file %s has size 0, skipping", expandedDir.
Data());
524 if (!strcmp(
gROOT->GetName(),
"Rint"))
525 Warning(
"GetOptions",
"file %s not found", expandedDir.
Data());
528 filesToAdd.emplace_back(argIdx,
new TObjString(arg.c_str()));
537 filesToAdd.emplace_back(argIdx,
new TObjString(arg.c_str()));
541 filesToAdd.emplace_back(argIdx,
new TNamed(
"NOT FOUND!", arg.c_str()));
544 if (!strcmp(
gROOT->GetName(),
"Rint")) {
545 Error(
"GetOptions",
"macro %s not found", fname.
Data());
555 if (!filesToAdd.empty()) {
556 std::sort(filesToAdd.begin(), filesToAdd.end(), [](
const auto &
a,
const auto &
b) { return a.first < b.first; });
559 for (
const auto &[_idx, file] : filesToAdd) {
566 if (lastArgBeforeDashDash != positionalArgsWithIndices.size()) {
568 bool warnShown =
false;
573 if (!
dynamic_cast<TNamed*
>(
f)) {
574 Error(
"GetOptions()",
"Inconsistent file entry (not a TObjString)!");
588 if (macro && !warnShown) {
590 Warning(
"GetOptions",
"-- is used with several macros. "
591 "The arguments will be passed to the last one.");
600 const auto &positionalArgs = opts.GetArgs();
601 str +=
'(' +
ROOT::Join(
",", positionalArgs.begin() + lastArgBeforeDashDash, positionalArgs.end()) +
')';
603 Warning(
"GetOptions",
"no macro to pass arguments to was provided. "
604 "Everything after the -- will be ignored.");
614 for (std::size_t idx : opts.GetUnprocessedArgsIndices()) {
615 argv[j++] = argv[idx + 1];
631 Emit(
"HandleIdleTimer()");
688#elif defined(R__WIN32)
690 TString cWindows(
"start \"\" ");
697 Warning(
"OpenInBrowser",
"The $DISPLAY is not set! Please manually open (e.g. Ctrl-click) %s\n", url.
Data());
705 if (res != EXIT_SUCCESS) {
706 Warning(
"OpenInBrowser",
"Could not automatically open web browser (e.g. due to missing X11)! Please manually open (e.g. Ctrl-click) %s\n", url.
Data());
709 Info(
"OpenInBrowser",
"A new tab should have opened in your browser.");
713enum EUrl { kURLforClass, kURLforNameSpace, kURLforStruct };
726 TString url =
"https://root.cern/doc/";
728 TPRegexp re4(R
"(.*/(v\d)-(\d\d)-00-patches)");
729 const char *branchName =
gROOT->GetGitBranch();
730 TObjArray *objarr = re4.MatchS(branchName);
748 if (scopeType == kURLforClass) {
750 }
else if (scopeType == kURLforStruct) {
785 methodArguments.
ReplaceAll(
"ostream",
"std::ostream");
786 methodArguments.
ReplaceAll(
"istream",
"std::istream");
787 methodArguments.
ReplaceAll(
"map",
"std::map");
788 methodArguments.
ReplaceAll(
"vector",
"std::vector");
792 scopeNameRE.Append(scopeName);
793 scopeNameRE.Append(
"::\\b");
795 argFix.Substitute(methodArguments,
"");
796 return methodArguments;
810 text.ReplaceAll(
"\n",
"%0A");
811 text.ReplaceAll(
"#",
"%23");
812 text.ReplaceAll(
";",
"%3B");
813 text.ReplaceAll(
"\"",
"%22");
814 text.ReplaceAll(
"`",
"%60");
815 text.ReplaceAll(
"+",
"%2B");
816 text.ReplaceAll(
"/",
"%2F");
839 scopeNameRE.Append(scopeName);
840 scopeNameRE.Append(
"::\\b");
842 returnFix.Substitute(returnType,
"");
848 returnType.
Prepend(
"virtual ");
858 returnType.
ReplaceAll(
"istream",
"std::istream");
859 returnType.
ReplaceAll(
"ostream",
"std::ostream");
861 returnType.
ReplaceAll(
"vector",
"std::vector");
885 if (!dataMember->
IsEnum()) {
890 md5DataMember.Append(
" ");
892 md5DataMember.Append(scopeName);
893 md5DataMember.Append(
"::");
895 md5DataMember.Append(dataMemberName);
896 md5DataMember.Append(dataMemberName);
898 TString urlForDataMember = UrlGenerator(scopeName, scopeType);
900 urlForDataMember.
Append(
"#a");
901 urlForDataMember.
Append(md5DataMember.MD5());
902 return urlForDataMember;
909 if (scopeEnumeration.
Contains(
"(unnamed)")) {
911 md5EnumClass.
Append(scopeName);
912 md5EnumClass.
Append(
"::@1@1");
916 md5EnumClass.
Append(scopeEnumeration);
920 md5EnumClass.
Append(enumOnlyName);
924 md5Enumerator.Append(scopeName);
925 md5Enumerator.Append(
"::");
926 md5Enumerator.Append(dataMemberName);
927 md5Enumerator.Append(dataMemberName);
929 TString url = UrlGenerator(scopeName, scopeType);
935 url.
Append(md5Enumerator.MD5());
953 TString md5Enumeration(scopeName);
954 md5Enumeration.Append(
"::");
955 md5Enumeration.Append(enumeration);
956 md5Enumeration.Append(enumeration);
958 TString url(UrlGenerator(scopeName, scopeType));
961 url.
Append(md5Enumeration.MD5());
967enum EMethodKind { kURLforMethod, kURLforStructor };
983 EMethodKind methodType, EUrl scopeType)
986 if (methodType == kURLforMethod) {
989 md5Text.
Append((FormatReturnTypeForDoxygen(scopeName, func)));
990 if (scopeType == kURLforNameSpace) {
999 md5Text.
Append(scopeName);
1001 md5Text.
Append(methodName);
1002 md5Text.
Append(methodName);
1004 md5Text.
Append(FormatMethodArgsForDoxygen(scopeName, func));
1006 TString url = UrlGenerator(scopeName, scopeType);
1021 std::vector<TString> lines;
1022 lines.emplace_back(
"```");
1024 gROOT->GetVersion()));
1026 if (!strcmp(
gROOT->GetGitBranch(),
gROOT->GetGitCommit())) {
1027 static const char *months[] = {
"January",
"February",
"March",
"April",
"May",
1028 "June",
"July",
"August",
"September",
"October",
1029 "November",
"December"};
1031 Int_t iday = idatqq%100;
1032 Int_t imonth = (idatqq/100)%100;
1033 Int_t iyear = (idatqq/10000);
1036 gROOT->GetGitBranch(),
1037 iday,months[imonth-1],iyear));
1042 gROOT->GetGitBranch(),
1043 gROOT->GetGitCommit()));
1047 lines.emplace_back(
"Binary directory: "+
gROOT->GetBinDir());
1048 lines.emplace_back(
"```");
1050 for (
auto&
line : lines) {
1067 if (
type ==
"bug") {
1071_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)_
1075A clear and concise description of what the wrong behavior is.
1077### Expected behavior
1079A clear and concise description of what you expected to happen.
1084Steps to reproduce the behavior:
10851. Your code that triggers the issue: at least a part; ideally something we can run ourselves.
10862. Don't forget to attach the required input files!
10873. How to run your code and / or build it, e.g. `root myMacro.C`, ...
1094Please specify also how you obtained ROOT, such as `dnf install` / binary download / you built it yourself.
1097### Additional context
1099Add any other context about the problem here.
1101 report_template = FormatHttpUrl(report_template);
1103 OpenInBrowser("\"https://root-forum.cern.ch/new-topic?category=ROOT&tags=bug&body="+report_template+
"&\"");
1105 Warning(
"OpenForumTopic",
"cannot find \"%s\" as type for a Forum topic\n"
1106 "Available types are 'bug'.",
type.Data());
1119 if (
type ==
"bug") {
1121 "\"https://github.com/root-project/root/issues/new?labels=bug&template=bug_report.yml&root-version=" +
1123 }
else if (
type ==
"improvement") {
1124 OpenInBrowser(
"\"https://github.com/root-project/root/issues/"
1125 "new?labels=improvement&template=improvement_report.yml&root-version=" +
1127 }
else if (
type ==
"feature") {
1129 "\"https://github.com/root-project/root/issues/new?labels=new+feature&template=feature_request.yml\"");
1132 "Cannot find GitHub issue type \"%s\".\n"
1133 "Available types are 'bug', 'feature' and 'improvement'.",
1154 scopeType = kURLforNameSpace;
1155 }
else if (clas->Property() &
kIsStruct) {
1156 scopeType = kURLforStruct;
1158 scopeType = kURLforClass;
1168 if (strippedClass == memberName) {
1169 Error(
"OpenReferenceGuideFor",
"Unknown entity \"%s\" - global variables / functions not supported yet!",
1170 strippedClass.
Data());
1179 Warning(
"OpenReferenceGuideFor",
"\"%s\" does not exist in ROOT!", scopeName.
Data());
1185 scopeType = kURLforNameSpace;
1187 scopeType = kURLforStruct;
1189 scopeType = kURLforClass;
1194 int bracket = memberName.
First(
"(");
1196 memberName.
Remove(bracket);
1203 EMethodKind methodType;
1205 if (baseClName == memberName) {
1206 methodType = kURLforStructor;
1208 }
else if (memberName[0] ==
'~') {
1209 methodType = kURLforStructor;
1212 methodType = kURLforMethod;
1215 OpenInBrowser(GetUrlForMethod(baseClName, memberName, func, methodType, scopeType));
1222 OpenInBrowser(GetUrlForEnumeration(scopeName, memberName, scopeType));
1230 OpenInBrowser(GetUrlForDataMember(baseClName, memberName, enumerator, scopeType));
1236 Warning(
"OpenReferenceGuideFor",
"cannot find \"%s\" as member of %s or its base classes! Check %s\n", memberName.
Data(),
1237 scopeName.
Data(), UrlGenerator(scopeName, scopeType).Data());
1250 if (!strippedCommand.
BeginsWith(
".forum ")) {
1251 Error(
"Forum",
"Unknown command! Use 'bug' after '.forum '");
1255 strippedCommand.
Remove(0, 7);
1272 Error(
"GitHub",
"Unknown command! Use 'bug', 'feature' or 'improvement' after '.gh '");
1276 strippedCommand.
Remove(0, 4);
1294 if ((strippedCommand ==
".help") || (strippedCommand ==
".?")) {
1296 Printf(
"\n ROOT special commands.");
1297 Printf(
" ==============================================================================");
1298 Printf(
" .L <filename>[flags]: load the given file with optional flags like\n"
1299 " + to compile or ++ to force recompile.\n"
1300 " Type .? TSystem::CompileMacro for a list of all flags.\n"
1301 " <filename> can also be a shared library; skip flags.");
1302 Printf(
" .(x|X) <filename>[flags](args) :\n"
1303 " same as .L <filename>[flags] and runs then a function\n"
1304 " with signature: ret_type filename(args).");
1305 Printf(
" .credits : show credits");
1306 Printf(
" .demo : launch GUI demo");
1307 Printf(
" .forum bug : ask for help with a bug or crash at the ROOT forum.");
1308 Printf(
" .gh [bug|feature|improvement]\n"
1309 " : submit a bug report, feature or improvement suggestion");
1310 Printf(
" .help Class::Member : open reference guide for that class member (or .?).\n"
1311 " Specifying '::Member' is optional.");
1312 Printf(
" .help edit : show line editing shortcuts (or .?)");
1313 Printf(
" .license : show license");
1314 Printf(
" .libraries : show loaded libraries");
1315 Printf(
" .ls : list contents of current TDirectory");
1316 Printf(
" .pwd : show current TDirectory, pad and style");
1317 Printf(
" .quit (or .exit) : quit ROOT (long form of .q)");
1318 Printf(
" .R [user@]host[:dir] [-l user] [-d dbg] [script] :\n"
1319 " launch process in a remote host");
1320 Printf(
" .qqq : quit ROOT - mandatory");
1321 Printf(
" .qqqqq : exit process immediately");
1322 Printf(
" .qqqqqqq : abort process");
1323 Printf(
" .which [file] : show path of macro file");
1324 Printf(
" .![OS_command] : execute OS-specific shell command");
1325 Printf(
" .!root -? : print ROOT usage (CLI options)");
1331 Error(
"Help",
"Unknown command!");
1336 strippedCommand.
Remove(0, 3);
1338 strippedCommand.
Remove(0, 5);
1343 if (strippedCommand ==
"edit") {
1344 Printf(
"\n ROOT terminal keyboard shortcuts (GNU-readline style).");
1346 #define FOOTNOTE " *"
1347 Printf(
"* Some of these commands might be intercepted by macOS predefined system shortcuts.");
1352 Printf(
" ==============================================================================");
1353 Printf(
" Arrow_Left : move cursor left [Ctrl+B]");
1354 Printf(
" Arrow_Right : move cursor right [Ctrl+F] [Ctrl+G]");
1356 Printf(
" Fn+Arrow_Left : move cursor to beginning of line [Ctrl+A]");
1358 Printf(
" Home : move cursor to beginning of line [Ctrl+A]");
1361 Printf(
" Fn+Arrow_Right : move cursor to end of line [Ctrl+E]");
1363 Printf(
" End : move cursor to end of line [Ctrl+E]");
1365 Printf(
" Ctrl+Arrow_Left : jump to previous word [Esc,B] [Alt,B]" FOOTNOTE);
1366 Printf(
" Ctrl+Arrow_Right : jump to next word [Esc,F] [Alt,F]" FOOTNOTE);
1368 Printf(
" Backspace : delete previous character [Ctrl+H]");
1369 Printf(
" Del : delete next character [Ctrl+D]");
1370 Printf(
" Esc,Backspace : delete previous word [Ctrl+W] [Esc,Ctrl+H] [Alt+Backspace] [Esc,Del] [Esc,Ctrl+Del]" FOOTNOTE);
1372 Printf(
" Ctrl+U : cut all characters between cursor and start of line");
1373 Printf(
" Ctrl+K : cut all characters between cursor and end of line");
1375 Printf(
" Ctrl+T : transpose characters");
1376 Printf(
" Esc,C : character to upper and jump to next word");
1377 Printf(
" Esc,L : word to lower case and jump to its end");
1378 Printf(
" Esc,U : word to upper case and jump to its end");
1379 Printf(
" Ctrl+Shift+C : copy clipboard content");
1380 Printf(
" Ctrl+Shift+V : paste clipboard content [Ctrl+Y] [Alt+Y]");
1382 Printf(
" Fn+Enter : toggle overwrite mode");
1384 Printf(
" Ins : toggle overwrite mode");
1387 Printf(
" Ctrl+_ : undo last keypress action");
1388 Printf(
" Tab : autocomplete command or print suggestions [Ctrl+I] [Esc,Tab]");
1389 Printf(
" Enter : execute command [Ctrl+J] [Ctrl+M]");
1390 Printf(
" Ctrl+L : clear prompt screen");
1391 Printf(
" Ctrl+D : quit ROOT (if empty line)");
1392 Printf(
" Ctrl+C : send kSigInt interrupt signal");
1393 Printf(
" Ctrl+Z : send kSigStop pause job signal");
1394 Printf(
" Ctrl+\\ : send kSigQuit quit job signal");
1396 Printf(
" Arrow_Down : navigate downwards in command history [Ctrl+N]");
1397 Printf(
" Arrow_Up : navigate upwards in command history [Ctrl+P]");
1398 Printf(
" Ctrl+R ; Ctrl+S : search command in your history by typing a string.\n"
1399 " Use Backspace if you mistyped (but not arrows).\n"
1400 " Press Ctrl+R (Ctrl+S) repeateadly to navigate matches in reverse (forward) order");
1401 Printf(
" Arrow_Right : after Ctrl+R (Ctrl+S), select current match of the history search\n"
1402 " [Ctrl+O] [Enter] [Ctrl+J] [Ctrl+M] [Arrow_Left] [Esc,Esc].\n"
1403 " Use Ctrl+F or Ctrl+G to cancel search and revert original line");
1417 if (
gROOT->IsBatch())
1420 if (
auto h =
gROOT->GetPluginManager()->FindHandler(
"TVirtualPad"))
1421 if (
h->LoadPlugin() == -1)
1426 if (guiFactory ==
"native")
1427 guiFactory =
"root";
1429 if (
auto h =
gROOT->GetPluginManager()->FindHandler(
"TGuiFactory", guiFactory)) {
1430 if (
h->LoadPlugin() == -1) {
1442 TString title1 =
"ROOT interface to ";
1446 nativex =
"win32gdk";
1448 title = title1 +
"Win32gdk";
1449#elif defined(R__HAS_COCOA)
1452 title = title1 +
"Quartz";
1456 title = title1 +
"X11";
1461 if (guiBackend ==
"native") {
1462 guiBackend = nativex;
1465 title = title1 + guiBackend;
1468 if (
auto h =
gROOT->GetPluginManager()->FindHandler(
"TVirtualX", guiBackend)) {
1469 if (
h->LoadPlugin() == -1) {
1509 if (!ln || strlen(ln) <= 0)
1521 while (
line.Tokenize(tkn, from,
" ")) {
1525 }
else if (tkn ==
"-d") {
1527 }
else if (tkn ==
"-close") {
1530 ::Warning(
"TApplication::ParseRemoteLine",
"unknown option: %s", tkn.
Data());
1538 }
else if (isHostDir) {
1543 }
else if (isScript) {
1573 if (!
line)
return 0;
1575 if (!strncmp(
line,
"-?", 2) || !strncmp(
line,
"-h", 2) ||
1576 !strncmp(
line,
"--help", 6)) {
1577 Info(
"ProcessRemote",
"remote session help:");
1578 Printf(
".R [user@]host[:dir] [-l user] [-d dbg] [[<]script] | [host] -close");
1579 Printf(
"Create a ROOT session on the specified remote host.");
1580 Printf(
"The variable \"dir\" is the remote directory to be used as working dir.");
1581 Printf(
"The username can be specified in two ways, \"-l\" having the priority");
1582 Printf(
"(as in ssh). A \"dbg\" value > 0 gives increasing verbosity.");
1583 Printf(
"The last argument \"script\" allows to specify an alternative script to");
1584 Printf(
"be executed remotely to startup the session, \"roots\" being");
1585 Printf(
"the default. If the script is preceded by a \"<\" the script will be");
1586 Printf(
"sourced, after which \"roots\" is executed. The sourced script can be ");
1587 Printf(
"used to change the PATH and other variables, allowing an alternative");
1588 Printf(
"\"roots\" script to be found.");
1589 Printf(
"To close down a session do \".R host -close\".");
1590 Printf(
"To switch between sessions do \".R host\", to switch to the local");
1591 Printf(
"session do \".R\".");
1592 Printf(
"To list all open sessions do \"gApplication->GetApplications()->Print()\".");
1596 TString hostdir, user, script;
1599 if (hostdir.
Length() <= 0) {
1609 }
else if (rc == 1) {
1620 const char *sc = (script.
Length() > 0) ? script.
Data() :
nullptr;
1631 static int PrintFile(
const char*
filename) {
1638 std::ifstream instr(sFileName);
1656 if (!strncmp(
line,
".R", 2)) {
1658 while (*(
line+
n) ==
' ')
1669 if (!strncasecmp(
line,
".qqqqqqq", 7)) {
1671 }
else if (!strncasecmp(
line,
".qqqqq", 5)) {
1672 Info(
"ProcessLine",
"Bye... (try '.qqqqqqq' if still running)");
1674 }
else if (!strncasecmp(
line,
".exit", 4) || !strncasecmp(
line,
".quit", 2)) {
1679 if (!strncmp(
line,
".gh", 3)) {
1684 if (!strncmp(
line,
".forum", 6)) {
1689 if (!strncmp(
line,
".?", 2) || !strncmp(
line,
".help", 5)) {
1694 if (!strncmp(
line,
".demo", 5)) {
1695 if (
gROOT->IsBatch()) {
1696 Error(
"ProcessLine",
"Cannot show demos in batch mode!");
1703 if (!strncmp(
line,
".license", 8)) {
1707 if (!strncmp(
line,
".credits", 8)) {
1711 return PrintFile(credits);
1714 if (!strncmp(
line,
".pwd", 4)) {
1724 if (!strncmp(
line,
".ls", 3)) {
1725 const char *opt =
nullptr;
1731 if (!strncmp(
line,
".which", 6)) {
1733 char *s = strtok(fn,
"+(");
1744 if (!strncmp(
line,
".L", 2) || !strncmp(
line,
".U", 2)) {
1745 TString aclicMode, arguments, io;
1750 Warning(
"ProcessLine",
"argument(s) \"%s\" ignored with .%c", arguments.
Data(),
line[1]);
1756 Ssiz_t posSpace = cmd.Index(
' ');
1757 if (posSpace ==
kNPOS)
1760 cmd.Remove(posSpace);
1774 if (!strncmp(
line,
".X", 2) || !strncmp(
line,
".x", 2)) {
1778 if (!strcmp(
line,
".reset")) {
1780 Printf(
"*** .reset not allowed, please use gROOT->Reset() ***");
1791 if (!strcmp(
line,
".libraries")) {
1817 static const Int_t kBufSize = 1024;
1819 if (!file || !*file)
return 0;
1828 ::Error(
"TApplication::ExecuteFile",
"macro %s not found in path %s", fname.
Data(),
1836 ::std::ifstream macro(exnam, std::ios::in);
1837 if (!macro.good()) {
1838 ::Error(
"TApplication::ExecuteFile",
"%s no such file", exnam);
1845 char currentline[kBufSize];
1846 char dummyline[kBufSize];
1856 bool res = (
bool)macro.getline(currentline, kBufSize);
1857 if (macro.eof())
break;
1862 while (!macro.getline(dummyline, kBufSize) && !macro.eof()) {
1867 while (s && (*s ==
' ' || *s ==
'\t')) s++;
1874 if (strstr(cs,
"#ifndef__CLING__") || strstr(cs,
"#ifndef__CINT__") ||
1875 strstr(cs,
"#if!defined(__CLING__)") || strstr(cs,
"#if!defined(__CINT__)"))
1877 else if (ifndefc && (strstr(cs,
"#ifdef") || strstr(cs,
"#ifndef") ||
1878 strstr(cs,
"#ifdefined") || strstr(cs,
"#if!defined")))
1880 else if (ifndefc && strstr(cs,
"#endif")) {
1885 }
else if (ifndefc && !ifdef && strstr(cs,
"#else"))
1889 if (!*s || *s ==
'#' || ifndefc || !strncmp(s,
"//", 2))
continue;
1891 if (!comment && (!strncmp(s,
".X", 2) || !strncmp(s,
".x", 2))) {
1897 if (!strncmp(s,
"/*", 2)) comment = 1;
1901 s = strstr(s,
"*/");
1906 while (s && (*s ==
' ' || *s ==
'\t')) s++;
1908 if (!strncmp(s,
"//", 2))
continue;
1909 if (!strncmp(s,
"/*", 2)) {
1915 if (!comment && *s ==
'{') tempfile = 1;
1916 if (!comment)
break;
1925 exname += aclicMode;
1927 exname += arguments;
1932 tempbuf.
Form(
".x %s", exname.
Data());
1934 tempbuf.
Form(
".X%s %s", keep ?
"k" :
" ", exname.Data());
2015 Emit(
"Terminate(Int_t)", status);
2029 Emit(
"LineProcessed(const char*)",
line);
2037 Emit(
"KeyPressed(Int_t)", key);
2045 Emit(
"ReturnPressed(char*)",
text);
2074 Printf(
"<TApplication::CreateApplication>: "
2075 "created default TApplication");
2076 delete []
a;
delete []
b;
2086 Int_t debug,
const char *script)
2103 if (strlen(au.GetUser()) > 0 && strlen(nu.GetUser()) > 0 &&
2104 !strcmp(au.GetUser(), nu.GetUser())) {
2105 if (!strncmp(au.GetHost(), nu.GetHost(), strlen(nu.GetHost())))
2112 ::Error(
"TApplication::Open",
"list of applications undefined - protocol error");
2124 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TApplication",
"remote"))) {
2125 if (
h->LoadPlugin() == 0) {
2126 ap = (
TApplication *)
h->ExecPlugin(3, nu.GetUrl(), debug, script);
2128 ::Error(
"TApplication::Open",
"failed to load plugin for TApplicationRemote");
2131 ::Error(
"TApplication::Open",
"failed to find plugin for TApplicationRemote");
2142 gROOT->RefreshBrowsers();
2146 "TApplicationRemote for %s could not be instantiated", url);
2166 gROOT->RefreshBrowsers();
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Boolean (0=false, 1=true) (bool)
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)
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
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 constexpr const char * kCommandLineOptionsHelp
static void CallEndOfProcessCleanups()
TApplication * gApplication
R__EXTERN TApplication * gApplication
R__EXTERN TClassTable * gClassTable
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
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.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Option_t Option_t TPoint TPoint const char text
R__EXTERN TGuiFactory * gBatchGuiFactory
R__EXTERN TGuiFactory * gGuiFactory
R__EXTERN TVirtualMutex * gInterpreterMutex
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
R__EXTERN TVirtualMutex * 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.
R__EXTERN TStyle * gStyle
R__EXTERN TSystem * gSystem
#define R__LOCKGUARD(mutex)
R__EXTERN TVirtualX * 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
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.
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.
void RecursiveRemove(TObject *obj) override
Recursively remove obj from browser.
void Add(TObject *obj, const char *name=nullptr, Int_t check=-1)
Add object with name to browser.
static DictFuncPtr_t GetDict(const char *cname)
Given the class name returns the Dictionary() function of a class (uses hash of name).
TClass instances represent classes, structs and namespaces in the ROOT type system.
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()
Initialize colors used by the TCanvas based graphics (via TColor objects).
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.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
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*".
This ABC is a factory for GUI components.
virtual TApplicationImp * CreateApplicationImp(const char *classname, int *argc, char **argv)
Create a batch version of TApplicationImp.
virtual Bool_t UseVirtualX() const
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.
void Add(TObject *obj) override
TObject * Remove(TObject *obj) override
Remove object from the list.
virtual TObjLink * FirstLink() const
Each ROOT class (see TClass) has a linked list of methods.
The TNamed class is the base class for all named ROOT classes.
const char * GetName() const override
Returns name of object.
Int_t GetEntries() const override
Return the number of objects in array (i.e.
void Delete(Option_t *option="") override
Remove all objects from the array AND delete all heap based objects.
TObject * At(Int_t idx) const override
void Add(TObject *obj) override
Collectable string class.
virtual const char * GetName() const
Returns name of object.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual void RecursiveRemove(TObject *obj)
Recursively remove this object from a list.
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 void ShutDown()
Shut down ROOT.
static const TString & GetTTFFontDir()
Get the fonts directory in the installation. 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 SetScreenFactor(Float_t factor=1)
virtual void NotifyApplicationCreated()
Hook to tell TSystem that the TApplication object has been created.
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
virtual const char * Getenv(const char *env)
Get environment variable.
virtual TString SplitAclicMode(const char *filename, TString &mode, TString &args, TString &io) const
This method split a filename of the form:
virtual Int_t Exec(const char *shellcmd)
Execute a command.
virtual void ListLibraries(const char *regexp="")
List the loaded shared libraries.
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual void Run()
System event loop.
virtual void ExitLoop()
Exit from event loop.
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
virtual const char * GetBuildCompilerVersionStr() const
Return the build compiler version identifier string.
virtual void Exit(int code, Bool_t mode=kTRUE)
Exit the application.
virtual const char * WorkingDirectory()
Return working directory.
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
virtual void SetProgname(const char *name)
Set the application name (from command line, argv[0]) and copy it in gProgName.
virtual const char * GetBuildArch() const
Return the build architecture.
virtual void Abort(int code=0)
Abort the application.
virtual TTimer * RemoveTimer(TTimer *t)
Remove timer from list of system timers.
Handles synchronous and a-synchronous timer events.
void Reset()
Reset the timer.
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
Semi-Abstract base class defining a generic interface to the underlying, low level,...
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...
std::string Join(const std::string &sep, InputIt_t begin, InputIt_t end)
Concatenate a list of strings with a separator.
std::pair< std::string_view, std::string_view > SplitAt(std::string_view str, char splitter)
Given a string str, returns a pair of string views into it: the first containing the substring preced...
const char * GetUnqualifiedName(const char *name)
Return the start of the unqualified name include in 'original'.