#include "ctx.h"
#include "stats.h"
#include "tui.h"
+#include "util.h"
#define MAX_STATS 1024
init_pair(2, COLOR_GREEN, COLOR_BLACK);
init_pair(3, COLOR_BLUE, COLOR_BLACK);
init_pair(4, COLOR_BLACK, COLOR_WHITE);
+ init_pair(5, COLOR_YELLOW, COLOR_BLACK);
// Enable raw mode
raw();
*/
static int fireperf_tui_draw_graph(struct fireperf_tui* tui) {
const struct fireperf_stats* stats = NULL;
+ char* scale = NULL;
int max_x = 0;
int max_y = 0;
size_t peak_bps = fireperf_tui_get_peak_bps(tui, max_x);
// Figure out how many bps a step represents
- double step = peak_bps / (max_y + 1);
+ double step = peak_bps / (max_y + 0);
+
+ // Make the brush yellow
+ wattron(tui->graph, COLOR_PAIR(5));
+
+ // Draw the grid
+ for (double line = 0; line <= 1; line += 0.25) {
+ scale = format_size(line * peak_bps, FIREPERF_FORMAT_BITS);
+ if (!scale)
+ continue;
+
+ size_t l = strlen(scale);
+
+ // Draw a horizontal line
+ for (unsigned int x = 0; x < max_x - l - 1; x++) {
+ mvwaddch(tui->graph, max_y - (max_y * line), x, ACS_HLINE);
+ }
+
+ // Write the scale
+ mvwaddnstr(tui->graph, max_y - (max_y * line), max_x - l, scale, l);
+ free(scale);
+ }
+
+ wattroff(tui->graph, COLOR_PAIR(5));
// Make the brush red
wattron(tui->graph, COLOR_PAIR(1));