diff options
| author | Nicolas Pitre <npitre@baylibre.com> | 2025-04-09 21:14:03 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-04-11 16:55:55 +0200 |
| commit | 547f57b88d5f2ad4e9ab5e0d63a668467c10c736 (patch) | |
| tree | 8a4673ce9f660679b0b204d8facd5faa8075c374 /drivers/tty/vt | |
| parent | c7cb5b0779d782c1bda10414af7a9fcadcc87e93 (diff) | |
| download | linux-next-547f57b88d5f2ad4e9ab5e0d63a668467c10c736.tar.gz linux-next-547f57b88d5f2ad4e9ab5e0d63a668467c10c736.zip | |
vt: pad double-width code points with a zero-white-space
In the Unicode screen buffer, we follow double-width code points with a
space to maintain proper column alignment. This, however, creates
semantic problems when e.g. using cut and paste or selection.
Let's use a better code point for the column padding's purpose i.e. a
zero-white-space rather than a full space.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Link: https://lore.kernel.org/r/20250410011839.64418-12-nico@fluxnic.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/vt')
| -rw-r--r-- | drivers/tty/vt/vt.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index e3d35c4f9204..dc84f9c6b7c6 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -2937,12 +2937,13 @@ static int vc_con_write_normal(struct vc_data *vc, int tc, int c, width = 2; } else if (ucs_is_zero_width(c)) { prev_c = vc_uniscr_getc(vc, -1); - if (prev_c == ' ' && + if (prev_c == 0x200B && ucs_is_double_width(vc_uniscr_getc(vc, -2))) { /* * Let's merge this zero-width code point with * the preceding double-width code point by - * replacing the existing whitespace padding. + * replacing the existing zero-white-space + * padding. */ vc_con_rewind(vc); } else if (c == 0xfe0f && prev_c != 0) { @@ -3040,7 +3041,11 @@ static int vc_con_write_normal(struct vc_data *vc, int tc, int c, tc = conv_uni_to_pc(vc, ' '); if (tc < 0) tc = ' '; - next_c = ' '; + /* + * Store a zero-white-space in the Unicode screen given that + * the previous code point is semantically double-width. + */ + next_c = 0x200B; } out: |
