Ticket #3261: mcview hex edit: CJK overflow.

At certain terminal widths (including the default 80), if the last byte
of a line begins a CJK character then the corresponding glyps is drawn
in the last column, so it's replaced by a replacement symbol.

The default layout should, at all possible terminal widths, have an
extra last character column that is empty normally, but allows room for
a CJK to overflow here.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Egmont Koblinger 2015-02-17 14:30:37 +03:00 committed by Andrew Borodin
parent bdb3d06f94
commit 10c938451d
2 changed files with 8 additions and 6 deletions

View File

@ -322,10 +322,10 @@ mcview_update_bytes_per_line (mcview_t * view)
const screen_dimen cols = view->data_area.width;
int bytes;
if (cols < 8 + 17)
if (cols < 9 + 17)
bytes = 4;
else
bytes = 4 * ((cols - 8) / ((cols < 80) ? 17 : 18));
bytes = 4 * ((cols - 9) / ((cols <= 80) ? 17 : 18));
#ifdef HAVE_ASSERT_H
assert (bytes != 0);
#endif

View File

@ -102,12 +102,14 @@ mcview_display_hex (mcview_t * view)
const screen_dimen height = view->data_area.height;
const screen_dimen width = view->data_area.width;
const int ngroups = view->bytes_per_line / 4;
const screen_dimen text_start = 8 + 13 * ngroups + ((width < 80) ? 0 : (ngroups - 1 + 1));
/* 8 characters are used for the file offset, and every hex group
* takes 13 characters. On "big" screens, the groups are separated
* by an extra vertical line, and there is an extra space before the
* text column.
* takes 13 characters. Starting at width of 80 columns, the groups
* are separated by an extra vertical line. Starting at width of 81,
* there is an extra space before the text column. There is always a
* mostly empty column on the right, to allow overflowing CJKs.
*/
const screen_dimen text_start = 8 + 13 * ngroups +
((width < 80) ? 0 : (width == 80) ? (ngroups - 1) : (ngroups - 1 + 1));
int row;
off_t from;