Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4UItcsh Class Reference

#include <G4UItcsh.hh>

+ Inheritance diagram for G4UItcsh:

Public Member Functions

 G4UItcsh (const G4String &prompt="%s> ", G4int maxhist=100)
 
 ~G4UItcsh ()
 
void SetLsColor (TermColorIndex dirColor, TermColorIndex cmdColor)
 
virtual G4String GetCommandLineString (const char *msg=0)
 
virtual void ResetTerminal ()
 
- Public Member Functions inherited from G4VUIshell
 G4VUIshell (const G4String &prompt="> ")
 
virtual ~G4VUIshell ()
 
void SetNColumn (G4int ncol)
 
void SetPrompt (const G4String &prompt)
 
void SetCurrentDirectory (const G4String &ccd)
 
virtual void SetLsColor (TermColorIndex, TermColorIndex)
 
virtual void ShowCurrentDirectory () const
 
virtual void ListCommand (const G4String &input, const G4String &candidate="") const
 
virtual G4String GetCommandLineString (const char *msg=0)=0
 
virtual void ResetTerminal ()
 

Protected Member Functions

virtual void MakePrompt (const char *msg=0)
 
G4bool IsCursorLast () const
 
void InitializeCommandLine ()
 
G4String ReadLine ()
 
void InsertCharacter (char cc)
 
void BackspaceCharacter ()
 
void DeleteCharacter ()
 
void ClearLine ()
 
void ClearAfterCursor ()
 
void ClearScreen ()
 
void ForwardCursor ()
 
void BackwardCursor ()
 
void MoveCursorTop ()
 
void MoveCursorEnd ()
 
void NextCommand ()
 
void PreviousCommand ()
 
void ListMatchedCommand ()
 
void CompleteCommand ()
 
G4String GetFirstMatchedString (const G4String &str1, const G4String &str2) const
 
void StoreHistory (G4String aCommand)
 
G4String RestoreHistory (G4int index)
 
void SetTermToInputMode ()
 
void RestoreTerm ()
 
- Protected Member Functions inherited from G4VUIshell
virtual void MakePrompt (const char *msg=0)
 
G4UIcommandTreeGetCommandTree (const G4String &dir) const
 
G4String GetAbsCommandDirPath (const G4String &apath) const
 
G4String GetCommandPathTail (const G4String &apath) const
 

Protected Attributes

G4String commandLine
 
G4int cursorPosition
 
G4String commandLineBuf
 
std::vector< G4StringcommandHistory
 
G4int maxHistory
 
G4int currentHistoryNo
 
G4int relativeHistoryIndex
 
termios tios
 
G4String clearString
 
- Protected Attributes inherited from G4VUIshell
G4String promptSetting
 
G4String promptString
 
G4int nColumn
 
G4bool lsColorFlag
 
TermColorIndex directoryColor
 
TermColorIndex commandColor
 
G4String currentCommandDir
 

Detailed Description

Definition at line 70 of file G4UItcsh.hh.

Constructor & Destructor Documentation

◆ G4UItcsh()

G4UItcsh::G4UItcsh ( const G4String prompt = "%s> ",
G4int  maxhist = 100 
)

Definition at line 65 of file G4UItcsh.cc.

66 : G4VUIshell(prompt),
68 commandHistory(maxhist), maxHistory(maxhist),
70/////////////////////////////////////////////////////////
71{
72 // get current terminal mode
73 tcgetattr(0, &tios);
74
75 // read a shell history file
76 const char* path = std::getenv("HOME");
77 if( path == NULL ) return;
78
79 G4String homedir= path;
80 G4String fname= homedir + historyFileName;
81
82 std::ifstream histfile;
83 enum { BUFSIZE= 1024 }; char linebuf[BUFSIZE];
84
85 histfile.open(fname, std::ios::in);
86 while (histfile.good()) {
87 if(histfile.eof()) break;
88
89 histfile.getline(linebuf, BUFSIZE);
90 G4String aline= G4StrUtil::strip_copy(linebuf);
91 if(aline.size() != 0) StoreHistory(linebuf);
92 }
93 histfile.close();
94}
G4int cursorPosition
Definition: G4UItcsh.hh:75
G4int currentHistoryNo
Definition: G4UItcsh.hh:107
termios tios
Definition: G4UItcsh.hh:115
G4String commandLine
Definition: G4UItcsh.hh:74
std::vector< G4String > commandHistory
Definition: G4UItcsh.hh:105
G4int maxHistory
Definition: G4UItcsh.hh:106
void StoreHistory(G4String aCommand)
Definition: G4UItcsh.cc:710
G4int relativeHistoryIndex
Definition: G4UItcsh.hh:108
G4String strip_copy(G4String str, char ch=' ')
Return copy of string with leading and trailing characters removed.

