74 Getlinem(kCleanUp, 0);
90Bool_t TInterruptHandler::Notify()
101 Break(
"TInterruptHandler::Notify",
"keyboard interrupt");
102 Getlinem(kInit,
"Root > ");
129Bool_t TTermInputHandler::Notify()
145 TApplication(appClassName, argc, argv, options, numOptions),
180 code =
"#include <iostream>\n"
181 "#include <string>\n"
182 "#include <DllImport.h>\n";
184 code +=
"#include <vector>\n"
185 "#include <utility>";
209 TInterruptHandler *ih =
new TInterruptHandler();
225 int hist_size =
gEnv->
GetValue(
"Rint.HistorySize", 500);
226 if (hist_size == 500)
228 int hist_save =
gEnv->
GetValue(
"Rint.HistorySave", 400);
229 if (hist_save == 400)
233 hist_size = atoi(envHist);
234 envHist = strchr(envHist,
':');
236 hist_save = atoi(envHist+1);
238 Gl_histsize(hist_size, hist_save);
239 Gl_histinit((
char *)logon);
242 static const char* defaultColorsBW[] = {
243 "bold blue",
"magenta",
"bold green",
"bold red underlined",
"default"
245 static const char* defaultColorsWB[] = {
246 "yellow",
"magenta",
"bold green",
"bold red underlined",
"default"
249 const char** defaultColors = defaultColorsBW;
252 defaultColors = defaultColorsWB;
259 Gl_setColors(colorType, colorTabCom, colorBracket, colorBadBracket, colorPrompt);
326 const char *logon =
gEnv->
GetValue(
"Rint.Logon", (
char*)0);
360 TObject *w =
gROOT->GetListOfBrowsables()->FindObject(
"workdir");
380 retval = 0; error = 0;
382 while (
TObject *fileObj = next()) {
383 if (
dynamic_cast<TNamed*
>(fileObj)) {
397 if (
file->String().EndsWith(
".root") ||
file->String().BeginsWith(
"file:")) {
400 rootfile =
gROOT->IsRootFile(
file->String());
404 if (
file->String().BeginsWith(
"\\\\"))
405 file->String().Prepend(
"\\\\");
406 file->String().ReplaceAll(
"\\",
"/");
407 const char *rfile = (
const char*)
file->String();
408 Printf(
"Attaching file %s as _file%d...", rfile, nfile);
411 Printf(
"Processing %s...", (
const char*)
file->String());
415 Getlinem(kCleanUp, 0);
422 needGetlinemInit =
kFALSE;
428 needGetlinemInit =
kTRUE;
442 if (retval < 0 || retval > 255)
453 if (needGetlinemInit) Getlinem(kInit,
GetPrompt());
467 Getlinem(kCleanUp, 0);
478 std::vector<TString> lines;
480 lines.emplace_back(
TString::Format(
"Welcome to ROOT %s%%shttps://root.cern",
481 gROOT->GetVersion()));
482 lines.emplace_back(
TString::Format(
"(c) 1995-2020, The ROOT Team; conception: R. Brun, F. Rademakers%%s"));
484 if (!strcmp(
gROOT->GetGitBranch(),
gROOT->GetGitCommit())) {
485 static const char *months[] = {
"January",
"February",
"March",
"April",
"May",
486 "June",
"July",
"August",
"September",
"October",
487 "November",
"December"};
489 Int_t iday = idatqq%100;
490 Int_t imonth = (idatqq/100)%100;
491 Int_t iyear = (idatqq/10000);
494 gROOT->GetGitBranch(),
495 iday,months[imonth-1],iyear));
500 gROOT->GetGitBranch(),
501 gROOT->GetGitCommit()));
503 lines.emplace_back(
TString(
"Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'%s"));
506 auto itLongest = std::max_element(lines.begin(), lines.end(),
508 return left.Length() < right.Length(); });
509 Ssiz_t lenLongest = itLongest->Length();
513 for (
const auto&
line: lines) {
525 for (
int i = 0; i <
Argc(); i++)
526 if (!strcmp(
Argv(i),
"-splash"))
527 kill(getppid(), SIGUSR1);
559 if (newPrompt && strlen(newPrompt) <= 55)
562 Error(
"SetPrompt",
"newPrompt too long (> 55 characters)");
575 if ((
line = Getlinem(kOneChar, 0))) {
576 if (
line[0] == 0 && Gl_eof())
586 sline = sline.
Chop();
599 TTHREAD_TLS(
Bool_t) added;
618 catch (std::exception&
e) {
624 const char* demangledType = demangledType_c;
626 demangledType_c =
nullptr;
627 demangledType =
"<UNKNOWN>";
629 Error(
"HandleTermInput()",
"%s caught: %s", demangledType,
e.what());
630 free(demangledType_c);
635 Error(
"HandleTermInput()",
"Exception caught!");
662 Getlinem(kCleanUp, 0);
663 Getlinem(kInit,
"Root > ");
675 Getlinem(kCleanUp, 0);
705 Gl_config(
"noecho", mode ? 0 : 1);
752 SetPrompt(
"root (cont'ed, cancel with .@) [%d]");
R__EXTERN TApplication * gApplication
R__EXTERN TBenchmark * gBenchmark
R__EXTERN TClassTable * gClassTable
void Break(const char *location, const char *msgfmt,...)
void Throw(int code)
If an exception context has been set (using the TRY and RETRY macros) jump back to where it was set.
R__EXTERN ExceptionContext_t * gException
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,...)
void Printf(const char *fmt,...)
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 Bool_t HandleTermInput()
virtual Long_t ProcessRemote(const char *line, Int_t *error=0)
Process the content of a line starting with ".R" (already stripped-off) The format is.
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 void ReturnPressed(char *text)
Emit signal when return key was pressed.
virtual Long_t ProcessLine(const char *line, Bool_t sync=kFALSE, Int_t *error=0)
Process a single command line, either a C++ statement or an interpreter command starting with a "....
const char * WorkingDirectory() const
virtual Long_t ProcessFile(const char *file, Int_t *error=0, Bool_t keep=kFALSE)
Process a file containing a C++ macro.
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.
virtual Bool_t Notify()
Notify when event occurred on descriptor associated with this handler.
virtual void Remove()
Remove file event handler from system file handler list.
virtual Bool_t ReadNotify()
Notify when something can be read from the descriptor associated with this handler.
virtual void Add()
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
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.
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 TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
virtual void HandleException(Int_t sig)
Handle signals (kSigBus, kSigSegmentationViolation, kSigIllegalInstruction and kSigFloatingException)...
virtual void Run(Bool_t retrn=kFALSE)
Main application eventloop.
virtual void Terminate(int status)
Terminate the application.
virtual const char * SetPrompt(const char *newPrompt)
Set a new default prompt.
Long_t ProcessRemote(const char *line, Int_t *error=0)
Process the content of a line starting with ".R" (already stripped-off) The format is [user@]host[:di...
Long_t ProcessLineNr(const char *filestem, const char *line, Int_t *error=0)
Calls ProcessLine() possibly prepending a line directive for better diagnostics.
virtual char * GetPrompt()
Get prompt from interpreter. Either "root [n]" or "end with '}'".
virtual ~TRint()
Destructor.
virtual void PrintLogo(Bool_t lite=kFALSE)
Print the ROOT logo on standard output.
void ExecLogon()
Execute logon macro's.
virtual void SetEchoMode(Bool_t mode)
Set console mode:
virtual Int_t TabCompletionHook(char *buf, int *pLoc, std::ostream &out)
Forward tab completion request to our TTabCom::Hook().
TString fNonContinuePrompt
virtual Bool_t HandleTermInput()
Handle input coming from terminal.
TFileHandler * fInputHandler
virtual Bool_t Notify()
Notify when signal occurs.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void Print(Option_t *option="") const
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 const char * HomeDirectory(const char *userName=0)
Return the user's home directory.
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 * 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.
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.
static constexpr double s