ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4VUIshell.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4VUIshell.hh
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 
56 class G4UIcommandTree;
57 
58 class G4VUIshell {
59 protected:
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
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 
80 public:
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 // ====================================================================
104 inline void G4VUIshell::SetNColumn(G4int ncol)
105 {
106  nColumn= ncol;
107 }
108 
109 inline void G4VUIshell::SetPrompt(const G4String& prompt)
110 {
111  promptSetting= prompt;
112 }
113 
115 {
117 }
118 
120 {
121 }
122 
124 {
126 }
127 
128 #endif