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

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