Skip to content

Commit

Permalink
Writes characters one by one to display full-width characters correctly
Browse files Browse the repository at this point in the history
Otherwise, full-width characters overlap on a new Windows console.
  • Loading branch information
shugo committed Mar 13, 2019
1 parent 1ee281a commit da2ce19
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions wincon/Makefile.mng
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions wincon/pdcdisp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit da2ce19

Please sign in to comment.