Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write characters one by one to display full-width characters correctly #108

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions wincon/pdcdisp.c
Expand Up @@ -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];
Expand Down Expand Up @@ -108,11 +110,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
}