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:
parent
0ce6762b57
commit
59f2f01f22
@ -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
|
static void
|
||||||
change_refresh_rate(void)
|
change_refresh_rate(void)
|
||||||
{
|
{
|
||||||
@ -2882,11 +2903,9 @@ show_stats(pthread_t *data_thread)
|
|||||||
long int time_last, time_dif;
|
long int time_last, time_dif;
|
||||||
struct timespec time_now;
|
struct timespec time_now;
|
||||||
int c;
|
int c;
|
||||||
int max_row, max_col;
|
|
||||||
uint8_t active_tab = THREADS_TAB;
|
uint8_t active_tab = THREADS_TAB;
|
||||||
uint8_t current_page = 0;
|
uint8_t current_page = 0;
|
||||||
uint8_t max_pages = 1;
|
uint8_t max_pages = 1;
|
||||||
uint16_t required_size = WINDOW_HEADER + 1;
|
|
||||||
uint64_t i;
|
uint64_t i;
|
||||||
char current_page_str[CURRENT_PAGE_STR_LEN];
|
char current_page_str[CURRENT_PAGE_STR_LEN];
|
||||||
bool force_refresh = true;
|
bool force_refresh = true;
|
||||||
@ -2897,19 +2916,7 @@ show_stats(pthread_t *data_thread)
|
|||||||
switch_tab(THREADS_TAB);
|
switch_tab(THREADS_TAB);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
/* Check if interface has to be resized (terminal size changed) */
|
check_resize_interface(active_tab, ¤t_page);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &time_now);
|
clock_gettime(CLOCK_MONOTONIC, &time_now);
|
||||||
time_dif = time_now.tv_sec - time_last;
|
time_dif = time_now.tv_sec - time_last;
|
||||||
|
Loading…
Reference in New Issue
Block a user