◆ ~G4UItcsh()

G4UItcsh::~G4UItcsh ( )

Definition at line 97 of file G4UItcsh.cc.

99{
100 // store a shell history
101 const char* path = std::getenv("HOME");
102 if( path == NULL ) return;
103
104 G4String homedir= path;
105 G4String fname= homedir + historyFileName;
106
107 std::ofstream histfile;
108 histfile.open(fname, std::ios::out);
109
110 G4int n0hist= 1;
112
113 for (G4int i=n0hist; i<= currentHistoryNo; i++) {
114 histfile << RestoreHistory(i) << G4endl;
115 }
116
117 histfile.close();
118}
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4String RestoreHistory(G4int index)
Definition: G4UItcsh.cc:721

Member Function Documentation

◆ BackspaceCharacter()

void G4UItcsh::BackspaceCharacter ( )
protected

Definition at line 218 of file G4UItcsh.cc.

220{
221 if(cursorPosition==1) return;
222
223 // display...
224 if(IsCursorLast()) {
225 G4cout << AsciiBS << ' ' << AsciiBS << std::flush;
226 } else {
227 G4cout << AsciiBS;
228 std::size_t i;
229 for(i=cursorPosition-2; i< commandLine.length()-1; ++i){
230 G4cout << commandLine[G4int(i+1)];
231 }
232 G4cout << ' ';
233 for(i=cursorPosition-2; i< commandLine.length(); ++i){
234 G4cout << AsciiBS;
235 }
236 G4cout << std::flush;
237 }
238
239 // command line string...
240 commandLine.erase(cursorPosition-2, 1);
241
243}
G4GLOB_DLL std::ostream G4cout
G4bool IsCursorLast() const
Definition: G4UItcsh.hh:133

Referenced by ReadLine().

◆ BackwardCursor()

void G4UItcsh::BackwardCursor ( )
protected

Definition at line 323 of file G4UItcsh.cc.

325{
326 if(cursorPosition==1) return;
327
329 G4cout << AsciiBS << std::flush;
330}

Referenced by ReadLine().

◆ ClearAfterCursor()

void G4UItcsh::ClearAfterCursor ( )
protected

Definition at line 283 of file G4UItcsh.cc.

285{
286 if(IsCursorLast()) return;
287
288 // display...
289 for(std::size_t i=cursorPosition; i<=commandLine.length(); ++i) G4cout << ' ';
290 for(G4int j=(G4int)commandLine.length(); j>=cursorPosition; --j) G4cout << AsciiBS;
291 G4cout << std::flush;
292
293 // command line string...
295 commandLine.length()-cursorPosition+1);
296}

Referenced by ReadLine().

◆ ClearLine()

void G4UItcsh::ClearLine ( )
protected

Definition at line 267 of file G4UItcsh.cc.

269{
270 // display...
271 std::size_t i;
272 for(i= cursorPosition; i>=2; i--) G4cout << AsciiBS;
273 for(i=1; i<=commandLine.length(); ++i) G4cout << ' ';
274 for(i=1; i<=commandLine.length(); ++i) G4cout << AsciiBS;
275 G4cout << std::flush;
276
277 // command line string...
278 commandLine.erase();
280}

Referenced by NextCommand(), and PreviousCommand().

◆ ClearScreen()

void G4UItcsh::ClearScreen ( )
protected

Definition at line 299 of file G4UItcsh.cc.

301{
302 if(! clearString.empty() ) {
304
305 G4cout << promptString << commandLine << std::flush;
306 // reset cursur position
307 for(G4int i=G4int(commandLine.length()+1); i>=cursorPosition+1; --i)
308 G4cout << AsciiBS << std::flush;
309 }
310}
G4String clearString
Definition: G4UItcsh.hh:116
G4String promptString
Definition: G4VUIshell.hh:61

◆ CompleteCommand()

void G4UItcsh::CompleteCommand ( )
protected

