32 #if defined(G4UI_BUILD_QT_SESSION)
37 #if defined(G4UI_BUILD_WT_SESSION)
42 #if defined(G4UI_BUILD_XM_SESSION)
46 #if defined(G4UI_BUILD_WIN32_SESSION)
58 #if defined(G4UI_BUILD_QT_SESSION)
64 #if defined(G4UI_BUILD_XM_SESSION)
70 #if defined(G4UI_BUILD_WIN32_SESSION)
76 #if defined(G4UI_BUILD_WT_SESSION)
88 #define DISCARD_PARAMETER(p) (void)p
92 : selected(
kNone),
session(NULL), shell(NULL), isGUI(false)
94 G4cout <<
"Available UI session types: [ ";
107 if (type !=
"") SelectSessionByArg(stype);
110 if ( selected == kNone ) SelectSessionByEnv();
113 if ( selected == kNone ) {
116 size_t islash = appinput.find_last_of(
"/\\");
117 if (islash == G4String::npos)
120 appname = appinput(islash+1, appinput.size()-islash-1);
122 SelectSessionByFile(appname);
126 if ( selected == kNone) SelectSessionByBestGuess();
129 switch ( selected ) {
131 #if defined(G4UI_BUILD_QT_SESSION)
132 session =
new G4UIQt(argc, argv);
137 #if defined(G4UI_BUILD_XM_SESSION)
138 session =
new G4UIXm(argc, argv);
143 #if defined(G4UI_BUILD_WIN32_SESSION)
146 session =
new G4UIWin32();
150 #if defined(G4UI_BUILD_WT_SESSION)
151 session =
new G4UIWt(argc, argv);
179 if ( session == NULL ) {
183 "Specified session type is not build in your system,\n"
184 "or no session type is specified.\n"
185 "A fallback session type is used.");
198 if ( selected != kWt )
delete session;
202 void G4UIExecutive::SelectSessionByArg(
const G4String& stype)
204 if (
qt_build && stype ==
"qt" ) selected = kQt;
205 else if (
xm_build && stype ==
"xm" ) selected = kXm;
206 else if (
win32_build && stype ==
"win32" ) selected = kWin32;
207 else if (
wt_build && stype ==
"wt" ) selected = kWt;
208 else if ( stype ==
"gag" ) selected = kGag;
209 else if (
tcsh_build && stype ==
"tcsh" ) selected = kTcsh;
210 else if ( stype ==
"csh" ) selected = kCsh;
214 void G4UIExecutive::SelectSessionByEnv()
216 if (
qt_build && getenv(
"G4UI_USE_QT") ) selected = kQt;
217 else if (
xm_build && getenv(
"G4UI_USE_XM") ) selected = kXm;
218 else if (
win32_build && getenv(
"G4UI_USE_WIN32") ) selected = kWin32;
219 else if (
wt_build && getenv(
"G4UI_USE_WT") ) selected = kWt;
220 else if ( getenv(
"G4UI_USE_GAG") ) selected = kGag;
221 else if (
tcsh_build && getenv(
"G4UI_USE_TCSH") ) selected = kTcsh;
225 void G4UIExecutive::SelectSessionByFile(
const G4String& appname)
227 const char* path = getenv(
"HOME");
228 if( path == NULL )
return;
234 G4String fname= homedir +
"\\.g4session";
237 std::ifstream fsession;
240 fsession.open(fname, std::ios::in);
245 while( fsession.good() ) {
246 if( fsession.eof())
break;
247 fsession.getline(linebuf,
BUFSIZE);
250 if ( aline(0) ==
'#' )
continue;
252 default_session = aline;
254 size_t idx = aline.find_first_of(
" ");
255 if ( idx == G4String::npos )
break;
256 G4String aname = aline.substr(0, idx);
257 idx = aline.find_first_not_of(
" ", idx);
258 if (idx == G4String::npos )
break;
259 G4String sname = aline.substr(idx, aline.size()-idx);
260 sessionMap[aname] = sname;
267 std::map<G4String, G4String>::iterator it = sessionMap.find(appname);
268 if ( it != sessionMap.end() ) stype = sessionMap[appname];
269 else stype = default_session;
273 if (
qt_build && stype ==
"qt" ) selected = kQt;
274 else if (
xm_build && stype ==
"xm" ) selected = kXm;
275 else if (
win32_build && stype ==
"win32" ) selected = kWin32;
277 else if ( stype ==
"gag" ) selected = kGag;
278 else if (
tcsh_build && stype ==
"tcsh" ) selected = kTcsh;
279 else if ( stype ==
"csh" ) selected = kCsh;
283 void G4UIExecutive::SelectSessionByBestGuess()
287 else if (
xm_build ) selected = kXm;
300 if(shell) shell->
SetLsColor(dirColor, cmdColor);
void SetLsColor(TermColorIndex dirColor, TermColorIndex cmdColor)
static const G4bool wt_build
static const G4bool win32_build
G4String strip(G4int strip_Type=trailing, char c=' ')
static const G4bool qt_build
#define DISCARD_PARAMETER(p)
void SetPrompt(const G4String &prompt)
G4GLOB_DLL std::ostream G4cout
G4UIExecutive(G4int argc, char **argv, const G4String &type="")
static const G4bool xm_build
static G4UIterminal * session
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static const G4bool tcsh_build