Ignore:
Timestamp:
Nov 9, 2007, 3:32:25 PM (17 years ago)
Author:
garnier
Message:

r627@mac-90108: laurentgarnier | 2007-11-09 07:57:42 +0100
modif dans les includes directives

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/geant4/interfaces/basic/src/G4UItcsh.cc

    r483 r593  
    2525//
    2626//
    27 // $Id: G4UItcsh.cc,v 1.12 2006/06/29 19:09:54 gunter Exp $
    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: $
    2929//
    3030
     
    3737#include <ctype.h>
    3838#include <sstream>
     39#include <fstream>
     40#include <stdlib.h>
    3941
    4042// ASCII character code
     
    5961static const int AsciiPrintableMin = 32;
    6062
     63// history file
     64static const G4String historyFileName= "/.g4_hist";
     65
    6166/////////////////////////////////////////////////////////
    6267G4UItcsh::G4UItcsh(const G4String& prompt, G4int maxhist)
     
    6974  // get current terminal mode
    7075  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();
    7194}
    7295
     
    7598/////////////////////
    7699{
    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  }
    78113 
    79 ///////////////////////////
     114  histfile.close();
     115}
     116
     117//////////////////////////////////////////
    80118void G4UItcsh::MakePrompt(const char* msg)
    81 ///////////////////////////
     119//////////////////////////////////////////
    82120{
    83121  if(promptSetting.length()<=1) {
     
    130168}
    131169
     170
     171//////////////////////////////
     172void G4UItcsh::ResetTerminal()
     173//////////////////////////////
     174{
     175  RestoreTerm();
     176}
     177
     178
    132179// --------------------------------------------------------------------
    133180//      commad line operations
     
    465512
    466513  G4int jt= input.find_last_of('/');
    467   if(jt<jhead) jt=G4String::npos;
     514  if(jt<jhead) jt=G4int(G4String::npos);
    468515
    469516  if(jt==G4int(G4String::npos)) jt= jhead;
     
    472519  G4String dspstr;
    473520  G4int i;
    474   for(i=jt; i<=G4int(input.length())-1; i++) dspstr+= G4String(AsciiBS); // cleanup
     521  for(i=jt; i<=G4int(input.length())-1; i++) dspstr+= G4String(AsciiBS);
    475522  for(i=jt; i<=G4int(input.length())-1; i++) dspstr+= G4String(' ');
    476523  for(i=jt; i<=G4int(input.length())-1; i++) dspstr+= G4String(AsciiBS);
     
    592639}
    593640
    594 ///////////////////////////////////
     641//////////////////////////////////////////////////
    595642G4String G4UItcsh::GetCommandLine(const char* msg)
    596 ///////////////////////////////////
     643//////////////////////////////////////////////////
    597644{
    598645  SetTermToInputMode();
Note: See TracChangeset for help on using the changeset viewer.