Definition at line 435 of file G4UItcsh.cc.

437{
438 // inputting string
440
441 // target token is last token
442 auto jhead= input.rfind(' ');
443 if(jhead != G4String::npos) {
444 input.erase(0, jhead);
445 G4StrUtil::lstrip(input);
446 }
447
448 // tail string
449 std::size_t thead = input.find_last_of('/');
450 G4String strtail = input;
451 if (thead != G4String::npos) strtail = input.substr(thead+1, input.size()-thead-1);
452
453 // command tree of "user specified directory"
455 G4String vcmd;
456
457 G4int len= (G4int)input.length();
458 if(!input.empty()) {
459 G4int indx= -1;
460 for(G4int i=len-1; i>=0; --i) {
461 if(input[i]=='/') {
462 indx= i;
463 break;
464 }
465 }
466 // get abs. path
467 if(indx != -1) vpath= GetAbsCommandDirPath(input.substr(0,indx+1));
468 if(!(indx==0 && len==1)) vcmd= input.substr(indx+1,len-indx-1); // care for "/"
469 }
470
471 G4UIcommandTree* atree= GetCommandTree(vpath); // get command tree
472 if(atree == NULL) return;
473
474 // list matched directories/commands
475 G4String stream, strtmp;
476 G4String inputpath= vpath+vcmd;
477 G4int nMatch= 0;
478
479 G4int Ndir= atree-> GetTreeEntry();
480 G4int Ncmd= atree-> GetCommandEntry();
481
482 // directory ...
483 for(G4int idir=1; idir<=Ndir; idir++) {
484 G4String fpdir= atree-> GetTree(idir)-> GetPathName();
485 // matching test
486 if( fpdir.find(inputpath, 0) == 0) {
487 if(nMatch==0) {
488 stream= GetCommandPathTail(fpdir);
489 } else {
490 strtmp= GetCommandPathTail(fpdir);
491 stream= GetFirstMatchedString(stream, strtmp);
492 }
493 nMatch++;
494 }
495 }
496
497 // command ...
498 for(G4int icmd=1; icmd<=Ncmd; icmd++){
499 G4String fpcmd= atree-> GetPathName() +
500 atree-> GetCommand(icmd) -> GetCommandName();
501 // matching test
502 if( fpcmd.find(inputpath, 0) ==0) {
503 if(nMatch==0) {
504 stream= GetCommandPathTail(fpcmd) + " ";
505 } else {
506 strtmp= GetCommandPathTail(fpcmd) + " ";
507 stream= GetFirstMatchedString(stream, strtmp);
508 }
509 nMatch++;
510 }
511 }
512
513 // display...
514 input= commandLine;
515 // target token is last token
516 jhead= input.rfind(' ');
517 if(jhead == G4String::npos) jhead=0;
518 else jhead++;
519
520 std::size_t jt = jhead;
521
522 G4String dspstr;
523 std::size_t i;
524 for(i=jt; i<=input.length()-1; ++i) dspstr+= AsciiBS;
525 for(i=jt; i<=input.length()-1; ++i) dspstr+= ' ';
526 for(i=jt; i<=input.length()-1; ++i) dspstr+= AsciiBS;
527
528 dspstr+= (vpath + stream);
529 if (nMatch == 0) dspstr+= strtail;
530 G4cout << dspstr << std::flush;
531
532 // command line string
533 input.erase(jt);
534 input+= (vpath + stream);
535 if (nMatch==0) input+= strtail;
536
537 commandLine= input;
538 cursorPosition= G4int(commandLine.length()+1);
539}
G4String GetFirstMatchedString(const G4String &str1, const G4String &str2) const
Definition: G4UItcsh.cc:685
G4UIcommandTree * GetCommandTree(const G4String &dir) const
Definition: G4VUIshell.cc:117
G4String currentCommandDir
Definition: G4VUIshell.hh:72
G4String GetCommandPathTail(const G4String &apath) const
Definition: G4VUIshell.cc:191
G4String GetAbsCommandDirPath(const G4String &apath) const
Definition: G4VUIshell.cc:145
void lstrip(G4String &str, char ch=' ')
Remove leading characters from string.
G4String lstrip_copy(G4String str, char ch=' ')
Return copy of string with leading characters removed.

Referenced by ReadLine().

◆ DeleteCharacter()

void G4UItcsh::DeleteCharacter ( )
protected

Definition at line 246 of file G4UItcsh.cc.

248{
249 if(IsCursorLast()) return;
250
251 // display...
252 std::size_t i;
253 for(i=cursorPosition-1; i< commandLine.length()-1; ++i){
254 G4cout << commandLine[G4int(i+1)];
255 }
256 G4cout << ' ';
257 for(i=cursorPosition-1; i< commandLine.length(); ++i){
258 G4cout << AsciiBS;
259 }
260 G4cout << std::flush;
261
262 // command lin string...
263 commandLine.erase(cursorPosition-1, 1);
264}

Referenced by ReadLine().

◆ ForwardCursor()

void G4UItcsh::ForwardCursor ( )
protected

Definition at line 313 of file G4UItcsh.cc.

315{
316 if(IsCursorLast()) return;
317
318 G4cout << commandLine[cursorPosition-1] << std::flush;
320}

Referenced by ReadLine().

◆ GetCommandLineString()

G4String G4UItcsh::GetCommandLineString ( const char *  msg = 0)
virtual

Implements G4VUIshell.

Definition at line 645 of file G4UItcsh.cc.

647{
649
650 MakePrompt(msg); // update
652
653 G4cout << promptString << std::flush;
654
655 G4String newCommand= ReadLine(); // read line...
656 // multi-line
657 while( (newCommand.length() > 0) &&
658 ( newCommand[G4int(newCommand.length()-1)] == '_') ) {
659 newCommand.erase(newCommand.length()-1);
660 G4cout << G4endl;
661 promptString= "? ";
662 G4cout << promptString << std::flush;
663 G4String newLine= ReadLine();
664 newCommand.append(newLine);
665 }
666
667 // update history...
668 G4bool isMeaningfull= FALSE; // check NULL command
669 for (G4int i=0; i<(G4int)newCommand.length(); ++i) {
670 if(newCommand[i] != ' ') {
671 isMeaningfull= TRUE;
672 break;
673 }
674 }
675 if( !newCommand.empty() && isMeaningfull) StoreHistory(newCommand);
676
677 // reset terminal
678 RestoreTerm();
679
680 G4cout << G4endl;
681 return newCommand;
682}
bool G4bool
Definition: G4Types.hh:86
virtual void MakePrompt(const char *msg=0)
Definition: G4UItcsh.cc:121
void RestoreTerm()
Definition: G4UItcsh.cc:752
G4String ReadLine()
Definition: G4UItcsh.cc:545
void SetTermToInputMode()
Definition: G4UItcsh.cc:736
#define TRUE
Definition: globals.hh:41
#define FALSE
Definition: globals.hh:38

◆ GetFirstMatchedString()

G4String G4UItcsh::GetFirstMatchedString ( const G4String str1,
const G4String str2 
) const
protected

Definition at line 685 of file G4UItcsh.cc.

688{
689 std::size_t nlen1= str1.length();
690 std::size_t nlen2= str2.length();
691
692 std::size_t nmin = nlen1<nlen2 ? nlen1 : nlen2;
693
694 G4String strMatched;
695 for(G4int i=0; i<(G4int)nmin; ++i){
696 if(str1[i]==str2[i]) {
697 strMatched+= str1[i];
698 } else {
699 break;
700 }
701 }
702
703 return strMatched;
704}

Referenced by CompleteCommand().

◆ InitializeCommandLine()

void G4UItcsh::InitializeCommandLine ( )
protected

Definition at line 186 of file G4UItcsh.cc.

188{
189 commandLine= "";
191}

Referenced by ReadLine().

◆ InsertCharacter()

void G4UItcsh::InsertCharacter ( char  cc)
protected

Definition at line 194 of file G4UItcsh.cc.

196{
197 if( ! (cc >= AsciiPrintableMin && isprint(cc)) ) return;
198
199 // display...
200 G4cout << cc;
201 std::size_t i;
202 for(i=cursorPosition-1; i<commandLine.length(); ++i)
203 G4cout << commandLine[(G4int)i];
204 for(i=cursorPosition-1; i<commandLine.length(); ++i)
205 G4cout << AsciiBS;
206 G4cout << std::flush;
207
208 // command line string...
209 if(IsCursorLast()) { // add
210 commandLine+= cc;
211 } else { // insert
212 commandLine.insert(cursorPosition-1, G4String(1,cc));
213 }
215}

Referenced by ReadLine().

◆ IsCursorLast()

G4bool G4UItcsh::IsCursorLast ( ) const
inlineprotected

Definition at line 133 of file G4UItcsh.hh.

134{
135 if(cursorPosition == G4int(commandLine.length()+1)) return TRUE;
136 else return FALSE;
137}

Referenced by BackspaceCharacter(), ClearAfterCursor(), DeleteCharacter(), ForwardCursor(), InsertCharacter(), and ReadLine().

◆ ListMatchedCommand()

void G4UItcsh::ListMatchedCommand ( )
protected

Definition at line 395 of file G4UItcsh.cc.

397{
398 G4cout << G4endl;
399
400 // input string
402 // target token is last token
403 auto jhead= input.rfind(' ');
404 if(jhead != G4String::npos) {
405 input.erase(0, jhead);
406 G4StrUtil::lstrip(input);
407 }
408
409 // command tree of "user specified directory"
411 G4String vcmd = "";
412
413 if( !input.empty() ) {
414 G4int len= (G4int)input.length();
415 G4int indx=-1;
416 for(G4int i=len-1; i>=0; --i) {
417 if(input[i]=='/') {
418 indx= (G4int)i;
419 break;
420 }
421 }
422 // get abs. path
423 if(indx != -1) vpath= GetAbsCommandDirPath(input.substr(0,indx+1));
424 if(!(indx==0 && len==1)) vcmd= input.substr(indx+1,len-indx-1); // care for "/"
425 }
426
427 // list matched dirs/commands
428 //G4cout << "@@@ vpath=" << vpath <<":vcmd=" << vcmd << G4endl;
429 ListCommand(vpath, vpath+vcmd);
430
431 G4cout << promptString << commandLine << std::flush;
432}
virtual void ListCommand(const G4String &input, const G4String &candidate="") const
Definition: G4VUIshell.cc:229

Referenced by ReadLine().

◆ MakePrompt()

void G4UItcsh::MakePrompt ( const char *  msg = 0)
protectedvirtual

Reimplemented from G4VUIshell.

Definition at line 121 of file G4UItcsh.cc.

123{
124 if(promptSetting.length()<=1) {
126 return;
127 }
128
129 promptString="";
130 G4int i;
131 for(i=0; i<(G4int)promptSetting.length()-1; ++i){
132 if(promptSetting[i]=='%'){
133 switch (promptSetting[i+1]) {
134 case 's': // current application status
135 {
136 G4String stateStr;
137 if(msg)
138 { stateStr = msg; }
139 else
140 {
142 stateStr= statM-> GetStateString(statM->GetCurrentState());
143 }
144 promptString.append(stateStr);
145 i++;
146 }
147 break;
148 case '/': // current working directory
150 i++;
151 break;
152 case 'h': // history#
153 {
154 std::ostringstream os;
155 os << currentHistoryNo;
156 promptString.append(os.str());
157 i++;
158 }
159 break;
160 default:
161 break;
162 }
163 } else {
165 }
166 }
167
168 // append last chaacter
169 if(i == G4int(promptSetting.length()-1))
171}
const G4ApplicationState & GetCurrentState() const
static G4StateManager * GetStateManager()
G4String promptSetting
Definition: G4VUIshell.hh:60

Referenced by GetCommandLineString().

◆ MoveCursorEnd()

void G4UItcsh::MoveCursorEnd ( )
protected

Definition at line 344 of file G4UItcsh.cc.

346{
347 for(G4int i=cursorPosition-1; i<(G4int)commandLine.length(); ++i){
348 G4cout << commandLine[i];
349 }
350 G4cout << std::flush;
351 cursorPosition=G4int(commandLine.length()+1);
352}

Referenced by ReadLine().

◆ MoveCursorTop()

void G4UItcsh::MoveCursorTop ( )
protected

Definition at line 333 of file G4UItcsh.cc.

335{
336 for(G4int i=cursorPosition; i>1; --i){
337 G4cout << AsciiBS;
338 }
339 G4cout << std::flush;
341}

Referenced by ReadLine().

◆ NextCommand()

void G4UItcsh::NextCommand ( )
protected

Definition at line 375 of file G4UItcsh.cc.

