1 /**
2  * Copyright (c) 2017, Timothy Stack
3  *
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * * Redistributions of source code must retain the above copyright notice, this
10  * list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  * * Neither the name of Timothy Stack nor the names of its contributors
15  * may be used to endorse or promote products derived from this software
16  * without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY
19  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
22  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef lnav_doc_status_source_hh
31 #define lnav_doc_status_source_hh
32 
33 #include <string>
34 
35 #include "statusview_curses.hh"
36 
37 class doc_status_source
38     : public status_data_source {
39 public:
40     typedef enum {
41         TSF_TITLE,
42         TSF_STITCH_TITLE,
43         TSF_DESCRIPTION,
44 
45         TSF__MAX
46     } field_t;
47 
doc_status_source()48     doc_status_source() {
49         this->tss_fields[TSF_TITLE].set_width(14);
50         this->tss_fields[TSF_TITLE].set_left_pad(1);
51         this->tss_fields[TSF_TITLE].set_role(view_colors::VCR_STATUS_TITLE);
52         this->tss_fields[TSF_STITCH_TITLE].set_width(2);
53         this->tss_fields[TSF_STITCH_TITLE].set_stitch_value(
54             view_colors::VCR_STATUS_STITCH_TITLE_TO_NORMAL,
55             view_colors::VCR_STATUS_STITCH_NORMAL_TO_TITLE);
56         this->tss_fields[TSF_DESCRIPTION].set_share(1);
57         this->tss_fields[TSF_DESCRIPTION].set_role(view_colors::VCR_STATUS);
58     };
59 
statusview_fields()60     size_t statusview_fields() override {
61         return TSF__MAX;
62     };
63 
statusview_value_for_field(int field)64     status_field &statusview_value_for_field(int field) override {
65         return this->tss_fields[field];
66     };
67 
set_title(const std::string & title)68     void set_title(const std::string &title) {
69         this->tss_fields[TSF_TITLE].set_value(title);
70     }
71 
set_description(const std::string & description)72     void set_description(const std::string &description) {
73         this->tss_fields[TSF_DESCRIPTION].set_value(description);
74     }
75 
76 private:
77     status_field tss_fields[TSF__MAX];
78 };
79 
80 #endif
81