Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TRint.cxx
Go to the documentation of this file.
1// @(#)root/rint:$Id$
2// Author: Rene Brun 17/02/95
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12//////////////////////////////////////////////////////////////////////////
13// //
14// Rint //
15// //
16// Rint is the ROOT Interactive Interface. It allows interactive access //
17// to the ROOT system via the Cling C/C++ interpreter. //
18// //
19//////////////////////////////////////////////////////////////////////////
20
21#include "TROOT.h"
22#include "TClass.h"
23#include "TClassEdit.h"
24#include "TVirtualX.h"
25#include "TObjectTable.h"
26#include "TClassTable.h"
27#include "TStopwatch.h"
28#include "TBenchmark.h"
29#include "TRint.h"
30#include "TSystem.h"
31#include "TEnv.h"
32#include "TSysEvtHandler.h"
33#include "TSystemDirectory.h"
34#include "TError.h"
35#include "TException.h"
36#include "TInterpreter.h"
37#include "TObjString.h"
38#include "TObjArray.h"
39#include "TStorage.h" // ROOT::Internal::gMmallocDesc
40#include "ThreadLocalStorage.h"
41#include "TTabCom.h"
42#include <cstdlib>
43#include <algorithm>
44#include <iostream>
45#include "Getline.h"
46#include "strlcpy.h"
47#include "snprintf.h"
48
49#ifdef R__UNIX
50#include <signal.h>
51#include <unistd.h>
52#endif
53
54////////////////////////////////////////////////////////////////////////////////
55
57{
59 return 0;
60}
61
62////////////////////////////////////////////////////////////////////////////////
63
65{
66 if (!gSystem) return 0;
67 gSystem->Beep();
68 return 1;
69}
70
71////////////////////////////////////////////////////////////////////////////////
72/// Restore terminal to non-raw mode.
73
74static void ResetTermAtExit()
75{
76 Getlinem(kCleanUp, nullptr);
77}
78
79
80//----- Interrupt signal handler -----------------------------------------------
81////////////////////////////////////////////////////////////////////////////////
82
88
89////////////////////////////////////////////////////////////////////////////////
90/// TRint interrupt handler.
91
93{
94 if (fDelay) {
95 fDelay++;
96 return kTRUE;
97 }
98
99 // make sure we use the sbrk heap (in case of mapped files)
101
102 if (TROOT::Initialized() && gROOT->IsLineProcessing()) {
103 Break("TInterruptHandler::Notify", "keyboard interrupt");
104 Getlinem(kInit, "Root > ");
105 gCling->Reset();
106#ifndef WIN32
107 if (gException)
108 Throw(GetSignal());
109#endif
110 } else {
111 // Reset input.
112 Getlinem(kClear, ((TRint*)gApplication)->GetPrompt());
113 }
114
115 return kTRUE;
116}
117
118//----- Terminal Input file handler --------------------------------------------
119////////////////////////////////////////////////////////////////////////////////
120
122public:
124 Bool_t Notify() override;
125 Bool_t ReadNotify() override { return Notify(); }
126};
127
128////////////////////////////////////////////////////////////////////////////////
129/// Notify implementation. Call the application interupt handler.
130
135
136
138
139
140namespace {
142{
143 bool forcePtrCheck = false;
144 if (argc != nullptr) {
145 for (int iarg = 1; iarg < *argc; ++iarg) {
146 if (!strcmp(argv[iarg], "--ptrcheck")) {
147 // Hide this, by moving all other args one down...
148 for (int jarg = iarg + 1; jarg < *argc; ++jarg)
149 argv[jarg - 1] = argv[jarg];
150 // ... and updating argc accordingly.
151 --*argc;
152 forcePtrCheck = true;
153 break;
154 }
155 }
156 }
157#ifdef R__UNIX
158 if (forcePtrCheck || isatty(0) || isatty(1))
159#endif
160 TROOT::AddExtraInterpreterArgs({"--ptrcheck"});
161 return 0;
162}
163}
164
165////////////////////////////////////////////////////////////////////////////////
166/// Create an application environment. The TRint environment provides an
167/// interface to the WM manager functionality and eventloop via inheritance
168/// of TApplication and in addition provides interactive access to
169/// the Cling C++ interpreter via the command line.
170
171TRint::TRint(const char *appClassName, Int_t *argc, char **argv, void *options, Int_t numOptions, Bool_t noLogo,
174 fCaughtSignal(-1)
175{
176
177 if (exitOnUnknownArgs && argc != nullptr && *argc > 1) {
178 // Early exit if there are remaining unrecognized options
179 // This branch supposes that TRint is created as a result of using the `root` command
180 for (auto n = 1; n < *argc; n++) {
181 std::cerr << "root: unrecognized option '" << argv[n] << "'\n";
182 }
183 std::cerr << "Try 'root --help' for more information.\n";
185 }
186
187 fNcmd = 0;
188 fDefaultPrompt = "root [%d] ";
190
191 gBenchmark = new TBenchmark();
192
193 if (!noLogo && !NoLogoOpt()) {
194 Bool_t lite = (Bool_t) gEnv->GetValue("Rint.WelcomeLite", 0);
196 }
197
198#ifndef R__USE_CXXMODULES
199 // When modules are not used, and therefore rootmaps, freestanding functions
200 // cannot trigger autoloading. Therefore, given the widespread usage of the
201 // freestanding functions in MathCore, we load the library explicitly.
202 // When modules are used to condense the reflection information, this manual
203 // loading is not needed, and it can be skipped in order to save time and
204 // memory when starting the ROOT prompt.
205 if (!gClassTable->GetDict("TRandom"))
206 gSystem->Load("libMathCore");
207#endif
208
209 if (!gInterpreter->HasPCMForLibrary("std")) {
210 // Load some frequently used includes
211 Int_t includes = gEnv->GetValue("Rint.Includes", 1);
212 // When the interactive ROOT starts, it can automatically load some frequently
213 // used includes. However, this introduces several overheads
214 // -The initialisation takes more time
215 // -Memory overhead when including <vector>
216 // In $ROOTSYS/etc/system.rootrc, you can set the variable Rint.Includes to 0
217 // to disable the loading of these includes at startup.
218 // You can set the variable to 1 (default) to load only <iostream>, <string> and <DllImport.h>
219 // You can set it to 2 to load in addition <vector> and <utility>
220 // We strongly recommend setting the variable to 2 if your scripts include <vector>
221 // and you execute your scripts multiple times.
222 if (includes > 0) {
223 TString code;
224 code = "#include <iostream>\n"
225 "#include <string>\n" // for std::string std::iostream.
226 "#include <DllImport.h>\n";// Defined R__EXTERN
227 if (includes > 1) {
228 code += "#include <vector>\n"
229 "#include <utility>";
230 }
231 ProcessLine(code, kTRUE);
232 }
233 }
234
235 // Load user functions
236 const char *logon;
237 logon = gEnv->GetValue("Rint.Load", (char*)nullptr);
238 if (logon) {
240 if (mac)
241 ProcessLine(Form(".L %s",logon), kTRUE);
242 delete [] mac;
243 }
244
245 // Execute logon macro
246 ExecLogon();
247
248 // Save current interpreter context
251
252 // Install interrupt and terminal input handlers
254 ih->Add();
256
257 // Handle stdin events
260
261 // Goto into raw terminal input mode
262 char defhist[kMAXPATHLEN];
263 snprintf(defhist, sizeof(defhist), "%s/.root_hist", gSystem->HomeDirectory());
264 logon = gEnv->GetValue("Rint.History", defhist);
265 // In the code we had HistorySize and HistorySave, in the rootrc and doc
266 // we have HistSize and HistSave. Keep the doc as it is and check
267 // now also for HistSize and HistSave in case the user did not use
268 // the History versions
269 int hist_size = gEnv->GetValue("Rint.HistorySize", 500);
270 if (hist_size == 500)
271 hist_size = gEnv->GetValue("Rint.HistSize", 500);
272 int hist_save = gEnv->GetValue("Rint.HistorySave", 400);
273 if (hist_save == 400)
274 hist_save = gEnv->GetValue("Rint.HistSave", 400);
275 const char *envHist = gSystem->Getenv("ROOT_HIST");
276 if (envHist) {
277 hist_size = atoi(envHist);
278 envHist = strchr(envHist, ':');
279 if (envHist)
280 hist_save = atoi(envHist+1);
281 }
283 Gl_histinit((char *)logon);
284
285 // black on white or white on black?
286 static const char* defaultColorsBW[] = {
287 "bold blue", "magenta", "bold green", "bold red underlined", "default"
288 };
289 static const char* defaultColorsWB[] = {
290 "yellow", "magenta", "bold green", "bold red underlined", "default"
291 };
292
293 const char** defaultColors = defaultColorsBW;
294 TString revColor = gEnv->GetValue("Rint.ReverseColor", "no");
295 if (revColor.Contains("yes", TString::kIgnoreCase)) {
297 }
298 TString colorType = gEnv->GetValue("Rint.TypeColor", defaultColors[0]);
299 TString colorTabCom = gEnv->GetValue("Rint.TabComColor", defaultColors[1]);
300 TString colorBracket = gEnv->GetValue("Rint.BracketColor", defaultColors[2]);
301 TString colorBadBracket = gEnv->GetValue("Rint.BadBracketColor", defaultColors[3]);
302 TString colorPrompt = gEnv->GetValue("Rint.PromptColor", defaultColors[4]);
304
306
308
309 // Setup for tab completion
310 gTabCom = new TTabCom;
313
314 // tell Cling to use our getline
316}
317
318////////////////////////////////////////////////////////////////////////////////
319/// Destructor.
320
322{
323 delete gTabCom;
324 gTabCom = nullptr;
325 Gl_in_key = nullptr;
326 Gl_beep_hook = nullptr;
328 delete fInputHandler;
329 // We can't know where the signal handler was changed since we started ...
330 // so for now let's not delete it.
331// TSignalHandler *ih = GetSignalHandler();
332// ih->Remove();
333// SetSignalHandler(0);
334// delete ih;
335}
336
337////////////////////////////////////////////////////////////////////////////////
338/// Execute logon macro's. There are three levels of logon macros that
339/// will be executed: the system logon etc/system.rootlogon.C, the global
340/// user logon ~/.rootlogon.C and the local ./.rootlogon.C. For backward
341/// compatibility also the logon macro as specified by the Rint.Logon
342/// environment setting, by default ./rootlogon.C, will be executed.
343/// No logon macros will be executed when the system is started with
344/// the -n option.
345
347{
348 if (NoLogOpt()) return;
349
350 TString name = ".rootlogon.C";
351 TString sname = "system";
352 sname += name;
355 ProcessFile(s);
356 }
357 delete [] s;
360 ProcessFile(s);
361 }
362 delete [] s;
363 // avoid executing ~/.rootlogon.C twice
367 }
368
369 // execute also the logon macro specified by "Rint.Logon"
370 const char *logon = gEnv->GetValue("Rint.Logon", (char*)nullptr);
371 if (logon) {
373 if (mac)
375 delete [] mac;
376 }
377}
378
379////////////////////////////////////////////////////////////////////////////////
380/// Main application eventloop. First process files given on the command
381/// line and then go into the main application event loop, unless the -q
382/// command line option was specified in which case the program terminates.
383/// When return is true this method returns even when -q was specified.
384///
385/// When QuitOpt is true and return is false, terminate the application with
386/// an error code equal to either the ProcessLine error (if any) or the
387/// return value of the command casted to a long.
388
390{
391 if (!QuitOpt()) {
392 // Prompt prompt only if we are expecting / allowing input.
393 Getlinem(kInit, GetPrompt());
394 }
395
396 Longptr_t retval = 0;
397 Int_t error = 0;
398 volatile Bool_t needGetlinemInit = kFALSE;
399
400 if (strlen(WorkingDirectory())) {
401 // if directory specified as argument make it the working directory
404 TObject *w = gROOT->GetListOfBrowsables()->FindObject("workdir");
405 TObjLink *lnk = gROOT->GetListOfBrowsables()->FirstLink();
406 while (lnk) {
407 if (lnk->GetObject() == w) {
408 lnk->SetObject(workdir);
409 lnk->SetOption(gSystem->WorkingDirectory());
410 break;
411 }
412 lnk = lnk->Next();
413 }
414 delete w;
415 }
416
417 // Process shell command line input files
418 if (InputFiles()) {
419 // Make sure that calls into the event loop
420 // ignore end-of-file on the terminal.
422 TIter next(InputFiles());
423 RETRY {
424 retval = 0; error = 0;
425 Int_t nfile = 0;
426 while (TObject *fileObj = next()) {
427 if (dynamic_cast<TNamed*>(fileObj)) {
428 // A file that TApplication did not find. Note the error.
429 retval = 1;
430 continue;
431 }
432 TObjString *file = (TObjString *)fileObj;
433 char cmd[kMAXPATHLEN+50];
434 if (!fNcmd)
435 printf("\n");
437
438 if (file->TestBit(kExpression)) {
439 snprintf(cmd, kMAXPATHLEN+50, "%s", (const char*)file->String());
440 } else {
441 if (file->String().EndsWith(".root") || file->String().BeginsWith("file:")) {
442 rootfile = kTRUE;
443 } else {
444 rootfile = gROOT->IsRootFile(file->String());
445 }
446 if (rootfile) {
447 // special trick to be able to open files using UNC path names
448 if (file->String().BeginsWith("\\\\"))
449 file->String().Prepend("\\\\");
450 file->String().ReplaceAll("\\","/");
451 const char *rfile = (const char*)file->String();
452 Printf("Attaching file %s as _file%d...", rfile, nfile);
453 snprintf(cmd, kMAXPATHLEN+50, "TFile *_file%d = TFile::Open(\"%s\")", nfile++, rfile);
454 } else {
455 Printf("Processing %s...", (const char*)file->String());
456 snprintf(cmd, kMAXPATHLEN+50, ".x %s", (const char*)file->String());
457 }
458 }
459 Getlinem(kCleanUp, nullptr);
461
462 // The ProcessLine might throw an 'exception'. In this case,
463 // GetLinem(kInit,"Root >") is called and we are jump back
464 // to RETRY ... and we have to avoid the Getlinem(kInit, GetPrompt());
466 retval = ProcessLineNr("ROOT_cli_", cmd, &error);
468 fNcmd++;
469
470 // The ProcessLine has successfully completed and we need
471 // to call Getlinem(kInit, GetPrompt());
473
474 if (error != 0 || fCaughtSignal != -1) break;
475 }
476 } ENDTRY;
477
478 if (QuitOpt()) {
479 if (retrn) return;
480 if (error) {
481 retval = error;
482 } else if (fCaughtSignal != -1) {
483 retval = fCaughtSignal + 128;
484 }
485 // Bring retval into sensible range, 0..255.
487 retval = 255;
489 }
490
491 // Allow end-of-file on the terminal to be noticed
492 // after we finish processing the command line input files.
494
496
497 if (needGetlinemInit) Getlinem(kInit, GetPrompt());
498 }
499
500 if (QuitOpt()) {
501 if (retrn) return;
502 Terminate(fCaughtSignal != -1 ? fCaughtSignal + 128 : 0);
503 }
504
506
507 // Reset to happiness.
508 fCaughtSignal = -1;
509
510 Getlinem(kCleanUp, nullptr);
511}
512
513////////////////////////////////////////////////////////////////////////////////
514/// Print the ROOT logo on standard output.
515
517{
518 if (!lite) {
519 // Fancy formatting: the content of lines are format strings; their %s is
520 // replaced by spaces needed to make all lines as long as the longest line.
521 std::vector<TString> lines;
522 // Here, %%s results in %s after TString::Format():
523 lines.emplace_back(TString::Format("Welcome to ROOT %s%%shttps://root.cern",
524 gROOT->GetVersion()));
525 lines.emplace_back(TString::Format("(c) 1995-2025, The ROOT Team; conception: R. Brun, F. Rademakers%%s"));
526 lines.emplace_back(TString::Format("Built for %s on %s%%s", gSystem->GetBuildArch(), gROOT->GetGitDate()));
527 if (!strcmp(gROOT->GetGitBranch(), gROOT->GetGitCommit())) {
528 static const char *months[] = {"January","February","March","April","May",
529 "June","July","August","September","October",
530 "November","December"};
531 Int_t idatqq = gROOT->GetVersionDate();
532 Int_t iday = idatqq%100;
533 Int_t imonth = (idatqq/100)%100;
534 Int_t iyear = (idatqq/10000);
535
536 lines.emplace_back(TString::Format("From tag %s, %d %s %4d%%s",
537 gROOT->GetGitBranch(),
538 iday,months[imonth-1],iyear));
539 } else {
540 // If branch and commit are identical - e.g. "v5-34-18" - then we have
541 // a release build. Else specify the git hash this build was made from.
542 lines.emplace_back(TString::Format("From %s@%s %%s",
543 gROOT->GetGitBranch(),
544 gROOT->GetGitCommit()));
545 }
546 lines.emplace_back(TString::Format("With %s %%s",
548 lines.emplace_back(TString("Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'%s"));
549
550 // Find the longest line and its length:
551 auto itLongest = std::max_element(lines.begin(), lines.end(),
552 [](const TString& left, const TString& right) {
553 return left.Length() < right.Length(); });
554 Ssiz_t lenLongest = itLongest->Length();
555
556
557 Printf(" %s", TString('-', lenLongest).Data());
558 for (const auto& line: lines) {
559 // Print the line, expanded with the necessary spaces at %s, and
560 // surrounded by some ASCII art.
561 Printf(" | %s |",
562 TString::Format(line.Data(),
563 TString(' ', lenLongest - line.Length()).Data()).Data());
564 }
565 Printf(" %s\n", TString('-', lenLongest).Data());
566 }
567}
568
569////////////////////////////////////////////////////////////////////////////////
570/// Get prompt from interpreter. Either "root [n]" or "end with '}'".
571
573{
574 char *s = gCling->GetPrompt();
575 if (s[0])
576 strlcpy(fPrompt, s, sizeof(fPrompt));
577 else
579
580 return fPrompt;
581}
582
583////////////////////////////////////////////////////////////////////////////////
584/// Set a new default prompt. It returns the previous prompt.
585/// The prompt may contain a %d which will be replaced by the commend
586/// number. The default prompt is "root [%d] ". The maximum length of
587/// the prompt is 55 characters. To set the prompt in an interactive
588/// session do:
589/// root [0] ((TRint*)gROOT->GetApplication())->SetPrompt("aap> ")
590/// aap>
591
592const char *TRint::SetPrompt(const char *newPrompt)
593{
594 static TString op;
596
597 if (newPrompt && strlen(newPrompt) <= 55)
599 else
600 Error("SetPrompt", "newPrompt too long (> 55 characters)");
601
602 return op.Data();
603}
604
605////////////////////////////////////////////////////////////////////////////////
606/// Handle input coming from terminal.
607
609{
610 static TStopwatch timer;
611 const char *line;
612
613 if ((line = Getlinem(kOneChar, nullptr))) {
614 if (line[0] == 0 && Gl_eof())
615 Terminate(0);
616
617 gVirtualX->SetKeyAutoRepeat(kTRUE);
618
620
622
623 // strip off '\n' and leading and trailing blanks
624 sline = sline.Chop();
625 sline = sline.Strip(TString::kBoth);
626 ReturnPressed((char*)sline.Data());
627
629
630 // prevent recursive calling of this input handler
632
633 if (gROOT->Timer()) timer.Start();
634
636 added = kFALSE; // reset on each call.
637
638 // This is needed when working with remote sessions
640
641 try {
642 TRY {
643 if (!sline.IsNull())
645 ProcessLineNr("ROOT_prompt_", sline);
646 } CATCH(excode) {
647 // enable again input handler
649 added = kTRUE;
650 Throw(excode);
651 } ENDTRY;
652 }
653 // handle every exception
654 catch (std::exception& e) {
655 // enable again intput handler
657
658 int err;
660 const char* demangledType = demangledType_c;
661 if (err) {
662 demangledType_c = nullptr;
663 demangledType = "<UNKNOWN>";
664 }
665 Error("HandleTermInput()", "%s caught: %s", demangledType, e.what());
667 }
668 catch (...) {
669 // enable again intput handler
671 Error("HandleTermInput()", "Exception caught!");
672 }
673
674 // `ProcessLineNr()` only prepends a `#line` directive if the previous
675 // input line was not terminated by a '\' (backslash-newline).
676 // Thus, to match source locations included in cling diagnostics, we only
677 // increment `fNcmd` if the next call to `ProcessLineNr()` will issue
678 // a new `#line`.
679 if (!fBackslashContinue && !sline.IsNull())
680 fNcmd++;
681
682 if (gROOT->Timer()) timer.Print("u");
683
684 // enable again intput handler
686
687 if (!sline.BeginsWith(".reset"))
689
690 gTabCom->ClearAll();
691 Getlinem(kInit, GetPrompt());
692 }
693 return kTRUE;
694}
695
696////////////////////////////////////////////////////////////////////////////////
697/// Handle signals (kSigBus, kSigSegmentationViolation,
698/// kSigIllegalInstruction and kSigFloatingException) trapped in TSystem.
699/// Specific TApplication implementations may want something different here.
700
702{
703 fCaughtSignal = sig;
704 if (TROOT::Initialized()) {
705 if (gException) {
706 Getlinem(kCleanUp, nullptr);
707 Getlinem(kInit, "Root > ");
708 }
709 }
711}
712
713////////////////////////////////////////////////////////////////////////////////
714/// Terminate the application. Reset the terminal to sane mode and call
715/// the logoff macro defined via Rint.Logoff environment variable.
716/// @note The function does not return, unless the class has
717/// been told to return from Run(), by a call to SetReturnFromRun().
718
720{
721 Getlinem(kCleanUp, nullptr);
722
723 if (ReturnFromRun()) {
724 gSystem->ExitLoop();
725 } else {
726 delete gTabCom;
727 gTabCom = nullptr;
728
729 //Execute logoff macro
730 const char *logoff;
731 logoff = gEnv->GetValue("Rint.Logoff", (char*)nullptr);
732 if (logoff && !NoLogOpt()) {
734 if (mac)
736 delete [] mac;
737 }
738
740 }
741}
742
743////////////////////////////////////////////////////////////////////////////////
744/// Set console mode:
745///
746/// mode = kTRUE - echo input symbols
747/// mode = kFALSE - noecho input symbols
748
750{
751 Gl_config("noecho", mode ? 0 : 1);
752}
753
754////////////////////////////////////////////////////////////////////////////////
755/// Process the content of a line starting with ".R" (already stripped-off)
756/// The format is
757/// [user@]host[:dir] [-l user] [-d dbg] [script]
758/// The variable 'dir' is the remote directory to be used as working dir.
759/// The username can be specified in two ways, "-l" having the priority
760/// (as in ssh).
761/// A 'dbg' value > 0 gives increasing verbosity.
762/// The last argument 'script' allows to specify an alternative script to
763/// be executed remotely to startup the session.
764
766{
768
769 if (ret == 1) {
770 if (fAppRemote) {
771 TString prompt; prompt.Form("%s:root [%%d] ", fAppRemote->ApplicationName());
773 } else {
774 SetPrompt("root [%d] ");
775 }
776 }
777
778 return ret;
779}
780
781
782////////////////////////////////////////////////////////////////////////////////
783/// Calls TRint::ProcessLine() possibly prepending a `#line` directive for
784/// better diagnostics.
785/// The user is responsible for incrementing `fNcmd`, where appropriate, after
786/// a call to this function.
787
788Longptr_t TRint::ProcessLineNr(const char* filestem, const char *line, Int_t *error /*= 0*/)
789{
790 Int_t err;
791 if (!error)
792 error = &err;
793 if (line && line[0] != '.') {
796 input += TString::Format("#line 1 \"%s%d\"\n", filestem, fNcmd);
797 input += line;
798 int res = ProcessLine(input, kFALSE, error);
799 if (gCling->GetMore()) {
802 SetPrompt("root (cont'ed, cancel with .@) [%d]");
803 } else if (fNonContinuePrompt.Length()) {
806 }
807 std::string_view sv(line);
808 auto lastNonSpace = sv.find_last_not_of(" \t");
809 fBackslashContinue = (lastNonSpace != std::string_view::npos
810 && sv[lastNonSpace] == '\\');
811 return res;
812 }
813 if (line && line[0] == '.' && line[1] == '@') {
814 ProcessLine(line, kFALSE, error);
815 SetPrompt("root [%d] ");
816 }
817 return ProcessLine(line, kFALSE, error);
818}
819
820
821////////////////////////////////////////////////////////////////////////////////
822/// Forward tab completion request to our TTabCom::Hook().
823
824Int_t TRint::TabCompletionHook(char *buf, int *pLoc, std::ostream& out)
825{
826 if (gTabCom)
827 return gTabCom->Hook(buf, pLoc, out);
828
829 return -1;
830}
#define e(i)
Definition RSha256.hxx:103
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
long Longptr_t
Integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:89
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
#define ClassImp(name)
Definition Rtypes.h:376
@ kMAXPATHLEN
Definition Rtypes.h:61
R__EXTERN TApplication * gApplication
R__EXTERN TBenchmark * gBenchmark
Definition TBenchmark.h:59
R__EXTERN TClassTable * gClassTable
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
void Break(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:230
#define CATCH(n)
Definition TException.h:58
#define ENDTRY
Definition TException.h:64
#define RETRY
Definition TException.h:44
#define TRY
Definition TException.h:51
R__EXTERN ExceptionContext_t * gException
Definition TException.h:69
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 input
Option_t Option_t TPoint TPoint const char mode
char name[80]
Definition TGX11.cxx:110
R__EXTERN TInterpreter * gCling
#define gInterpreter
#define gROOT
Definition TROOT.h:411
static void ResetTermAtExit()
Restore terminal to non-raw mode.
Definition TRint.cxx:74
static Int_t Key_Pressed(Int_t key)
Definition TRint.cxx:56
static Int_t BeepHook()
Definition TRint.cxx:64
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2496
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2510
@ kSigInterrupt
@ kReadPermission
Definition TSystem.h:55
R__EXTERN TSystem * gSystem
Definition TSystem.h:572
R__EXTERN TTabCom * gTabCom
Definition TTabCom.h:229
#define gVirtualX
Definition TVirtualX.h:337
#define free
Definition civetweb.c:1578
#define snprintf
Definition civetweb.c:1579
const_iterator begin() const
const_iterator end() const
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
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 "....
virtual Bool_t HandleTermInput()
TObjArray * InputFiles() const
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.
Bool_t ReturnFromRun() const
virtual void Run(Bool_t retrn=kFALSE)
Main application eventloop. Calls system dependent eventloop via gSystem.
virtual void HandleException(Int_t sig)
Handle exceptions (kSigBus, kSigSegmentationViolation, kSigIllegalInstruction and kSigFloatingExcepti...
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
virtual const char * ApplicationName() const
virtual Longptr_t ProcessFile(const char *file, Int_t *error=nullptr, Bool_t keep=kFALSE)
Process a file containing a C++ macro.
virtual void ReturnPressed(char *text)
Emit signal when return key was pressed.
Bool_t NoLogOpt() const
Bool_t NoLogoOpt() const
const char * WorkingDirectory() const
Bool_t QuitOpt() const
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
void SetSignalHandler(TSignalHandler *sh)
This class is a ROOT utility to help benchmarking applications.
Definition TBenchmark.h:29
static DictFuncPtr_t GetDict(const char *cname)
Given the class name returns the Dictionary() function of a class (uses hash of name).
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:491
void Remove() override
Remove file event handler from system file handler list.
void Add() override
Add file event handler to system file handler list.
virtual char * GetPrompt()=0
virtual void SaveGlobalsContext()=0
virtual void EndOfLineAction()=0
virtual void Reset()=0
virtual void SetGetline(const char *(*getlineFunc)(const char *prompt), void(*histaddFunc)(const char *line))=0
virtual void SaveContext()=0
virtual Int_t GetMore() const =0
Returns whether the interpreter is waiting for more input, i.e.
Bool_t Notify() override
TRint interrupt handler.
Definition TRint.cxx:92
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
Collectable string class.
Definition TObjString.h:28
TString & String()
Definition TObjString.h:48
Mother of all ROOT objects.
Definition TObject.h:41
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:202
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:865
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1072
static const char * GetMacroPath()
Get macro search path. Static utility function.
Definition TROOT.cxx:2765
static Bool_t Initialized()
Return kTRUE if the TROOT object has been initialized.
Definition TROOT.cxx:2914
static const std::vector< std::string > & AddExtraInterpreterArgs(const std::vector< std::string > &args)
Provide command line arguments to the interpreter construction.
Definition TROOT.cxx:2960
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
Definition TROOT.cxx:3108
Definition TRint.h:31
void SetEchoMode(Bool_t mode) override
Set console mode:
Definition TRint.cxx:749
Bool_t HandleTermInput() override
Handle input coming from terminal.
Definition TRint.cxx:608
Bool_t fInterrupt
Definition TRint.h:38
void Run(Bool_t retrn=kFALSE) override
Main application eventloop.
Definition TRint.cxx:389
Longptr_t ProcessLineNr(const char *filestem, const char *line, Int_t *error=nullptr)
Calls TRint::ProcessLine() possibly prepending a #line directive for better diagnostics.
Definition TRint.cxx:788
virtual const char * SetPrompt(const char *newPrompt)
Set a new default prompt.
Definition TRint.cxx:592
virtual void Terminate(int status) override
Terminate the application.
Definition TRint.cxx:719
char fPrompt[64]
Definition TRint.h:37
Int_t TabCompletionHook(char *buf, int *pLoc, std::ostream &out) override
Forward tab completion request to our TTabCom::Hook().
Definition TRint.cxx:824
virtual char * GetPrompt()
Get prompt from interpreter. Either "root [n]" or "end with '}'".
Definition TRint.cxx:572
void HandleException(Int_t sig) override
Handle signals (kSigBus, kSigSegmentationViolation, kSigIllegalInstruction and kSigFloatingException)...
Definition TRint.cxx:701
virtual ~TRint()
Destructor.
Definition TRint.cxx:321
virtual void PrintLogo(Bool_t lite=kFALSE)
Print the ROOT logo on standard output.
Definition TRint.cxx:516
void ExecLogon()
Execute logon macro's.
Definition TRint.cxx:346
Longptr_t ProcessRemote(const char *line, Int_t *error=nullptr) override
Process the content of a line starting with ".R" (already stripped-off) The format is [user@]host[:di...
Definition TRint.cxx:765
Bool_t fBackslashContinue
Definition TRint.h:41
TString fDefaultPrompt
Definition TRint.h:35
TString fNonContinuePrompt
Definition TRint.h:36
Int_t fCaughtSignal
Definition TRint.h:39
Int_t fNcmd
Definition TRint.h:34
TRint(const TRint &)=delete
TFileHandler * fInputHandler
Definition TRint.h:40
ESignals GetSignal() const
Stopwatch class.
Definition TStopwatch.h:28
Basic string class.
Definition TString.h:138
Ssiz_t Length() const
Definition TString.h:425
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition TString.cxx:2251
void Clear()
Clear string without changing its capacity.
Definition TString.cxx:1242
const char * Data() const
Definition TString.h:384
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:712
@ kBoth
Definition TString.h:284
@ kIgnoreCase
Definition TString.h:285
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition TString.h:631
TString & Prepend(const char *cs)
Definition TString.h:681
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2385
void DeActivate()
De-activate a system event handler.
void Activate()
Activate a system event handler.
Describes an Operating System directory for the browser.
void Beep(Int_t freq=-1, Int_t duration=-1, Bool_t setDefault=kFALSE)
Beep for duration milliseconds with a tone of frequency freq.
Definition TSystem.cxx:324
virtual const char * Getenv(const char *env)
Get environment variable.
Definition TSystem.cxx:1678
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name.
Definition TSystem.cxx:1084
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition TSystem.cxx:1870
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
Definition TSystem.cxx:1309
virtual void ExitLoop()
Exit from event loop.
Definition TSystem.cxx:392
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
Definition TSystem.cxx:874
virtual const char * GetBuildCompilerVersionStr() const
Return the build compiler version identifier string.
Definition TSystem.cxx:3925
virtual const char * WorkingDirectory()
Return working directory.
Definition TSystem.cxx:883
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
Definition TSystem.cxx:1561
virtual const char * GetBuildArch() const
Return the build architecture.
Definition TSystem.cxx:3901
virtual const char * HomeDirectory(const char *userName=nullptr)
Return the user's home directory.
Definition TSystem.cxx:899
Int_t Hook(char *buf, int *pLoc, std::ostream &out)
[private]
Definition TTabCom.cxx:1573
void ClearAll()
clears all lists except for user names and system include files.
Definition TTabCom.cxx:319
TTermInputHandler(Int_t fd)
Definition TRint.cxx:123
Bool_t ReadNotify() override
Notify when something can be read from the descriptor associated with this handler.
Definition TRint.cxx:125
Bool_t Notify() override
Notify implementation. Call the application interupt handler.
Definition TRint.cxx:131
TLine * line
const Int_t n
Definition legend1.C:16
R__EXTERN void * gMmallocDesc
Definition TStorage.h:141
char * DemangleTypeIdName(const std::type_info &ti, int &errorCode)
Demangle in a portable way the type id name.