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

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

Correction du ticket #99 et #85

File size: 4.5 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.7 2007/06/14 05:44:58 kmura Exp $
28// GEANT4 tag $Name: geant4-09-00-ref-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
54// terminal color index
55enum TermColorIndex{ BLACK=0, RED, GREEN, YELLOW, 
56                     BLUE, PURPLE, CYAN, WHITE};
57
58class G4UIcommandTree;
59
60class G4VUIshell {
61protected:
62  G4String promptSetting; // including %-directive
63  G4String promptString;
64  virtual void MakePrompt(const char* msg=0);  // make prompt string
65  G4int nColumn;  // column size of terminal (default=80)
66
67  // color code support (effective if your terminal supports color code.)
68  // default setting is off.
69  G4bool lsColorFlag; // color flag for list command
70  TermColorIndex directoryColor;
71  TermColorIndex commandColor;
72
73  // for treating G4 command tree...
74  G4String currentCommandDir; // current command directory (absolute path)
75  // get tree node
76  G4UIcommandTree* GetCommandTree(const G4String& dir) const; 
77  // absolute path name (ignore command)
78  G4String GetAbsCommandDirPath(const G4String& apath) const;   
79  // tail of path ( xxx/xxx/zzz -> zzz, trancated //// -> /)
80  G4String GetCommandPathTail(const G4String& apath) const; 
81
82public:
83  G4VUIshell(const G4String& prompt="> ");
84  virtual ~G4VUIshell();
85
86  void SetNColumn(G4int ncol);
87  void SetPrompt(const G4String& prompt);
88  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 GetCommandLine(const char* msg=0)= 0;
98
99  virtual void ResetTerminal();
100};
101
102// ====================================================================
103//   inline functions
104// ====================================================================
105inline void G4VUIshell::SetNColumn(G4int ncol)
106{
107  nColumn= ncol;
108}
109
110inline void G4VUIshell::SetPrompt(const G4String& prompt)
111{
112  promptSetting= prompt;
113}
114
115inline void G4VUIshell::SetCurrentDirectory(const G4String& dir)
116{
117  currentCommandDir= dir;
118}
119
120inline void G4VUIshell::ShowCurrentDirectory() const
121{
122  G4cout << currentCommandDir << G4endl;
123}
124
125#endif
Note: See TracBrowser for help on using the repository browser.