76 Getlinem(kCleanUp,
nullptr);
103 Break(
"TInterruptHandler::Notify",
"keyboard interrupt");
104 Getlinem(kInit,
"Root > ");
140static int SetExtraClingArgsBeforeTAppCtor(
Int_t *argc,
char **argv)
142 bool forcePtrCheck =
false;
143 if (argc !=
nullptr) {
144 for (
int iarg = 1; iarg < *argc; ++iarg) {
145 if (!strcmp(argv[iarg],
"--ptrcheck")) {
147 for (
int jarg = iarg + 1; jarg < *argc; ++jarg)
148 argv[jarg - 1] = argv[jarg];
151 forcePtrCheck =
true;
157 if (forcePtrCheck || isatty(0) || isatty(1))
172 :
TApplication(appClassName, argc, argv, options, numOptions + SetExtraClingArgsBeforeTAppCtor(argc, argv)),
176 if (exitOnUnknownArgs && argc !=
nullptr && *argc > 1) {
179 for (
auto n = 1;
n < *argc;
n++) {
180 std::cerr <<
"root: unrecognized option '" << argv[
n] <<
"'\n";
182 std::cerr <<
"Try 'root --help' for more information.\n";
197#ifndef R__USE_CXXMODULES
210 Int_t includes =
gEnv->GetValue(
"Rint.Includes", 1);
223 code =
"#include <iostream>\n"
224 "#include <string>\n"
225 "#include <DllImport.h>\n";
227 code +=
"#include <vector>\n"
228 "#include <utility>";
236 logon =
gEnv->GetValue(
"Rint.Load", (
char*)
nullptr);
249 gCling->SaveGlobalsContext();
262 snprintf(defhist,
sizeof(defhist),
"%s/.root_hist",
gSystem->HomeDirectory());
263 logon =
gEnv->GetValue(
"Rint.History", defhist);
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");
276 hist_size = atoi(envHist);
277 envHist = strchr(envHist,
':');
279 hist_save = atoi(envHist+1);
281 Gl_histsize(hist_size, hist_save);
282 Gl_histinit((
char *)logon);
285 static const char* defaultColorsBW[] = {
286 "bold blue",
"magenta",
"bold green",
"bold red underlined",
"default"
288 static const char* defaultColorsWB[] = {
289 "yellow",
"magenta",
"bold green",
"bold red underlined",
"default"
292 const char** defaultColors = defaultColorsBW;
293 TString revColor =
gEnv->GetValue(
"Rint.ReverseColor",
"no");
295 defaultColors = defaultColorsWB;
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]);
302 Gl_setColors(colorType, colorTabCom, colorBracket, colorBadBracket, colorPrompt);
314 gCling->SetGetline(Getline, Gl_histadd);
325 Gl_beep_hook =
nullptr;
358 const char *
s1 =
gSystem->PrependPathName(
gSystem->HomeDirectory(), temp_name);
363 if (strcmp(
gSystem->HomeDirectory(),
gSystem->WorkingDirectory())) {
369 const char *logon =
gEnv->GetValue(
"Rint.Logon", (
char*)
nullptr);
403 TObject *w =
gROOT->GetListOfBrowsables()->FindObject(
"workdir");
423 retval = 0; error = 0;
425 while (
TObject *fileObj = next()) {
426 if (
dynamic_cast<TNamed*
>(fileObj)) {
453 const char *rfile = (
const char*)file->
String();
454 Printf(
"Attaching file %s as _file%d...", rfile, nfile);
457 Printf(
"Processing %s...", (
const char*)file->
String());
461 Getlinem(kCleanUp,
nullptr);
467 needGetlinemInit =
kFALSE;
469 gCling->EndOfLineAction();
474 needGetlinemInit =
kTRUE;
488 if (retval < 0 || retval > 255)
499 if (needGetlinemInit) Getlinem(kInit,
GetPrompt());
512 Getlinem(kCleanUp,
nullptr);
523 std::vector<TString> lines;
525 lines.emplace_back(
TString::Format(
"Welcome to ROOT %s%%shttps://root.cern",
526 gROOT->GetVersion()));
527 lines.emplace_back(
TString::Format(
"(c) 1995-2025, The ROOT Team; conception: R. Brun, F. Rademakers%%s"));
529 if (!strcmp(
gROOT->GetGitBranch(),
gROOT->GetGitCommit())) {
530 static const char *months[] = {
"January",
"February",
"March",
"April",
"May",
531 "June",
"July",
"August",
"September",
"October",
532 "November",
"December"};
534 Int_t iday = idatqq%100;
535 Int_t imonth = (idatqq/100)%100;
536 Int_t iyear = (idatqq/10000);
539 gROOT->GetGitBranch(),
540 iday,months[imonth-1],iyear));
545 gROOT->GetGitBranch(),
546 gROOT->GetGitCommit()));
549 gSystem->GetBuildCompilerVersionStr(), __cplusplus));
550 lines.emplace_back(
TString(
"Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'%s"));
553 auto itLongest = std::max_element(lines.begin(), lines.end(),
555 return left.Length() < right.Length(); });
556 Ssiz_t lenLongest = itLongest->Length();
560 for (
const auto&
line: lines) {
576 char *s =
gCling->GetPrompt();
599 if (newPrompt && strlen(newPrompt) <= 55)
602 Error(
"SetPrompt",
"newPrompt too long (> 55 characters)");
615 if ((
line = Getlinem(kOneChar,
nullptr))) {
616 if (
line[0] == 0 && Gl_eof())
626 sline = sline.
Chop();
637 TTHREAD_TLS(
Bool_t) added;
656 catch (std::exception&
e) {
662 const char* demangledType = demangledType_c;
664 demangledType_c =
nullptr;
665 demangledType =
"<UNKNOWN>";
667 Error(
"HandleTermInput()",
"%s caught: %s", demangledType,
e.what());
668 free(demangledType_c);
673 Error(
"HandleTermInput()",
"Exception caught!");
690 gCling->EndOfLineAction();
708 Getlinem(kCleanUp,
nullptr);
709 Getlinem(kInit,
"Root > ");
723 Getlinem(kCleanUp,
nullptr);
733 logoff =
gEnv->GetValue(
"Rint.Logoff", (
char*)
nullptr);
753 Gl_config(
"noecho", mode ? 0 : 1);
804 SetPrompt(
"root (cont'ed, cancel with .@) [%d]");
809 std::string_view sv(
line);
810 auto lastNonSpace = sv.find_last_not_of(
" \t");
812 && sv[lastNonSpace] ==
'\\');
829 return gTabCom->Hook(buf, pLoc, out);
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).
bool Bool_t
Boolean (0=false, 1=true) (bool).
externTApplication * gApplication
externTBenchmark * gBenchmark
externTClassTable * gClassTable
void Break(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.
externTInterpreter * gCling
static void ResetTermAtExit()
Restore terminal to non-raw mode.
static Int_t Key_Pressed(Int_t key)
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
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 "....
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.
TApplication(const TApplication &)=delete
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 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.
const char * WorkingDirectory() 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.
Bool_t Notify() override
TRint interrupt handler.
The TNamed class is the base class for all named ROOT classes.
Wrapper around a TObject so it can be stored in a TList.
virtual void SetOption(Option_t *)
void SetObject(TObject *obj)
TObject * GetObject() const
Collectable string class.
Bool_t TestBit(UInt_t f) const
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.
TObject()
TObject constructor.
static const char * GetMacroPath()
Get macro search path. Static utility function.
static Bool_t Initialized()
Return kTRUE if the TROOT object has been initialized.
static const std::vector< std::string > & AddExtraInterpreterArgs(const std::vector< std::string > &args)
Provide command line arguments to the interpreter construction.
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
void SetEchoMode(Bool_t mode) override
Set console mode:
Bool_t HandleTermInput() override
Handle input coming from terminal.
void Run(Bool_t retrn=kFALSE) override
Main application eventloop.
Longptr_t ProcessLineNr(const char *filestem, const char *line, Int_t *error=nullptr)
Calls TRint::ProcessLine() possibly prepending a #line directive for better diagnostics.
virtual const char * SetPrompt(const char *newPrompt)
Set a new default prompt.
virtual void Terminate(int status) override
Terminate the application.
Int_t TabCompletionHook(char *buf, int *pLoc, std::ostream &out) override
Forward tab completion request to our TTabCom::Hook().
virtual char * GetPrompt()
Get prompt from interpreter. Either "root [n]" or "end with '}'".
void HandleException(Int_t sig) override
Handle signals (kSigBus, kSigSegmentationViolation, kSigIllegalInstruction and kSigFloatingException)...
virtual ~TRint()
Destructor.
virtual void PrintLogo(Bool_t lite=kFALSE)
Print the ROOT logo on standard output.
void ExecLogon()
Execute logon macro's.
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[:dir...
Bool_t fBackslashContinue
TString fNonContinuePrompt
TRint(const TRint &)=delete
TFileHandler * fInputHandler
void Add() override
Add signal handler to system signal handler list.
ESignals GetSignal() const
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void Print(Option_t *option="") const override
Print the real and cpu time passed between the start and stop events.
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.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
TString & Prepend(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
Describes an Operating System directory for the browser.
externvoid * gMmallocDesc
char * DemangleTypeIdName(const std::type_info &ti, int &errorCode)
Demangle in a portable way the type id name.