64 G4cout <<
"aborting Run ...";
69 <<
"Session terminated." <<
G4endl;
74 "KeyboardInterrput with Ctrl-C");
95 UI-> SetSession(
this);
96 UI-> SetCoutDestination(
this);
101 if(aShell) shell= aShell;
117 if(shell)
delete shell;
120 UI-> SetSession(NULL);
121 UI-> SetCoutDestination(NULL);
141 ExecuteCommand(newCommand);
142 newCommand= GetCommand();
153 G4String newCommand= GetCommand(msg);
155 ExecuteCommand(newCommand);
156 newCommand= GetCommand(msg);
161 void G4UIterminal::ExecuteCommand(
const G4String& aCommand)
164 if(aCommand.length()<2)
return;
166 G4int returnVal = UI-> ApplyCommand(aCommand);
168 G4int paramIndex = returnVal % 100;
171 G4int commandStatus = returnVal - paramIndex;
177 switch(commandStatus) {
182 if( aCommand.
index(
"@@") != G4String::npos) {
187 G4cerr <<
"illegal application state -- command refused" <<
G4endl;
199 G4cerr <<
"Parameter is out of candidate list (index " << paramIndex <<
")" <<
G4endl;
203 G4cerr <<
"Parameter is wrong type and/or is not omittable (index " << paramIndex <<
")" <<
G4endl;
207 G4cerr <<
"command refused (" << commandStatus <<
")" <<
G4endl;
212 G4String G4UIterminal::GetCommand(
const char* msg)
218 newCommand= shell-> GetCommandLineString(msg);
221 if( nC.length() == 0 ) {
222 newCommand= nullString;
224 }
else if( nC(0) ==
'#' ) {
226 newCommand= nullString;
228 }
else if(nC==
"ls" || nC.substr(0,3)==
"ls " ) {
230 newCommand= nullString;
232 }
else if(nC==
"lc" || nC.substr(0,3)==
"lc " ) {
233 shell-> ListCommand(nC.
remove(0,2));
234 newCommand= nullString;
236 }
else if(nC ==
"pwd") {
237 G4cout <<
"Current Command Directory : "
239 newCommand= nullString;
241 }
else if(nC ==
"cwd") {
242 shell-> ShowCurrentDirectory();
243 newCommand= nullString;
245 }
else if(nC ==
"cd" || nC.substr(0,3) ==
"cd ") {
248 newCommand= nullString;
250 }
else if(nC ==
"help" || nC.substr(0,5) ==
"help ") {
252 newCommand= nullString;
254 }
else if(nC(0) ==
'?') {
256 newCommand= nullString;
258 }
else if(nC ==
"hist" || nC ==
"history") {
259 G4int nh= UI-> GetNumberOfHistory();
260 for (
G4int i=0; i<nh; i++) {
263 newCommand= nullString;
265 }
else if(nC(0) ==
'!') {
269 std::istringstream is(tt);
271 G4int nh= UI-> GetNumberOfHistory();
273 newCommand= UI-> GetPreviousCommand(vl);
276 G4cerr <<
"history " << vl <<
" is not found." <<
G4endl;
277 newCommand= nullString;
280 }
else if(nC ==
"exit") {
283 G4cout <<
"Please abort it using \"/run/abort\" command first" <<
G4endl;
284 G4cout <<
" and use \"continue\" command until the application"
289 newCommand= nullString;
292 }
else if( nC ==
"cont" || nC ==
"continue"){
294 newCommand= nullString;
296 }
else if( nC.empty() ){
297 newCommand= nullString;
310 std::cout << coutString << std::flush;
318 std::cerr << cerrString << std::flush;
329 G4cin.ignore(30,
'\n');
336 void G4UIterminal::ExitHelp() const
340 G4cin.getline(temp, 100);
G4String GetParameterCandidates() const
G4String GetPreviousCommand(G4int i) const
static G4ThreadLocal G4VUIshell * theshell
virtual G4int ReceiveG4cout(const G4String &coutString)
void ChangeDirectoryCommand(const G4String &)
void TerminalHelp(const G4String &)
G4String & remove(str_size)
G4String strip(G4int strip_Type=trailing, char c=' ')
virtual G4int ReceiveG4cerr(const G4String &cerrString)
static void SignalHandler(G4int)
static G4UImanager * GetUIpointer()
void SetPrompt(const G4String &prompt)
static G4StateManager * GetStateManager()
G4GLOB_DLL std::ostream G4cout
str_size index(const char *, G4int pos=0) const
virtual void PauseSessionStart(const G4String &msg)
G4UIparameter * GetParameter(G4int i) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4String ModifyToFullPathCommand(const char *aCommandLine) const
void ShowCurrent(const G4String &) const
void ListDirectory(const G4String &) const
G4String SolveAlias(const char *aCmd)
G4UIterminal(G4VUIshell *aShell=0, G4bool qsig=true)
G4String GetCurrentWorkingDirectory() const
G4UIcommand * FindCommand(const char *commandName) const
G4int ApplyCommand(const char *aCommand)
G4GLOB_DLL std::ostream G4cerr
virtual G4UIsession * SessionStart()