75 Getlinem(kCleanUp, 0);
91 Bool_t TInterruptHandler::Notify()
102 Break(
"TInterruptHandler::Notify",
"keyboard interrupt");
103 Getlinem(kInit,
"Root > ");
124 Bool_t ReadNotify() {
return Notify(); }
130 Bool_t TTermInputHandler::Notify()
146 TApplication(appClassName, argc, argv, options, numOptions),
150 fDefaultPrompt =
"root [%d] ";
155 if (!noLogo && !NoLogoOpt()) {
180 code =
"#include <iostream>\n" 181 "#include <string>\n" 182 "#include <DllImport.h>\n";
184 code +=
"#include <vector>\n" 185 "#include <utility>";
187 ProcessLine(code,
kTRUE);
208 TInterruptHandler *ih =
new TInterruptHandler();
210 SetSignalHandler(ih);
213 fInputHandler =
new TTermInputHandler(0);
214 fInputHandler->Add();
224 int hist_size =
gEnv->
GetValue(
"Rint.HistorySize", 500);
225 if (hist_size == 500)
227 int hist_save =
gEnv->
GetValue(
"Rint.HistorySave", 400);
228 if (hist_save == 400)
232 hist_size = atoi(envHist);
233 envHist = strchr(envHist,
':');
235 hist_save = atoi(envHist+1);
237 Gl_histsize(hist_size, hist_save);
238 Gl_histinit((
char *)logon);
241 static const char* defaultColorsBW[] = {
242 "bold blue",
"magenta",
"bold green",
"bold red underlined",
"default" 244 static const char* defaultColorsWB[] = {
245 "yellow",
"magenta",
"bold green",
"bold red underlined",
"default" 248 const char** defaultColors = defaultColorsBW;
251 defaultColors = defaultColorsWB;
258 Gl_setColors(colorType, colorTabCom, colorBracket, colorBadBracket, colorPrompt);
282 fInputHandler->Remove();
283 delete fInputHandler;
303 if (NoLogOpt())
return;
335 const char *logon =
gEnv->
GetValue(
"Rint.Logon", (
char*)0);
356 Getlinem(kInit, GetPrompt());
362 if (strlen(WorkingDirectory())) {
366 TObject *w =
gROOT->GetListOfBrowsables()->FindObject(
"workdir");
383 fInputHandler->DeActivate();
384 TIter next(InputFiles());
386 retval = 0; error = 0;
395 if (file->
TestBit(kExpression)) {
408 const char *rfile = (
const char*)file->
String();
409 Printf(
"Attaching file %s as _file%d...", rfile, nfile);
412 Printf(
"Processing %s...", (
const char*)file->
String());
416 Getlinem(kCleanUp, 0);
423 needGetlinemInit =
kFALSE;
424 retval = ProcessLineNr(
"ROOT_cli_", cmd, &error);
429 needGetlinemInit =
kTRUE;
431 if (error != 0 || fCaughtSignal)
break;
439 }
else if (fCaughtSignal) {
440 retval = fCaughtSignal + 128;
443 if (retval < 0 || retval > 255)
450 fInputHandler->Activate();
454 if (needGetlinemInit) Getlinem(kInit, GetPrompt());
460 Terminate(fCaughtSignal ? fCaughtSignal + 128 : 0);
468 Getlinem(kCleanUp, 0);
479 std::vector<TString> lines;
481 lines.emplace_back(
TString::Format(
"Welcome to ROOT %s%%shttp://root.cern.ch",
482 gROOT->GetVersion()));
483 lines.emplace_back(
TString::Format(
"%%s(c) 1995-2016, The ROOT Team"));
485 if (!strcmp(
gROOT->GetGitBranch(),
gROOT->GetGitCommit())) {
486 static const char *months[] = {
"January",
"February",
"March",
"April",
"May",
487 "June",
"July",
"August",
"September",
"October",
488 "November",
"December"};
490 Int_t iday = idatqq%100;
491 Int_t imonth = (idatqq/100)%100;
492 Int_t iyear = (idatqq/10000);
495 gROOT->GetGitBranch(),
496 iday,months[imonth-1],iyear));
501 gROOT->GetGitBranch(),
504 lines.emplace_back(
TString(
"Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'%s"));
507 auto itLongest = std::max_element(lines.begin(), lines.end(),
509 return left.
Length() < right.Length(); });
510 Ssiz_t lenLongest = itLongest->Length();
514 for (
const auto&
line: lines) {
526 for (
int i = 0; i < Argc(); i++)
527 if (!strcmp(Argv(i),
"-splash"))
528 kill(getppid(), SIGUSR1);
539 strlcpy(fPrompt, s,
sizeof(fPrompt));
541 snprintf(fPrompt,
sizeof(fPrompt), fDefaultPrompt.Data(), fNcmd);
560 if (newPrompt && strlen(newPrompt) <= 55)
561 fDefaultPrompt = newPrompt;
563 Error(
"SetPrompt",
"newPrompt too long (> 55 characters)");
576 if ((line = Getlinem(kOneChar, 0))) {
577 if (line[0] == 0 && Gl_eof())
587 sline = sline.
Chop();
589 ReturnPressed((
char*)sline.
Data());
596 fInputHandler->DeActivate();
600 TTHREAD_TLS(
Bool_t) added;
604 SetBit(kProcessRemotely);
609 LineProcessed(sline);
610 ProcessLineNr(
"ROOT_prompt_", sline);
613 fInputHandler->Activate();
619 catch (std::exception&
e) {
621 if (!added) fInputHandler->Activate();
625 const char* demangledType = demangledType_c;
627 demangledType_c =
nullptr;
628 demangledType =
"<UNKNOWN>";
630 Error(
"HandleTermInput()",
"%s caught: %s", demangledType, e.what());
631 free(demangledType_c);
635 if (!added) fInputHandler->Activate();
636 Error(
"HandleTermInput()",
"Exception caught!");
642 fInputHandler->Activate();
648 Getlinem(kInit, GetPrompt());
663 Getlinem(kCleanUp, 0);
664 Getlinem(kInit,
"Root > ");
676 Getlinem(kCleanUp, 0);
678 if (ReturnFromRun()) {
687 if (logoff && !NoLogOpt()) {
706 Gl_config(
"noecho", mode ? 0 : 1);
726 TString prompt; prompt.
Form(
"%s:root [%%d] ", fAppRemote->ApplicationName());
729 SetPrompt(
"root [%d] ");
747 if (line && line[0] !=
'.') {
749 int res = ProcessLine(lineWithNr + line,
kFALSE, error);
751 if (!fNonContinuePrompt.Length())
752 fNonContinuePrompt = fDefaultPrompt;
753 SetPrompt(
"root (cont'ed, cancel with .@) [%d]");
754 }
else if (fNonContinuePrompt.Length()) {
755 SetPrompt(fNonContinuePrompt);
756 fNonContinuePrompt.Clear();
760 if (line && line[0] ==
'.' && line[1] ==
'@') {
761 ProcessLine(line,
kFALSE, error);
762 SetPrompt(
"root [%d] ");
764 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 Int_t GetMore() const =0
void Print(Option_t *option="") const
Print the real and cpu time passed between the start and stop events.
virtual void Terminate(int status)
Terminate the application.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
virtual const char * WorkingDirectory()
Return working directory.
Collectable string class.
R__EXTERN TClassTable * gClassTable
virtual const char * GetBuildArch() const
Return the build architecture.
TString & ReplaceAll(const TString &s1, const TString &s2)
virtual Bool_t HandleTermInput()
Handle input coming from terminal.
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
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
virtual Bool_t HandleTermInput()
static const char * GetMacroPath()
Get macro search path. Static utility function.
const char * Data() const
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
static void ResetTermAtExit()
Restore terminal to non-raw mode.
virtual void ExitLoop()
Exit from event loop.
char * DemangleTypeIdName(const std::type_info &ti, int &errorCode)
Demangle in a portable way the type id name.
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 Int_t TabCompletionHook(char *buf, int *pLoc, std::ostream &out)
Forward tab completion request to our TTabCom::Hook().
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
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 signals (kSigBus, kSigSegmentationViolation, kSigIllegalInstruction and kSigFloatingException)...
TObject * GetObject() const
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Bool_t TestBit(UInt_t f) const
char * Form(const char *fmt,...)
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)
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
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.
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.
R__EXTERN const char * gRootDir
ESignals GetSignal() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
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)