[571] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
---|
| 2 | <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> |
---|
| 3 | <title>G4VUIshell.cc Source File</title> |
---|
| 4 | <link href="doxygen.css" rel="stylesheet" type="text/css"> |
---|
| 5 | </head><body> |
---|
| 6 | <!-- Generated by Doxygen 1.3.4 --> |
---|
| 7 | <div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a></div> |
---|
| 8 | <h1>G4VUIshell.cc</h1><a href="G4VUIshell_8cc.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">//</span> |
---|
| 9 | 00002 <span class="comment">// ********************************************************************</span> |
---|
| 10 | 00003 <span class="comment">// * License and Disclaimer *</span> |
---|
| 11 | 00004 <span class="comment">// * *</span> |
---|
| 12 | 00005 <span class="comment">// * The Geant4 software is copyright of the Copyright Holders of *</span> |
---|
| 13 | 00006 <span class="comment">// * the Geant4 Collaboration. It is provided under the terms and *</span> |
---|
| 14 | 00007 <span class="comment">// * conditions of the Geant4 Software License, included in the file *</span> |
---|
| 15 | 00008 <span class="comment">// * LICENSE and available at http://cern.ch/geant4/license . These *</span> |
---|
| 16 | 00009 <span class="comment">// * include a list of copyright holders. *</span> |
---|
| 17 | 00010 <span class="comment">// * *</span> |
---|
| 18 | 00011 <span class="comment">// * Neither the authors of this software system, nor their employing *</span> |
---|
| 19 | 00012 <span class="comment">// * institutes,nor the agencies providing financial support for this *</span> |
---|
| 20 | 00013 <span class="comment">// * work make any representation or warranty, express or implied, *</span> |
---|
| 21 | 00014 <span class="comment">// * regarding this software system or assume any liability for its *</span> |
---|
| 22 | 00015 <span class="comment">// * use. Please see the license in the file LICENSE and URL above *</span> |
---|
| 23 | 00016 <span class="comment">// * for the full disclaimer and the limitation of liability. *</span> |
---|
| 24 | 00017 <span class="comment">// * *</span> |
---|
| 25 | 00018 <span class="comment">// * This code implementation is the result of the scientific and *</span> |
---|
| 26 | 00019 <span class="comment">// * technical work of the GEANT4 collaboration. *</span> |
---|
| 27 | 00020 <span class="comment">// * By using, copying, modifying or distributing the software (or *</span> |
---|
| 28 | 00021 <span class="comment">// * any work based on the software) you agree to acknowledge its *</span> |
---|
| 29 | 00022 <span class="comment">// * use in resulting scientific publications, and indicate your *</span> |
---|
| 30 | 00023 <span class="comment">// * acceptance of all terms of the Geant4 Software license. *</span> |
---|
| 31 | 00024 <span class="comment">// ********************************************************************</span> |
---|
| 32 | 00025 <span class="comment">//</span> |
---|
| 33 | 00026 <span class="comment">//</span> |
---|
| 34 | 00027 <span class="comment">// $Id: G4VUIshell.cc,v 1.9 2006/06/29 19:09:59 gunter Exp $</span> |
---|
| 35 | 00028 <span class="comment">// GEANT4 tag $Name: geant4-08-01-patch-01 $</span> |
---|
| 36 | 00029 <span class="comment">//</span> |
---|
| 37 | 00030 |
---|
| 38 | 00031 <span class="preprocessor">#include "G4UImanager.hh"</span> |
---|
| 39 | 00032 <span class="preprocessor">#include "G4UIcommand.hh"</span> |
---|
| 40 | 00033 <span class="preprocessor">#include "G4UIcommandTree.hh"</span> |
---|
| 41 | 00034 <span class="preprocessor">#include "G4StateManager.hh"</span> |
---|
| 42 | 00035 <span class="preprocessor">#include "G4UIcommandStatus.hh"</span> |
---|
| 43 | 00036 <span class="preprocessor">#include "<a class="code" href="G4VUIshell_8hh.html">G4VUIshell.hh</a>"</span> |
---|
| 44 | 00037 <span class="preprocessor">#include "<a class="code" href="G4UIArrayString_8hh.html">G4UIArrayString.hh</a>"</span> |
---|
| 45 | 00038 |
---|
| 46 | 00039 <span class="comment">// terminal color string</span> |
---|
| 47 | <a name="l00040"></a><a class="code" href="G4VUIshell_8cc.html#a0">00040</a> <span class="keyword">static</span> <span class="keyword">const</span> G4String <a class="code" href="G4VUIshell_8cc.html#a0">strESC</a>= <span class="charliteral">'\033'</span>; |
---|
| 48 | <a name="l00041"></a><a class="code" href="G4VUIshell_8cc.html#a1">00041</a> <span class="keyword">static</span> <span class="keyword">const</span> G4String <a class="code" href="G4VUIshell_8cc.html#a1">TermColorString</a>[8] ={ |
---|
| 49 | 00042 <a class="code" href="G4VUIshell_8cc.html#a0">strESC</a>+<span class="stringliteral">"[30m"</span>, <a class="code" href="G4VUIshell_8cc.html#a0">strESC</a>+<span class="stringliteral">"[31m"</span>, <a class="code" href="G4VUIshell_8cc.html#a0">strESC</a>+<span class="stringliteral">"[32m"</span>, <a class="code" href="G4VUIshell_8cc.html#a0">strESC</a>+<span class="stringliteral">"[33m"</span>, |
---|
| 50 | 00043 <a class="code" href="G4VUIshell_8cc.html#a0">strESC</a>+<span class="stringliteral">"[34m"</span>, <a class="code" href="G4VUIshell_8cc.html#a0">strESC</a>+<span class="stringliteral">"[35m"</span>, <a class="code" href="G4VUIshell_8cc.html#a0">strESC</a>+<span class="stringliteral">"[36m"</span>, <a class="code" href="G4VUIshell_8cc.html#a0">strESC</a>+<span class="stringliteral">"[37m"</span> |
---|
| 51 | 00044 }; |
---|
| 52 | 00045 |
---|
| 53 | <a name="l00047"></a><a class="code" href="classG4VUIshell.html#a0">00047</a> <a class="code" href="classG4VUIshell.html#a0">G4VUIshell::G4VUIshell</a>(<span class="keyword">const</span> G4String& prompt) |
---|
| 54 | 00048 : promptSetting(prompt), promptString(""), nColumn(80), |
---|
| 55 | 00049 lsColorFlag(FALSE), directoryColor(<a class="code" href="G4VUIshell_8hh.html#a8a0">BLACK</a>), commandColor(<a class="code" href="G4VUIshell_8hh.html#a8a0">BLACK</a>), |
---|
| 56 | 00050 currentCommandDir("/") |
---|
| 57 | 00052 { |
---|
| 58 | 00053 } |
---|
| 59 | 00054 |
---|
| 60 | <a name="l00056"></a><a class="code" href="classG4VUIshell.html#a1">00056</a> <a class="code" href="classG4VUIshell.html#a1">G4VUIshell::~G4VUIshell</a>() |
---|
| 61 | 00058 { |
---|
| 62 | 00059 } |
---|
| 63 | 00060 |
---|
| 64 | <a name="l00062"></a><a class="code" href="classG4VUIshell.html#b0">00062</a> <span class="keywordtype">void</span> <a class="code" href="classG4VUIshell.html#b0">G4VUIshell::MakePrompt</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* msg) |
---|
| 65 | 00063 |
---|
| 66 | 00064 { |
---|
| 67 | 00065 <span class="keywordflow">if</span>(<a class="code" href="classG4VUIshell.html#p0">promptSetting</a>.length()<=1) { |
---|
| 68 | 00066 <a class="code" href="classG4VUIshell.html#p1">promptString</a>= <a class="code" href="classG4VUIshell.html#p0">promptSetting</a>; |
---|
| 69 | 00067 <span class="keywordflow">return</span>; |
---|
| 70 | 00068 } |
---|
| 71 | 00069 |
---|
| 72 | 00070 <a class="code" href="classG4VUIshell.html#p1">promptString</a>=<span class="stringliteral">""</span>; |
---|
| 73 | 00071 G4int i; |
---|
| 74 | 00072 <span class="keywordflow">for</span>(i=0; i<G4int(<a class="code" href="classG4VUIshell.html#p0">promptSetting</a>.length())-1; i++){ |
---|
| 75 | 00073 <span class="keywordflow">if</span>(<a class="code" href="classG4VUIshell.html#p0">promptSetting</a>[(size_t)i]==<span class="charliteral">'%'</span>){ |
---|
| 76 | 00074 <span class="keywordflow">switch</span> (<a class="code" href="classG4VUIshell.html#p0">promptSetting</a>[(size_t)(i+1)]) { |
---|
| 77 | 00075 <span class="keywordflow">case</span> <span class="charliteral">'s'</span>: <span class="comment">// current application status</span> |
---|
| 78 | 00076 { |
---|
| 79 | 00077 G4String stateStr; |
---|
| 80 | 00078 <span class="keywordflow">if</span>(msg) |
---|
| 81 | 00079 { stateStr = msg; } |
---|
| 82 | 00080 <span class="keywordflow">else</span> |
---|
| 83 | 00081 { |
---|
| 84 | 00082 G4StateManager* statM= G4StateManager::GetStateManager(); |
---|
| 85 | 00083 stateStr= statM-> GetStateString(statM->GetCurrentState()); |
---|
| 86 | 00084 } |
---|
| 87 | 00085 <a class="code" href="classG4VUIshell.html#p1">promptString</a>.append(stateStr); |
---|
| 88 | 00086 i++; |
---|
| 89 | 00087 } |
---|
| 90 | 00088 <span class="keywordflow">break</span>; |
---|
| 91 | 00089 <span class="keywordflow">case</span> <span class="charliteral">'/'</span>: <span class="comment">// current working directory</span> |
---|
| 92 | 00090 <a class="code" href="classG4VUIshell.html#p1">promptString</a>.append(<a class="code" href="classG4VUIshell.html#p6">currentCommandDir</a>); |
---|
| 93 | 00091 i++; |
---|
| 94 | 00092 <span class="keywordflow">break</span>; |
---|
| 95 | 00093 <span class="keywordflow">default</span>: |
---|
| 96 | 00094 <a class="code" href="classG4VUIshell.html#p1">promptString</a>.append(G4String(<a class="code" href="classG4VUIshell.html#p0">promptSetting</a>[(size_t)i])); |
---|
| 97 | 00095 <span class="keywordflow">break</span>; |
---|
| 98 | 00096 } |
---|
| 99 | 00097 } <span class="keywordflow">else</span> { |
---|
| 100 | 00098 <a class="code" href="classG4VUIshell.html#p1">promptString</a>.append(G4String(<a class="code" href="classG4VUIshell.html#p0">promptSetting</a>[(size_t)i])); |
---|
| 101 | 00099 } |
---|
| 102 | 00100 } |
---|
| 103 | 00101 |
---|
| 104 | 00102 <span class="comment">// append last chaacter</span> |
---|
| 105 | 00103 <span class="keywordflow">if</span>(i == G4int(<a class="code" href="classG4VUIshell.html#p0">promptSetting</a>.length())-1) |
---|
| 106 | 00104 <a class="code" href="classG4VUIshell.html#p1">promptString</a>.append(G4String(<a class="code" href="classG4VUIshell.html#p0">promptSetting</a>[(size_t)i])); |
---|
| 107 | 00105 } |
---|
| 108 | 00106 |
---|
| 109 | 00107 |
---|
| 110 | 00108 <span class="comment">// --------------------------------------------------------------------</span> |
---|
| 111 | 00109 <span class="comment">// G4command operations</span> |
---|
| 112 | 00110 <span class="comment">// --------------------------------------------------------------------</span> |
---|
| 113 | <a name="l00112"></a><a class="code" href="classG4VUIshell.html#b1">00112</a> <span class="comment"></span>G4UIcommandTree* <a class="code" href="classG4VUIshell.html#b1">G4VUIshell::GetCommandTree</a>(<span class="keyword">const</span> G4String& input) <span class="keyword">const</span> |
---|
| 114 | 00114 { |
---|
| 115 | 00115 G4UImanager* UI= G4UImanager::GetUIpointer(); |
---|
| 116 | 00116 |
---|
| 117 | 00117 G4UIcommandTree* cmdTree= UI-> GetTree(); <span class="comment">// root tree</span> |
---|
| 118 | 00118 |
---|
| 119 | 00119 G4String absPath= input; <span class="comment">// G4String::strip() CONST !!</span> |
---|
| 120 | 00120 absPath= GetAbsCommandDirPath(absPath.strip(G4String::both)); |
---|
| 121 | 00121 |
---|
| 122 | 00122 <span class="comment">// parsing absolute path ...</span> |
---|
| 123 | 00123 <span class="keywordflow">if</span>(absPath.length()==0) <span class="keywordflow">return</span> NULL; |
---|
| 124 | 00124 <span class="keywordflow">if</span>(absPath[absPath.length()-1] != <span class="charliteral">'/'</span>) <span class="keywordflow">return</span> NULL; <span class="comment">// error??</span> |
---|
| 125 | 00125 <span class="keywordflow">if</span>(absPath==<span class="stringliteral">"/"</span>) <span class="keywordflow">return</span> cmdTree; |
---|
| 126 | 00126 |
---|
| 127 | 00127 <span class="keywordflow">for</span>(G4int indx=1; indx<G4int(absPath.length())-1; ) { |
---|
| 128 | 00128 G4int jslash= absPath.index(<span class="stringliteral">"/"</span>, indx); <span class="comment">// search index begin with "/" </span> |
---|
| 129 | 00129 <span class="keywordflow">if</span>(jslash != G4int(G4String::npos)) { |
---|
| 130 | 00130 <span class="keywordflow">if</span>(cmdTree != NULL) |
---|
| 131 | 00131 cmdTree= cmdTree-> GetTree(G4String(absPath(0,jslash+1))); |
---|
| 132 | 00132 } |
---|
| 133 | 00133 indx= jslash+1; |
---|
| 134 | 00134 } |
---|
| 135 | 00135 |
---|
| 136 | 00136 <span class="keywordflow">if</span>(cmdTree == NULL) <span class="keywordflow">return</span> NULL; |
---|
| 137 | 00137 <span class="keywordflow">else</span> <span class="keywordflow">return</span> cmdTree; |
---|
| 138 | 00138 } |
---|
| 139 | 00139 |
---|
| 140 | <a name="l00141"></a><a class="code" href="classG4VUIshell.html#b2">00141</a> G4String <a class="code" href="classG4VUIshell.html#b2">G4VUIshell::GetAbsCommandDirPath</a>(<span class="keyword">const</span> G4String& apath) <span class="keyword">const</span> |
---|
| 141 | 00143 { |
---|
| 142 | 00144 <span class="keywordflow">if</span>(apath.empty()) <span class="keywordflow">return</span> apath; <span class="comment">// null string</span> |
---|
| 143 | 00145 |
---|
| 144 | 00146 <span class="comment">// if "apath" does not start with "/", </span> |
---|
| 145 | 00147 <span class="comment">// then it is treared as relative path</span> |
---|
| 146 | 00148 G4String bpath= apath; |
---|
| 147 | 00149 <span class="keywordflow">if</span>(apath[(size_t)0] != <span class="charliteral">'/'</span>) bpath= currentCommandDir + apath; |
---|
| 148 | 00150 |
---|
| 149 | 00151 <span class="comment">// parsing...</span> |
---|
| 150 | 00152 G4String absPath= <span class="stringliteral">"/"</span>; |
---|
| 151 | 00153 <span class="keywordflow">for</span>(G4int indx=1; indx<=G4int(bpath.length())-1; ) { |
---|
| 152 | 00154 G4int jslash= bpath.index(<span class="stringliteral">"/"</span>, indx); <span class="comment">// search index begin with "/"</span> |
---|
| 153 | 00155 <span class="keywordflow">if</span>(jslash != G4int(G4String::npos)) { |
---|
| 154 | 00156 <span class="keywordflow">if</span>(bpath(indx,jslash-indx) == <span class="stringliteral">".."</span>){ <span class="comment">// directory up</span> |
---|
| 155 | 00157 <span class="keywordflow">if</span>(absPath.length() >=1) { |
---|
| 156 | 00158 absPath.remove(absPath.length()-1); <span class="comment">// remove last "/"</span> |
---|
| 157 | 00159 G4int jpre= absPath.last(<span class="charliteral">'/'</span>); |
---|
| 158 | 00160 <span class="keywordflow">if</span>(jpre != G4int(G4String::npos)) absPath.remove(jpre+1); |
---|
| 159 | 00161 } |
---|
| 160 | 00162 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(bpath(indx,jslash-indx) == <span class="stringliteral">"."</span>){ <span class="comment">// nothing to do</span> |
---|
| 161 | 00163 } <span class="keywordflow">else</span> { <span class="comment">// add</span> |
---|
| 162 | 00164 <span class="keywordflow">if</span>( !(jslash==indx && bpath(indx)==<span class="charliteral">'/'</span>) ) <span class="comment">// truncate "////"</span> |
---|
| 163 | 00165 absPath+= bpath(indx, jslash-indx+1); |
---|
| 164 | 00166 <span class="comment">// better to be check directory existence. (it costs!)</span> |
---|
| 165 | 00167 } |
---|
| 166 | 00168 } <span class="keywordflow">else</span> { <span class="comment">// directory ONLY (ignore non-"/" terminated string)</span> |
---|
| 167 | 00169 } |
---|
| 168 | 00170 indx= jslash+1; |
---|
| 169 | 00171 } |
---|
| 170 | 00172 <span class="keywordflow">return</span> absPath; |
---|
| 171 | 00173 } |
---|
| 172 | 00174 |
---|
| 173 | 00175 |
---|
| 174 | <a name="l00177"></a><a class="code" href="classG4VUIshell.html#b3">00177</a> G4String <a class="code" href="classG4VUIshell.html#b3">G4VUIshell::GetCommandPathTail</a>(<span class="keyword">const</span> G4String& apath) <span class="keyword">const</span> |
---|
| 175 | 00179 { <span class="comment">// xxx/xxx/zzz -> zzz, trancate /// -> /</span> |
---|
| 176 | 00180 <span class="keywordflow">if</span>(apath.empty()) <span class="keywordflow">return</span> apath; |
---|
| 177 | 00181 |
---|
| 178 | 00182 G4int lstr= apath.length(); |
---|
| 179 | 00183 |
---|
| 180 | 00184 <span class="comment">// for trancating "/"</span> |
---|
| 181 | 00185 G4bool Qsla= FALSE; |
---|
| 182 | 00186 <span class="keywordflow">if</span>(apath[(size_t)(lstr-1)]==<span class="charliteral">'/'</span>) Qsla= TRUE; |
---|
| 183 | 00187 |
---|
| 184 | 00188 <span class="comment">// searching last '/' from tail</span> |
---|
| 185 | 00189 G4int indx= -1; |
---|
| 186 | 00190 <span class="keywordflow">for</span>(G4int i=lstr-1; i>=0; i--) { |
---|
| 187 | 00191 <span class="keywordflow">if</span>(Qsla && apath[(size_t)i]!=<span class="charliteral">'/'</span>) Qsla= FALSE; <span class="comment">// break "/" flag!!</span> |
---|
| 188 | 00192 <span class="keywordflow">if</span>(apath[(size_t)i]==<span class="charliteral">'/'</span> && !Qsla) { |
---|
| 189 | 00193 indx= i; |
---|
| 190 | 00194 <span class="keywordflow">break</span>; |
---|
| 191 | 00195 } |
---|
| 192 | 00196 } |
---|
| 193 | 00197 |
---|
| 194 | 00198 <span class="keywordflow">if</span>(indx==-1) <span class="keywordflow">return</span> apath; <span class="comment">// not found</span> |
---|
| 195 | 00199 |
---|
| 196 | 00200 <span class="keywordflow">if</span>(indx==0 && lstr==1) { <span class="comment">// "/"</span> |
---|
| 197 | 00201 G4String nullStr; |
---|
| 198 | 00202 <span class="keywordflow">return</span> nullStr; |
---|
| 199 | 00203 } <span class="keywordflow">else</span> { |
---|
| 200 | 00204 <span class="comment">//G4String newPath= apath(indx+1,lstr-indx-1); </span> |
---|
| 201 | 00205 G4String newPath= apath; |
---|
| 202 | 00206 newPath= newPath(indx+1,lstr-indx-1); |
---|
| 203 | 00207 <span class="keywordflow">return</span> newPath; |
---|
| 204 | 00208 } |
---|
| 205 | 00209 } |
---|
| 206 | 00210 |
---|
| 207 | 00211 <span class="comment">// --------------------------------------------------------------------</span> |
---|
| 208 | 00212 <span class="comment">// shell commands</span> |
---|
| 209 | 00213 <span class="comment">// --------------------------------------------------------------------</span> |
---|
| 210 | <a name="l00215"></a><a class="code" href="classG4VUIshell.html#a6">00215</a> <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="classG4VUIshell.html#a6">G4VUIshell::ListCommand</a>(<span class="keyword">const</span> G4String& dir, |
---|
| 211 | 00216 <span class="keyword">const</span> G4String& candidate) <span class="keyword">const</span> |
---|
| 212 | 00218 { |
---|
| 213 | 00219 <span class="comment">// specified directpry</span> |
---|
| 214 | 00220 G4String input= dir; <span class="comment">// ...</span> |
---|
| 215 | 00221 input= input.strip(G4String::both); |
---|
| 216 | 00222 |
---|
| 217 | 00223 <span class="comment">// command tree of "user specified directory"</span> |
---|
| 218 | 00224 G4String vpath= currentCommandDir; |
---|
| 219 | 00225 G4String vcmd; |
---|
| 220 | 00226 |
---|
| 221 | 00227 G4int len= input.length(); |
---|
| 222 | 00228 <span class="keywordflow">if</span>(! input.empty()) { |
---|
| 223 | 00229 G4int indx= -1; |
---|
| 224 | 00230 <span class="keywordflow">for</span>(G4int i=len-1; i>=0; i--) { <span class="comment">// search last '/'</span> |
---|
| 225 | 00231 <span class="keywordflow">if</span>(input[(size_t)i]==<span class="charliteral">'/'</span>) { |
---|
| 226 | 00232 indx= i; |
---|
| 227 | 00233 <span class="keywordflow">break</span>; |
---|
| 228 | 00234 } |
---|
| 229 | 00235 } |
---|
| 230 | 00236 <span class="comment">// get abs. path</span> |
---|
| 231 | 00237 <span class="keywordflow">if</span>(indx != -1) vpath= GetAbsCommandDirPath(input(0,indx+1)); |
---|
| 232 | 00238 <span class="keywordflow">if</span>(!(indx==0 && len==1)) vcmd= input(indx+1,len-indx-1); <span class="comment">// care for "/"</span> |
---|
| 233 | 00239 } |
---|
| 234 | 00240 |
---|
| 235 | 00241 <span class="comment">// check "vcmd" is directory?</span> |
---|
| 236 | 00242 G4String inputpath= vpath+vcmd; |
---|
| 237 | 00243 <span class="keywordflow">if</span>(! vcmd.empty()){ |
---|
| 238 | 00244 G4String tmpstr= inputpath + <span class="stringliteral">"/"</span>; |
---|
| 239 | 00245 <span class="keywordflow">if</span>(GetCommandTree(tmpstr) != NULL) { |
---|
| 240 | 00246 vpath= tmpstr; |
---|
| 241 | 00247 vcmd= <span class="stringliteral">""</span>; |
---|
| 242 | 00248 } |
---|
| 243 | 00249 } |
---|
| 244 | 00250 |
---|
| 245 | 00251 <span class="comment">// check "vpath" directory exists?</span> |
---|
| 246 | 00252 G4UIcommandTree* atree= GetCommandTree(vpath); |
---|
| 247 | 00253 <span class="keywordflow">if</span>(atree == NULL) { |
---|
| 248 | 00254 G4cout << <span class="stringliteral">"<"</span> << input << <span class="stringliteral">">: No such directory"</span> << G4endl; |
---|
| 249 | 00255 <span class="keywordflow">return</span>; |
---|
| 250 | 00256 } |
---|
| 251 | 00257 |
---|
| 252 | 00258 <span class="comment">// list matched directories/commands</span> |
---|
| 253 | 00259 G4String stream; |
---|
| 254 | 00260 G4bool isMatch= FALSE; |
---|
| 255 | 00261 |
---|
| 256 | 00262 G4int Ndir= atree-> GetTreeEntry(); |
---|
| 257 | 00263 G4int Ncmd= atree-> GetCommandEntry(); |
---|
| 258 | 00264 <span class="keywordflow">if</span>(Ndir==0 && Ncmd==0) <span class="keywordflow">return</span>; <span class="comment">// no contents</span> |
---|
| 259 | 00265 |
---|
| 260 | 00266 <span class="comment">// directory ...</span> |
---|
| 261 | 00267 <span class="keywordflow">for</span>(G4int idir=1; idir<=Ndir; idir++) { |
---|
| 262 | 00268 <span class="keywordflow">if</span>(idir==1 && lsColorFlag) stream+= <a class="code" href="G4VUIshell_8cc.html#a1">TermColorString</a>[directoryColor]; |
---|
| 263 | 00269 G4String fpdir= atree-> GetTree(idir)-> GetPathName(); |
---|
| 264 | 00270 <span class="comment">// matching test</span> |
---|
| 265 | 00271 <span class="keywordflow">if</span>(candidate.empty()) { <span class="comment">// list all</span> |
---|
| 266 | 00272 <span class="keywordflow">if</span>(vcmd==<span class="stringliteral">""</span> || fpdir==inputpath) { |
---|
| 267 | 00273 stream+= GetCommandPathTail(fpdir); stream+= <span class="stringliteral">" "</span>; |
---|
| 268 | 00274 isMatch= TRUE; |
---|
| 269 | 00275 } |
---|
| 270 | 00276 } <span class="keywordflow">else</span> { <span class="comment">// list only matched with candidate</span> |
---|
| 271 | 00277 <span class="keywordflow">if</span>( fpdir.index(candidate, 0) == 0) { |
---|
| 272 | 00278 stream+= GetCommandPathTail(fpdir); stream+= <span class="stringliteral">" "</span>; |
---|
| 273 | 00279 } |
---|
| 274 | 00280 } |
---|
| 275 | 00281 } |
---|
| 276 | 00282 |
---|
| 277 | 00283 <span class="comment">// command ...</span> |
---|
| 278 | 00284 <span class="keywordflow">for</span>(G4int icmd=1; icmd<=Ncmd; icmd++){ |
---|
| 279 | 00285 <span class="keywordflow">if</span>(icmd==1 && lsColorFlag) stream+= <a class="code" href="G4VUIshell_8cc.html#a1">TermColorString</a>[commandColor]; |
---|
| 280 | 00286 G4String fpcmd= atree-> GetPathName() + |
---|
| 281 | 00287 atree-> GetCommand(icmd) -> GetCommandName(); |
---|
| 282 | 00288 <span class="comment">// matching test</span> |
---|
| 283 | 00289 <span class="keywordflow">if</span>(candidate.empty()) { <span class="comment">// list all</span> |
---|
| 284 | 00290 <span class="keywordflow">if</span>(vcmd==<span class="stringliteral">""</span> || fpcmd==inputpath) { |
---|
| 285 | 00291 stream+= GetCommandPathTail(fpcmd); stream+= <span class="stringliteral">"* "</span>; |
---|
| 286 | 00292 isMatch= TRUE; |
---|
| 287 | 00293 } |
---|
| 288 | 00294 } <span class="keywordflow">else</span> { <span class="comment">// list only matched with candidate</span> |
---|
| 289 | 00295 <span class="keywordflow">if</span>( fpcmd.index(candidate, 0) == 0) { |
---|
| 290 | 00296 stream+= GetCommandPathTail(fpcmd); stream+= <span class="stringliteral">"* "</span>; |
---|
| 291 | 00297 } |
---|
| 292 | 00298 } |
---|
| 293 | 00299 } |
---|
| 294 | 00300 |
---|
| 295 | 00301 <span class="comment">// waring : not matched</span> |
---|
| 296 | 00302 <span class="keywordflow">if</span>(!isMatch && candidate.empty()) |
---|
| 297 | 00303 G4cout << <span class="stringliteral">"<"</span> << input |
---|
| 298 | 00304 << <span class="stringliteral">">: No such directory or command"</span> << std::flush; |
---|
| 299 | 00305 |
---|
| 300 | 00306 <span class="comment">// display</span> |
---|
| 301 | 00307 <a class="code" href="classG4UIArrayString.html">G4UIArrayString</a> arrayString(stream); |
---|
| 302 | 00308 arrayString.<a class="code" href="classG4UIArrayString.html#a2">Show</a>(nColumn); |
---|
| 303 | 00309 } |
---|
| 304 | </pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri Jun 22 11:07:02 2007 by |
---|
| 305 | <a href="http://www.doxygen.org/index.html"> |
---|
| 306 | <img src="doxygen.png" alt="doxygen" align="middle" border=0 > |
---|
| 307 | </a>1.3.4 </small></address> |
---|
| 308 | </body> |
---|
| 309 | </html> |
---|