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 <csignal>
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
137
138
139namespace {
141{
142 bool forcePtrCheck = false;
143 if (argc != nullptr) {
144 for (int iarg = 1; iarg < *argc; ++iarg) {
145 if (!strcmp(argv[iarg], "--ptrcheck")) {
146 // Hide this, by moving all other args one down...
147 for (int jarg = iarg + 1; jarg < *argc; ++jarg)
148 argv[jarg - 1] = argv[jarg];
149 // ... and updating argc accordingly.
150 --*argc;
151 forcePtrCheck = true;
152 break;
153 }
154 }
155 }
156#ifdef R__UNIX
157 if (forcePtrCheck || isatty(0) || isatty(1))
158#endif
159 TROOT::AddExtraInterpreterArgs({"--ptrcheck"});
160 return 0;
161}
162}
163
164////////////////////////////////////////////////////////////////////////////////
165/// Create an application environment. The TRint environment provides an
166/// interface to the WM manager functionality and eventloop via inheritance
167/// of TApplication and in addition provides interactive access to
168/// the Cling C++ interpreter via the command line.
169
170TRint::TRint(const char *appClassName, Int_t *argc, char **argv, void *options, Int_t numOptions, Bool_t noLogo,
173 fCaughtSignal(-1)
174{
175
176 if (exitOnUnknownArgs && argc != nullptr && *argc > 1) {
177 // Early exit if there are remaining unrecognized options
178 // This branch supposes that TRint is created as a result of using the `root` command
179 for (auto n = 1; n < *argc; n++) {
180 std::cerr << "root: unrecognized option '" << argv[n] << "'\n";
181 }
182 std::cerr << "Try 'root --help' for more information.\n";
184 }
185
186 fNcmd = 0;
187 fDefaultPrompt = "root [%d] ";
189
190 gBenchmark = new TBenchmark();
191
192 if (!noLogo && !NoLogoOpt()) {
193 Bool_t lite = (Bool_t) gEnv->GetValue("Rint.WelcomeLite", 0);
195 }
196
197#ifndef R__USE_CXXMODULES
198 // When modules are not used, and therefore rootmaps, freestanding functions
199 // cannot trigger autoloading. Therefore, given the widespread usage of the
200 // freestanding functions in MathCore, we load the library explicitly.
201 // When modules are used to condense the reflection information, this manual
202 // loading is not needed, and it can be skipped in order to save time and
203 // memory when starting the ROOT prompt.
204 if (!gClassTable->GetDict("TRandom"))
205 gSystem->Load("libMathCore");
206#endif
207
208 if (!gInterpreter->HasPCMForLibrary("std")) {
209 // Load some frequently used includes
210 Int_t includes = gEnv->GetValue("Rint.Includes", 1);
211 // When the interactive ROOT starts, it can automatically load some frequently
212 // used includes. However, this introduces several overheads
213 // -The initialisation takes more time
214 // -Memory overhead when including <vector>
215 // In $ROOTSYS/etc/system.rootrc, you can set the variable Rint.Includes to 0
216 // to disable the loading of these includes at startup.
217 // You can set the variable to 1 (default) to load only <iostream>, <string> and <DllImport.h>
218 // You can set it to 2 to load in addition <vector> and <utility>
219 // We strongly recommend setting the variable to 2 if your scripts include <vector>
220 // and you execute your scripts multiple times.
221 if (includes > 0) {
222 TString code;
223 code = "#include <iostream>\n"
224 "#include <string>\n" // for std::string std::iostream.
225 "#include <DllImport.h>\n";// Defined R__EXTERN
226 if (includes > 1) {
227 code += "#include <vector>\n"
228 "#include <utility>";
229 }
230 ProcessLine(code, kTRUE);
231 }
232 }
233
234 // Load user functions
235 const char *logon;
236 logon = gEnv->GetValue("Rint.Load", (char*)nullptr);
237 if (logon) {
239 if (mac)
240 ProcessLine(Form(".L %s",logon), kTRUE);
241 delete [] mac;
242 }
243
244 // Execute logon macro
245 ExecLogon();
246
247 // Save current interpreter context
250
251 // Install interrupt and terminal input handlers
253 ih->Add();
255
256 // Handle stdin events
259
260 // Goto into raw terminal input mode
261 char defhist[kMAXPATHLEN];
262 snprintf(defhist, sizeof(defhist), "%s/.root_hist", gSystem->HomeDirectory());
263 logon = gEnv->GetValue("Rint.History", defhist);
264 // In the code we had HistorySize and HistorySave, in the rootrc and doc
265 // we have HistSize and HistSave. Keep the doc as it is and check
266 // now also for HistSize and HistSave in case the user did not use
267 // the History versions
268 int hist_size = gEnv->GetValue("Rint.HistorySize", 500);
269 if (hist_size == 500)
270 hist_size = gEnv->GetValue("Rint.HistSize", 500);
271 int hist_save = gEnv->GetValue("Rint.HistorySave", 400);
272 if (hist_save == 400)
273 hist_save = gEnv->GetValue("Rint.HistSave", 400);
274 const char *envHist = gSystem->Getenv("ROOT_HIST");
275 if (envHist) {
276 hist_size = atoi(envHist);
277 envHist = strchr(envHist, ':');
278 if (envHist)
279 hist_save = atoi(envHist+1);
280 }
282 Gl_histinit((char *)logon);
283
284 // black on white or white on black?
285 static const char* defaultColorsBW[] = {
286 "bold blue", "magenta", "bold green", "bold red underlined", "default"
287 };
288 static const char* defaultColorsWB[] = {
289 "yellow", "magenta", "bold green", "bold red underlined", "default"
290 };
291
292 const char** defaultColors = defaultColorsBW;
293 TString revColor = gEnv->GetValue("Rint.ReverseColor", "no");
294 if (revColor.Contains("yes", TString::kIgnoreCase)) {
296 }
297 TString colorType = gEnv->GetValue("Rint.TypeColor", defaultColors[0]);
298 TString colorTabCom = gEnv->GetValue("Rint.TabComColor", defaultColors[1]);
299 TString colorBracket = gEnv->GetValue("Rint.BracketColor", defaultColors[2]);
300 TString colorBadBracket = gEnv->GetValue("Rint.BadBracketColor", defaultColors[3]);
301 TString colorPrompt = gEnv->GetValue("Rint.PromptColor", defaultColors[4]);
303
305
307
308 // Setup for tab completion
309 gTabCom = new TTabCom;
312
313 // tell Cling to use our getline
315}
316
317////////////////////////////////////////////////////////////////////////////////
318/// Destructor.
319
321{
322 delete gTabCom;
323 gTabCom = nullptr;
324 Gl_in_key = nullptr;
325 Gl_beep_hook = nullptr;
327 delete fInputHandler;
328 // We can't know where the signal handler was changed since we started ...
329 // so for now let's not delete it.
330// TSignalHandler *ih = GetSignalHandler();
331// ih->Remove();
332// SetSignalHandler(0);
333// delete ih;
334}
335
336////////////////////////////////////////////////////////////////////////////////
337/// Execute logon macro's. There are three levels of logon macros that
338/// will be executed: the system logon etc/system.rootlogon.C, the global
339/// user logon ~/.rootlogon.C and the local ./.rootlogon.C. For backward
340/// compatibility also the logon macro as specified by the Rint.Logon
341/// environment setting, by default ./rootlogon.C, will be executed.
342/// No logon macros will be executed when the system is started with
343/// the -n option.
344
346{
347 if (NoLogOpt()) return;
348
349 TString name = ".rootlogon.C";
350 TString sname = "system";
351 sname += name;
354 ProcessFile(s);
355 }
356 delete [] s;
359 ProcessFile(s);
360 }
361 delete [] s;
362 // avoid executing ~/.rootlogon.C twice
366 }
367
368 // execute also the logon macro specified by "Rint.Logon"
369 const char *logon = gEnv->GetValue("Rint.Logon", (char*)nullptr);
370 if (logon) {
372 if (mac)
374 delete [] mac;
375 }
376}
377
378////////////////////////////////////////////////////////////////////////////////
379/// Main application eventloop. First process files given on the command
380/// line and then go into the main application event loop, unless the -q
381/// command line option was specified in which case the program terminates.
382/// When return is true this method returns even when -q was specified.
383///
384/// When QuitOpt is true and return is false, terminate the application with
385/// an error code equal to either the ProcessLine error (if any) or the
386/// return value of the command casted to a long.
387
389{
390 if (!QuitOpt()) {
391 // Prompt prompt only if we are expecting / allowing input.
392 Getlinem(kInit, GetPrompt());
393 }
394
395 Longptr_t retval = 0;
396 Int_t error = 0;
397 volatile Bool_t needGetlinemInit = kFALSE;
398
399 if (strlen(WorkingDirectory())) {
400 // if directory specified as argument make it the working directory
403 TObject *w = gROOT->GetListOfBrowsables()->FindObject("workdir");
404 TObjLink *lnk = gROOT->GetListOfBrowsables()->FirstLink();
405 while (lnk) {
406 if (lnk->GetObject() == w) {
407 lnk->SetObject(workdir);
408 lnk->SetOption(gSystem->WorkingDirectory());
409 break;
410 }
411 lnk = lnk->Next();
412 }
413 delete w;
414 }
415
416 // Process shell command line input files
417 if (InputFiles()) {
418 // Make sure that calls into the event loop
419 // ignore end-of-file on the terminal.
421 TIter next(InputFiles());
422 RETRY {
423 retval = 0; error = 0;
424 Int_t nfile = 0;
425 while (TObject *fileObj = next()) {
426 if (dynamic_cast<TNamed*>(fileObj)) {
427 // A file that TApplication did not find. Note the error.
428 retval = 1;
429 continue;
430 }
431 TObjString *file = (TObjString *)fileObj;
432 char cmd[kMAXPATHLEN+50];
433 if (!fNcmd)
434 printf("\n");
436
437 if (file->TestBit(kExpression)) {
438 snprintf(cmd, kMAXPATHLEN+50, "%s", (const char*)file->String());
439 } else {
440 if (file->String().EndsWith(".root") || file->String().BeginsWith("file:")) {
441 rootfile = kTRUE;
442 } else {
443 rootfile = gROOT->IsRootFile(file->String());
444 }
445 if (rootfile) {
446 // special trick to be able to open files using UNC path names
447 if (file->String().BeginsWith("\\\\"))
448 file->String().Prepend("\\\\");
449 file->String().ReplaceAll("\\","/");
450 const char *rfile = (const char*)file->String();
451 Printf("Attaching file %s as _file%d...", rfile, nfile);
452 snprintf(cmd, kMAXPATHLEN+50, "TFile *_file%d = TFile::Open(\"%s\")", nfile++, rfile);
453 } else {
454 Printf("Processing %s...", (const char*)file->String());
455 snprintf(cmd, kMAXPATHLEN+50, ".x %s", (const char*)file->String());
456 }
457 }
458 Getlinem(kCleanUp, nullptr);
460
461 // The ProcessLine might throw an 'exception'. In this case,
462 // GetLinem(kInit,"Root >") is called and we are jump back
463 // to RETRY ... and we have to avoid the Getlinem(kInit, GetPrompt());
465 retval = ProcessLineNr("ROOT_cli_", cmd, &error);
467 fNcmd++;
468
469 // The ProcessLine has successfully completed and we need
470 // to call Getlinem(kInit, GetPrompt());
472
473 if (error != 0 || fCaughtSignal != -1) break;
474 }
475 } ENDTRY;
476
477 if (QuitOpt()) {
478 if (retrn) return;
479 if (error) {
480 retval = error;
481 } else if (fCaughtSignal != -1) {
482 retval = fCaughtSignal + 128;
483 }
484 // Bring retval into sensible range, 0..255.
486 retval = 255;
488 }
489
490 // Allow end-of-file on the terminal to be noticed
491 // after we finish processing the command line input files.
493
495
496 if (needGetlinemInit) Getlinem(kInit, GetPrompt());
497 }
498
499 if (QuitOpt()) {
500 if (retrn) return;
501 Terminate(fCaughtSignal != -1 ? fCaughtSignal + 128 : 0);
502 }
503
505
506 // Reset to happiness.
507 fCaughtSignal = -1;
508
509 Getlinem(kCleanUp, nullptr);
510}
511
512////////////////////////////////////////////////////////////////////////////////
513/// Print the ROOT logo on standard output.
514
516{
517 if (!lite) {
518 // Fancy formatting: the content of lines are format strings; their %s is
519 // replaced by spaces needed to make all lines as long as the longest line.
520 std::vector<TString> lines;
521 // Here, %%s results in %s after TString::Format():
522 lines.emplace_back(TString::Format("Welcome to ROOT %s%%shttps://root.cern",
523 gROOT->GetVersion()));
524 lines.emplace_back(TString::Format("(c) 1995-2025, The ROOT Team; conception: R. Brun, F. Rademakers%%s"));
525 lines.emplace_back(TString::Format("Built for %s on %s%%s", gSystem->GetBuildArch(), gROOT->GetGitDate()));
526 if (!strcmp(gROOT->GetGitBranch(), gROOT->GetGitCommit())) {
527 static const char *months[] = {"January","February","March","April","May",
528 "June","July","August","September","October",
529 "November","December"};
530 Int_t idatqq = gROOT->GetVersionDate();
531 Int_t iday = idatqq%100;
532 Int_t imonth = (idatqq/100)%100;
533 Int_t iyear = (idatqq/10000);
534
535 lines.emplace_back(TString::Format("From tag %s, %d %s %4d%%s",
536 gROOT->GetGitBranch(),
537 iday,months[imonth-1],iyear));
538 } else {
539 // If branch and commit are identical - e.g. "v5-34-18" - then we have
540 // a release build. Else specify the git hash this build was made from.
541 lines.emplace_back(TString::Format("From %s@%s %%s",
542 gROOT->GetGitBranch(),
543 gROOT->GetGitCommit()));
544 }
545 lines.emplace_back(TString::Format("With %s %%s",
547 lines.emplace_back(TString("Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'%s"));
548
549 // Find the longest line and its length:
550 auto itLongest = std::max_element(lines.begin(), lines.end(),
551 [](const TString& left, const TString& right) {
552 return left.Length() < right.Length(); });
553 Ssiz_t lenLongest = itLongest->Length();
554
555
556 Printf(" %s", TString('-', lenLongest).Data());
557 for (const auto& line: lines) {
558 // Print the line, expanded with the necessary spaces at %s, and
559 // surrounded by some ASCII art.
560 Printf(" | %s |",
561 TString::Format(line.Data(),
562 TString(' ', lenLongest - line.Length()).Data()).Data());
563 }
564 Printf(" %s\n", TString('-', lenLongest).Data());
565 }
566}
567
568////////////////////////////////////////////////////////////////////////////////
569/// Get prompt from interpreter. Either "root [n]" or "end with '}'".
570
572{
573 char *s = gCling->GetPrompt();
574 if (s[0])
575 strlcpy(fPrompt, s, sizeof(fPrompt));
576 else
578
579 return fPrompt;
580}
581
582////////////////////////////////////////////////////////////////////////////////
583/// Set a new default prompt. It returns the previous prompt.
584/// The prompt may contain a %d which will be replaced by the commend
585/// number. The default prompt is "root [%d] ". The maximum length of
586/// the prompt is 55 characters. To set the prompt in an interactive
587/// session do:
588/// root [0] ((TRint*)gROOT->GetApplication())->SetPrompt("aap> ")
589/// aap>
590
591const char *TRint::SetPrompt(const char *newPrompt)
592{
593 static TString op;
595
596 if (newPrompt && strlen(newPrompt) <= 55)
598 else
599 Error("SetPrompt", "newPrompt too long (> 55 characters)");
600
601 return op.Data();
602}
603
604////////////////////////////////////////////////////////////////////////////////
605/// Handle input coming from terminal.
606
608{
609 static TStopwatch timer;
610 const char *line;
611
612 if ((line = Getlinem(kOneChar, nullptr))) {
613 if (line[0] == 0 && Gl_eof())
614 Terminate(0);
615
616 gVirtualX->SetKeyAutoRepeat(kTRUE);
617
619
621
622 // strip off '\n' and leading and trailing blanks
623 sline = sline.Chop();
624 sline = sline.Strip(TString::kBoth);
625 ReturnPressed((char*)sline.Data());
626
628
629 // prevent recursive calling of this input handler
631
632 if (gROOT->Timer()) timer.Start();
633
635 added = kFALSE; // reset on each call.
636
637 // This is needed when working with remote sessions
639
640 try {
641 TRY {
642 if (!sline.IsNull())
644 ProcessLineNr("ROOT_prompt_", sline);
645 } CATCH(excode) {
646 // enable again input handler
648 added = kTRUE;
649 Throw(excode);
650 } ENDTRY;
651 }
652 // handle every exception
653 catch (std::exception& e) {
654 // enable again intput handler
656
657 int err;
659 const char* demangledType = demangledType_c;
660 if (err) {
661 demangledType_c = nullptr;
662 demangledType = "<UNKNOWN>";
663 }
664 Error("HandleTermInput()", "%s caught: %s", demangledType, e.what());
666 }
667 catch (...) {
668 // enable again intput handler
670 Error("HandleTermInput()", "Exception caught!");
671 }
672
673 // `ProcessLineNr()` only prepends a `#line` directive if the previous
674 // input line was not terminated by a '\' (backslash-newline).
675 // Thus, to match source locations included in cling diagnostics, we only
676 // increment `fNcmd` if the next call to `ProcessLineNr()` will issue
677 // a new `#line`.
678 if (!fBackslashContinue && !sline.IsNull())
679 fNcmd++;
680
681 if (gROOT->Timer()) timer.Print("u");
682
683 // enable again intput handler
685
686 if (!sline.BeginsWith(".reset"))
688
689 gTabCom->ClearAll();
690 Getlinem(kInit, GetPrompt());
691 }
692 return kTRUE;
693}
694
695////////////////////////////////////////////////////////////////////////////////
696/// Handle signals (kSigBus, kSigSegmentationViolation,
697/// kSigIllegalInstruction and kSigFloatingException) trapped in TSystem.
698/// Specific TApplication implementations may want something different here.
699
701{
702 fCaughtSignal = sig;
703 if (TROOT::Initialized()) {
704 if (gException) {
705 Getlinem(kCleanUp, nullptr);
706 Getlinem(kInit, "Root > ");
707 }
708 }
710}
711
712////////////////////////////////////////////////////////////////////////////////
713/// Terminate the application. Reset the terminal to sane mode and call
714/// the logoff macro defined via Rint.Logoff environment variable.
715/// @note The function does not return, unless the class has
716/// been told to return from Run(), by a call to SetReturnFromRun().
717
719{
720 Getlinem(kCleanUp, nullptr);
721
722 if (ReturnFromRun()) {
723 gSystem->ExitLoop();
724 } else {
725 delete gTabCom;
726 gTabCom = nullptr;
727
728 //Execute logoff macro
729 const char *logoff;
730 logoff = gEnv->GetValue("Rint.Logoff", (char*)nullptr);
731 if (logoff && !NoLogOpt()) {
733 if (mac)
735 delete [] mac;
736 }
737
739 }
740}
741
742////////////////////////////////////////////////////////////////////////////////
743/// Set console mode:
744///
745/// mode = kTRUE - echo input symbols
746/// mode = kFALSE - noecho input symbols
747
749{
750 Gl_config("noecho", mode ? 0 : 1);
751}
752
753////////////////////////////////////////////////////////////////////////////////
754/// Process the content of a line starting with ".R" (already stripped-off)
755/// The format is
756/// [user@]host[:dir] [-l user] [-d dbg] [script]
757/// The variable 'dir' is the remote directory to be used as working dir.
758/// The username can be specified in two ways, "-l" having the priority
759/// (as in ssh).
760/// A 'dbg' value > 0 gives increasing verbosity.
761/// The last argument 'script' allows to specify an alternative script to
762/// be executed remotely to startup the session.
763
765{
767
768 if (ret == 1) {
769 if (fAppRemote) {
770 TString prompt; prompt.Form("%s:root [%%d] ", fAppRemote->ApplicationName());
772 } else {
773 SetPrompt("root [%d] ");
774 }
775 }
776
777 return ret;
778}
779
780
781////////////////////////////////////////////////////////////////////////////////
782/// Calls TRint::ProcessLine() possibly prepending a `#line` directive for
783/// better diagnostics.
784/// The user is responsible for incrementing `fNcmd`, where appropriate, after
785/// a call to this function.
786
787Longptr_t TRint::ProcessLineNr(const char* filestem, const char *line, Int_t *error /*= 0*/)
788{
789 Int_t err;
790 if (!error)
791 error = &err;
792 if (line && line[0] != '.') {
795 input += TString::Format("#line 1 \"%s%d\"\n", filestem, fNcmd);
796 input += line;
797 int res = ProcessLine(input, kFALSE, error);
798 if (gCling->GetMore()) {
801 SetPrompt("root (cont'ed, cancel with .@) [%d]");
802 } else if (fNonContinuePrompt.Length()) {
805 }
806 std::string_view sv(line);
807 auto lastNonSpace = sv.find_last_not_of(" \t");
808 fBackslashContinue = (lastNonSpace != std::string_view::npos
809 && sv[lastNonSpace] == '\\');
810 return res;
811 }
812 if (line && line[0] == '.' && line[1] == '@') {
813 ProcessLine(line, kFALSE, error);
814 SetPrompt("root [%d] ");
815 }
816 return ProcessLine(line, kFALSE, error);
817}
818
819
820////////////////////////////////////////////////////////////////////////////////
821/// Forward tab completion request to our TTabCom::Hook().
822
823Int_t TRint::TabCompletionHook(char *buf, int *pLoc, std::ostream& out)
824{
825 if (gTabCom)
826 return gTabCom->Hook(buf, pLoc, out);
827
828 return -1;
829}
#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
@ 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:2495
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2509
@ 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:490
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:864
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1071
static const char * GetMacroPath()
Get macro search path. Static utility function.
Definition TROOT.cxx:2764
static Bool_t Initialized()
Return kTRUE if the TROOT object has been initialized.
Definition TROOT.cxx:2913
static const std::vector< std::string > & AddExtraInterpreterArgs(const std::vector< std::string > &args)
Provide command line arguments to the interpreter construction.
Definition TROOT.cxx:2959
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
Definition TROOT.cxx:3107
Definition TRint.h:31
void SetEchoMode(Bool_t mode) override
Set console mode:
Definition TRint.cxx:748
Bool_t HandleTermInput() override
Handle input coming from terminal.
Definition TRint.cxx:607
Bool_t fInterrupt
Definition TRint.h:38
void Run(Bool_t retrn=kFALSE) override
Main application eventloop.
Definition TRint.cxx:388
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:787
virtual const char * SetPrompt(const char *newPrompt)
Set a new default prompt.
Definition TRint.cxx:591
virtual void Terminate(int status) override
Terminate the application.
Definition TRint.cxx:718
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:823
virtual char * GetPrompt()
Get prompt from interpreter. Either "root [n]" or "end with '}'".
Definition TRint.cxx:571
void HandleException(Int_t sig) override
Handle signals (kSigBus, kSigSegmentationViolation, kSigIllegalInstruction and kSigFloatingException)...
Definition TRint.cxx:700
virtual ~TRint()
Destructor.
Definition TRint.cxx:320
virtual void PrintLogo(Bool_t lite=kFALSE)
Print the ROOT logo on standard output.
Definition TRint.cxx:515
void ExecLogon()
Execute logon macro's.
Definition TRint.cxx:345
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:764
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:2250
void Clear()
Clear string without changing its capacity.
Definition TString.cxx:1241
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:2384
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:322
virtual const char * Getenv(const char *env)
Get environment variable.
Definition TSystem.cxx:1676
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name.
Definition TSystem.cxx:1082
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition TSystem.cxx:1868
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:1307
virtual void ExitLoop()
Exit from event loop.
Definition TSystem.cxx:390
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
Definition TSystem.cxx:872
virtual const char * GetBuildCompilerVersionStr() const
Return the build compiler version identifier string.
Definition TSystem.cxx:3923
virtual const char * WorkingDirectory()
Return working directory.
Definition TSystem.cxx:881
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
Definition TSystem.cxx:1559
virtual const char * GetBuildArch() const
Return the build architecture.
Definition TSystem.cxx:3899
virtual const char * HomeDirectory(const char *userName=nullptr)
Return the user's home directory.
Definition TSystem.cxx:897
Int_t Hook(char *buf, int *pLoc, std::ostream &out)
[private]
Definition TTabCom.cxx:1572
void ClearAll()
clears all lists except for user names and system include files.
Definition TTabCom.cxx:318
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.