Geant4  10.02.p01
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 // $Id: G4VUIshell.hh 66892 2013-01-17 10:57:59Z gunter $
28 //
29 
30 #ifndef G4VUIshell_h
31 #define G4VUIshell_h 1
32 
33 #include "globals.hh"
34 
35 // ====================================================================
36 // Description:
37 // This class is the abstract base class for various UI shells.
38 //
39 // GetCommadLineString() (virtual) returns a command string input from
40 // a commad line.
41 //
42 // Two pre-inplemented shell commands(still virtual) are also included,
43 // (somewhat differnt flavor from ones provided by G4VBasicShell)
44 // ShowCurrentDirectory() ... show current directory
45 // ListCommand() ... list commands
46 //
47 // [prompt string substitution] (default)
48 // %s ... current application status
49 // %/ ... current working directory
50 //
51 // ====================================================================
52 
53 // terminal color index
56 
57 class G4UIcommandTree;
58 
59 class G4VUIshell {
60 protected:
61  G4String promptSetting; // including %-directive
63  virtual void MakePrompt(const char* msg=0); // make prompt string
64  G4int nColumn; // column size of terminal (default=80)
65 
66  // color code support (effective if your terminal supports color code.)
67  // default setting is off.
68  G4bool lsColorFlag; // color flag for list command
71 
72  // for treating G4 command tree...
73  G4String currentCommandDir; // current command directory (absolute path)
74  // get tree node
75  G4UIcommandTree* GetCommandTree(const G4String& dir) const;
76  // absolute path name (ignore command)
77  G4String GetAbsCommandDirPath(const G4String& apath) const;
78  // tail of path ( xxx/xxx/zzz -> zzz, trancated //// -> /)
79  G4String GetCommandPathTail(const G4String& apath) const;
80 
81 public:
82  G4VUIshell(const G4String& prompt="> ");
83  virtual ~G4VUIshell();
84 
85  void SetNColumn(G4int ncol);
86  void SetPrompt(const G4String& prompt);
87  void SetCurrentDirectory(const G4String& ccd);
89 
90  // shell commands
91  virtual void ShowCurrentDirectory() const;
92  virtual void ListCommand(const G4String& input,
93  const G4String& candidate="") const;
94  // "candidate" is specified with full path.
95 
96  // get command string from a command line
97  virtual G4String GetCommandLineString(const char* msg=0)= 0;
98 
99  virtual void ResetTerminal();
100 };
101 
102 // ====================================================================
103 // inline functions
104 // ====================================================================
105 inline void G4VUIshell::SetNColumn(G4int ncol)
106 {
107  nColumn= ncol;
108 }
109 
110 inline void G4VUIshell::SetPrompt(const G4String& prompt)
111 {
112  promptSetting= prompt;
113 }
114 
116 {
117  currentCommandDir= dir;
118 }
119 
121 {
122 }
123 
125 {
127 }
128 
129 #endif
virtual void MakePrompt(const char *msg=0)
Definition: G4VUIshell.cc:61
G4String GetCommandPathTail(const G4String &apath) const
Definition: G4VUIshell.cc:193
G4String promptString
Definition: G4VUIshell.hh:62
TermColorIndex directoryColor
Definition: G4VUIshell.hh:69
void SetNColumn(G4int ncol)
Definition: G4VUIshell.hh:105
void SetPrompt(const G4String &prompt)
Definition: G4VUIshell.hh:110
virtual void ListCommand(const G4String &input, const G4String &candidate="") const
Definition: G4VUIshell.cc:231
int G4int
Definition: G4Types.hh:78
G4String GetAbsCommandDirPath(const G4String &apath) const
Definition: G4VUIshell.cc:147
TermColorIndex commandColor
Definition: G4VUIshell.hh:70
G4GLOB_DLL std::ostream G4cout
G4int nColumn
Definition: G4VUIshell.hh:64
virtual ~G4VUIshell()
Definition: G4VUIshell.cc:55
bool G4bool
Definition: G4Types.hh:79
G4bool lsColorFlag
Definition: G4VUIshell.hh:68
virtual void SetLsColor(TermColorIndex, TermColorIndex)
Definition: G4VUIshell.hh:120
G4UIcommandTree * GetCommandTree(const G4String &dir) const
Definition: G4VUIshell.cc:118
virtual void ResetTerminal()
Definition: G4VUIshell.cc:108
TermColorIndex
Definition: G4VUIshell.hh:54
G4String currentCommandDir
Definition: G4VUIshell.hh:73
#define G4endl
Definition: G4ios.hh:61
virtual G4String GetCommandLineString(const char *msg=0)=0
G4String promptSetting
Definition: G4VUIshell.hh:61
virtual void ShowCurrentDirectory() const
Definition: G4VUIshell.hh:124
G4VUIshell(const G4String &prompt="> ")
Definition: G4VUIshell.cc:46
void SetCurrentDirectory(const G4String &ccd)
Definition: G4VUIshell.hh:115