diff options
| author | Eli Zaretskii | 2026-04-11 14:49:47 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2026-04-11 14:49:47 +0300 |
| commit | 1eb7218f90159459e857734c3e5f4b7cdf2f2bda (patch) | |
| tree | 8b21b790c23b0acb9e90f9335bdf0b3f282e5c1d /src | |
| parent | adfa1e969f869381b0a59cb1124bc38e3dd93d03 (diff) | |
| download | emacs-1eb7218f90159459e857734c3e5f4b7cdf2f2bda.tar.gz emacs-1eb7218f90159459e857734c3e5f4b7cdf2f2bda.zip | |
Fix display of ambiguous-width characters on MS-Windows terminal
* src/w32console.c (syms_of_ntterm) <w32--terminal-is-conhost>:
New variable.
(initialize_w32_display): Set 'w32--terminal-is-conhost' non-nil
when running on ConHost.
* lisp/international/characters.el (use-cjk-char-width-table):
When Emacs runs on MS-Windows Terminal, behave as if
'cjk-ambiguous-chars-are-wide' were nil even in CJK locales.
(Bug#79298)
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32console.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/w32console.c b/src/w32console.c index b0a2f0c1c0e..8737b9cca70 100644 --- a/src/w32console.c +++ b/src/w32console.c | |||
| @@ -59,12 +59,13 @@ static WORD w32_face_attributes (struct frame *f, int face_id); | |||
| 59 | static int w32con_write_vt_seq (const char *); | 59 | static int w32con_write_vt_seq (const char *); |
| 60 | static void turn_on_face (struct frame *, int face_id); | 60 | static void turn_on_face (struct frame *, int face_id); |
| 61 | static void turn_off_face (struct frame *, int face_id); | 61 | static void turn_off_face (struct frame *, int face_id); |
| 62 | static COORD w32con_get_cursor_coords (); | 62 | static COORD w32con_get_cursor_coords (void); |
| 63 | 63 | ||
| 64 | static COORD cursor_coords; | 64 | static COORD cursor_coords; |
| 65 | static HANDLE prev_screen, cur_screen; | 65 | static HANDLE prev_screen, cur_screen; |
| 66 | static WORD char_attr_normal; | 66 | static WORD char_attr_normal; |
| 67 | static DWORD prev_console_mode; | 67 | static DWORD prev_console_mode; |
| 68 | static DWORD prev_output_mode; | ||
| 68 | static int bg_normal; | 69 | static int bg_normal; |
| 69 | static int fg_normal; | 70 | static int fg_normal; |
| 70 | 71 | ||
| @@ -121,7 +122,7 @@ w32con_write_vt_seq (const char *seq) | |||
| 121 | } | 122 | } |
| 122 | 123 | ||
| 123 | static COORD | 124 | static COORD |
| 124 | w32con_get_cursor_coords () | 125 | w32con_get_cursor_coords (void) |
| 125 | { | 126 | { |
| 126 | CONSOLE_SCREEN_BUFFER_INFO info; | 127 | CONSOLE_SCREEN_BUFFER_INFO info; |
| 127 | GetConsoleScreenBufferInfo (GetStdHandle (STD_OUTPUT_HANDLE), &info); | 128 | GetConsoleScreenBufferInfo (GetStdHandle (STD_OUTPUT_HANDLE), &info); |
| @@ -1005,6 +1006,13 @@ initialize_w32_display (struct terminal *term, int *width, int *height) | |||
| 1005 | GetConsoleCursorInfo (prev_screen, &prev_console_cursor); | 1006 | GetConsoleCursorInfo (prev_screen, &prev_console_cursor); |
| 1006 | #endif | 1007 | #endif |
| 1007 | 1008 | ||
| 1009 | /* Record whether we are on ConHost or Windows Terminal. */ | ||
| 1010 | const DWORD virt_mode_flags | ||
| 1011 | = (ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING); | ||
| 1012 | GetConsoleMode (cur_screen, &prev_output_mode); | ||
| 1013 | w32__terminal_is_conhost = | ||
| 1014 | (prev_output_mode & virt_mode_flags) != virt_mode_flags; | ||
| 1015 | |||
| 1008 | /* Respect setting of LINES and COLUMNS environment variables. */ | 1016 | /* Respect setting of LINES and COLUMNS environment variables. */ |
| 1009 | { | 1017 | { |
| 1010 | char * lines = getenv ("LINES"); | 1018 | char * lines = getenv ("LINES"); |
| @@ -1204,6 +1212,12 @@ may be preferable when working directly at the console with a large | |||
| 1204 | scroll-back buffer. */); | 1212 | scroll-back buffer. */); |
| 1205 | w32_use_full_screen_buffer = 0; | 1213 | w32_use_full_screen_buffer = 0; |
| 1206 | 1214 | ||
| 1215 | DEFVAR_BOOL ("w32--terminal-is-conhost", | ||
| 1216 | w32__terminal_is_conhost, | ||
| 1217 | doc: /* Non-nil means Emacs text-mode terminal is MS-Windows ConHost. | ||
| 1218 | If nil, Emacs is displaying text-mode frames on the Windows Terminal. */); | ||
| 1219 | w32__terminal_is_conhost = 0; | ||
| 1220 | |||
| 1207 | defsubr (&Sset_screen_color); | 1221 | defsubr (&Sset_screen_color); |
| 1208 | defsubr (&Sget_screen_color); | 1222 | defsubr (&Sget_screen_color); |
| 1209 | defsubr (&Sw32_use_virtual_terminal); | 1223 | defsubr (&Sw32_use_virtual_terminal); |