From 27960e7c164ca75c09db8a209c3f743976d61cf8 Mon Sep 17 00:00:00 2001 From: Shugo Maeda Date: Wed, 13 Mar 2019 11:28:15 +0900 Subject: [PATCH 1/2] Write characters one by one to display full-width characters correctly Otherwise, full-width characters overlap on a new Windows console. --- wincon/Makefile.mng | 4 ++++ wincon/pdcdisp.c | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/wincon/Makefile.mng b/wincon/Makefile.mng index 65ce363e..1a8f685a 100644 --- a/wincon/Makefile.mng +++ b/wincon/Makefile.mng @@ -86,6 +86,10 @@ ifeq ($(WIDE),Y) CFLAGS += -DPDC_WIDE endif +ifeq ($(NEW_WINCON_WORKAROUND),Y) + CFLAGS += -DPDC_NEW_WINCON_WORKAROUND +endif + ifeq ($(UTF8),Y) CFLAGS += -DPDC_FORCE_UTF8 endif diff --git a/wincon/pdcdisp.c b/wincon/pdcdisp.c index fe14ff3c..e4f664b6 100644 --- a/wincon/pdcdisp.c +++ b/wincon/pdcdisp.c @@ -108,11 +108,34 @@ void PDC_transform_line(int lineno, int x, int len, const chtype *srcp) #endif ci[dst].Char.UnicodeChar = (WCHAR)char_out; +#ifdef PDC_NEW_WINCON_WORKAROUND + sr.Left = x + src; + if( src < len - 1 && + (srcp[src + 1] & A_CHARTEXT) == DUMMY_CHAR_NEXT_TO_FULLWIDTH) + { + /* necessary to erase garbage */ + ci[dst + 1].Char.UnicodeChar = (WCHAR)' '; + ci[dst + 1].Attributes = ci[dst].Attributes; + bufSize.X = 2; + bufSize.Y = 1; + sr.Right = sr.Left + 2; + } + else + { + bufSize.X = 1; + bufSize.Y = 1; + sr.Right = sr.Left + 1; + } + WriteConsoleOutput(pdc_con_out, ci, bufSize, bufPos, &sr); +#else dst++; +#endif } +#ifndef PDC_NEW_WINCON_WORKAROUND bufSize.X = dst; bufSize.Y = 1; WriteConsoleOutput(pdc_con_out, ci, bufSize, bufPos, &sr); +#endif } From c163cdb9dbddbcfa3d2b71dc1c3d6815463726f4 Mon Sep 17 00:00:00 2001 From: Shugo Maeda Date: Mon, 8 Apr 2019 14:30:20 +0900 Subject: [PATCH 2/2] Enable workaround code for new Windows console by default --- wincon/Makefile.mng | 4 ---- wincon/pdcdisp.c | 2 ++ 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/wincon/Makefile.mng b/wincon/Makefile.mng index 1a8f685a..65ce363e 100644 --- a/wincon/Makefile.mng +++ b/wincon/Makefile.mng @@ -86,10 +86,6 @@ ifeq ($(WIDE),Y) CFLAGS += -DPDC_WIDE endif -ifeq ($(NEW_WINCON_WORKAROUND),Y) - CFLAGS += -DPDC_NEW_WINCON_WORKAROUND -endif - ifeq ($(UTF8),Y) CFLAGS += -DPDC_FORCE_UTF8 endif diff --git a/wincon/pdcdisp.c b/wincon/pdcdisp.c index e4f664b6..7c4c1048 100644 --- a/wincon/pdcdisp.c +++ b/wincon/pdcdisp.c @@ -50,6 +50,8 @@ void PDC_gotoyx(int row, int col) int PDC_expand_combined_characters( const cchar_t c, cchar_t *added); /* addch.c */ #endif +#define PDC_NEW_WINCON_WORKAROUND 1 + void PDC_transform_line(int lineno, int x, int len, const chtype *srcp) { CHAR_INFO ci[512];