Imported Upstream version 3.17.1
[platform/upstream/cmake.git] / Source / CursesDialog / cmCursesLongMessageForm.h
1 /* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2    file Copyright.txt or https://cmake.org/licensing for details.  */
3 #ifndef cmCursesLongMessageForm_h
4 #define cmCursesLongMessageForm_h
5
6 #include "cmConfigure.h" // IWYU pragma: keep
7
8 #include <string>
9 #include <vector>
10
11 #include "cmCursesForm.h"
12 #include "cmCursesStandardIncludes.h"
13
14 class cmCursesLongMessageForm : public cmCursesForm
15 {
16 public:
17   enum class ScrollBehavior
18   {
19     NoScroll,
20     ScrollDown
21   };
22
23   cmCursesLongMessageForm(std::vector<std::string> const& messages,
24                           const char* title, ScrollBehavior scrollBehavior);
25   ~cmCursesLongMessageForm() override;
26
27   cmCursesLongMessageForm(cmCursesLongMessageForm const&) = delete;
28   cmCursesLongMessageForm& operator=(cmCursesLongMessageForm const&) = delete;
29
30   void UpdateContent(std::string const& output, std::string const& title);
31
32   // Description:
33   // Handle user input.
34   void HandleInput() override;
35
36   // Description:
37   // Display form. Use a window of size width x height, starting
38   // at top, left.
39   void Render(int left, int top, int width, int height) override;
40
41   // Description:
42   // This method should normally  called only by the form.
43   // The only exception is during a resize.
44   void PrintKeys();
45
46   // Description:
47   // This method should normally  called only by the form.
48   // The only exception is during a resize.
49   void UpdateStatusBar() override;
50
51 protected:
52   static constexpr int MAX_CONTENT_SIZE = 60000;
53
54   void DrawMessage(const char* msg) const;
55
56   std::string Messages;
57   std::string Title;
58   ScrollBehavior Scrolling;
59
60   FIELD* Fields[2];
61 };
62
63 #endif // cmCursesLongMessageForm_h