40 :currentDirectory(
"/")
50 G4String rawCommandLine = aCommandLine;
51 if(rawCommandLine.
isNull()||rawCommandLine(0)==
'\0')
return rawCommandLine;
55 size_t i = commandLine.
index(
" ");
56 if( i != std::string::npos )
58 commandString = commandLine(0,i);
59 parameterString =
" ";
60 parameterString += commandLine(i+1,commandLine.length()-(i+1));
63 { commandString = commandLine; }
67 return fullPathCommandLine;
80 if( newDirectory( newDirectory.length() - 1 ) !=
'/' )
81 { newDirectory +=
"/"; }
93 if( targetDir( targetDir.length()-1 ) !=
'/' )
96 if( targetDir ==
"/" )
99 while( idx < targetDir.length()-1 )
101 size_t i = targetDir.
index(
"/",idx);
102 comTree = comTree->
GetTree(targetDir.substr(0,i+1).c_str());
103 if( comTree == NULL )
112 G4String rawCommandLine = commandName;
115 size_t i = commandLine.
index(
" ");
116 if( i != std::string::npos )
117 { commandString = commandLine(0,i); }
119 { commandString = commandLine; }
127 if( tempPath.length() == 0 )
return tempPath;
132 if( tempPath(0) ==
'/') newPath = tempPath;
137 size_t idx = newPath.find(
"/./");
138 if( idx == G4String::npos)
break;
139 newPath.erase(idx,2);
143 size_t idx = newPath.find(
"/../");
144 if( idx == G4String::npos)
break;
149 size_t idx2 = newPath.find_last_of(
'/', idx-1);
150 if(idx2 != G4String::npos) newPath.erase(idx2, idx-idx2+3);
154 if ( newPath.size() >= 3 ) {
155 if(newPath(newPath.size()-3,3) ==
"/..") {
156 if( newPath.size() == 3) {
159 size_t idx = newPath.find_last_of(
'/', newPath.size()-4);
160 if(idx != G4String::npos) newPath.erase(idx+1);
165 if ( newPath.size() >= 2 ) {
166 if(newPath(newPath.size()-2,2) ==
"/.") newPath.erase(newPath.size()-1,1);
171 size_t idx = newPath.find(
"//");
172 if( idx == G4String::npos)
break;
173 newPath.erase(idx,1);
183 G4String rawCommandLine = commandName;
185 size_t i = commandLine.
index(
" ");
186 if( i != std::string::npos )
return rawCommandLine;
188 G4String commandString = commandLine;
192 if(value==
"")
return rawCommandLine;
199 return aTree-> CompleteCommandPath(aCommandPath);
211 if(aCommand.length()<2)
return;
215 switch(commandStatus) {
219 G4cerr <<
"command not found: " <<
"\"" << aCommand <<
"\"" <<
G4endl;
222 G4cerr <<
"illegal application state -- command refused:" <<
"\"" << aCommand <<
"\"" <<
G4endl;
228 G4cerr <<
"command refused (" << commandStatus <<
"):" <<
"\"" << aCommand <<
"\"" <<
G4endl;
244 if( command(0) ==
'#' ) {
248 }
else if( command ==
"ls" || command(0,3) ==
"ls " ) {
252 }
else if( command ==
"pwd" ) {
254 G4cout <<
"Current Working Directory : "
257 }
else if( command ==
"cd" || command(0,3) ==
"cd ") {
261 }
else if( command ==
"help" || command(0,5) ==
"help ") {
265 }
else if( command(0) ==
'?' ) {
269 }
else if( command ==
"hist" || command ==
"history") {
272 for(
G4int i=0;i<nh;i++) {
276 }
else if( command(0) ==
'!' ) {
281 std::istringstream is(tt);
289 G4cerr <<
"history " << vl <<
" is not found." <<
G4endl;
292 }
else if( command ==
"exit" ) {
294 if( exitPause ==
false) {
296 G4cout <<
"Please abort it using \"/run/abort\" command first" <<
G4endl;
297 G4cout <<
" and use \"continue\" command until the application" <<
G4endl;
303 }
else if( command ==
"cont" || command ==
"continue"){
318 G4String comString = newCommand.substr(1,newCommand.length()-1);
322 G4cout <<
"Current value(s) of the parameter(s) : " << curV <<
G4endl;
329 if( newCommand.length() <= 3 ) {
332 G4String aNewPrefix = newCommand.substr(3, newCommand.length()-3);
336 G4cout <<
"directory <" << prefix <<
"> not found." <<
G4endl;
343 if( newCommand.length() <= 3 ) {
346 G4String newPrefix = newCommand.substr(3, newCommand.length()-3);
350 if( commandTree == NULL ) {
351 G4cout <<
"Directory <" << targetDir <<
"> is not found." <<
G4endl;
361 size_t i = newCommand.
index(
" ");
362 if( i != std::string::npos )
364 G4String newValue = newCommand.substr(i+1, newCommand.length()-(i+1));
368 if( theCommand != NULL )
375 G4cout <<
"Command <" << newValue <<
" is not found." <<
G4endl;
383 size_t prefixIndex = 1;
385 while( prefixIndex < prefix.length()-1 )
387 size_t ii = prefix.
index(
"/",prefixIndex);
400 G4cout << G4endl <<
"Not a number, once more" <<
G4endl;
403 if( iFloor < (
size_t)-j ) iFloor = 0;
415 if( j <= n_tree + floor[iFloor]->GetCommandEntry() )
422 floor[iFloor+1] = floor[iFloor]->
GetTree(j);
G4String currentDirectory
G4UIcommandTree * GetTree() const
G4int ApplyCommand(const char *aCommand)
void TerminalHelp(const G4String &)
str_size index(const char *, G4int pos=0) const
G4String FindMatchingPath(G4UIcommandTree *, const G4String &)
static G4UImanager * GetUIpointer()
void ListCurrentWithNum() const
G4String GetPreviousCommand(G4int i) const
virtual void ExecuteCommand(const G4String &)
G4UIcommand * GetCommand(G4int i)
void ApplyShellCommand(const G4String &, G4bool &, G4bool &)
G4String GetCurrentValues(const char *aCommand)
G4String ModifyPath(const G4String &tempPath) const
const XML_Char int const XML_Char * value
virtual void ExitHelp() const =0
G4bool ChangeDirectory(const char *newDir)
G4String Complete(const G4String &)
G4String strip(G4int strip_Type=trailing, char c=' ')
G4GLOB_DLL std::ostream G4cerr
G4UIcommand * FindCommand(const char *commandName) const
G4String GetCurrentWorkingDirectory() const
void ListDirectory(const G4String &) const
void ChangeDirectoryCommand(const G4String &)
G4GLOB_DLL std::ostream G4cout
G4int GetTreeEntry() const
void ShowCurrent(const G4String &) const
virtual G4bool GetHelpChoice(G4int &)=0
G4String ModifyToFullPathCommand(const char *aCommandLine) const
G4int GetNumberOfHistory() const
G4UIcommandTree * FindDirectory(const char *dirName) const
G4UIcommand * FindPath(const char *commandPath) const
G4UIcommandTree * GetTree(G4int i)