Skip to content

Conversation

@tmzullinger
Copy link
Contributor

A number of minor issues crept in as the output plugins were refactored.

Ensure padding_len is greater than 0. When calculating the terminal width, if the output is piped, we can end up with a negative padding length. This results in no space between the filename the size. Set padding_len to a minimum of 1.

The - lines printed by _getHardRule() are too short when output is not to a terminal, i.e.: when sending to a pager. This turns out to be due to the LINES and COLUMNS being transposed in getTtySize. When the terminal size cannot be determined, we want to set it to something like 80x24 (COLUMNS x LINES), but instead we set it to 25x78, which results in very short lines from _getHardRule(). Fix the transposition and adjust the values to 79x25 which ensures the output is aligned with printAudioInfo(). The audio info line uses two hard tabs and has a minimum width of 79 COLUMNS.

Fix an off-by-one in the size_len var in _getFileHeader(). We add 4 characters ([ & ]) rather than 5. This was added in 599eddd (display the ellipsis file name and path, and the file size right justified in printHeader., 2015-10-20), released in 0.7.9.

The output is now neatly aligned when output is not directly to a terminal:

$ eyeD3 ~/mp3/tool/ænima/13-ænema.mp3 | cat
/home/foo/mp3/tool/ænima/13-ænema.mp3 [ 14.50 MB ]

Time: 06:40 MPEG1, Layer III [ ~278 kb/s @ 44100 Hz - Joint stereo ]

A number of minor issues crept in as the output plugins were refactored.

Ensure `padding_len` is greater than 0.  When calculating the terminal
width, if the output is piped, we can end up with a negative padding
length.  This results in no space between the filename the size.  Set
`padding_len` to a minimum of 1.

The `-` lines printed by `_getHardRule()` are too short when output is
not to a terminal, i.e.: when sending to a pager.  This turns out to be
due to the LINES and COLUMNS being transposed in `getTtySize`.  When the
terminal size cannot be determined, we want to set it to something like
80x24 (COLUMNS x LINES), but instead we set it to 25x78, which results
in very short lines from `_getHardRule()`.  Fix the transposition and
adjust the values to 79x25 which ensures the output is aligned with
`printAudioInfo()`.  The audio info line uses two hard tabs and has a
minimum width of 79 COLUMNS.

Fix an off-by-one in the `size_len` var in `_getFileHeader()`.  We add 4
characters (`[ ` & ` ]`) rather than 5.  This was added in 599eddd
(display the ellipsis file name and path, and the file size right
justified in printHeader., 2015-10-20), released in 0.7.9.

The output is now neatly aligned when output is not directly to a
terminal:

$ eyeD3 ~/mp3/tool/ænima/13-ænema.mp3 | cat
/home/foo/mp3/tool/ænima/13-ænema.mp3                              [ 14.50 MB ]
-------------------------------------------------------------------------------
Time: 06:40	MPEG1, Layer III	[ ~278 kb/s @ 44100 Hz - Joint stereo ]
-------------------------------------------------------------------------------
@tmzullinger tmzullinger force-pushed the fix-alignment-in-classic-plugin branch from 044c5b6 to 6deb1e2 Compare April 22, 2025 14:40
@nicfit nicfit merged commit 313c8f5 into nicfit:0.9.x Apr 23, 2025
8 checks passed
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