41 strESC+
"[30m", strESC+
"[31m", strESC+
"[32m", strESC+
"[33m",
42 strESC+
"[34m", strESC+
"[35m", strESC+
"[36m", strESC+
"[37m"
47 : promptSetting(prompt), promptString(
""), nColumn(80),
49 currentCommandDir(
"/")
129 if(absPath.length()==0)
return NULL;
130 if(absPath[absPath.length()-1] !=
'/')
return NULL;
131 if(absPath==
"/")
return cmdTree;
133 for(
G4int indx=1; indx<
G4int(absPath.length())-1; ) {
135 if(jslash !=
G4int(G4String::npos)) {
137 cmdTree= cmdTree-> GetTree(
G4String(absPath(0,jslash+1)));
142 if(cmdTree == NULL)
return NULL;
150 if(apath.empty())
return apath;
155 if(apath[(
size_t)0] !=
'/') bpath= currentCommandDir + apath;
159 for(
G4int indx=1; indx<=
G4int(bpath.length())-1; ) {
165 if(jslash !=
G4int(G4String::npos)) {
166 if(bpath.substr(indx,jslash-indx) ==
".."){
171 if(absPath.length() >= 2) {
172 absPath.
remove(absPath.length()-1);
174 if(jpre !=
G4int(G4String::npos)) absPath.
remove(jpre+1);
176 }
else if(bpath.substr(indx,jslash-indx) ==
"."){
178 if( !(jslash==indx && bpath(indx)==
'/') )
179 absPath+= bpath(indx, jslash-indx+1);
196 if(apath.empty())
return apath;
198 G4int lstr= apath.length();
202 if(apath[(
size_t)(lstr-1)]==
'/') Qsla=
TRUE;
206 for(
G4int i=lstr-1; i>=0; i--) {
207 if(Qsla && apath[(
size_t)i]!=
'/') Qsla=
FALSE;
208 if(apath[(
size_t)i]==
'/' && !Qsla) {
214 if(indx==-1)
return apath;
216 if(indx==0 && lstr==1) {
222 newPath= newPath(indx+1,lstr-indx-1);
244 if(! input.empty()) {
246 for(
G4int i=len-1; i>=0; i--) {
247 if(input[(
size_t)i]==
'/') {
253 if(indx != -1) vpath= GetAbsCommandDirPath(input(0,indx+1));
254 if(!(indx==0 && len==1)) vcmd= input(indx+1,len-indx-1);
261 if(GetCommandTree(tmpstr) != NULL) {
270 G4cout <<
"<" << input <<
">: No such directory" <<
G4endl;
278 G4int Ndir= atree-> GetTreeEntry();
279 G4int Ncmd= atree-> GetCommandEntry();
280 if(Ndir==0 && Ncmd==0)
return;
283 for(
G4int idir=1; idir<=Ndir; idir++) {
284 if(idir==1 && lsColorFlag) stream+= TermColorString[directoryColor];
285 G4String fpdir= atree-> GetTree(idir)-> GetPathName();
287 if(candidate.empty()) {
288 if(vcmd==
"" || fpdir==inputpath) {
289 stream+= GetCommandPathTail(fpdir); stream+=
" ";
293 if( fpdir.
index(candidate, 0) == 0) {
294 stream+= GetCommandPathTail(fpdir); stream+=
" ";
300 for(
G4int icmd=1; icmd<=Ncmd; icmd++){
301 if(icmd==1 && lsColorFlag) stream+= TermColorString[commandColor];
302 G4String fpcmd= atree-> GetPathName() +
303 atree-> GetCommand(icmd) -> GetCommandName();
305 if(candidate.empty()) {
306 if(vcmd==
"" || fpcmd==inputpath) {
307 stream+= GetCommandPathTail(fpcmd); stream+=
"* ";
311 if( fpcmd.
index(candidate, 0) == 0) {
312 stream+= GetCommandPathTail(fpcmd); stream+=
"* ";
318 if(!isMatch && candidate.empty())
320 <<
">: No such directory or command" << std::flush;
324 arrayString.
Show(nColumn);
virtual void MakePrompt(const char *msg=0)
G4String GetCommandPathTail(const G4String &apath) const
G4String & remove(str_size)
G4String strip(G4int strip_Type=trailing, char c=' ')
static const G4String strESC
virtual void ListCommand(const G4String &input, const G4String &candidate="") const
static G4UImanager * GetUIpointer()
G4String GetAbsCommandDirPath(const G4String &apath) const
static G4StateManager * GetStateManager()
static const G4String TermColorString[8]
G4GLOB_DLL std::ostream G4cout
str_size index(const char *, G4int pos=0) const
G4ApplicationState GetCurrentState() const
G4UIcommandTree * GetCommandTree(const G4String &dir) const
virtual void ResetTerminal()
G4String & append(const G4String &)
G4String currentCommandDir
G4VUIshell(const G4String &prompt="> ")