74 Getlinem(kCleanUp, 0);
90 Bool_t TInterruptHandler::Notify()
100 Break(
"TInterruptHandler::Notify",
"keyboard interrupt");
102 Getlinem(kInit,
"Root > ");
120 Bool_t ReadNotify() {
return Notify(); }
126 Bool_t TTermInputHandler::Notify()
142 TApplication(appClassName, argc, argv, options, numOptions),
146 fDefaultPrompt =
"root [%d] ";
151 if (!noLogo && !NoLogoOpt()) {
176 code =
"#include <iostream>\n" 177 "#include <string>\n" 178 "#include <DllImport.h>\n";
180 code +=
"#include <vector>\n" 181 "#include <utility>";
183 ProcessLine(code,
kTRUE);
204 TInterruptHandler *ih =
new TInterruptHandler();
206 SetSignalHandler(ih);
209 fInputHandler =
new TTermInputHandler(0);
210 fInputHandler->Add();
220 int hist_size =
gEnv->
GetValue(
"Rint.HistorySize", 500);
221 if (hist_size == 500)
223 int hist_save =
gEnv->
GetValue(
"Rint.HistorySave", 400);
224 if (hist_save == 400)
228 hist_size = atoi(envHist);
229 envHist = strchr(envHist,
':');
231 hist_save = atoi(envHist+1);
233 Gl_histsize(hist_size, hist_save);
234 Gl_histinit((
char *)logon);
237 static const char* defaultColorsBW[] = {
238 "bold blue",
"magenta",
"bold green",
"bold red underlined",
"default" 240 static const char* defaultColorsWB[] = {
241 "yellow",
"magenta",
"bold green",
"bold red underlined",
"default" 244 const char** defaultColors = defaultColorsBW;
247 defaultColors = defaultColorsWB;
254 Gl_setColors(colorType, colorTabCom, colorBracket, colorBadBracket, colorPrompt);
278 fInputHandler->Remove();
279 delete fInputHandler;
299 if (NoLogOpt())
return;
321 const char *logon =
gEnv->
GetValue(
"Rint.Logon", (
char*)0);
342 Getlinem(kInit, GetPrompt());
348 if (strlen(WorkingDirectory())) {
352 TObject *w =
gROOT->GetListOfBrowsables()->FindObject(
"workdir");
369 fInputHandler->DeActivate();
370 TIter next(InputFiles());
372 retval = 0; error = 0;
381 if (file->
TestBit(kExpression)) {
394 const char *rfile = (
const char*)file->
String();
395 Printf(
"Attaching file %s as _file%d...", rfile, nfile);
396 snprintf(cmd,
kMAXPATHLEN+50,
"TFile *_file%d = TFile::Open(\"%s\")", nfile++, rfile);
398 Printf(
"Processing %s...", (
const char*)file->
String());
402 Getlinem(kCleanUp, 0);
409 needGetlinemInit =
kFALSE;
410 retval = ProcessLineNr(
"ROOT_cli_", cmd, &error);
415 needGetlinemInit =
kTRUE;
417 if (error != 0 || fCaughtException)
break;
425 }
else if (fCaughtException) {
429 if (retval < 0) retval = 1;
430 else if (retval > 125) retval = 1;
436 fInputHandler->Activate();
440 if (needGetlinemInit) Getlinem(kInit, GetPrompt());
446 Terminate(fCaughtException ? 1 : 0);
451 Getlinem(kCleanUp, 0);
462 std::vector<TString> lines;
464 lines.emplace_back(
TString::Format(
"Welcome to ROOT %s%%shttp://root.cern.ch",
465 gROOT->GetVersion()));
466 lines.emplace_back(
TString::Format(
"%%s(c) 1995-2016, The ROOT Team"));
468 if (!strcmp(
gROOT->GetGitBranch(),
gROOT->GetGitCommit())) {
469 static const char *months[] = {
"January",
"February",
"March",
"April",
"May",
470 "June",
"July",
"August",
"September",
"October",
471 "November",
"December"};
473 Int_t iday = idatqq%100;
474 Int_t imonth = (idatqq/100)%100;
475 Int_t iyear = (idatqq/10000);
478 gROOT->GetGitBranch(),
479 iday,months[imonth-1],iyear));
484 gROOT->GetGitBranch(),
487 lines.emplace_back(
TString(
"Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'%s"));
490 auto itLongest = std::max_element(lines.begin(), lines.end(),
492 return left.
Length() < right.Length(); });
493 Ssiz_t lenLongest = itLongest->Length();
497 for (
const auto&
line: lines) {
509 for (
int i = 0; i < Argc(); i++)
510 if (!strcmp(Argv(i),
"-splash"))
511 kill(getppid(), SIGUSR1);
522 strlcpy(fPrompt, s,
sizeof(fPrompt));
524 snprintf(fPrompt,
sizeof(fPrompt), fDefaultPrompt.Data(), fNcmd);
540 static TString op = fDefaultPrompt;
542 if (newPrompt && strlen(newPrompt) <= 55)
543 fDefaultPrompt = newPrompt;
545 Error(
"SetPrompt",
"newPrompt too long (> 55 characters)");
558 if ((line = Getlinem(kOneChar, 0))) {
559 if (line[0] == 0 && Gl_eof())
569 sline = sline.
Chop();
571 ReturnPressed((
char*)sline.
Data());
578 fInputHandler->DeActivate();
587 SetBit(kProcessRemotely);
594 LineProcessed(sline);
595 ProcessLineNr(
"ROOT_prompt_", sline);
598 fInputHandler->Activate();
609 if (!added) fInputHandler->Activate();
617 fInputHandler->Activate();
623 Getlinem(kInit, GetPrompt());
635 fCaughtException =
kTRUE;
638 Getlinem(kCleanUp, 0);
639 Getlinem(kInit,
"Root > ");
651 Getlinem(kCleanUp, 0);
653 if (ReturnFromRun()) {
662 if (logoff && !NoLogOpt()) {
681 Gl_config(
"noecho", mode ? 0 : 1);
701 TString prompt; prompt.
Form(
"%s:root [%%d] ", fAppRemote->ApplicationName());
704 SetPrompt(
"root [%d] ");
722 if (line && line[0] !=
'.') {
724 int res = ProcessLine(lineWithNr + line,
kFALSE, error);
726 SetPrompt(
"root (cont'ed, cancel with .@) [%d]");
728 SetPrompt(
"root [%d] ");
731 if (line && line[0] ==
'.' && line[1] ==
'@') {
732 ProcessLine(line,
kFALSE, error);
733 SetPrompt(
"root [%d] ");
735 return ProcessLine(line,
kFALSE, error);
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 Terminate(int status)
Terminate the application.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
virtual const char * WorkingDirectory()
Return working directory.
void Print(Option_t *option="") const
Print the real and cpu time passed between the start and stop events.
Collectable string class.
R__EXTERN TClassTable * gClassTable
TString & ReplaceAll(const TString &s1, const TString &s2)
virtual Bool_t HandleTermInput()
Handle input coming from terminal.
Bool_t TestBit(UInt_t f) const
virtual const char * HomeDirectory(const char *userName=0)
Return the user's home directory.
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
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 * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
void Break(const char *location, const char *msgfmt,...)
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
TString & Prepend(const char *cs)
R__EXTERN TApplication * gApplication
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 [user@]host[:di...
virtual void SetGetline(const char *(*getlineFunc)(const char *prompt), void(*histaddFunc)(const char *line))=0
virtual Bool_t HandleTermInput()
static const char * GetMacroPath()
Get macro search path. Static utility function.
virtual void EndOfLineAction()=0
virtual void SetOption(Option_t *)
virtual Bool_t Notify()
Notify when signal occurs.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
void ExecLogon()
Execute logon macro's.
virtual void Run(Bool_t retrn=kFALSE)
Main application eventloop. Calls system dependent eventloop via gSystem.
virtual void SetEchoMode(Bool_t mode)
Set console mode:
static Bool_t Initialized()
Return kTRUE if the TROOT object has been initialized.
Int_t Hook(char *buf, int *pLoc, std::ostream &out)
[private]
virtual const char * Getenv(const char *env)
Get environment variable.
std::vector< std::vector< double > > Data
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
static void ResetTermAtExit()
Restore terminal to non-raw mode.
virtual void ExitLoop()
Exit from event loop.
virtual Int_t GetMore() const =0
void Error(const char *location, const char *msgfmt,...)
void ClearAll()
clears all lists except for user names and system include files.
virtual const char * SetPrompt(const char *newPrompt)
Set a new default prompt.
Describes an Operating System directory for the browser.
virtual const char * GetBuildArch() const
Return the build architecture.
virtual Int_t TabCompletionHook(char *buf, int *pLoc, std::ostream &out)
Forward tab completion request to our TTabCom::Hook().
R__EXTERN TSystem * gSystem
R__EXTERN TBenchmark * gBenchmark
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
virtual void HandleException(Int_t sig)
Handle exceptions (kSigBus, kSigSegmentationViolation, kSigIllegalInstruction and kSigFloatingExcepti...
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
char * Form(const char *fmt,...)
ESignals GetSignal() const
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
virtual void SaveContext()=0
This class is a ROOT utility to help benchmarking applications.
virtual void Run(Bool_t retrn=kFALSE)
Main application eventloop.
virtual void PrintLogo(Bool_t lite=kFALSE)
Print the ROOT logo on standard output.
R__EXTERN ExceptionContext_t * gException
virtual char * GetPrompt()=0
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...
static DictFuncPtr_t GetDict(const char *cname)
Given the class name returns the Dictionary() function of a class (uses hash of name).
virtual void KeyPressed(Int_t key)
Emit signal when console keyboard key was pressed.
Wrapper around a TObject so it can be stored in a TList.
static Int_t Key_Pressed(Int_t key)
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
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 void SaveGlobalsContext()=0
void Throw(int code)
If an exception context has been set (using the TRY and RETRY macros) jump back to where it was set...
Mother of all ROOT objects.
TObject * GetObject() const
virtual void HandleException(Int_t sig)
Handle exceptions (kSigBus, kSigSegmentationViolation, kSigIllegalInstruction and kSigFloatingExcepti...
virtual char * GetPrompt()
Get prompt from interpreter. Either "root [n]" or "end with '}'".
virtual ~TRint()
Destructor.
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
R__EXTERN void * gMmallocDesc
R__EXTERN TInterpreter * gCling
R__EXTERN TTabCom * gTabCom
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name. User must delete returned string.
void SetObject(TObject *obj)
const char * Data() const