source: trunk/geant4/interfaces/basic/include/G4VUIshell.hh @ 526

Last change on this file since 526 was 483, checked in by garnier, 17 years ago

r569@mac-90108: laurentgarnier | 2007-06-05 15:53:34 +0200
version contre geant4.8.2.p01

File size: 4.2 KB
Line 
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,v 1.6 2006/06/29 19:09:41 gunter Exp $
28// GEANT4 tag $Name: geant4-08-01-patch-01 $
29//
30
31#ifndef G4VUIshell_h
32#define G4VUIshell_h 1
33
34#include "globals.hh"
35
36//
37//   Description:
38//   This class is the abstract base class for various UI shells.
39//
40//   GetCommadLine() (virtual) returns a command string input from
41//    a commad line.
42//
43//   Two pre-inplemented shell commands(still virtual) are also included,
44//   (somewhat differnt flavor from ones provided by G4VBasicShell)
45//     ShowCurrentDirectory()   ... show current directory
46//     ListCommand()            ... list commands
47//
48//   [prompt string substitution] (default)
49//   %s ... current application status
50//   %/ ... current working directory
51//
52
53// terminal color index
54enum TermColorIndex{ BLACK=0, RED, GREEN, YELLOW, 
55                     BLUE, PURPLE, CYAN, WHITE};
56
57class G4UIcommandTree;
58
59class G4VUIshell {
60protected:
61  G4String promptSetting; // including %-directive
62  G4String promptString;
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
69  TermColorIndex directoryColor;
70  TermColorIndex commandColor;
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
81public:
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);
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 GetCommandLine(const char* msg=0)= 0;
97};
98
99
100// inlines...
101inline void G4VUIshell::SetNColumn(G4int ncol)
102{
103  nColumn= ncol;
104}
105
106inline void G4VUIshell::SetPrompt(const G4String& prompt)
107{
108  promptSetting= prompt;
109}
110
111inline void G4VUIshell::SetCurrentDirectory(const G4String& dir)
112{
113  currentCommandDir= dir;
114}
115
116inline void G4VUIshell::ShowCurrentDirectory() const
117{
118  G4cout << currentCommandDir << G4endl;
119}
120
121#endif
Note: See TracBrowser for help on using the repository browser.