Changeset 593 for trunk/geant4/interfaces/basic/src/G4UItcsh.cc
- Timestamp:
- Nov 9, 2007, 3:32:25 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/geant4/interfaces/basic/src/G4UItcsh.cc
r483 r593 25 25 // 26 26 // 27 // $Id: G4UItcsh.cc,v 1.1 2 2006/06/29 19:09:54 gunterExp $28 // GEANT4 tag $Name: geant4-08-01-patch-01$27 // $Id: G4UItcsh.cc,v 1.15 2007/11/06 09:36:23 kmura Exp $ 28 // GEANT4 tag $Name: $ 29 29 // 30 30 … … 37 37 #include <ctype.h> 38 38 #include <sstream> 39 #include <fstream> 40 #include <stdlib.h> 39 41 40 42 // ASCII character code … … 59 61 static const int AsciiPrintableMin = 32; 60 62 63 // history file 64 static const G4String historyFileName= "/.g4_hist"; 65 61 66 ///////////////////////////////////////////////////////// 62 67 G4UItcsh::G4UItcsh(const G4String& prompt, G4int maxhist) … … 69 74 // get current terminal mode 70 75 tcgetattr(0, &tios); 76 77 // read a shell history file 78 G4String homedir= getenv("HOME"); 79 G4String fname= homedir + historyFileName; 80 81 std::ifstream histfile; 82 enum { BUFSIZE= 1024 }; char linebuf[BUFSIZE]; 83 84 histfile.open(fname, std::ios::in); 85 while (histfile.good()) { 86 if(histfile.eof()) break; 87 88 histfile.getline(linebuf, BUFSIZE); 89 G4String aline= linebuf; 90 aline.strip(G4String::both); 91 if(aline.size() != 0) StoreHistory(linebuf); 92 } 93 histfile.close(); 71 94 } 72 95 … … 75 98 ///////////////////// 76 99 { 77 } 100 // store a shell history 101 G4String homedir= getenv("HOME"); 102 G4String fname= homedir + historyFileName; 103 104 std::ofstream histfile; 105 histfile.open(fname, std::ios::out); 106 107 G4int n0hist= 1; 108 if( currentHistoryNo > maxHistory ) n0hist= currentHistoryNo-maxHistory+1; 109 110 for (G4int i=n0hist; i<= currentHistoryNo; i++) { 111 histfile << RestoreHistory(i) << G4endl; 112 } 78 113 79 /////////////////////////// 114 histfile.close(); 115 } 116 117 ////////////////////////////////////////// 80 118 void G4UItcsh::MakePrompt(const char* msg) 81 /////////////////////////// 119 ////////////////////////////////////////// 82 120 { 83 121 if(promptSetting.length()<=1) { … … 130 168 } 131 169 170 171 ////////////////////////////// 172 void G4UItcsh::ResetTerminal() 173 ////////////////////////////// 174 { 175 RestoreTerm(); 176 } 177 178 132 179 // -------------------------------------------------------------------- 133 180 // commad line operations … … 465 512 466 513 G4int jt= input.find_last_of('/'); 467 if(jt<jhead) jt=G4 String::npos;514 if(jt<jhead) jt=G4int(G4String::npos); 468 515 469 516 if(jt==G4int(G4String::npos)) jt= jhead; … … 472 519 G4String dspstr; 473 520 G4int i; 474 for(i=jt; i<=G4int(input.length())-1; i++) dspstr+= G4String(AsciiBS); // cleanup521 for(i=jt; i<=G4int(input.length())-1; i++) dspstr+= G4String(AsciiBS); 475 522 for(i=jt; i<=G4int(input.length())-1; i++) dspstr+= G4String(' '); 476 523 for(i=jt; i<=G4int(input.length())-1; i++) dspstr+= G4String(AsciiBS); … … 592 639 } 593 640 594 /////////////////////////////////// 641 ////////////////////////////////////////////////// 595 642 G4String G4UItcsh::GetCommandLine(const char* msg) 596 /////////////////////////////////// 643 ////////////////////////////////////////////////// 597 644 { 598 645 SetTermToInputMode();
Note: See TracChangeset
for help on using the changeset viewer.