377{
378 G4int nhmax= currentHistoryNo-1 >= maxHistory ?
380
381 if(relativeHistoryIndex>=-nhmax && relativeHistoryIndex<=-1) {
382 ClearLine();
384
387
388 G4cout << commandLine << std::flush;
389 cursorPosition= G4int(commandLine.length()+1);
390 }
391}
G4String commandLineBuf
Definition: G4UItcsh.hh:76
void ClearLine()
Definition: G4UItcsh.cc:267

Referenced by ReadLine().

◆ PreviousCommand()

void G4UItcsh::PreviousCommand ( )
protected

Definition at line 355 of file G4UItcsh.cc.

357{
358 G4int nhmax= currentHistoryNo-1 >= maxHistory ?
360
361 // retain current input
363
364 if(relativeHistoryIndex>=-nhmax+1 && relativeHistoryIndex<=0) {
365 ClearLine();
368
369 G4cout << commandLine << std::flush;
370 cursorPosition= G4int(commandLine.length()+1);
371 }
372}

Referenced by ReadLine().

◆ ReadLine()

G4String G4UItcsh::ReadLine ( )
protected

Definition at line 545 of file G4UItcsh.cc.

547{
549
550 char cc;
551 do{ // input loop
552 G4cin.get(cc);
553
554 // treatment for special character
555 switch(cc){
556 case AsciiCtrA: // ... move cursor to the top
558 break;
559 case AsciiCtrB: // ... backward cursor
561 break;
562 case AsciiCtrD: // ... delete/exit/show matched list
563 if(commandLine.length()!=0 && IsCursorLast()) ListMatchedCommand();
564 else if (commandLine.empty()) {
565 return G4String("exit");
566 } else DeleteCharacter();
567 break;
568 case AsciiCtrE: // ... move cursor to the end
570 break;
571 case AsciiCtrF: // ... forward cursor
573 break;
574 case AsciiCtrK: // ... clear after the cursor
576 break;
577 case AsciiCtrL: // ... clear screen
578 // ClearScreen();
579 break;
580 case AsciiCtrN: // ... next command
581 NextCommand();
582 break;
583 case AsciiCtrP: // ... previous command
585 break;
586 case AsciiTAB: // ... command completion
587 if( (!commandLine.empty()) && IsCursorLast()) CompleteCommand();
588 break;
589 case AsciiDEL: // ... backspace
591 break;
592 case AsciiBS: // ... backspace
594 break;
595 case AsciiCtrC: // ... kill prompt
596 break;
597 case AsciiCtrQ: // ... restarts suspeded output
598 break;
599 case AsciiCtrS: // ... suspend output
600 break;
601 case AsciiCtrZ: // ... suspend
602 break;
603 default:
604 break;
605 }
606
607 // treatment for ESC. character
608 if( cc == AsciiESC) { // ESC
609 G4cin.get(cc);
610 if (cc == '[' || cc == 'O') { // care for another termcap, such as konsole
611 G4cin.get(cc);
612 switch(cc) {
613 case 'A': // [UP]
614 cc = 'P' - '@';
615 PreviousCommand(); // ... show previous commad
616 break;
617 case 'B': // [DOWN]
618 cc = 'N' - '@';
619 NextCommand(); // ... show next commad
620 break;
621 case 'C': // [RIGHT]
622 cc = 'F' - '@';
623 ForwardCursor(); // ... forward cursor
624 break;
625 case 'D': // [LEFT]
626 cc = 'B' - '@';
627 BackwardCursor(); // ... backward cursor
628 break;
629 default: // who knows !?
630 cc = 0;
631 break;
632 }
633 }
634 }
635
636 // insert character to command line and display
637 InsertCharacter(cc);
638
639 } while( cc != '\n');
640
641 return commandLine;
642}
#define G4cin
Definition: G4ios.hh:56
void MoveCursorTop()
Definition: G4UItcsh.cc:333
void InsertCharacter(char cc)
Definition: G4UItcsh.cc:194
void PreviousCommand()
Definition: G4UItcsh.cc:355
void CompleteCommand()
Definition: G4UItcsh.cc:435
void NextCommand()
Definition: G4UItcsh.cc:375
void ForwardCursor()
Definition: G4UItcsh.cc:313
void MoveCursorEnd()
Definition: G4UItcsh.cc:344
void DeleteCharacter()
Definition: G4UItcsh.cc:246
void ListMatchedCommand()
Definition: G4UItcsh.cc:395
void InitializeCommandLine()
Definition: G4UItcsh.cc:186
void BackwardCursor()
Definition: G4UItcsh.cc:323
void ClearAfterCursor()
Definition: G4UItcsh.cc:283
void BackspaceCharacter()
Definition: G4UItcsh.cc:218

