/*
* out_curses.c Curses Output
*
* Copyright (c) 2001-2013 Thomas Graf <tgraf@suug.ch>
* Copyright (c) 2013 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include <bmon/bmon.h>
#include <bmon/conf.h>
#include <bmon/attr.h>
#include <bmon/element.h>
#include <bmon/element_cfg.h>
#include <bmon/input.h>
#include <bmon/history.h>
#include <bmon/graph.h>
#include <bmon/output.h>
#include <bmon/utils.h>
enum {
GRAPH_DISPLAY_SIDE_BY_SIDE = 1,
GRAPH_DISPLAY_STANDARD = 2,
};
enum {
KEY_TOGGLE_LIST = 'l',
KEY_TOGGLE_GRAPH = 'g',
KEY_TOGGLE_DETAILS = 'd',
KEY_TOGGLE_INFO = 'i',
KEY_COLLECT_HISTORY = 'h',
};
#define DETAILS_COLS 40
#define LIST_COL_1 31
#define LIST_COL_2 55
/* Set to element_current() before drawing */
static struct element *current_element;
static struct attr *current_attr;
/* Length of list to draw, updated in draw_content() */
static int list_length;
static int list_req;
/* Number of graphs to draw (may be < c_ngraph) */
static int ngraph;
/*
* Offset in number of lines within the the element list of the currently
* selected element. Updated while summing up required lines.
*/
static unsigned int selection_offset;
/*
* Offset in number of lines of the first element to be drawn. Updated
* in draw_content()
*/
static int offset;
/*
* Offset to the first graph to draw in number of attributes with graphs.
*/
static unsigned int graph_offset;
static int graph_display = GRAPH_DISPLAY_STANDARD;
/*
* Number of detail columns
*/
static int detail_cols;
static int info_cols;
static int initialized;
static int print_help;
static int quit_mode;
static int help_page;
/* Current row */
static int row;
/* Number of rows */
static int rows;
/* Number of columns */
static int cols;
static int c_show_graph = 1;
static int c_ngraph = 1;
static int c_use_colors = 1;
static int c_show_details = 0;
static int c_show_list = 1;
static int c_show_info = 0;
static int c_list_min = 6;
static struct graph_cfg c_graph_cfg = {
.gc_width =