提交 12944934 编写于 作者: N nocjj

display: modify screen wrap if screen is not wide enough

Add width limit and height limit to display.
If display is out of range, do not display this task or field.
Signed-off-by: NJiajun Chen <1250062498@qq.com>
上级 35d75a19
......@@ -25,6 +25,9 @@
int delay_time;
int quit_flag;
int scr_row_size; /* screen height, and will refresh in every loop */
int scr_col_size; /* screen width, and will refresh in every loop */
int showd_task; /* the num that has been showd, include task be hidden */
struct domain_list scr_cur;
struct domain_list scr_pre;
......@@ -74,10 +77,13 @@ static void summary(void)
static void show_header(void)
{
int showd_width = 0;
attron(A_REVERSE);
for (int i = 0; i < FD_END; i++) {
if (fields[i].display_flag == 1) {
if (fields[i].display_flag == 1 &&
(showd_width + fields[i].align) < scr_col_size) {
printw("%*s", fields[i].align, fields[i].name);
showd_width += fields[i].align;
}
}
attroff(A_REVERSE);
......@@ -172,13 +178,20 @@ static void print_domain_field(struct domain *dom, int field)
static void show_task(struct domain *task)
{
int showd_width = 0; /* make show width do not beyond screen */
if (showd_task + 1 > scr_row_size - 4) {
return;
}
clrtoeol();
for (int i = 0; i < FD_END; i++) {
if (fields[i].display_flag == 1) {
if (fields[i].display_flag == 1 &&
(showd_width + fields[i].align) < scr_col_size) {
print_domain_field(task, i);
showd_width += fields[i].align;
}
}
printw("\n");
showd_task++;
}
static void show_domains_threads(struct domain *dom)
......@@ -197,6 +210,7 @@ static void show_domains_threads(struct domain *dom)
static void show_domains(struct domain_list *list)
{
showd_task = 0;
for (int i = 0; i < list->num; i++) {
struct domain *dom = &(list->domains[i]);
show_task(dom);
......@@ -308,6 +322,8 @@ int main(int argc, char *argv[])
do {
refresh_domains(&scr_cur, &scr_pre);
getmaxyx(stdscr, scr_row_size, scr_col_size);
/* display frame make */
move(0, 0);
summary();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册