/////////////////////////////////////////////
| 213 | |
| 214 | ////////////////////////////////////////////////// |
| 215 | G4String G4UIterminal::GetCommand(const char* msg) |
| 216 | ////////////////////////////////////////////////// |
| 217 | { |
| 218 | G4String newCommand = shell->GetCommandLineString(msg); |
| 219 | const G4String& nullString = ""; |
| 220 | |
| 221 | G4String nC = G4StrUtil::lstrip_copy(newCommand); |
| 222 | |
| 223 | if (nC.length() == 0) { |
| 224 | newCommand = nullString; |
| 225 | } |
| 226 | else if (nC[0] == '#') { |
| 227 | G4cout << nC << G4endl; |
| 228 | newCommand = nullString; |
| 229 | } |
| 230 | else if (nC == "ls" || nC.substr(0, 3) == "ls ") { // list commands |
| 231 | ListDirectory(nC); |
| 232 | newCommand = nullString; |
| 233 | } |
| 234 | else if (nC == "lc" || nC.substr(0, 3) == "lc ") { // ... by shell |
| 235 | shell->ListCommand(nC.erase(0, 2)); |
| 236 | newCommand = nullString; |
| 237 | } |
| 238 | else if (nC == "pwd") { // show current directory |
| 239 | G4cout << "Current Command Directory : " << GetCurrentWorkingDirectory() << G4endl; |
| 240 | newCommand = nullString; |
| 241 | } |
| 242 | else if (nC == "cwd") { // ... by shell |
| 243 | shell->ShowCurrentDirectory(); |
| 244 | newCommand = nullString; |
| 245 | } |
| 246 | else if (nC == "cd" || nC.substr(0, 3) == "cd ") { // "cd" |
| 247 | ChangeDirectoryCommand(nC); |
| 248 | shell->SetCurrentDirectory(GetCurrentWorkingDirectory()); |
| 249 | newCommand = nullString; |
| 250 | } |
| 251 | else if (nC == "help" || nC.substr(0, 5) == "help ") { // "help" |
| 252 | TerminalHelp(nC); |
| 253 | newCommand = nullString; |
| 254 | } |
| 255 | else if (nC[0] == '?') { // "show current value of a parameter" |
| 256 | ShowCurrent(nC); |
| 257 | newCommand = nullString; |
| 258 | } |
| 259 | else if (nC == "hist" || nC == "history") { // "hist/history" |
| 260 | G4int nh = UI->GetNumberOfHistory(); |
| 261 | for (G4int i = 0; i < nh; i++) { |
| 262 | G4cout << i << ": " << UI->GetPreviousCommand(i) << G4endl; |
| 263 | } |
| 264 | newCommand = nullString; |
| 265 | } |
| 266 | else if (nC[0] == '!') { // "!" |
| 267 | G4String ss = nC.substr(1, nC.length() - 1); |
| 268 | G4int vl; |
| 269 | const char* tt = ss; |
| 270 | std::istringstream is(tt); |
| 271 | is >> vl; |
| 272 | G4int nh = UI->GetNumberOfHistory(); |
no test coverage detected