Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VUIshell.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27//
28
29#ifndef G4VUIshell_h
30#define G4VUIshell_h 1
31
32#include "globals.hh"
33
34// ====================================================================
35// Description:
36// This class is the abstract base class for various UI shells.
37//
38// GetCommadLineString() (virtual) returns a command string input from
39// a commad line.
40//
41// Two pre-inplemented shell commands(still virtual) are also included,
42// (somewhat differnt flavor from ones provided by G4VBasicShell)
43// ShowCurrentDirectory() ... show current directory
44// ListCommand() ... list commands
45//
46// [prompt string substitution] (default)
47// %s ... current application status
48// %/ ... current working directory
49//
50// ====================================================================
51
52// terminal color index
55
56class G4UIcommandTree;
57
59protected:
60 G4String promptSetting; // including %-directive
62 virtual void MakePrompt(const char* msg=0); // make prompt string
63 G4int nColumn; // column size of terminal (default=80)
64
65 // color code support (effective if your terminal supports color code.)
66 // default setting is off.
67 G4bool lsColorFlag; // color flag for list command
70
71 // for treating G4 command tree...
72 G4String currentCommandDir; // current command directory (absolute path)
73 // get tree node
74 G4UIcommandTree* GetCommandTree(const G4String& dir) const;
75 // absolute path name (ignore command)
76 G4String GetAbsCommandDirPath(const G4String& apath) const;
77 // tail of path ( xxx/xxx/zzz -> zzz, trancated //// -> /)
78 G4String GetCommandPathTail(const G4String& apath) const;
79
80public:
81 G4VUIshell(const G4String& prompt="> ");
82 virtual ~G4VUIshell();
83
84 void SetNColumn(G4int ncol);
85 void SetPrompt(const G4String& prompt);
86 void SetCurrentDirectory(const G4String& ccd);
88
89 // shell commands
90 virtual void ShowCurrentDirectory() const;
91 virtual void ListCommand(const G4String& input,
92 const G4String& candidate="") const;
93 // "candidate" is specified with full path.
94
95 // get command string from a command line
96 virtual G4String GetCommandLineString(const char* msg=0)= 0;
97
98 virtual void ResetTerminal();
99};
100
101// ====================================================================
102// inline functions
103// ====================================================================
105{
106 nColumn= ncol;
107}
108
109inline void G4VUIshell::SetPrompt(const G4String& prompt)
110{
111 promptSetting= prompt;
112}
113
115{
117}
118
120{
121}
122
124{
126}
127
128#endif
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
TermColorIndex
Definition: G4VUIshell.hh:53
@ PURPLE
Definition: G4VUIshell.hh:54
@ WHITE
Definition: G4VUIshell.hh:54
@ BLUE
Definition: G4VUIshell.hh:54
@ GREEN
Definition: G4VUIshell.hh:53
@ CYAN
Definition: G4VUIshell.hh:54
@ YELLOW
Definition: G4VUIshell.hh:53
@ BLACK
Definition: G4VUIshell.hh:53
@ RED
Definition: G4VUIshell.hh:53
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
TermColorIndex directoryColor
Definition: G4VUIshell.hh:68
G4int nColumn
Definition: G4VUIshell.hh:63
virtual void ResetTerminal()
Definition: G4VUIshell.cc:107
virtual void MakePrompt(const char *msg=0)
Definition: G4VUIshell.cc:60
virtual void ListCommand(const G4String &input, const G4String &candidate="") const
Definition: G4VUIshell.cc:230
void SetNColumn(G4int ncol)
Definition: G4VUIshell.hh:104
virtual void ShowCurrentDirectory() const
Definition: G4VUIshell.hh:123
G4UIcommandTree * GetCommandTree(const G4String &dir) const
Definition: G4VUIshell.cc:117
G4String currentCommandDir
Definition: G4VUIshell.hh:72
TermColorIndex commandColor
Definition: G4VUIshell.hh:69
G4String promptString
Definition: G4VUIshell.hh:61
void SetCurrentDirectory(const G4String &ccd)
Definition: G4VUIshell.hh:114
G4bool lsColorFlag
Definition: G4VUIshell.hh:67
virtual void SetLsColor(TermColorIndex, TermColorIndex)
Definition: G4VUIshell.hh:119
void SetPrompt(const G4String &prompt)
Definition: G4VUIshell.hh:109
G4String promptSetting
Definition: G4VUIshell.hh:60
G4String GetCommandPathTail(const G4String &apath) const
Definition: G4VUIshell.cc:192
virtual ~G4VUIshell()
Definition: G4VUIshell.cc:54
G4String GetAbsCommandDirPath(const G4String &apath) const
Definition: G4VUIshell.cc:146
virtual G4String GetCommandLineString(const char *msg=0)=0