Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:28

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 //
0028 
0029 #ifndef G4VUIshell_h
0030 #define G4VUIshell_h 1
0031 
0032 #include "globals.hh"
0033 
0034 // ====================================================================
0035 //   Description:
0036 //   This class is the abstract base class for various UI shells.
0037 //
0038 //   GetCommadLineString() (virtual) returns a command string input from
0039 //    a commad line.
0040 //
0041 //   Two pre-inplemented shell commands(still virtual) are also included,
0042 //   (somewhat differnt flavor from ones provided by G4VBasicShell)
0043 //     ShowCurrentDirectory()   ... show current directory
0044 //     ListCommand()            ... list commands
0045 //
0046 //   [prompt string substitution] (default)
0047 //   %s ... current application status
0048 //   %/ ... current working directory
0049 //
0050 // ====================================================================
0051 
0052 // terminal color index
0053 enum TermColorIndex
0054 {
0055   BLACK = 0,
0056   RED,
0057   GREEN,
0058   YELLOW,
0059   BLUE,
0060   PURPLE,
0061   CYAN,
0062   WHITE
0063 };
0064 
0065 class G4UIcommandTree;
0066 
0067 class G4VUIshell
0068 {
0069  public:
0070   G4VUIshell(const G4String& prompt = "> ");
0071   virtual ~G4VUIshell();
0072 
0073   void SetNColumn(G4int ncol);
0074   void SetPrompt(const G4String& prompt);
0075   void SetCurrentDirectory(const G4String& ccd);
0076   virtual void SetLsColor(TermColorIndex, TermColorIndex);
0077 
0078   // shell commands
0079   virtual void ShowCurrentDirectory() const;
0080 
0081   //  "candidate" is specified with full path.
0082   virtual void ListCommand(const G4String& input, const G4String& candidate = "") const;
0083 
0084   // get command string from a command line
0085   virtual G4String GetCommandLineString(const char* msg = nullptr) = 0;
0086 
0087   virtual void ResetTerminal();
0088 
0089  protected:
0090   // make prompt string
0091   virtual void MakePrompt(const char* msg = nullptr); 
0092 
0093   // get tree node
0094   G4UIcommandTree* GetCommandTree(const G4String& dir) const;
0095 
0096   // absolute path name (ignore command)
0097   G4String GetAbsCommandDirPath(const G4String& apath) const;
0098   
0099   // tail of path ( xxx/xxx/zzz -> zzz, trancated //// -> /)
0100   G4String GetCommandPathTail(const G4String& apath) const;
0101 
0102   G4String promptSetting;  // including %-directive
0103   G4String promptString;
0104   G4int nColumn;  // column size of terminal (default=80)
0105 
0106   // color code support (effective if your terminal supports color code.)
0107   // default setting is off.
0108   G4bool lsColorFlag;  // color flag for list command
0109   TermColorIndex directoryColor;
0110   TermColorIndex commandColor;
0111 
0112   // for treating G4 command tree...
0113   G4String currentCommandDir;  // current command directory (absolute path)
0114 };
0115 
0116 // ====================================================================
0117 //   inline functions
0118 // ====================================================================
0119 inline void G4VUIshell::SetNColumn(G4int ncol) { nColumn = ncol; }
0120 
0121 inline void G4VUIshell::SetPrompt(const G4String& prompt) { promptSetting = prompt; }
0122 
0123 inline void G4VUIshell::SetCurrentDirectory(const G4String& dir) { currentCommandDir = dir; }
0124 
0125 inline void G4VUIshell::SetLsColor(TermColorIndex, TermColorIndex) {}
0126 
0127 inline void G4VUIshell::ShowCurrentDirectory() const { G4cout << currentCommandDir << G4endl; }
0128 
0129 #endif