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),
179 code =
"#include <iostream>\n"
180 "#include <string>\n"
181 "#include <DllImport.h>\n";
183 code +=
"#include <vector>\n"
184 "#include <utility>";
207 TInterruptHandler *ih =
new TInterruptHandler();
223 int hist_size =
gEnv->
GetValue(
"Rint.HistorySize", 500);
224 if (hist_size == 500)
226 int hist_save =
gEnv->
GetValue(
"Rint.HistorySave", 400);
227 if (hist_save == 400)
231 hist_size = atoi(envHist);
232 envHist = strchr(envHist,
':');
234 hist_save = atoi(envHist+1);
236 Gl_histsize(hist_size, hist_save);
237 Gl_histinit((
char *)logon);
240 static const char* defaultColorsBW[] = {
241 "bold blue",
"magenta",
"bold green",
"bold red underlined",
"default"
243 static const char* defaultColorsWB[] = {
244 "yellow",
"magenta",
"bold green",
"bold red underlined",
"default"
247 const char** defaultColors = defaultColorsBW;
250 defaultColors = defaultColorsWB;
257 Gl_setColors(colorType, colorTabCom, colorBracket, colorBadBracket, colorPrompt);
324 const char *logon =
gEnv->
GetValue(
"Rint.Logon", (
char*)0);
358 TObject *w =
gROOT->GetListOfBrowsables()->FindObject(
"workdir");
378 retval = 0; error = 0;
380 while (
TObject *fileObj = next()) {
381 if (
dynamic_cast<TNamed*
>(fileObj)) {
395 if (
file->String().EndsWith(
".root") ||
file->String().BeginsWith(
"file:")) {
398 rootfile =
gROOT->IsRootFile(
file->String());
402 if (
file->String().BeginsWith(
"\\\\"))
403 file->String().Prepend(
"\\\\");
404 file->String().ReplaceAll(
"\\",
"/");
405 const char *rfile = (
const char*)
file->String();
406 Printf(
"Attaching file %s as _file%d...", rfile, nfile);
409 Printf(
"Processing %s...", (
const char*)
file->String());
413 Getlinem(kCleanUp, 0);
420 needGetlinemInit =
kFALSE;
426 needGetlinemInit =
kTRUE;
440 if (retval < 0 || retval > 255)
451 if (needGetlinemInit) Getlinem(kInit,
GetPrompt());
465 Getlinem(kCleanUp, 0);
476 std::vector<TString> lines;
478 lines.emplace_back(
TString::Format(
"Welcome to ROOT %s%%shttps://root.cern",
479 gROOT->GetVersion()));
480 lines.emplace_back(
TString::Format(
"%%s(c) 1995-2019, The ROOT Team"));
482 if (!strcmp(
gROOT->GetGitBranch(),
gROOT->GetGitCommit())) {
483 static const char *months[] = {
"January",
"February",
"March",
"April",
"May",
484 "June",
"July",
"August",
"September",
"October",
485 "November",
"December"};
487 Int_t iday = idatqq%100;
488 Int_t imonth = (idatqq/100)%100;
489 Int_t iyear = (idatqq/10000);
492 gROOT->GetGitBranch(),
493 iday,months[imonth-1],iyear));
498 gROOT->GetGitBranch(),
499 gROOT->GetGitCommit()));
501 lines.emplace_back(
TString(
"Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'%s"));
504 auto itLongest = std::max_element(lines.begin(), lines.end(),
506 return left.Length() < right.Length(); });
507 Ssiz_t lenLongest = itLongest->Length();
511 for (
const auto&
line: lines) {
523 for (
int i = 0; i <
Argc(); i++)
524 if (!strcmp(
Argv(i),
"-splash"))
525 kill(getppid(), SIGUSR1);
557 if (newPrompt && strlen(newPrompt) <= 55)
560 Error(
"SetPrompt",
"newPrompt too long (> 55 characters)");
573 if ((
line = Getlinem(kOneChar, 0))) {
574 if (
line[0] == 0 && Gl_eof())
584 sline = sline.
Chop();
597 TTHREAD_TLS(
Bool_t) added;
616 catch (std::exception&
e) {
622 const char* demangledType = demangledType_c;
624 demangledType_c =
nullptr;
625 demangledType =
"<UNKNOWN>";
627 Error(
"HandleTermInput()",
"%s caught: %s", demangledType,
e.what());
628 free(demangledType_c);
633 Error(
"HandleTermInput()",
"Exception caught!");
660 Getlinem(kCleanUp, 0);
661 Getlinem(kInit,
"Root > ");
673 Getlinem(kCleanUp, 0);
703 Gl_config(
"noecho", mode ? 0 : 1);
750 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