49 G4String rawCommandLine = aCommandLine;
50 if(rawCommandLine.
isNull()||rawCommandLine(0)==
'\0')
return rawCommandLine;
54 size_t i = commandLine.
index(
" ");
55 if( i != std::string::npos )
57 commandString = commandLine(0,i);
58 parameterString =
" ";
59 parameterString += commandLine(i+1,commandLine.length()-(i+1));
62 { commandString = commandLine; }
65 = ModifyPath( commandString )+parameterString;
66 return fullPathCommandLine;
71 return currentDirectory;
78 G4String newDirectory = ModifyPath( newPrefix );
79 if( newDirectory( newDirectory.length() - 1 ) !=
'/' )
80 { newDirectory +=
"/"; }
83 currentDirectory = newDirectory;
91 G4String targetDir = ModifyPath( theDir );
92 if( targetDir( targetDir.length()-1 ) !=
'/' )
95 if( targetDir ==
"/" )
98 while( idx < targetDir.length()-1 )
100 size_t i = targetDir.
index(
"/",idx);
101 comTree = comTree->
GetTree(targetDir.substr(0,i+1).c_str());
102 if( comTree == NULL )
111 G4String rawCommandLine = commandName;
114 size_t i = commandLine.
index(
" ");
115 if( i != std::string::npos )
116 { commandString = commandLine(0,i); }
118 { commandString = commandLine; }
120 G4String targetCom = ModifyPath(commandString);
126 if( tempPath.length() == 0 )
return tempPath;
131 if( tempPath(0) ==
'/') newPath = tempPath;
132 else newPath = currentDirectory + tempPath;
136 size_t idx = newPath.find(
"/./");
137 if( idx == G4String::npos)
break;
138 newPath.erase(idx,2);
142 size_t idx = newPath.find(
"/../");
143 if( idx == G4String::npos)
break;
148 size_t idx2 = newPath.find_last_of(
'/', idx-1);
149 if(idx2 != G4String::npos) newPath.erase(idx2, idx-idx2+3);
153 if ( newPath.size() >= 3 ) {
154 if(newPath(newPath.size()-3,3) ==
"/..") {
155 if( newPath.size() == 3) {
158 size_t idx = newPath.find_last_of(
'/', newPath.size()-4);
159 if(idx != G4String::npos) newPath.erase(idx+1);
164 if ( newPath.size() >= 2 ) {
165 if(newPath(newPath.size()-2,2) ==
"/.") newPath.erase(newPath.size()-1,1);
170 size_t idx = newPath.find(
"//");
171 if( idx == G4String::npos)
break;
172 newPath.erase(idx,1);
182 G4String rawCommandLine = commandName;
184 size_t i = commandLine.
index(
" ");
185 if( i != std::string::npos )
return rawCommandLine;
187 G4String commandString = commandLine;
188 G4String targetCom = ModifyPath(commandString);
191 if(value==
"")
return rawCommandLine;
198 return aTree-> CompleteCommandPath(aCommandPath);
210 if(aCommand.length()<2)
return;
214 switch(commandStatus) {
218 G4cerr <<
"command not found: " <<
"\"" << aCommand <<
"\"" <<
G4endl;
221 G4cerr <<
"illegal application state -- command refused:" <<
"\"" << aCommand <<
"\"" <<
G4endl;
227 G4cerr <<
"command refused (" << commandStatus <<
"):" <<
"\"" << aCommand <<
"\"" <<
G4endl;
243 if( command(0) ==
'#' ) {
247 }
else if( command ==
"ls" || command(0,3) ==
"ls " ) {
251 }
else if( command ==
"pwd" ) {
253 G4cout <<
"Current Working Directory : "
256 }
else if( command ==
"cd" || command(0,3) ==
"cd ") {
260 }
else if( command ==
"help" || command(0,5) ==
"help ") {
264 }
else if( command(0) ==
'?' ) {
268 }
else if( command ==
"hist" || command ==
"history") {
271 for(
G4int i=0;i<nh;i++) {
275 }
else if( command(0) ==
'!' ) {
277 G4String ss = command(1,command.length()-1);
280 std::istringstream is(tt);
288 G4cerr <<
"history " << vl <<
" is not found." <<
G4endl;
291 }
else if( command ==
"exit" ) {
293 if( exitPause ==
false) {
295 G4cout <<
"Please abort it using \"/run/abort\" command first" <<
G4endl;
296 G4cout <<
" and use \"continue\" command until the application" <<
G4endl;
302 }
else if( command ==
"cont" || command ==
"continue"){
317 G4String comString = newCommand.substr(1,newCommand.length()-1);
321 G4cout <<
"Current value(s) of the parameter(s) : " << curV <<
G4endl;
328 if( newCommand.length() <= 3 ) {
331 G4String aNewPrefix = newCommand.substr(3, newCommand.length()-3);
342 if( newCommand.length() <= 3 ) {
345 G4String newPrefix = newCommand.substr(3, newCommand.length()-3);
349 if( commandTree == NULL ) {
350 G4cout <<
"Directory <" << targetDir <<
"> is not found." <<
G4endl;
360 size_t i = newCommand.
index(
" ");
361 if( i != std::string::npos )
363 G4String newValue = newCommand.substr(i+1, newCommand.length()-(i+1));
367 if( theCommand != NULL )
374 G4cout <<
"Command <" << newValue <<
" is not found." <<
G4endl;
382 size_t prefixIndex = 1;
384 while( prefixIndex <
prefix.length()-1 )
386 size_t ii =
prefix.index(
"/",prefixIndex);
402 if( iFloor < (
size_t)-j ) iFloor = 0;
414 if( j <= n_tree + floor[iFloor]->GetCommandEntry() )
421 floor[iFloor+1] = floor[iFloor]->
GetTree(j);
@ fParameterOutOfCandidates
@ fIllegalApplicationState
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
str_size index(const char *, G4int pos=0) const
G4String strip(G4int strip_Type=trailing, char c=' ')
G4UIcommand * GetCommand(G4int i)
G4int GetTreeEntry() const
G4UIcommandTree * GetTree(G4int i)
void ListCurrentWithNum() const
G4UIcommand * FindPath(const char *commandPath) const
G4UIcommandTree * GetTree() const
G4int ApplyCommand(const char *aCommand)
G4int GetNumberOfHistory() const
G4String GetPreviousCommand(G4int i) const
G4String GetCurrentValues(const char *aCommand)
static G4UImanager * GetUIpointer()
G4UIcommand * FindCommand(const char *commandName) const
G4String FindMatchingPath(G4UIcommandTree *, const G4String &)
G4String ModifyToFullPathCommand(const char *aCommandLine) const
G4String Complete(const G4String &)
void ShowCurrent(const G4String &) const
void TerminalHelp(const G4String &)
virtual void ExecuteCommand(const G4String &)
void ListDirectory(const G4String &) const
void ApplyShellCommand(const G4String &, G4bool &, G4bool &)
virtual void ExitHelp() const =0
G4String GetCurrentWorkingDirectory() const
G4bool ChangeDirectory(const char *newDir)
void ChangeDirectoryCommand(const G4String &)
G4UIcommandTree * FindDirectory(const char *dirName) const
virtual G4bool GetHelpChoice(G4int &)=0