Geant4 10.7.0
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= linebuf;
91 aline.strip(G4String::both);
92 if(aline.size() != 0) StoreHistory(linebuf);
93 }
94 histfile.close();
95}
G4String strip(G4int strip_Type=trailing, char c=' ')
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:712
G4int relativeHistoryIndex
Definition: G4UItcsh.hh:108

◆ ~G4UItcsh()

G4UItcsh::~G4UItcsh ( )

Definition at line 98 of file G4UItcsh.cc.

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

Member Function Documentation

◆ BackspaceCharacter()

void G4UItcsh::BackspaceCharacter ( )
protected

Definition at line 219 of file G4UItcsh.cc.

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

Referenced by ReadLine().

◆ BackwardCursor()

void G4UItcsh::BackwardCursor ( )
protected

Definition at line 325 of file G4UItcsh.cc.

327{
328 if(cursorPosition==1) return;
329
331 G4cout << AsciiBS << std::flush;
332}

Referenced by ReadLine().

◆ ClearAfterCursor()

void G4UItcsh::ClearAfterCursor ( )
protected

Definition at line 284 of file G4UItcsh.cc.

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

Referenced by ReadLine().

◆ ClearLine()

void G4UItcsh::ClearLine ( )
protected

Definition at line 268 of file G4UItcsh.cc.

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

Referenced by NextCommand(), and PreviousCommand().

◆ ClearScreen()

void G4UItcsh::ClearScreen ( )
protected

Definition at line 301 of file G4UItcsh.cc.

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

◆ CompleteCommand()

void G4UItcsh::CompleteCommand ( )
protected

Definition at line 438 of file G4UItcsh.cc.

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

Referenced by ReadLine().

◆ DeleteCharacter()

void G4UItcsh::DeleteCharacter ( )
protected

Definition at line 247 of file G4UItcsh.cc.

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

Referenced by ReadLine().

◆ ForwardCursor()

void G4UItcsh::ForwardCursor ( )
protected

Definition at line 315 of file G4UItcsh.cc.

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

Referenced by ReadLine().

◆ GetCommandLineString()

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

Implements G4VUIshell.

Definition at line 647 of file G4UItcsh.cc.

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

◆ GetFirstMatchedString()

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

Definition at line 687 of file G4UItcsh.cc.

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

Referenced by CompleteCommand().

◆ InitializeCommandLine()

void G4UItcsh::InitializeCommandLine ( )
protected

Definition at line 187 of file G4UItcsh.cc.

189{
190 commandLine= "";
192}

Referenced by ReadLine().

◆ InsertCharacter()

void G4UItcsh::InsertCharacter ( char  cc)
protected

Definition at line 195 of file G4UItcsh.cc.

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

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 397 of file G4UItcsh.cc.

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

Referenced by ReadLine().

◆ MakePrompt()

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

Reimplemented from G4VUIshell.

Definition at line 122 of file G4UItcsh.cc.

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

Referenced by GetCommandLineString().

◆ MoveCursorEnd()

void G4UItcsh::MoveCursorEnd ( )
protected

Definition at line 346 of file G4UItcsh.cc.

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

Referenced by ReadLine().

◆ MoveCursorTop()

void G4UItcsh::MoveCursorTop ( )
protected

Definition at line 335 of file G4UItcsh.cc.

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

Referenced by ReadLine().

◆ NextCommand()

void G4UItcsh::NextCommand ( )
protected

Definition at line 377 of file G4UItcsh.cc.

379{
380 G4int nhmax= currentHistoryNo-1 >= maxHistory ?
382
383 if(relativeHistoryIndex>=-nhmax && relativeHistoryIndex<=-1) {
384 ClearLine();
386
389
390 G4cout << commandLine << std::flush;
391 cursorPosition= commandLine.length()+1;
392 }
393}
G4String commandLineBuf
Definition: G4UItcsh.hh:76
void ClearLine()
Definition: G4UItcsh.cc:268

Referenced by ReadLine().

◆ PreviousCommand()

void G4UItcsh::PreviousCommand ( )
protected

Definition at line 357 of file G4UItcsh.cc.

359{
360 G4int nhmax= currentHistoryNo-1 >= maxHistory ?
362
363 // retain current input
365
366 if(relativeHistoryIndex>=-nhmax+1 && relativeHistoryIndex<=0) {
367 ClearLine();
370
371 G4cout << commandLine << std::flush;
372 cursorPosition= commandLine.length()+1;
373 }
374}

Referenced by ReadLine().

◆ ReadLine()

G4String G4UItcsh::ReadLine ( )
protected

Definition at line 547 of file G4UItcsh.cc.

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

Referenced by GetCommandLineString().

◆ ResetTerminal()

void G4UItcsh::ResetTerminal ( )
virtual

Reimplemented from G4VUIshell.

Definition at line 176 of file G4UItcsh.cc.

178{
179 RestoreTerm();
180}

◆ RestoreHistory()

G4String G4UItcsh::RestoreHistory ( G4int  index)
protected

Definition at line 723 of file G4UItcsh.cc.

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

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

◆ RestoreTerm()

void G4UItcsh::RestoreTerm ( )
protected

Definition at line 754 of file G4UItcsh.cc.

756{
757 tcsetattr(0, TCSAFLUSH, &tios);
758}

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 738 of file G4UItcsh.cc.

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

Referenced by GetCommandLineString().

◆ StoreHistory()

void G4UItcsh::StoreHistory ( G4String  aCommand)
protected

Definition at line 712 of file G4UItcsh.cc.

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

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: