Skip to content

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

Open
lelandbatey wants to merge 1 commit into
rolandriegel:masterfrom
lelandbatey:unicode-fullwidth-characters
Open

Move to 'block' characters for bar graph display#14
lelandbatey wants to merge 1 commit into
rolandriegel:masterfrom
lelandbatey:unicode-fullwidth-characters

Conversation

@lelandbatey

Copy link
Copy Markdown

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.

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.

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

perguth commented Apr 16, 2024

Copy link
Copy Markdown

I would prefer the ASCII version.

Is the rendering shown correctly?
image

@lelandbatey

Copy link
Copy Markdown
Author

@perguth No, it's not displaying correctly. The strange offsets come from how Github displays the text in the browser. If you open that text in your terminal, it looks like this:
2025-09-14_17-12-49

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants