1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
---|
2 | <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> |
---|
3 | <title>G4UItcsh.hh Source File</title> |
---|
4 | <link href="doxygen.css" rel="stylesheet" type="text/css"> |
---|
5 | </head><body> |
---|
6 | <!-- Generated by Doxygen 1.3.4 --> |
---|
7 | <div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a></div> |
---|
8 | <h1>G4UItcsh.hh</h1><a href="G4UItcsh_8hh.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">//</span> |
---|
9 | 00002 <span class="comment">// ********************************************************************</span> |
---|
10 | 00003 <span class="comment">// * License and Disclaimer *</span> |
---|
11 | 00004 <span class="comment">// * *</span> |
---|
12 | 00005 <span class="comment">// * The Geant4 software is copyright of the Copyright Holders of *</span> |
---|
13 | 00006 <span class="comment">// * the Geant4 Collaboration. It is provided under the terms and *</span> |
---|
14 | 00007 <span class="comment">// * conditions of the Geant4 Software License, included in the file *</span> |
---|
15 | 00008 <span class="comment">// * LICENSE and available at http://cern.ch/geant4/license . These *</span> |
---|
16 | 00009 <span class="comment">// * include a list of copyright holders. *</span> |
---|
17 | 00010 <span class="comment">// * *</span> |
---|
18 | 00011 <span class="comment">// * Neither the authors of this software system, nor their employing *</span> |
---|
19 | 00012 <span class="comment">// * institutes,nor the agencies providing financial support for this *</span> |
---|
20 | 00013 <span class="comment">// * work make any representation or warranty, express or implied, *</span> |
---|
21 | 00014 <span class="comment">// * regarding this software system or assume any liability for its *</span> |
---|
22 | 00015 <span class="comment">// * use. Please see the license in the file LICENSE and URL above *</span> |
---|
23 | 00016 <span class="comment">// * for the full disclaimer and the limitation of liability. *</span> |
---|
24 | 00017 <span class="comment">// * *</span> |
---|
25 | 00018 <span class="comment">// * This code implementation is the result of the scientific and *</span> |
---|
26 | 00019 <span class="comment">// * technical work of the GEANT4 collaboration. *</span> |
---|
27 | 00020 <span class="comment">// * By using, copying, modifying or distributing the software (or *</span> |
---|
28 | 00021 <span class="comment">// * any work based on the software) you agree to acknowledge its *</span> |
---|
29 | 00022 <span class="comment">// * use in resulting scientific publications, and indicate your *</span> |
---|
30 | 00023 <span class="comment">// * acceptance of all terms of the Geant4 Software license. *</span> |
---|
31 | 00024 <span class="comment">// ********************************************************************</span> |
---|
32 | 00025 <span class="comment">//</span> |
---|
33 | 00026 <span class="comment">//</span> |
---|
34 | 00027 <span class="comment">// $Id: G4UItcsh.hh,v 1.7 2006/06/29 19:09:37 gunter Exp $</span> |
---|
35 | 00028 <span class="comment">// GEANT4 tag $Name: geant4-08-01-patch-01 $</span> |
---|
36 | 00029 <span class="comment">//</span> |
---|
37 | 00030 |
---|
38 | 00031 <span class="preprocessor">#ifndef G4UItcsh_h</span> |
---|
39 | 00032 <span class="preprocessor"></span><span class="preprocessor">#define G4UItcsh_h 1</span> |
---|
40 | 00033 <span class="preprocessor"></span> |
---|
41 | 00034 <span class="preprocessor">#ifndef WIN32</span> |
---|
42 | 00035 <span class="preprocessor"></span> |
---|
43 | 00036 <span class="preprocessor">#include <termios.h></span> |
---|
44 | 00037 <span class="preprocessor">#include <vector></span> |
---|
45 | 00038 <span class="preprocessor">#include "<a class="code" href="G4VUIshell_8hh.html">G4VUIshell.hh</a>"</span> |
---|
46 | 00039 <span class="preprocessor">#include "G4UIcommand.hh"</span> |
---|
47 | 00040 <span class="preprocessor">#include "G4UIcommandTree.hh"</span> |
---|
48 | 00041 |
---|
49 | 00042 <span class="comment">//</span> |
---|
50 | 00043 <span class="comment">// Description:</span> |
---|
51 | 00044 <span class="comment">// This class gives tcsh-like shell.</span> |
---|
52 | 00045 <span class="comment">// </span> |
---|
53 | 00046 <span class="comment">// If your terminal supports color code, colored strings are available </span> |
---|
54 | 00047 <span class="comment">// in ListCommand(). For activating color support, </span> |
---|
55 | 00048 <span class="comment">// e.g.</span> |
---|
56 | 00049 <span class="comment">// tcsh-> SetLsColor(GREEN, CYAN); // (dir, command) color</span> |
---|
57 | 00050 <span class="comment">// </span> |
---|
58 | 00051 <span class="comment">// [key binding]</span> |
---|
59 | 00052 <span class="comment">// ^A ... move cursor to the top</span> |
---|
60 | 00053 <span class="comment">// ^B ... backward cursor ([LEFT])</span> |
---|
61 | 00054 <span class="comment">// ^D ... delete/exit/show matched list</span> |
---|
62 | 00055 <span class="comment">// ^E ... move cursor to the end</span> |
---|
63 | 00056 <span class="comment">// ^F ... forward cursor ([RIGHT])</span> |
---|
64 | 00057 <span class="comment">// ^K ... clear after the cursor</span> |
---|
65 | 00058 <span class="comment">// ^L ... clear screen (not implemented)</span> |
---|
66 | 00059 <span class="comment">// ^N ... next command ([DOWN])</span> |
---|
67 | 00060 <span class="comment">// ^P ... previous command ([UP])</span> |
---|
68 | 00061 <span class="comment">// TAB... command completion</span> |
---|
69 | 00062 <span class="comment">// DEL... backspace</span> |
---|
70 | 00063 <span class="comment">// BS ... backspace</span> |
---|
71 | 00064 <span class="comment">//</span> |
---|
72 | 00065 <span class="comment">// [prompt string substitution]</span> |
---|
73 | 00066 <span class="comment">// %s ... current application status</span> |
---|
74 | 00067 <span class="comment">// %/ ... current working directory</span> |
---|
75 | 00068 <span class="comment">// %h ... history# (different from G4 history#)</span> |
---|
76 | 00069 <span class="comment">//</span> |
---|
77 | 00070 |
---|
78 | <a name="l00071"></a><a class="code" href="classG4UItcsh.html">00071</a> <span class="keyword">class </span><a class="code" href="classG4UItcsh.html">G4UItcsh</a> : <span class="keyword">public</span> <a class="code" href="classG4VUIshell.html">G4VUIshell</a> { |
---|
79 | 00072 <span class="keyword">protected</span>: |
---|
80 | 00073 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classG4UItcsh.html#b0">MakePrompt</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* msg=0); |
---|
81 | 00074 |
---|
82 | <a name="l00075"></a><a class="code" href="classG4UItcsh.html#p0">00075</a> G4String <a class="code" href="classG4UItcsh.html#p0">commandLine</a>; <span class="comment">// command line string;</span> |
---|
83 | <a name="l00076"></a><a class="code" href="classG4UItcsh.html#p1">00076</a> G4int <a class="code" href="classG4UItcsh.html#p1">cursorPosition</a>; <span class="comment">// cursor position </span> |
---|
84 | <a name="l00077"></a><a class="code" href="classG4UItcsh.html#p2">00077</a> G4String <a class="code" href="classG4UItcsh.html#p2">commandLineBuf</a>; <span class="comment">// temp. command line;</span> |
---|
85 | 00078 G4bool <a class="code" href="classG4UItcsh.html#b1">IsCursorLast</a>() <span class="keyword">const</span>; |
---|
86 | 00079 <span class="comment">// Is cursor position at the last of command line ?</span> |
---|
87 | 00080 |
---|
88 | 00081 <span class="keywordtype">void</span> <a class="code" href="classG4UItcsh.html#b2">InitializeCommandLine</a>(); |
---|
89 | 00082 G4String <a class="code" href="classG4UItcsh.html#b3">ReadLine</a>(); |
---|
90 | 00083 <span class="keywordtype">void</span> <a class="code" href="classG4UItcsh.html#b4">InsertCharacter</a>(<span class="keywordtype">char</span> cc); <span class="comment">// insert character</span> |
---|
91 | 00084 <span class="keywordtype">void</span> <a class="code" href="classG4UItcsh.html#b5">BackspaceCharacter</a>(); <span class="comment">// backspace character</span> |
---|
92 | 00085 <span class="keywordtype">void</span> <a class="code" href="classG4UItcsh.html#b6">DeleteCharacter</a>(); <span class="comment">// delete character</span> |
---|
93 | 00086 <span class="keywordtype">void</span> <a class="code" href="classG4UItcsh.html#b7">ClearLine</a>(); <span class="comment">// clear command line</span> |
---|
94 | 00087 <span class="keywordtype">void</span> <a class="code" href="classG4UItcsh.html#b8">ClearAfterCursor</a>(); <span class="comment">// clear after the cursor</span> |
---|
95 | 00088 <span class="keywordtype">void</span> <a class="code" href="classG4UItcsh.html#b9">ClearScreen</a>(); <span class="comment">// clear screen</span> |
---|
96 | 00089 |
---|
97 | 00090 <span class="keywordtype">void</span> <a class="code" href="classG4UItcsh.html#b10">ForwardCursor</a>(); <span class="comment">// move cursor forward</span> |
---|
98 | 00091 <span class="keywordtype">void</span> <a class="code" href="classG4UItcsh.html#b11">BackwardCursor</a>(); <span class="comment">// move cursor backward</span> |
---|
99 | 00092 <span class="keywordtype">void</span> <a class="code" href="classG4UItcsh.html#b12">MoveCursorTop</a>(); <span class="comment">// move cursor to the top</span> |
---|
100 | 00093 <span class="keywordtype">void</span> <a class="code" href="classG4UItcsh.html#b13">MoveCursorEnd</a>(); <span class="comment">// move cursor to the end</span> |
---|
101 | 00094 |
---|
102 | 00095 <span class="keywordtype">void</span> <a class="code" href="classG4UItcsh.html#b14">NextCommand</a>(); <span class="comment">// next command</span> |
---|
103 | 00096 <span class="keywordtype">void</span> <a class="code" href="classG4UItcsh.html#b15">PreviousCommand</a>(); <span class="comment">// previous command</span> |
---|
104 | 00097 |
---|
105 | 00098 <span class="keywordtype">void</span> <a class="code" href="classG4UItcsh.html#b16">ListMatchedCommand</a>(); <span class="comment">// list matched commands</span> |
---|
106 | 00099 <span class="keywordtype">void</span> <a class="code" href="classG4UItcsh.html#b17">CompleteCommand</a>(); <span class="comment">// complete command</span> |
---|
107 | 00100 |
---|
108 | 00101 <span class="comment">// utilities...</span> |
---|
109 | 00102 G4String <a class="code" href="classG4UItcsh.html#b18">GetFirstMatchedString</a>(<span class="keyword">const</span> G4String& str1, |
---|
110 | 00103 <span class="keyword">const</span> G4String& str2) <span class="keyword">const</span>; |
---|
111 | 00104 |
---|
112 | 00105 <span class="comment">// history functionality (history# is managed in itself)</span> |
---|
113 | <a name="l00106"></a><a class="code" href="classG4UItcsh.html#p3">00106</a> std::vector<G4String> <a class="code" href="classG4UItcsh.html#p3">commandHistory</a>; |
---|
114 | <a name="l00107"></a><a class="code" href="classG4UItcsh.html#p4">00107</a> G4int <a class="code" href="classG4UItcsh.html#p4">maxHistory</a>; <span class="comment">// max# of histories stored</span> |
---|
115 | <a name="l00108"></a><a class="code" href="classG4UItcsh.html#p5">00108</a> G4int <a class="code" href="classG4UItcsh.html#p5">currentHistoryNo</a>; <span class="comment">// global</span> |
---|
116 | <a name="l00109"></a><a class="code" href="classG4UItcsh.html#p6">00109</a> G4int <a class="code" href="classG4UItcsh.html#p6">relativeHistoryIndex</a>; <span class="comment">// local index relative to current history#</span> |
---|
117 | 00110 |
---|
118 | 00111 <span class="keywordtype">void</span> <a class="code" href="classG4UItcsh.html#b19">StoreHistory</a>(G4String aCommand); |
---|
119 | 00112 G4String <a class="code" href="classG4UItcsh.html#b20">RestoreHistory</a>(G4int index); <span class="comment">// index is global history#</span> |
---|
120 | 00113 |
---|
121 | 00114 |
---|
122 | 00115 <span class="comment">// (re)set termios</span> |
---|
123 | <a name="l00116"></a><a class="code" href="classG4UItcsh.html#p7">00116</a> termios <a class="code" href="classG4UItcsh.html#p7">tios</a>; <span class="comment">// terminal mode (prestatus)</span> |
---|
124 | <a name="l00117"></a><a class="code" href="classG4UItcsh.html#p8">00117</a> G4String <a class="code" href="classG4UItcsh.html#p8">clearString</a>; <span class="comment">// "clear code (^L)"</span> |
---|
125 | 00118 <span class="keywordtype">void</span> <a class="code" href="classG4UItcsh.html#b21">SetTermToInputMode</a>(); |
---|
126 | 00119 <span class="keywordtype">void</span> <a class="code" href="classG4UItcsh.html#b22">RestoreTerm</a>(); |
---|
127 | 00120 |
---|
128 | 00121 <span class="keyword">public</span>: |
---|
129 | 00122 <a class="code" href="classG4UItcsh.html#a0">G4UItcsh</a>(<span class="keyword">const</span> G4String& prompt=<span class="stringliteral">"%s> "</span>, G4int maxhist=100); |
---|
130 | 00123 <a class="code" href="classG4UItcsh.html#a1">~G4UItcsh</a>(); |
---|
131 | 00124 |
---|
132 | 00125 <span class="keywordtype">void</span> <a class="code" href="classG4UItcsh.html#a2">SetLsColor</a>(TermColorIndex dirColor, TermColorIndex cmdColor); |
---|
133 | 00126 <span class="keyword">virtual</span> G4String <a class="code" href="classG4UItcsh.html#a3">GetCommandLine</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* msg=0); |
---|
134 | 00127 }; |
---|
135 | 00128 |
---|
136 | <a name="l00129"></a><a class="code" href="classG4UItcsh.html#b1">00129</a> <span class="keyword">inline</span> G4bool <a class="code" href="classG4UItcsh.html#b1">G4UItcsh::IsCursorLast</a>()<span class="keyword"> const</span> |
---|
137 | 00130 <span class="keyword"></span>{ |
---|
138 | 00131 <span class="keywordflow">if</span>(<a class="code" href="classG4UItcsh.html#p1">cursorPosition</a> == G4int(<a class="code" href="classG4UItcsh.html#p0">commandLine</a>.length()+1)) <span class="keywordflow">return</span> TRUE; |
---|
139 | 00132 <span class="keywordflow">else</span> <span class="keywordflow">return</span> FALSE; |
---|
140 | 00133 } |
---|
141 | 00134 |
---|
142 | <a name="l00135"></a><a class="code" href="classG4UItcsh.html#a2">00135</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classG4UItcsh.html#a2">G4UItcsh::SetLsColor</a>(TermColorIndex dirColor, |
---|
143 | 00136 TermColorIndex cmdColor) |
---|
144 | 00137 { |
---|
145 | 00138 <a class="code" href="classG4VUIshell.html#p3">lsColorFlag</a>= TRUE; |
---|
146 | 00139 <a class="code" href="classG4VUIshell.html#p4">directoryColor</a>= dirColor; |
---|
147 | 00140 <a class="code" href="classG4VUIshell.html#p5">commandColor</a>= cmdColor; |
---|
148 | 00141 } |
---|
149 | 00142 |
---|
150 | 00143 <span class="preprocessor">#endif</span> |
---|
151 | 00144 <span class="preprocessor"></span><span class="preprocessor">#endif</span> |
---|
152 | 00145 <span class="preprocessor"></span> |
---|
153 | </pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri Jun 22 11:07:02 2007 by |
---|
154 | <a href="http://www.doxygen.org/index.html"> |
---|
155 | <img src="doxygen.png" alt="doxygen" align="middle" border=0 > |
---|
156 | </a>1.3.4 </small></address> |
---|
157 | </body> |
---|
158 | </html> |
---|