keyviewer.cxx

Go to the documentation of this file.
00001 //
00002 // Copyright 2002, Lowell Boggs Jr.
00003 //
00004 // This file or directory, containing source code for a computer program,
00005 // is Copyrighted by Lowell Boggs, Jr.  987 Regency Drive, Lewisville
00006 // TX (USA), 75067.  You may use, copy, modify, and distribute this
00007 // source file without charge or obligation so long as you agree to
00008 // the following:
00009 //
00010 //  1.  You must indemnify Lowell Boggs against any and all financial
00011 //      obligations caused by its use, misuse, function, or malfunction.
00012 //      Further, you acknowledge that there is no warranty of any kind,
00013 //      whatsoever.
00014 //
00015 //  2.  You agree not to attempt to patent any portion of this original
00016 //      work -- though you may attempt to patent your own extensions to
00017 //      it if you so choose.
00018 //
00019 //  3.  You keep this copyright notice with the file and all copies
00020 //      of the file and do not change it anyway except language translation.
00021 //
00022 // You are responsible for enforcing your own compliance with these
00023 // conditions and may not use this source file if you cannot agree to the
00024 // above terms and conditions.
00025 //
00026 // Warning:  not all files in this directory structure are covered by the
00027 // same copyright.  Some of them are part of the GNU source distribution
00028 // and you must obey the GPL copyright for those files.
00029 
00030 
00034 
00035 #include <cxxtls/keyviewer.h>
00036 
00037 #include <iomanip>
00038 
00039 namespace cxxtls
00040 {
00041 
00042 std::string KeyViewer::app_name = "KeyViewer";
00043 
00044 bool KeyViewer::is_marked(size_t line) { return 0; }
00045 
00046 void
00047 KeyViewer::
00048 handle_resize(CursorWindow::row_col const &vp_size)
00049 {
00050   // ignore this
00051 }
00052 
00053 int
00054 KeyViewer::
00055 handle_event(CursorWindow::input_event const *e,
00056              size_t index,
00057              ViewerManager* vm
00058             )
00059 {
00060   if(e->type_ == CursorWindow::input_event::ForceExitKey)
00061     return 2;  // terminate window
00062 
00063 
00064   using namespace std;
00065 
00066   StreamableString text;
00067 
00068   text << "Key [" << std::setw(3) << strings_.size() << "] "
00069        << "name is " << std::setw(12) << CursorWindow::key_name(e->value_) << " and"
00070        << " the key value is 0x" << std::setbase(16) << e->value_ << "." ;
00071 
00072   strings_.push_back(text);
00073 
00074   if(e->value_ == ('K' - '@') )
00075     return 2;
00076 
00077   return 1;
00078 }
00079 
00080 
00081 std::auto_ptr< std::list<std::string> >
00082 KeyViewer::
00083 help_text()
00084 {
00085   std::list< std::string > *rv = new std::list<std::string>;
00086 
00087   rv->push_back(" ");
00088   rv->push_back("The KeyViewer lets you see what key is being pressed");
00089   rv->push_back(" ");
00090   rv->push_back("The ^K key terminates the key viewer.");
00091   rv->push_back(" ");
00092   rv->push_back("Note that not all keys are interpreted directly by the viewer");
00093   rv->push_back("so window switching keys, arrow keys, paging, help");
00094   rv->push_back("keys are not 'displayable' if they are properly interpreted.");
00095   rv->push_back("The help keys are interpreted like this as well.");
00096   rv->push_back(" ");
00097 
00098   return std::auto_ptr< std::list<std::string> >(rv);
00099 }
00100 
00101 Viewer*
00102 KeyViewer::
00103 app(ViewerManager*vm, std::string &fullname)
00104 {
00105   KeyViewer *com = new KeyViewer();
00106 
00107   return new ListViewer(com,vm);
00108 }
00109 
00110 KeyViewer::
00111 KeyViewer()
00112 {
00113   title_ = "Key value displayer (press ^K to quit or F1 for help)";
00114 }
00115 
00116 
00117 KeyViewer::
00118 ~KeyViewer()
00119 {
00120 }
00121 
00122 } // namespace cxxtls
Generated on Wed Feb 29 22:50:05 2012 for CXXUtilities by  doxygen 1.6.3