Skip to content

Commit

Permalink
Ticket #3261: mcview hex edit: CJK overflow.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
egmontkob authored and aborodin committed Feb 17, 2015
1 parent bdb3d06 commit 10c9384
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/viewer/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions src/viewer/hex.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 10c9384

Please sign in to comment.