fixes issue #110 - dynamic DEV column length, MIN=5, MAX=15
This commit is contained in:
36
src/cui.cpp
36
src/cui.cpp
@@ -225,6 +225,25 @@ void Line::log() {
|
|||||||
std::cout << '/' << m_pid << '/' << m_uid << "\t" << sent_value << "\t" << recv_value << std::endl;
|
std::cout << '/' << m_pid << '/' << m_uid << "\t" << sent_value << "\t" << recv_value << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int get_devlen(Line *lines[], int nproc, int rows)
|
||||||
|
{
|
||||||
|
int devlen = MIN_COLUMN_WIDTH_DEV; int curlen;
|
||||||
|
for (int i = 0; i < nproc; i++) {
|
||||||
|
if (i + 3 < rows)
|
||||||
|
{
|
||||||
|
curlen = strlen(lines[i]->devicename);
|
||||||
|
if(curlen > devlen)
|
||||||
|
curlen = devlen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(devlen > MAX_COLUMN_WIDTH_DEV)
|
||||||
|
devlen = MAX_COLUMN_WIDTH_DEV;
|
||||||
|
|
||||||
|
return devlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int GreatestFirst(const void *ma, const void *mb) {
|
int GreatestFirst(const void *ma, const void *mb) {
|
||||||
Line **pa = (Line **)ma;
|
Line **pa = (Line **)ma;
|
||||||
Line **pb = (Line **)mb;
|
Line **pb = (Line **)mb;
|
||||||
@@ -336,21 +355,8 @@ void show_ncurses(Line *lines[], int nproc) {
|
|||||||
cols = PROGNAME_WIDTH;
|
cols = PROGNAME_WIDTH;
|
||||||
|
|
||||||
|
|
||||||
//issue #110 - dynamic length devicename
|
//issue #110 - maximum devicename length min=5, max=15
|
||||||
int devlen = MIN_COLUMN_WIDTH_DEV; int curlen;
|
int devlen = get_devlen(lines, nproc, rows);
|
||||||
|
|
||||||
for (int i = 0; i < nproc; i++) {
|
|
||||||
if (i + 3 < rows)
|
|
||||||
{
|
|
||||||
curlen = strlen(lines[i]->devicename);
|
|
||||||
if(curlen > devlen)
|
|
||||||
curlen = devlen;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(devlen > MAX_COLUMN_WIDTH_DEV)
|
|
||||||
devlen = MAX_COLUMN_WIDTH_DEV;
|
|
||||||
|
|
||||||
|
|
||||||
proglen = cols - 50 - devlen;
|
proglen = cols - 50 - devlen;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user