76 Getlinem(kCleanUp, 0);
103 Break(
"TInterruptHandler::Notify",
"keyboard interrupt");
104 Getlinem(kInit,
"Root > ");
141static int SetExtraClingArgsBeforeTAppCtor(
Int_t *argc,
char **argv)
143 bool forcePtrCheck =
false;
144 if (argc !=
nullptr) {
145 for (
int iarg = 1; iarg < *argc; ++iarg) {
146 if (!strcmp(argv[iarg],
"--ptrcheck")) {
148 for (
int jarg = iarg + 1; jarg < *argc; ++jarg)
149 argv[jarg - 1] = argv[jarg];
152 forcePtrCheck =
true;
158 if (forcePtrCheck || isatty(0) || isatty(1))
173 :
TApplication(appClassName, argc, argv, options, numOptions + SetExtraClingArgsBeforeTAppCtor(argc, argv)),
177 if (exitOnUnknownArgs && argc !=
nullptr && *argc > 1) {
180 for (
auto n = 1;
n < *argc;
n++) {
181 std::cerr <<
"root: unrecognized option '" << argv[
n] <<
"'\n";
183 std::cerr <<
"Try 'root --help' for more information.\n";
219 code =
"#include <iostream>\n"
220 "#include <string>\n"
221 "#include <DllImport.h>\n";
223 code +=
"#include <vector>\n"
224 "#include <utility>";
264 int hist_size =
gEnv->
GetValue(
"Rint.HistorySize", 500);
265 if (hist_size == 500)
267 int hist_save =
gEnv->
GetValue(
"Rint.HistorySave", 400);
268 if (hist_save == 400)
272 hist_size = atoi(envHist);
273 envHist = strchr(envHist,
':');
275 hist_save = atoi(envHist+1);
277 Gl_histsize(hist_size, hist_save);
278 Gl_histinit((
char *)logon);
281 static const char* defaultColorsBW[] = {
282 "bold blue",
"magenta",
"bold green",
"bold red underlined",
"default"
284 static const char* defaultColorsWB[] = {
285 "yellow",
"magenta",
"bold green",
"bold red underlined",
"default"
288 const char** defaultColors = defaultColorsBW;
291 defaultColors = defaultColorsWB;
298 Gl_setColors(colorType, colorTabCom, colorBracket, colorBadBracket, colorPrompt);
365 const char *logon =
gEnv->
GetValue(
"Rint.Logon", (
char*)0);
419 retval = 0; error = 0;
421 while (
TObject *fileObj = next()) {
422 if (
dynamic_cast<TNamed*
>(fileObj)) {
436 if (
file->String().EndsWith(
".root") ||
file->String().BeginsWith(
"file:")) {
439 rootfile =
gROOT->IsRootFile(
file->String());
443 if (
file->String().BeginsWith(
"\\\\"))
444 file->String().Prepend(
"\\\\");
445 file->String().ReplaceAll(
"\\",
"/");
446 const char *rfile = (
const char*)
file->String();
447 Printf(
"Attaching file %s as _file%d...", rfile, nfile);
450 Printf(
"Processing %s...", (
const char*)
file->String());
454 Getlinem(kCleanUp, 0);
460 needGetlinemInit =
kFALSE;
467 needGetlinemInit =
kTRUE;
481 if (retval < 0 || retval > 255)
492 if (needGetlinemInit) Getlinem(kInit,
GetPrompt());
506 Getlinem(kCleanUp, 0);
517 std::vector<TString> lines;
519 lines.emplace_back(
TString::Format(
"Welcome to ROOT %s%%shttps://root.cern",
520 gROOT->GetVersion()));
521 lines.emplace_back(
TString::Format(
"(c) 1995-2024, The ROOT Team; conception: R. Brun, F. Rademakers%%s"));
523 if (!strcmp(
gROOT->GetGitBranch(),
gROOT->GetGitCommit())) {
524 static const char *months[] = {
"January",
"February",
"March",
"April",
"May",
525 "June",
"July",
"August",
"September",
"October",
526 "November",
"December"};
528 Int_t iday = idatqq%100;
529 Int_t imonth = (idatqq/100)%100;
530 Int_t iyear = (idatqq/10000);
533 gROOT->GetGitBranch(),
534 iday,months[imonth-1],iyear));
539 gROOT->GetGitBranch(),
540 gROOT->GetGitCommit()));
544 lines.emplace_back(
TString(
"Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'%s"));
547 auto itLongest = std::max_element(lines.begin(), lines.end(),
549 return left.Length() < right.Length(); });
550 Ssiz_t lenLongest = itLongest->Length();
554 for (
const auto&
line: lines) {
566 for (
int i = 0; i <
Argc(); i++)
567 if (!strcmp(
Argv(i),
"-splash"))
568 kill(getppid(), SIGUSR1);
600 if (newPrompt && strlen(newPrompt) <= 55)
603 Error(
"SetPrompt",
"newPrompt too long (> 55 characters)");
616 if ((
line = Getlinem(kOneChar, 0))) {
617 if (
line[0] == 0 && Gl_eof())
627 sline = sline.
Chop();
638 TTHREAD_TLS(
Bool_t) added;
657 catch (std::exception&
e) {
663 const char* demangledType = demangledType_c;
665 demangledType_c =
nullptr;
666 demangledType =
"<UNKNOWN>";
668 Error(
"HandleTermInput()",
"%s caught: %s", demangledType,
e.what());
669 free(demangledType_c);
674 Error(
"HandleTermInput()",
"Exception caught!");
709 Getlinem(kCleanUp, 0);
710 Getlinem(kInit,
"Root > ");
724 Getlinem(kCleanUp, 0);
754 Gl_config(
"noecho",
mode ? 0 : 1);
805 SetPrompt(
"root (cont'ed, cancel with .@) [%d]");
810 std::string_view sv(
line);
811 auto lastNonSpace = sv.find_last_not_of(
" \t");
813 && sv[lastNonSpace] ==
'\\');
R__EXTERN TApplication * gApplication
R__EXTERN TBenchmark * gBenchmark
R__EXTERN TClassTable * 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.
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
R__EXTERN TInterpreter * 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.
R__EXTERN TSystem * gSystem
R__EXTERN TTabCom * gTabCom
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.
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.
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.
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 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.
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.
Mother of all ROOT objects.
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
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.
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[:di...
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.
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
void Clear()
Clear string without changing its capacity.
const char * Data() const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
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
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.
virtual const char * Getenv(const char *env)
Get environment variable.
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name. User must delete returned string.
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
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 ExitLoop()
Exit from event loop.
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
virtual const char * GetBuildCompilerVersionStr() const
Return the build compiler version identifier string.
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 const char * GetBuildArch() const
Return the build architecture.
virtual const char * HomeDirectory(const char *userName=nullptr)
Return the user's home directory.
Int_t Hook(char *buf, int *pLoc, std::ostream &out)
[private]
void ClearAll()
clears all lists except for user names and system include files.
R__EXTERN void * gMmallocDesc
char * DemangleTypeIdName(const std::type_info &ti, int &errorCode)
Demangle in a portable way the type id name.