rolandriegel / nload

Real-time network traffic monitor
GNU General Public License v2.0
305 stars 35 forks source link

Move to 'block' characters for bar graph display #14

Open lelandbatey opened 2 years ago

lelandbatey commented 2 years ago

This change modifies the characters used to display the "progressbars" of the graph. Instead of being purely ascii characters such as #, |, and ., it uses longer 'block elements' characters , , and , respectively. On terminals which support it, this makes for a much improved visual display.

Here's an example of the bar-graph output with this change:

Device xxxxxxxx [192.168.100.212] (3/3):     
=========================================================     
Incoming (100% @ 256 MBit/s):     

                                   Cur: 594.95 kBit/s     
   ▗   ▗▗                          Avg: 7.75 MBit/s     
  ████████▟▟▟                      Min: 0.00 Bit/s     
 ▗████████████▟██                  Max: 147.28 MBit/s     
 █████████████████                 Ttl: 42.43 GByte     
Outgoing (100% @ 32 MBit/s):     
                                   Cur: 23.57 MBit/s     
                            ▗█▟▟▗▗ Avg: 748.59 kBit/s     
                            ██████ Min: 0.00 Bit/s     
                           ▗██████ Max: 25.71 MBit/s     
                 ▗▗        ███████ Ttl: 5.03 GByte     

This is accomplished by swapping the characters being printed, then by changing the program/build system slightly so that it will link against ncursesw (the version of ncurses which supports full-width characters instead of only purely ascii).

Since this change would permanently shift this entire codebase so that it uses ncursesw instead of "classic ncurses", and since it would force the use of multiwidth 'block' characters which may not be compatible with many of the original terminals where nload is used, I don't recommend upstreaming this change to nload, at least not until someone makes further changes which make this a toggle-able setting and which maintains total backwards compatibility with systems where ncursesw isn't available.

Until then, this change will exist as an option for those who want it (like me), and as an example for the interested.

perguth commented 3 months ago

I would prefer the ASCII version.

Is the rendering shown correctly? image