Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vt: selection: take screen contents from uniscr if available

This preserves whatever was written even if we can't currently display the
given glyph. Mouse paste won't corrupt any character of wcwidth() == 1
anymore.

Note that for now uniscr doesn't get allocated until something reads
/dev/vcsuN for that console, making this code dormant for most users.

Signed-off-by: Adam Borowski <kilobyte@angband.pl>
Acked-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Adam Borowski and committed by
Greg Kroah-Hartman
9bfdc261 df155d2d

+18 -4
+7 -4
drivers/tty/vt/selection.c
··· 57 57 complement_pos(sel_cons, where); 58 58 } 59 59 60 - static u16 60 + static u32 61 61 sel_pos(int n) 62 62 { 63 + if (use_unicode) 64 + return screen_glyph_unicode(sel_cons, n / 2); 63 65 return inverse_translate(sel_cons, screen_glyph(sel_cons, n), 64 - use_unicode); 66 + 0); 65 67 } 66 68 67 69 /** ··· 92 90 0x07FFFFFE, /* lowercase */ 93 91 }; 94 92 95 - static inline int inword(const u16 c) { 93 + static inline int inword(const u32 c) 94 + { 96 95 return c > 0x7f || (( inwordLut[c>>5] >> (c & 0x1F) ) & 1); 97 96 } 98 97 ··· 170 167 struct tiocl_selection v; 171 168 char *bp, *obp; 172 169 int i, ps, pe, multiplier; 173 - u16 c; 170 + u32 c; 174 171 int mode; 175 172 176 173 poke_blanked_console();
+10
drivers/tty/vt/vt.c
··· 4543 4543 } 4544 4544 EXPORT_SYMBOL_GPL(screen_glyph); 4545 4545 4546 + u32 screen_glyph_unicode(struct vc_data *vc, int n) 4547 + { 4548 + struct uni_screen *uniscr = get_vc_uniscr(vc); 4549 + 4550 + if (uniscr) 4551 + return uniscr->lines[n / vc->vc_cols][n % vc->vc_cols]; 4552 + return inverse_translate(vc, screen_glyph(vc, n * 2), 1); 4553 + } 4554 + EXPORT_SYMBOL_GPL(screen_glyph_unicode); 4555 + 4546 4556 /* used by vcs - note the word offset */ 4547 4557 unsigned short *screen_pos(struct vc_data *vc, int w_offset, int viewed) 4548 4558 {
+1
include/linux/selection.h
··· 32 32 33 33 extern unsigned short *screen_pos(struct vc_data *vc, int w_offset, int viewed); 34 34 extern u16 screen_glyph(struct vc_data *vc, int offset); 35 + extern u32 screen_glyph_unicode(struct vc_data *vc, int offset); 35 36 extern void complement_pos(struct vc_data *vc, int offset); 36 37 extern void invert_screen(struct vc_data *vc, int offset, int count, int shift); 37 38