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_preview_status_source_hh
31 #define lnav_preview_status_source_hh
32 
33 #include <string>
34 
35 #include "statusview_curses.hh"
36 
37 class preview_status_source
38     : public status_data_source {
39 public:
40     typedef enum {
41         TSF_TITLE,
42         TSF_STITCH_TITLE,
43         TSF_DESCRIPTION,
44         TSF_TOGGLE,
45 
46         TSF__MAX
47     } field_t;
48 
preview_status_source()49     preview_status_source() {
50         static const char TOGGLE_MSG[] = "Press CTRL+P to show/hide";
51 
52         this->tss_fields[TSF_TITLE].set_width(14);
53         this->tss_fields[TSF_TITLE].set_role(view_colors::VCR_STATUS_TITLE);
54         this->tss_fields[TSF_TITLE].set_value(" Preview Data ");
55         this->tss_fields[TSF_STITCH_TITLE].set_width(2);
56         this->tss_fields[TSF_STITCH_TITLE].set_stitch_value(
57             view_colors::VCR_STATUS_STITCH_TITLE_TO_NORMAL,
58             view_colors::VCR_STATUS_STITCH_NORMAL_TO_TITLE);
59         this->tss_fields[TSF_DESCRIPTION].set_share(1);
60         this->tss_fields[TSF_TOGGLE].set_width(strlen(TOGGLE_MSG) + 1);
61         this->tss_fields[TSF_TOGGLE].set_value(TOGGLE_MSG);
62         this->tss_fields[TSF_TOGGLE].right_justify(true);
63     };
64 
statusview_fields()65     size_t statusview_fields() override { return TSF__MAX; };
66 
statusview_value_for_field(int field)67     status_field &statusview_value_for_field(int field) override {
68         return this->tss_fields[field];
69     };
70 
get_description()71     status_field &get_description() {
72         return this->tss_fields[TSF_DESCRIPTION];
73     };
74 
75 private:
76     status_field tss_fields[TSF__MAX];
77 };
78 
79 #endif
80