mirror of
https://github.com/Syllo/nvtop.git
synced 2026-04-22 06:58:24 -04:00
Update interface codebase
The interface layout selection has been updated to support the interface option. The interface option stores which data that needs to be plotted for each devices. The plot drawing code now supports the reverse plotting option. The interface uses the ring buffer, the updated version of the layout computation and plots the data specified by the interface options.
This commit is contained in:
15
src/plot.c
15
src/plot.c
@@ -9,7 +9,7 @@ static inline int data_level(double rows, double data, double increment) {
|
||||
|
||||
void nvtop_line_plot(WINDOW *win, size_t num_data, const double *data,
|
||||
double min, double max, unsigned num_plots,
|
||||
const char *legend[]) {
|
||||
bool legend_left, char legend[4][PLOT_MAX_LEGEND_SIZE]) {
|
||||
if (num_data == 0)
|
||||
return;
|
||||
int rows, cols;
|
||||
@@ -87,14 +87,15 @@ void nvtop_line_plot(WINDOW *win, size_t num_data, const double *data,
|
||||
int plot_y_position = 0;
|
||||
for (unsigned i = 0; i < num_plots && plot_y_position < rows; ++i) {
|
||||
if (legend[i]) {
|
||||
size_t length = strlen(legend[i]);
|
||||
wattron(win, COLOR_PAIR(1 + i % 5));
|
||||
if (length < (size_t)cols) {
|
||||
mvwprintw(win, plot_y_position, cols - length, "%s", legend[i]);
|
||||
if (legend_left) {
|
||||
mvwprintw(win, plot_y_position, 0, "%.*s", cols, legend[i]);
|
||||
} else {
|
||||
wmove(win, plot_y_position, 0);
|
||||
for (int j = 0; j < cols; ++j) {
|
||||
waddch(win, legend[i][j]);
|
||||
size_t length = strlen(legend[i]);
|
||||
if (length <= (size_t)cols) {
|
||||
mvwprintw(win, plot_y_position, cols - length, "%s", legend[i]);
|
||||
} else {
|
||||
mvwprintw(win, plot_y_position, 0, "%.*s", length - cols, legend[i]);
|
||||
}
|
||||
}
|
||||
wattroff(win, COLOR_PAIR(1 + i % 5));
|
||||
|
||||
Reference in New Issue
Block a user