/*========================================================================= Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile$ Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "../cmCacheManager.h" #include "../cmSystemTools.h" #include "../cmake.h" #include "cmCursesLongMessageForm.h" #include "cmCursesMainForm.h" inline int ctrl(int z) { return (z&037); } 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; } char debugMessage[128]; while(1) { int key = getch(); sprintf(debugMessage, "Message widget handling input, key: %d", key); cmCursesForm::LogMessage(debugMessage); // quit if ( key == 'o' || key == 'e' ) { break; } else if ( key == KEY_DOWN || key == ctrl('n') ) { form_driver(m_Form, REQ_SCR_FLINE); } else if ( key == KEY_UP || key == ctrl('p') ) { form_driver(m_Form, REQ_SCR_BLINE); } else if ( key == KEY_NPAGE || key == ctrl('d') ) { form_driver(m_Form, REQ_SCR_FPAGE); } else if ( key == KEY_PPAGE || key == ctrl('u') ) { form_driver(m_Form, REQ_SCR_BPAGE); } this->UpdateStatusBar(); this->PrintKeys(); touchwin(stdscr); wrefresh(stdscr); } }