source: trunk/source/interfaces/basic/include/G4VUIshell.hh@ 1178

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

maj en aussi sur CVS

File size: 4.6 KB
RevLine 
[476]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//
[1043]27// $Id: G4VUIshell.hh,v 1.8 2009/05/13 09:01:36 kmura Exp $
28// GEANT4 tag $Name: $
[476]29//
30
31#ifndef G4VUIshell_h
32#define G4VUIshell_h 1
33
34#include "globals.hh"
35
[593]36// ====================================================================
[476]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//
[593]52// ====================================================================
[476]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);
[1043]89 virtual void SetLsColor(TermColorIndex, TermColorIndex);
[476]90
91 // shell commands
92 virtual void ShowCurrentDirectory() const;
93 virtual void ListCommand(const G4String& input,
94 const G4String& candidate="") const;
95 // "candidate" is specified with full path.
96
97 // get command string from a command line
98 virtual G4String GetCommandLine(const char* msg=0)= 0;
[593]99
100 virtual void ResetTerminal();
[476]101};
102
[593]103// ====================================================================
104// inline functions
105// ====================================================================
[476]106inline void G4VUIshell::SetNColumn(G4int ncol)
107{
108 nColumn= ncol;
109}
110
111inline void G4VUIshell::SetPrompt(const G4String& prompt)
112{
113 promptSetting= prompt;
114}
115
116inline void G4VUIshell::SetCurrentDirectory(const G4String& dir)
117{
118 currentCommandDir= dir;
119}
120
[1043]121inline void G4VUIshell::SetLsColor(TermColorIndex, TermColorIndex)
122{
123}
124
[476]125inline void G4VUIshell::ShowCurrentDirectory() const
126{
127 G4cout << currentCommandDir << G4endl;
128}
129
130#endif
Note: See TracBrowser for help on using the repository browser.