diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx new file mode 100644 index 0000000000..f97fee12c3 --- /dev/null +++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx @@ -0,0 +1,178 @@ +#include "../cmCacheManager.h" +#include "../cmSystemTools.h" +#include "../cmake.h" +#include "cmCursesLongMessageForm.h" +#include "cmCursesMainForm.h" + +cmCursesLongMessageForm::cmCursesLongMessageForm(std::vector const& + messages, const char* + title) +{ + // Append all messages into on big string + std::vector::const_iterator it; + for(it=messages.begin(); it != messages.end(); it++) + { + m_Messages += (*it); + // Add one blank line after each message + m_Messages += "\n\n"; + } + m_Title = title; + m_Fields[0] = 0; + m_Fields[1] = 0; +} + +cmCursesLongMessageForm::~cmCursesLongMessageForm() +{ + if (m_Fields[0]) + { + free_field(m_Fields[0]); + } +} + + +void cmCursesLongMessageForm::UpdateStatusBar() +{ + int x,y; + getmaxyx(stdscr, y, x); + + char bar[cmCursesMainForm::MAX_WIDTH]; + int size = strlen(m_Title.c_str()); + if ( size >= cmCursesMainForm::MAX_WIDTH ) + { + size = cmCursesMainForm::MAX_WIDTH-1; + } + strncpy(bar, m_Title.c_str(), size); + for(int i=size-1; iUpdateStatusBar(); + this->PrintKeys(); + touchwin(stdscr); + refresh(); + +} + +void cmCursesLongMessageForm::HandleInput() +{ + if (!m_Form) + { + return; + } + + while(1) + { + int key = getch(); + + // quit + if ( key == 'o' ) + { + break; + } + else if ( key == KEY_DOWN ) + { + form_driver(m_Form, REQ_SCR_FLINE); + } + else if ( key == KEY_UP ) + { + form_driver(m_Form, REQ_SCR_BLINE); + } + + this->UpdateStatusBar(); + this->PrintKeys(); + touchwin(stdscr); + wrefresh(stdscr); + } + +} diff --git a/Source/CursesDialog/cmCursesLongMessageForm.h b/Source/CursesDialog/cmCursesLongMessageForm.h new file mode 100644 index 0000000000..6f28bd2538 --- /dev/null +++ b/Source/CursesDialog/cmCursesLongMessageForm.h @@ -0,0 +1,47 @@ +#ifndef __cmCursesLongMessageForm_h +#define __cmCursesLongMessageForm_h + +#include "../cmStandardIncludes.h" +#include "cmCursesForm.h" +#include "cmCursesStandardIncludes.h" + +class cmCursesCacheEntryComposite; + +class cmCursesLongMessageForm : public cmCursesForm +{ +public: + cmCursesLongMessageForm(std::vector const& messages, + const char* title); + virtual ~cmCursesLongMessageForm(); + + // Description: + // Handle user input. + virtual void HandleInput(); + + // Description: + // Display form. Use a window of size width x height, starting + // at top, left. + virtual void Render(int left, int top, int width, int height); + + // Description: + // This method should normally called only by the form. + // The only exception is during a resize. + void PrintKeys(); + + // Description: + // This method should normally called only by the form. + // The only exception is during a resize. + virtual void UpdateStatusBar(); + +protected: + cmCursesLongMessageForm(const cmCursesLongMessageForm& from); + void operator=(const cmCursesLongMessageForm&); + + std::string m_Messages; + std::string m_Title; + + FIELD* m_Fields[2]; + +}; + +#endif // __cmCursesLongMessageForm_h