61 fCommand->Connect(
"ReturnPressed()",
"TGCommandPlugin",
this,
63 fCommand->Connect(
"CursorOutUp()",
"TGCommandPlugin",
this,
64 "HandleArrows(=kKey_Up)");
65 fCommand->Connect(
"CursorOutDown()",
"TGCommandPlugin",
this,
66 "HandleArrows(=kKey_Down)");
67 fCommand->Connect(
"TabPressed()",
"TGCommandPlugin",
this,
69 fCommand->Connect(
"TextChanged(const char *)",
"TGCommandPlugin",
this,
70 "HandleTextChanged(const char *)");
74 gClient->GetColorByName(
"#a0a0a0", pxl);
83 FILE *lunin = fopen(defhist.
Data(),
"rt");
88 while (fgets(histline, 256, lunin))
91 if (linecount > 500) {
93 while(--linecount > 0)
94 if (!fgets(histline, 256, lunin))
98 while (fgets(histline, 256, lunin)) {
99 histline[strlen(histline)-1] = 0;
100 fComboCmd->InsertEntry(histline, linecount, -1);
102 if (++linecount > 500)
123 fCommand->Disconnect(
"ReturnPressed()");
124 fCommand->Disconnect(
"CursorOutUp()");
125 fCommand->Disconnect(
"CursorOutDown()");
126 fCommand->Disconnect(
"TabPressed()");
127 fCommand->Disconnect(
"TextChanged(const char *)");
144 if (end > 0 && end !=
kNPOS) {
147 gClient->GetColorByName(
"#ff0000", pxl);
148 fLabel->SetTextColor(pxl);
153 gClient->GetColorByName(
"#000000", pxl);
154 fLabel->SetTextColor(pxl);
155 fLabel->SetText(
"Command (local):");
195 if (strlen(
string) > 0) {
202 sPrompt = ((
TRint*)
gROOT->GetApplication())->GetPrompt();
203 FILE *lunout = fopen(pathtmp.
Data(),
"a+t");
205 fputs(
Form(
"%s%s\n",sPrompt.
Data(),
string), lunout);
210 gROOT->ProcessLine(
string);
212 fComboCmd->InsertEntry(
string, entries, -1);
215 Gl_histadd((
char *)
string);
231 std::vector<std::string> result;
232 size_t cur =
line.length();
234 if (result.size() == 1) {
236 std::string found = result[0];
238 size_t colon =
line.find_last_of(
"::");
239 if (colon != std::string::npos)
241 size_t pos = found.find(
what) +
what.length();
242 std::string suffix = found.substr(pos);
243 fCommand->AppendText(suffix.c_str());
247 if (prompt.find(
"root") == std::string::npos)
251 fStatus->AddLine(prompt.c_str());
253 for (
auto& res : result) {
ULong_t Pixel_t
Pixel value.
int Int_t
Signed integer 4 bytes (int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
bool Bool_t
Boolean (0=false, 1=true) (bool).
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
externTApplication * gApplication
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
A combobox (also known as a drop down listbox) allows the selection of one item out of a list of item...
TGHorizontalFrame * fHf
horizontal frame
void SetHistAdd(Bool_t add=kTRUE)
The function SetHistAdd() is needed for a standalone TApplication to log the TGCommandPlugin commands...
Bool_t fHistAdd
flag to add commands to history
TGTextBuffer * fCommandBuf
command text buffer
Int_t fPid
current process id
TTimer * fTimer
for local/remote update
void HandleCommand()
Handle command line from the "command" combo box.
TGTextEntry * fCommand
command text entry widget
void HandleTextChanged(const char *)
Handle the text changed events.
TGCommandPlugin(const TGWindow *p, UInt_t w, UInt_t h)
TGCommandPlugin Constructor.
TString fTempString
temporary command string
void ToggleTimer(Bool_t on)
Let user stop the internal timer when there is no need to check for remote.
void HandleTab()
Handle the 'TAB' key events.
Bool_t HandleTimer(TTimer *t) override
Handle timer event.
TGComboBox * fComboCmd
commands combobox
void CheckRemote(const char *)
Check if actual ROOT session is a remote one or a local one.
TGTextView * fStatus
output capture view
TGLabel * fLabel
"command :" label
~TGCommandPlugin() override
Destructor.
Int_t fPos
current history position
void HandleArrows(Int_t keysym)
Handle the 'up' and 'down' arrow key events.
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
void SetCleanup(Int_t mode=kLocalCleanup) override
Turn on automatic cleanup of child frames in dtor.
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
static Pixel_t GetWhitePixel()
Get white pixel value.
void MapWindow() override
map window
A composite frame that layout their children in horizontal way.
This class handles GUI labels.
This class describes layout hints used by the layout classes.
TGMainFrame(const TGMainFrame &)=delete
const char * GetString() const
Text string listbox entries.
const TGString * GetText() const
A TGTextView is a text viewer widget.
ROOT GUI Window base class.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
const char * Data() const
TString & Remove(Ssiz_t pos)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Handles synchronous and a-synchronous timer events.