Merge branch '3261_hexedit_cjk_overflow'

* 3261_hexedit_cjk_overflow:
  Ticket #3261: mcview hex edit: CJK overflow.
This commit is contained in:
Andrew Borodin 2015-02-17 14:33:14 +03:00
commit 45d135d768
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; const screen_dimen cols = view->data_area.width;
int bytes; int bytes;
if (cols < 8 + 17) if (cols < 9 + 17)
bytes = 4; bytes = 4;
else else
bytes = 4 * ((cols - 8) / ((cols < 80) ? 17 : 18)); bytes = 4 * ((cols - 9) / ((cols <= 80) ? 17 : 18));
#ifdef HAVE_ASSERT_H #ifdef HAVE_ASSERT_H
assert (bytes != 0); assert (bytes != 0);
#endif #endif

View File

@ -102,12 +102,14 @@ mcview_display_hex (mcview_t * view)
const screen_dimen height = view->data_area.height; const screen_dimen height = view->data_area.height;
const screen_dimen width = view->data_area.width; const screen_dimen width = view->data_area.width;
const int ngroups = view->bytes_per_line / 4; 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 /* 8 characters are used for the file offset, and every hex group
* takes 13 characters. On "big" screens, the groups are separated * takes 13 characters. Starting at width of 80 columns, the groups
* by an extra vertical line, and there is an extra space before the * are separated by an extra vertical line. Starting at width of 81,
* text column. * 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; int row;
off_t from; off_t from;