source: trunk/FACT++/src/ReadlineColor.cc@ 10316

Last change on this file since 10316 was 10313, checked in by tbretz, 14 years ago
Some updates to the output of help messages.
File size: 6.4 KB
Line 
1// **************************************************************************
2/** @namespace ReadlineColor
3
4@brief A fewer helper functions to apply color attributes and redirect the output
5
6 */
7// **************************************************************************
8#include "ReadlineColor.h"
9
10#include "Time.h"
11#include "Readline.h"
12#include "WindowLog.h"
13
14using namespace std;
15
16// --------------------------------------------------------------------------
17//
18//! @returns
19//! always true
20//
21bool ReadlineColor::PrintBootMsg(ostream &out, const string &name)
22{
23 out << endl;
24 out << kBlue << kBold << kUnderline << " Master Control Program " << endl;
25 out << endl;
26 out << kBlue << " ENCOM MX 16-923 USER # 0" << int(Time().Mjd()) << Time::fmt(" %H:%M:%S") << Time() << Time::reset << " INFORMATION" << endl;
27 out << endl;
28 out << kBlue << " TELESCOPE CONTROL PROGRAM: " << name << endl;
29 out << kBlue << " ANNEXED BY FACT COLLABORATION" << endl;
30 out << kBlue << " ORIGINAL PROGRAM WRITTEN BY T.BRETZ" << endl;
31 out << kBlue << " THIS INFOMATION " << kUnderline << "PRIORITY ONE" << endl;
32 out << kBlue << " END OF LINE" << endl << endl;
33 out << endl;
34
35 return true;
36}
37
38// --------------------------------------------------------------------------
39//
40//! @returns
41//! always true
42//
43bool ReadlineColor::PrintCommands(ostream &out)
44{
45 out << endl;
46 out << " " << kUnderline << " Commands:" << endl;
47 out << " No application specific commands defined." << endl;
48 out << endl;
49
50 return true;
51}
52
53// --------------------------------------------------------------------------
54//
55//! Displays the available ncurses attributes, like color.
56//!
57//! @returns
58//! always true
59//
60bool ReadlineColor::PrintAttributes(ostream &out)
61{
62 out << endl;
63 out << " Attributes:" << endl;
64 out << " " << kReset << "kReset" << endl;
65 out << " " << kNormal << "kNormal" << endl;
66 out << " " << kHighlight << "kHighlight" << endl;
67 out << " " << kReverse << "kReverse" << endl;
68 out << " " << kUnderline << "kUnderline" << endl;
69 out << " " << kBlink << "kBlink" << endl;
70 out << " " << kDim << "kDim" << endl;
71 out << " " << kBold << "kBold" << endl;
72 out << " " << kProtect << "kProtect" << endl;
73 out << " " << kInvisible << "kInvisible" << endl;
74 out << " " << kAltCharset << "kAltCharset" << kReset << " (kAltCharset)" << endl;
75 out << endl;
76 out << " Colors:" << endl;
77 out << " " << kDefault << "kDefault " << kBold << "+ kBold" << endl;
78 out << " " << kRed << "kRed " << kBold << "+ kBold" << endl;
79 out << " " << kGreen << "kGreen " << kBold << "+ kBold" << endl;
80 out << " " << kYellow << "kYellow " << kBold << "+ kBold" << endl;
81 out << " " << kBlue << "kBlue " << kBold << "+ kBold" << endl;
82 out << " " << kMagenta << "kMagenta " << kBold << "+ kBold" << endl;
83 out << " " << kCyan << "kCyan " << kBold << "+ kBold" << endl;
84 out << " " << kWhite << "kWhite " << kBold << "+ kBold" << endl;
85 out << " " << endl;
86
87 return true;
88}
89
90// --------------------------------------------------------------------------
91//
92//! Displays the keybindings available due to the Shell class
93//!
94//! @returns
95//! always true
96//!
97//! @todo
98//! Update output
99//
100bool ReadlineColor::PrintKeyBindings(ostream &out)
101{
102 out << endl;
103 out << " " << kUnderline << "Key bindings:" << endl << endl;;
104 out << " Default key-bindings are identical with your bash." << endl;
105 out << endl;
106 out << kBold << " Page-up " << kReset << "Search backward in history" << endl;
107 out << kBold << " Page-dn " << kReset << "Search forward in history" << endl;
108 out << kBold << " Ctrl-left " << kReset << "One word backward" << endl;
109 out << kBold << " Ctrl-right " << kReset << "One word forward" << endl;
110 out << kBold << " Ctrl-y " << kReset << "Delete line" << endl;
111 out << kBold << " Alt-end/Ctrl-k " << kReset << "Delete until the end of the line" << endl;
112 out << endl;
113
114 return true;
115}
116
117// --------------------------------------------------------------------------
118//
119//! Print a general help text which also includes the commands pre-defined
120//! by the Shell class.
121//!
122//! @returns
123//! always true
124//!
125//! @todo
126//! Get it up-to-date
127//
128bool ReadlineColor::PrintGeneralHelp(ostream &out, const string &name)
129{
130 out << endl;
131 out << " " << kUnderline << "General help:" << endl << endl;
132 out << " The command history is automatically loaded and saves to" << endl;
133 out << " and from " << name << endl;
134 out << endl;
135 out << kBold << " h,help " << kReset << "Print this help message" << endl;
136 out << kBold << " clear " << kReset << "Clear history buffer" << endl;
137 out << kBold << " lh,history " << kReset << "Dump the history buffer to the screen" << endl;
138 out << kBold << " v,variable " << kReset << "Dump readline variables" << endl;
139 out << kBold << " f,function " << kReset << "Dump readline functions" << endl;
140 out << kBold << " m,funmap " << kReset << "Dump readline funmap" << endl;
141 out << kBold << " c,command " << kReset << "Dump available commands" << endl;
142 out << kBold << " k,keylist " << kReset << "Dump key bindings" << endl;
143 out << kBold << " a,attrs " << kReset << "Dump available stream attributes" << endl;
144 out << kBold << " .q,quit " << kReset << "Quit" << endl;
145 out << endl;
146
147 return true;
148}
149
150
151bool ReadlineColor::Process(ostream &out, const string &str)
152{
153 // ----------- Readline -----------
154
155 if (str=="lh" || str=="history")
156 {
157 out << endl << kBold << "History:" << endl;
158 return Readline::RedirectionWrapper(out, Readline::DumpHistory);
159 }
160
161 if (str=="v" || str=="variable")
162 {
163 out << endl << kBold << "Variables:" << endl;
164 return Readline::RedirectionWrapper(out, Readline::DumpVariables);
165 }
166
167 if (str=="f" || str=="function")
168 {
169 out << endl << kBold << "Functions:" << endl;
170 return Readline::RedirectionWrapper(out, Readline::DumpFunctions);
171 }
172
173 if (str=="m" || str=="funmap")
174 {
175 out << endl << kBold << "Funmap:" << endl;
176 return Readline::RedirectionWrapper(out, Readline::DumpFunmap);
177 }
178
179 // ------------ ReadlineWindow -------------
180
181 if (str=="a" || str=="attrs")
182 return PrintAttributes(out);
183
184 return false;
185}
Note: See TracBrowser for help on using the repository browser.