scripttableviewer.h
Go to the documentation of this file.00001 #ifndef SCRIPT_TABLE_VIEWER_HEADER_INCLUDED_p
00002 #define SCRIPT_TABLE_VIEWER_HEADER_INCLUDED_p
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include <cxxtls/tableeditor.h>
00029 #include <map>
00030
00031 namespace cxxtls
00032 {
00033
00034 class ScriptTableViewer
00035 : public TableEditor
00070 {
00071 std::string scriptname_;
00072 std::string fileError_;
00073 bool keyKludge_;
00074 std::string title_;
00075
00076 std::vector<int> invocationKeys_;
00077
00078 std::string directory_;
00079
00080 struct SessionInfo
00081 {
00082
00083 std::map<std::string,std::string> options_;
00084
00085 CursorInfo startCursorPosition_;
00086
00087 std::string commandLine_;
00088
00089
00090
00091
00092
00093 std::vector< std::pair<size_t, size_t> > returnedCells_;
00128
00129
00130 SessionInfo()
00131 : startCursorPosition_(0,0,false)
00132 {
00133 }
00134
00135 bool isPopup() const { return !returnedCells_.empty(); }
00137
00138
00139 };
00140
00141 std::vector<SessionInfo> sessions_;
00142
00143
00144
00145
00146
00147
00148 std::vector<std::pair<TableViewer, std::string> > prevScreenLayouts_;
00149
00150
00151
00152
00153 void handleReturnedCells();
00155
00156 public:
00157
00158 ScriptTableViewer(ViewerManager *vm,
00159 std::string const &scriptName,
00160 std::string directory=std::string()
00161 );
00177
00178 bool ok() const { return fileError_.empty(); }
00181
00182 std::string const &error() const { return fileError_; }
00184
00185 virtual ~ScriptTableViewer();
00186
00187
00188
00189 virtual std::string const &application_name() const;
00190 virtual std::string description() const;
00191 static Viewer* app(ViewerManager*vm, std::string &fullname);
00197
00198
00199 virtual bool handle_event( CursorWindow::input_event const * e,
00200 CursorWindow::viewport * vp
00201 );
00204
00205 virtual void help();
00206
00207 void populateTable(std::string const &scriptParms, CursorWindow::viewport *vp=0);
00219
00220 void invokeCommand(CursorWindow::viewport *vp, int cmdKey);
00221
00222 void restartSession(CursorWindow::viewport *vp);
00223
00224 virtual void repaintTitle(CursorWindow::viewport *vp);
00225
00226 void setDir(std::string const &dir) { directory_ = dir; }
00227
00228
00229 bool fieldExecutable(size_t tableRow, size_t tableCol) const
00240
00241 {
00242 if( tableRow >= rows_.size()
00243 || tableCol >= cols_.size()
00244 )
00245 return false;
00246
00247 return rows_[tableRow].executable_ && cols_[tableCol].executable_;
00248 }
00249
00250 bool fieldExecutable(CursorInfo const &cur) const
00260 {
00261 return fieldExecutable(cur.row_, cur.col_);
00262 }
00263
00264 bool showPopup(CursorWindow::viewport *vp,
00265 std::string const &definition,
00266 std::vector< std::pair<std::string,std::string> > &userInputs
00267 );
00290
00291 void saveScreenLayout()
00293 {
00294 prevScreenLayouts_.push_back( std::pair<TableViewer,std::string>(*this,title_) );
00295 }
00296
00297 void restoreSavedScreenLayout()
00300 {
00301 TableViewer &me = *this;
00302
00303 me = prevScreenLayouts_.back().first;
00304 title_ = prevScreenLayouts_.back().second;
00305
00306 prevScreenLayouts_.pop_back();
00307
00308 }
00309
00310 void discardSavedScreenLayout()
00312 {
00313 prevScreenLayouts_.pop_back();
00314 }
00315
00316 };
00317 }
00318 #endif