summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpdw <>2010-11-27 11:14:43 +0000
committerpdw <>2010-11-27 11:14:43 +0000
commite533714b782dfb3112a01229399d34a324eaf21f (patch)
treeadd91e34218d2a63138211bb9ae1137b0e9c4652
parent6197223f5265dcd983a5bb9b17c86d691462e06c (diff)
downloadiftop-e533714b782dfb3112a01229399d34a324eaf21f.zip
Changed sort behaviour to be based on what is displayed when displaying only
to/from traffic. Damián Viano <des@debian.org>
-rw-r--r--ui.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/ui.c b/ui.c
index 7cc4757..9f97621 100644
--- a/ui.c
+++ b/ui.c
@@ -97,10 +97,30 @@ int dontshowdisplay = 0;
*/
int screen_line_bandwidth_compare(host_pair_line* aa, host_pair_line* bb, int start_div) {
int i;
- for(i = start_div; i < HISTORY_DIVISIONS; i++) {
- if(aa->recv[i] + aa->sent[i] != bb->recv[i] + bb->sent[i]) {
- return(aa->recv[i] + aa->sent[i] < bb->recv[i] + bb->sent[i]);
+ switch(options.linedisplay) {
+ case OPTION_LINEDISPLAY_ONE_LINE_SENT:
+ for(i = start_div; i < HISTORY_DIVISIONS; i++) {
+ if(aa->sent[i] != bb->sent[i]) {
+ return(aa->sent[i] < bb->sent[i]);
+ }
+ }
+ break;
+ case OPTION_LINEDISPLAY_ONE_LINE_RECV:
+ for(i = start_div; i < HISTORY_DIVISIONS; i++) {
+ if(aa->recv[i] != bb->recv[i]) {
+ return(aa->recv[i] < bb->recv[i]);
+ }
}
+ break;
+ case OPTION_LINEDISPLAY_TWO_LINE:
+ case OPTION_LINEDISPLAY_ONE_LINE_BOTH:
+ /* fallback to the combined sent+recv that also act as fallback for sent/recv */
+ break;
+ }
+ for(i = start_div; i < HISTORY_DIVISIONS; i++) {
+ if(aa->recv[i] + aa->sent[i] != bb->recv[i] + bb->sent[i]) {
+ return(aa->recv[i] + aa->sent[i] < bb->recv[i] + bb->sent[i]);
+ }
}
return 1;
}