00001 #ifndef CSV_VIEWER_HEADER_INCLUDED_p 00002 #define CSV_VIEWER_HEADER_INCLUDED_p 00003 // 00004 // Copyright 2010, Lowell Boggs Jr. 00005 // 00006 // This file or directory, containing source code for a computer program, 00007 // is Copyrighted by Lowell Boggs, Jr. 987 Regency Drive, Lewisville 00008 // TX (USA), 75067. You may use, copy, modify, and distribute this 00009 // source file without charge or obligation so long as you agree to 00010 // the following: 00011 // 00012 // 1. You must indemnify Lowell Boggs against any and all financial 00013 // obligations caused by its use, misuse, function, or malfunction. 00014 // Further, you acknowledge that there is no warranty of any kind, 00015 // whatsoever. 00016 // 00017 // 2. You agree not to attempt to patent any portion of this original 00018 // work -- though you may attempt to patent your own extensions to 00019 // it if you so choose. 00020 // 00021 // 3. You keep this copyright notice with the file and all copies 00022 // of the file and do not change it anyway except language translation. 00023 // 00024 // You are responsible for enforcing your own compliance with these 00025 // conditions and may not use this source file if you cannot agree to the 00026 // above terms and conditions. 00027 00028 #include <cxxtls/tableeditor.h> 00029 00030 namespace cxxtls 00031 { 00032 00033 class CsvViewer 00034 : public TableEditor 00042 { 00043 std::string filename_; 00044 std::string fileError_; 00045 00046 00047 public: 00048 00049 CsvViewer(ViewerManager *vm, 00050 std::string const &filename, 00051 int delimChar=',' 00052 ); 00071 00072 bool ok() const { return fileError_.empty(); } 00075 00076 std::string const &error() const { return fileError_; } 00078 00079 virtual ~CsvViewer(); 00080 00081 00082 00083 virtual std::string const &application_name() const; 00084 virtual std::string description() const; 00085 static Viewer* app(ViewerManager*vm, std::string &fullname); 00091 00092 private: 00093 00094 virtual bool handle_event( CursorWindow::input_event const * e, 00095 CursorWindow::viewport * vp 00096 ); 00099 00100 00101 virtual void setCursorInfo(CursorWindow::viewport *vp, 00102 size_t worldRow, 00103 size_t worldCol, 00104 bool displayed 00105 ); 00109 00110 00111 void saveTo(std::string const &filename); 00113 00114 bool okToQuit(CursorWindow::viewport *vp); 00116 00117 virtual void help(); 00118 00119 }; 00120 } // namespace cxxtls 00121 #endif