Referenced by GetCommandLineString().

◆ ResetTerminal()

void G4UItcsh::ResetTerminal ( )
virtual

Reimplemented from G4VUIshell.

Definition at line 175 of file G4UItcsh.cc.

177{
178 RestoreTerm();
179}

◆ RestoreHistory()

G4String G4UItcsh::RestoreHistory ( G4int  index)
protected

Definition at line 721 of file G4UItcsh.cc.

723{
724 if(histNo>= currentHistoryNo) return "";
725
726 G4int index= histNo%maxHistory;
727 if(index==0) index= maxHistory;
728
729 return commandHistory[index-1]; // 0-offset
730}

Referenced by NextCommand(), PreviousCommand(), and ~G4UItcsh().

◆ RestoreTerm()

void G4UItcsh::RestoreTerm ( )
protected

Definition at line 752 of file G4UItcsh.cc.

754{
755 tcsetattr(0, TCSAFLUSH, &tios);
756}

Referenced by GetCommandLineString(), and ResetTerminal().

◆ SetLsColor()

void G4UItcsh::SetLsColor ( TermColorIndex  dirColor,
TermColorIndex  cmdColor 
)
inlinevirtual

Reimplemented from G4VUIshell.

Definition at line 139 of file G4UItcsh.hh.

141{
143 directoryColor= dirColor;
144 commandColor= cmdColor;
145}
TermColorIndex directoryColor
Definition: G4VUIshell.hh:68
TermColorIndex commandColor
Definition: G4VUIshell.hh:69
G4bool lsColorFlag
Definition: G4VUIshell.hh:67

◆ SetTermToInputMode()

void G4UItcsh::SetTermToInputMode ( )
protected

Definition at line 736 of file G4UItcsh.cc.

738{
739 termios tiosbuf= tios;
740
741 tiosbuf.c_iflag &= ~(BRKINT | ISTRIP);
742 tiosbuf.c_iflag |= (IGNBRK | IGNPAR);
743 tiosbuf.c_lflag &= ~(ICANON | IEXTEN | ECHO);
744 tiosbuf.c_cc[VMIN] = 1;
745 tiosbuf.c_cc[VTIME] = 0;
746
747 tcsetattr(0, TCSAFLUSH, &tiosbuf);
748}

Referenced by GetCommandLineString().

◆ StoreHistory()

void G4UItcsh::StoreHistory ( G4String  aCommand)
protected

Definition at line 710 of file G4UItcsh.cc.

712{
714 if(i==0) i=maxHistory;
715
716 commandHistory[i-1]= aCommand; // 0-offset
718}

Referenced by G4UItcsh(), and GetCommandLineString().

Member Data Documentation

◆ clearString

G4String G4UItcsh::clearString
protected

Definition at line 116 of file G4UItcsh.hh.

Referenced by ClearScreen().

◆ commandHistory

std::vector<G4String> G4UItcsh::commandHistory
protected

Definition at line 105 of file G4UItcsh.hh.

Referenced by RestoreHistory(), and StoreHistory().

◆ commandLine

◆ commandLineBuf

G4String G4UItcsh::commandLineBuf
protected

Definition at line 76 of file G4UItcsh.hh.

Referenced by NextCommand(), and PreviousCommand().

◆ currentHistoryNo

G4int G4UItcsh::currentHistoryNo
protected

◆ cursorPosition

◆ maxHistory

G4int G4UItcsh::maxHistory
protected

Definition at line 106 of file G4UItcsh.hh.

Referenced by NextCommand(), PreviousCommand(), RestoreHistory(), StoreHistory(), and ~G4UItcsh().

◆ relativeHistoryIndex

G4int G4UItcsh::relativeHistoryIndex
protected

Definition at line 108 of file G4UItcsh.hh.

Referenced by GetCommandLineString(), NextCommand(), and PreviousCommand().

◆ tios

termios G4UItcsh::tios
protected

Definition at line 115 of file G4UItcsh.hh.

Referenced by G4UItcsh(), RestoreTerm(), and SetTermToInputMode().


The documentation for this class was generated from the following files: