"Fossies" - the Fresh Open Source Software Archive

Member "sysdig-0.26.1/userspace/libsinsp/cursesspectro.h" (24 May 2019, 3107 Bytes) of package /linux/misc/sysdig-0.26.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "cursesspectro.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2 Copyright (C) 2013-2018 Draios Inc dba Sysdig.
    3 
    4 This file is part of sysdig.
    5 
    6 Licensed under the Apache License, Version 2.0 (the "License");
    7 you may not use this file except in compliance with the License.
    8 You may obtain a copy of the License at
    9 
   10     http://www.apache.org/licenses/LICENSE-2.0
   11 
   12 Unless required by applicable law or agreed to in writing, software
   13 distributed under the License is distributed on an "AS IS" BASIS,
   14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   15 See the License for the specific language governing permissions and
   16 limitations under the License.
   17 
   18 */
   19 
   20 #ifdef CSYSDIG
   21 #ifndef NOCURSESUI
   22 
   23 class colpalette_entry
   24 {
   25 public:
   26     colpalette_entry(int color, char ch)
   27     {
   28         m_color = color;
   29         m_char = ch;
   30     }
   31 
   32     int m_color;
   33     char m_char;
   34 };
   35 
   36 class curses_spectro_history_row
   37 {
   38 public:
   39     void clear(uint64_t ts)
   40     {
   41         m_ts = ts;
   42         m_data.clear();
   43     }
   44 
   45     void push_back(uint32_t val)
   46     {
   47         m_data.push_back(val);
   48     }
   49 
   50     uint64_t m_ts;
   51     vector<uint32_t> m_data;
   52 };
   53 
   54 class curses_spectro : 
   55     public sinsp_chart
   56 {
   57 public:
   58     enum alignment
   59     {
   60         ALIGN_LEFT,
   61         ALIGN_RIGHT,
   62     };
   63 
   64     curses_spectro(sinsp_cursesui* parent, sinsp* inspector, bool is_tracer);
   65     ~curses_spectro();
   66 
   67     void configure(sinsp_table* table);
   68     void update_data(vector<sinsp_sample_row>* data, bool force_selection_change = false);
   69     void render(bool data_changed);
   70     sysdig_table_action handle_input(int ch);
   71     void set_x_start(uint32_t x)
   72     {
   73         m_table_x_start = x;
   74     }
   75     void recreate_win(int h);
   76     uint32_t get_data_size()
   77     {
   78         if(m_table != NULL)
   79         {
   80             return m_data->size();
   81         }
   82         else
   83         {
   84             return 0;
   85         }
   86     }
   87     bool get_position(OUT int32_t* pos, OUT int32_t* totlines, OUT float* percent, OUT bool* truncated)
   88     {
   89         return false;
   90     }
   91 
   92     sinsp_table_field_storage m_last_key;
   93     bool m_drilled_up;
   94     bool m_selection_changed;
   95     MEVENT m_last_mevent;
   96     string m_selection_filter;
   97     bool m_scroll_paused;
   98     
   99 private:
  100     void print_error(string wstr);
  101     uint32_t mkcol(uint64_t n);
  102     void draw_axis();
  103     void draw_menu(bool there_is_more);
  104     int64_t get_history_value_from_coordinate(uint32_t y, uint32_t x);
  105     int64_t get_history_color_from_coordinate(uint32_t y, uint32_t x);
  106     curses_spectro_history_row* get_history_row_from_coordinate(uint32_t y);
  107     uint64_t latency_from_coordinate(uint32_t x);
  108     void draw_square(int32_t y1, int32_t x1, int32_t y2, int32_t x2, char c);
  109 
  110     sinsp* m_inspector;
  111     WINDOW* m_tblwin;
  112     sinsp_cursesui* m_parent;
  113     sinsp_table* m_table;
  114     int32_t m_table_x_start;
  115     uint32_t m_table_y_start;
  116     vector<curses_table_column_info> m_legend;
  117     vector<sinsp_sample_row>* m_data;
  118     uint32_t m_w;
  119     uint32_t m_h;
  120     vector<uint32_t> m_colpalette;
  121     sinsp_filter_check_reference* m_converter;
  122     uint64_t m_n_flushes;
  123     uint64_t m_n_flushes_with_data;
  124     vector<curses_spectro_history_row> m_history;
  125     curses_spectro_history_row m_t_row;
  126     bool m_mouse_masked;
  127     int32_t m_lastx, m_lasty;
  128     int32_t m_selstart_x, m_selstart_y;
  129     int32_t m_prev_sel_x1, m_prev_sel_x2;
  130     int32_t m_prev_sel_y1, m_prev_sel_y2;
  131     bool m_is_tracer;
  132     bool m_selecting;
  133 
  134     friend class curses_spectro_sidemenu;
  135 };
  136 
  137 #endif // NOCURSESUI
  138 #endif // CSYSDIG