1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-28 01:35:32 +00:00

Use new macro UCS_ORPHAN_CELL for broken double-cell characters.

UCS_ORPHAN_CELL is currently defined as U+0020 SPACE, which was
already used before this macro, so the behaviour does not change,
but the code seems clearer now.

I searched for ' ' and 32 and 0x20 and \x20, and replaced with
UCS_ORPHAN_CELL wherever UCS_NO_CHAR was involved.  However,
some BFU widgets first draw spaces and then overwrite with text;
those will require a more complex fix if UCS_ORPHAN_CELL is ever
changed to some other character.
This commit is contained in:
Kalle Olavi Niemitalo 2006-11-12 19:53:31 +02:00 committed by Kalle Olavi Niemitalo
parent 89fd7efa3a
commit 8b8cd57941
4 changed files with 31 additions and 19 deletions

View File

@ -483,7 +483,7 @@ utf8:
UCS_NO_CHAR, 0, hk_color);
} else {
draw_char(term, xbase + x - 1, y,
' ', 0, hk_color);
UCS_ORPHAN_CELL, 0, hk_color);
}
} else {
#ifdef CONFIG_DEBUG
@ -508,7 +508,7 @@ utf8:
y, UCS_NO_CHAR, 0, color);
} else {
draw_char(term, xbase + x - !!hk_state,
y, ' ', 0, color);
y, UCS_ORPHAN_CELL, 0, color);
}
} else {
draw_char(term, xbase + x - !!hk_state,
@ -1171,10 +1171,10 @@ display_mainmenu(struct terminal *term, struct menu *menu)
/* Is second cell of double-width char on the place where
* first char of the R_MAINMENU_SPACE will be displayed? */
if (schar->data == UCS_NO_CHAR) {
/* Replace double-width char with ' '. */
/* Replace double-width char with UCS_ORPHAN_CELL. */
schar++;
draw_char_data(term, term->width - R_MAINMENU_SPACE - 1,
0, ' ');
0, UCS_ORPHAN_CELL);
}
}
#endif

View File

@ -16,6 +16,17 @@ typedef uint32_t unicode_val_T;
* for the second cell of a double-cell character. */
#define UCS_NO_CHAR ((unicode_val_T) 0xFFFFFFFD)
/* If ELinks should display a double-cell character but there is only
* one cell available, it displays this character instead. This must
* be a single-cell character but need not be unique. Possible values
* might be U+0020 SPACE or U+303F IDEOGRAPHIC HALF FILL SPACE.
*
* Some BFU widgets (at least input fields and list boxes) currently
* ignore this setting and use U+0020 instead. (They first draw spaces
* and then overwrite with text; look for utf8_cells2bytes calls.)
* We should fix that if we ever change the value. */
#define UCS_ORPHAN_CELL ((unicode_val_T) 0x20)
/*   replacement character. See u2cp(). */
#define NBSP_CHAR ((unsigned char) 1)
#define NBSP_CHAR_STRING "\001"

View File

@ -160,7 +160,7 @@ draw_line(struct terminal *term, int x, int y, int l, struct screen_char *line)
sc = line;
data_save = sc->data;
sc->data = ' ';
sc->data = UCS_ORPHAN_CELL;
copy_screen_chars(screen_char, line, 1);
sc->data = data_save;
size--;
@ -169,13 +169,13 @@ draw_line(struct terminal *term, int x, int y, int l, struct screen_char *line)
}
/* Instead of displaying double-width character at last column
* display only space. */
* display only UCS_ORPHAN_CELL. */
if (size - 1 > 0 && unicode_to_cell(line[size - 1].data) == 2) {
unicode_val_T data_save;
sc = &line[size - 1];
data_save = sc->data;
sc->data = ' ';
sc->data = UCS_ORPHAN_CELL;
copy_screen_chars(screen_char, line, size);
sc->data = data_save;
} else {
@ -256,7 +256,7 @@ draw_border(struct terminal *term, struct box *box,
#ifdef CONFIG_UTF8
/* Checks cells left and right to the box for broken double-width chars.
* Replace it with ' '.
* Replace it with UCS_ORPHAN_CELL.
* 1+---+3
* 1|box|##4
* 1| |##4
@ -284,7 +284,7 @@ fix_dwchar_around_box(struct terminal *term, struct box *box, int border,
schar = get_char(term, x, y);
for (;height--; schar += term->width)
if (unicode_to_cell(schar->data) == 2)
schar->data = ' ';
schar->data = UCS_ORPHAN_CELL;
}
/* 2 */
@ -296,7 +296,7 @@ fix_dwchar_around_box(struct terminal *term, struct box *box, int border,
schar = get_char(term, x, y);
for (;height--; schar += term->width)
if (unicode_to_cell(schar->data) == 2)
schar->data = ' ';
schar->data = UCS_ORPHAN_CELL;
}
/* 3 */
@ -308,7 +308,7 @@ fix_dwchar_around_box(struct terminal *term, struct box *box, int border,
schar = get_char(term, x, y);
for (;height--; schar += term->width)
if (schar->data == UCS_NO_CHAR)
schar->data = ' ';
schar->data = UCS_ORPHAN_CELL;
}
/* 4 */
@ -320,7 +320,7 @@ fix_dwchar_around_box(struct terminal *term, struct box *box, int border,
schar = get_char(term, x, y);
for (;height--; schar += term->width)
if (schar->data == UCS_NO_CHAR)
schar->data = ' ';
schar->data = UCS_ORPHAN_CELL;
}
}
#endif
@ -437,7 +437,7 @@ draw_text_utf8(struct terminal *term, int x, int y,
}
if (start->data == UCS_NO_CHAR && x - 1 > 0)
draw_char_data(term, x - 1, y, ' ');
draw_char_data(term, x - 1, y, UCS_ORPHAN_CELL);
pos = start;
@ -451,7 +451,7 @@ draw_text_utf8(struct terminal *term, int x, int y,
pos->data = UCS_NO_CHAR;
pos->attr = 0;
} else {
pos->data = (unicode_val_T)' ';
pos->data = UCS_ORPHAN_CELL;
}
} else {
pos->data = data;
@ -474,7 +474,7 @@ draw_text_utf8(struct terminal *term, int x, int y,
pos->data = UCS_NO_CHAR;
pos->attr = 0;
} else {
pos->data = (unicode_val_T)' ';
pos->data = UCS_ORPHAN_CELL;
}
} else {
pos->data = data;

View File

@ -412,13 +412,14 @@ retry_after_scroll:
}
/* The character does not fit completely.
* Write spaces to the cells that do fit. */
* Write UCS_ORPHAN_CELL to the cells that
* do fit. */
for (cell = 0; cell < cells; cell++) {
if (col_is_in_box(box, x + i + cell)
&& i + cell < fc->size)
draw_char_data(term,
x + i + cell,
y, ' ');
x + i + cell, y,
UCS_ORPHAN_CELL);
}
drew_char:
@ -538,7 +539,7 @@ utf8_select:
data = UCS_NO_CHAR;
i++;
} else if (cell == 2) {
data = ' ';
data = UCS_ORPHAN_CELL;
}
} else
data = '_';