ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
G4UItcsh.hh
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4UItcsh.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 G4UItcsh_h
30
#define G4UItcsh_h 1
31
32
#ifndef WIN32
33
34
#include <termios.h>
35
#include <vector>
36
#include "
G4VUIshell.hh
"
37
#include "
G4UIcommand.hh
"
38
#include "
G4UIcommandTree.hh
"
39
40
// ====================================================================
41
// Description:
42
// This class gives tcsh-like shell.
43
//
44
// If your terminal supports color code, colored strings are available
45
// in ListCommand(). For activating color support,
46
// e.g.
47
// tcsh-> SetLsColor(GREEN, CYAN); // (dir, command) color
48
//
49
// [key binding]
50
// ^A ... move cursor to the top
51
// ^B ... backward cursor ([LEFT])
52
// ^D ... delete/exit/show matched list
53
// ^E ... move cursor to the end
54
// ^F ... forward cursor ([RIGHT])
55
// ^K ... clear after the cursor
56
// ^L ... clear screen (not implemented)
57
// ^N ... next command ([DOWN])
58
// ^P ... previous command ([UP])
59
// TAB... command completion
60
// DEL... backspace
61
// BS ... backspace
62
//
63
// [prompt string substitution]
64
// %s ... current application status
65
// %/ ... current working directory
66
// %h ... history# (different from G4 history#)
67
//
68
// ====================================================================
69
70
class
G4UItcsh
:
public
G4VUIshell
{
71
protected
:
72
virtual
void
MakePrompt
(
const
char
* msg=0);
73
74
G4String
commandLine
;
// command line string;
75
G4int
cursorPosition
;
// cursor position
76
G4String
commandLineBuf
;
// temp. command line;
77
G4bool
IsCursorLast
()
const
;
78
// Is cursor position at the last of command line ?
79
80
void
InitializeCommandLine
();
81
G4String
ReadLine
();
82
void
InsertCharacter
(
char
cc);
// insert character
83
void
BackspaceCharacter
();
// backspace character
84
void
DeleteCharacter
();
// delete character
85
void
ClearLine
();
// clear command line
86
void
ClearAfterCursor
();
// clear after the cursor
87
void
ClearScreen
();
// clear screen
88
89
void
ForwardCursor
();
// move cursor forward
90
void
BackwardCursor
();
// move cursor backward
91
void
MoveCursorTop
();
// move cursor to the top
92
void
MoveCursorEnd
();
// move cursor to the end
93
94
void
NextCommand
();
// next command
95
void
PreviousCommand
();
// previous command
96
97
void
ListMatchedCommand
();
// list matched commands
98
void
CompleteCommand
();
// complete command
99
100
// utilities...
101
G4String
GetFirstMatchedString
(
const
G4String
& str1,
102
const
G4String
& str2)
const
;
103
104
// history functionality (history# is managed in itself)
105
std::vector<G4String>
commandHistory
;
106
G4int
maxHistory
;
// max# of histories stored
107
G4int
currentHistoryNo
;
// global
108
G4int
relativeHistoryIndex
;
// local index relative to current history#
109
110
void
StoreHistory
(
G4String
aCommand);
111
G4String
RestoreHistory
(
G4int
index);
// index is global history#
112
113
114
// (re)set termios
115
termios
tios
;
// terminal mode (prestatus)
116
G4String
clearString
;
// "clear code (^L)"
117
void
SetTermToInputMode
();
118
void
RestoreTerm
();
119
120
public
:
121
G4UItcsh
(
const
G4String
& prompt=
"%s> "
,
G4int
maxhist=100);
122
~G4UItcsh
();
123
124
void
SetLsColor
(
TermColorIndex
dirColor,
TermColorIndex
cmdColor);
125
virtual
G4String
GetCommandLineString
(
const
char
* msg=0);
126
127
virtual
void
ResetTerminal
();
128
};
129
130
// ====================================================================
131
// inline functions
132
// ====================================================================
133
inline
G4bool
G4UItcsh::IsCursorLast
()
const
134
{
135
if
(
cursorPosition
==
G4int
(
commandLine
.length()+1))
return
TRUE
;
136
else
return
FALSE
;
137
}
138
139
inline
void
G4UItcsh::SetLsColor
(
TermColorIndex
dirColor,
140
TermColorIndex
cmdColor)
141
{
142
lsColorFlag
=
TRUE
;
143
directoryColor
= dirColor;
144
commandColor
= cmdColor;
145
}
146
147
#endif
148
#endif
149
geant4
tree
geant4-10.6-release
source
interfaces
basic
include
G4UItcsh.hh
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:22
using
1.8.2 with
ECCE GitHub integration