spdk_top: make checking interface resize into a function

Creates new function to check interface resize.
This will be used in the next patch.

Signed-off-by: Krzysztof Karas <krzysztof.karas@intel.com>
Change-Id: I147145be2db4fdab6f97b67baf3c2936abf7f6a3
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7499
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Krzysztof Karas 2021-04-19 14:03:16 +02:00 committed by Tomasz Zawadzki
parent 0ce6762b57
commit 59f2f01f22

View File

@ -2131,6 +2131,27 @@ change_sorting(uint8_t tab, int winnum, bool *pstop_loop)
}
}
static void
check_resize_interface(uint8_t active_tab, uint8_t *current_page)
{
int max_row, max_col;
uint16_t required_size = WINDOW_HEADER + 1;
/* Check if interface has to be resized (terminal size changed) */
getmaxyx(stdscr, max_row, max_col);
if (max_row != g_max_row || max_col != g_max_col) {
if (max_row != g_max_row) {
*current_page = 0;
}
g_max_row = spdk_max(max_row, required_size);
g_max_col = max_col;
g_data_win_size = g_max_row - required_size + 1;
g_max_data_rows = g_max_row - WINDOW_HEADER;
resize_interface(active_tab);
}
}
static void
change_refresh_rate(void)
{
@ -2882,11 +2903,9 @@ show_stats(pthread_t *data_thread)
long int time_last, time_dif;
struct timespec time_now;
int c;
int max_row, max_col;
uint8_t active_tab = THREADS_TAB;
uint8_t current_page = 0;
uint8_t max_pages = 1;
uint16_t required_size = WINDOW_HEADER + 1;
uint64_t i;
char current_page_str[CURRENT_PAGE_STR_LEN];
bool force_refresh = true;
@ -2897,19 +2916,7 @@ show_stats(pthread_t *data_thread)
switch_tab(THREADS_TAB);
while (1) {
/* Check if interface has to be resized (terminal size changed) */
getmaxyx(stdscr, max_row, max_col);
if (max_row != g_max_row || max_col != g_max_col) {
if (max_row != g_max_row) {
current_page = 0;
}
g_max_row = spdk_max(max_row, required_size);
g_max_col = max_col;
g_data_win_size = g_max_row - required_size + 1;
g_max_data_rows = g_max_row - WINDOW_HEADER;
resize_interface(active_tab);
}
check_resize_interface(active_tab, &current_page);
clock_gettime(CLOCK_MONOTONIC, &time_now);
time_dif = time_now.tv_sec - time_last;