Skip to content

Commit da2ce19

Browse files
committed
Writes characters one by one to display full-width characters correctly
Otherwise, full-width characters overlap on a new Windows console.
1 parent 1ee281a commit da2ce19

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

wincon/Makefile.mng

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ ifeq ($(WIDE),Y)
8686
CFLAGS += -DPDC_WIDE
8787
endif
8888

89+
ifeq ($(NEW_WINCON_WORKAROUND),Y)
90+
CFLAGS += -DPDC_NEW_WINCON_WORKAROUND
91+
endif
92+
8993
ifeq ($(UTF8),Y)
9094
CFLAGS += -DPDC_FORCE_UTF8
9195
endif

wincon/pdcdisp.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,34 @@ void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
108108
#endif
109109
ci[dst].Char.UnicodeChar = (WCHAR)char_out;
110110

111+
#ifdef PDC_NEW_WINCON_WORKAROUND
112+
sr.Left = x + src;
113+
if( src < len - 1 &&
114+
(srcp[src + 1] & A_CHARTEXT) == DUMMY_CHAR_NEXT_TO_FULLWIDTH)
115+
{
116+
/* necessary to erase garbage */
117+
ci[dst + 1].Char.UnicodeChar = (WCHAR)' ';
118+
ci[dst + 1].Attributes = ci[dst].Attributes;
119+
bufSize.X = 2;
120+
bufSize.Y = 1;
121+
sr.Right = sr.Left + 2;
122+
}
123+
else
124+
{
125+
bufSize.X = 1;
126+
bufSize.Y = 1;
127+
sr.Right = sr.Left + 1;
128+
}
129+
WriteConsoleOutput(pdc_con_out, ci, bufSize, bufPos, &sr);
130+
#else
111131
dst++;
132+
#endif
112133
}
113134

135+
#ifndef PDC_NEW_WINCON_WORKAROUND
114136
bufSize.X = dst;
115137
bufSize.Y = 1;
116138

117139
WriteConsoleOutput(pdc_con_out, ci, bufSize, bufPos, &sr);
140+
#endif
118141
}

0 commit comments

Comments
 (0)