Commit MetaInfo

Revisionffb5e64d55137675ce6f26a62ac55418101794c3 (tree)
Time2019-06-17 01:39:16
AuthorSHIRAKATA Kentaro <argrath@ub32...>
CommiterSHIRAKATA Kentaro

Log Message

patch for win32/tty

Change Summary

Incremental Difference

--- a/sys/winnt/nttty.c
+++ b/sys/winnt/nttty.c
@@ -49,11 +49,20 @@ extern int redirect_stdout;
4949 typedef struct {
5050 WCHAR character;
5151 WORD attribute;
52+#if 1 /*JP*/
53+ int iskanji;
54+#endif
5255 } cell_t;
5356
57+#if 0 /*JP*/
5458 cell_t clear_cell = { CONSOLE_CLEAR_CHARACTER, CONSOLE_CLEAR_ATTRIBUTE };
5559 cell_t undefined_cell = { CONSOLE_UNDEFINED_CHARACTER,
5660 CONSOLE_UNDEFINED_ATTRIBUTE };
61+#else
62+cell_t clear_cell = { CONSOLE_CLEAR_CHARACTER, CONSOLE_CLEAR_ATTRIBUTE, 0 };
63+cell_t undefined_cell = { CONSOLE_UNDEFINED_CHARACTER,
64+ CONSOLE_UNDEFINED_ATTRIBUTE, 0 };
65+#endif
5766
5867 /*
5968 * The following WIN32 Console API routines are used in this file.
@@ -223,6 +232,35 @@ static void back_buffer_flip()
223232
224233 for (pos.Y = 0; pos.Y < console.height; pos.Y++) {
225234 for (pos.X = 0; pos.X < console.width; pos.X++) {
235+#if 1 /*JP*/
236+ if (back->iskanji == 1) {
237+ cell_t * back2 = back + 1;
238+ cell_t * front2 = front + 1;
239+ if (back->attribute != front->attribute ||
240+ back2->attribute != front2->attribute) {
241+ WORD attrs[2];
242+ attrs[0] = attrs[1] = back->attribute;
243+ WriteConsoleOutputAttribute(console.hConOut, attrs,
244+ 2, pos, &unused);
245+ front->attribute = back->attribute;
246+ front2->attribute = back2->attribute;
247+ }
248+ if (back->character != front->character ||
249+ back2->character != front2->character) {
250+ unsigned char buf[2];
251+ buf[0] = (unsigned char)(back->character);
252+ buf[1] = (unsigned char)(back2->character);
253+ WriteConsoleOutputCharacter(console.hConOut, buf, 2, pos,
254+ &unused);
255+ front->character = back->character;
256+ front2->character = back2->character;
257+ }
258+ pos.X++;
259+ back += 2;
260+ front += 2;
261+ continue;
262+ }
263+#endif
226264 if (back->attribute != front->attribute) {
227265 WriteConsoleOutputAttribute(console.hConOut, &back->attribute,
228266 1, pos, &unused);
@@ -547,8 +585,60 @@ xputc2_core(ch1, ch2)
547585 unsigned int ch1;
548586 unsigned int ch2;
549587 {
550- xputc_core(ch1);
551- xputc_core(ch2);
588+ nhassert(console.cursor.X >= 0 && console.cursor.X < console.width);
589+ nhassert(console.cursor.Y >= 0 && console.cursor.Y < console.height);
590+
591+ boolean inverse = FALSE;
592+ cell_t cell;
593+
594+ /* xputc_core()からのコピー */
595+ inverse = (console.current_nhattr[ATR_INVERSE] && iflags.wc_inverse);
596+ console.attr = (inverse) ?
597+ ttycolors_inv[console.current_nhcolor] :
598+ ttycolors[console.current_nhcolor];
599+ if (console.current_nhattr[ATR_BOLD])
600+ console.attr |= (inverse) ?
601+ BACKGROUND_INTENSITY : FOREGROUND_INTENSITY;
602+
603+ cell.attribute = console.attr;
604+
605+ /* 右端に1バイト分しか空きがない場合 */
606+ if (console.cursor.X == console.width - 2) {
607+ /* 空白表示 */
608+ cell.character = ' ';
609+ cell.iskanji = 0;
610+ buffer_write(console.back_buffer, &cell, console.cursor);
611+ console.cursor.X++;
612+ if (console.cursor.Y < console.height - 1) {
613+ /* 次の行に */
614+ console.cursor.X = 1;
615+ console.cursor.Y++;
616+ } else {
617+ /* 既に下端の場合はなにもしない */
618+ return;
619+ }
620+ }
621+
622+ cell.character = ch1;
623+ cell.iskanji = 1;
624+ buffer_write(console.back_buffer, &cell, console.cursor);
625+ console.cursor.X++;
626+
627+ cell.character = ch2;
628+ cell.iskanji = 2;
629+ buffer_write(console.back_buffer, &cell, console.cursor);
630+
631+ if (console.cursor.X == console.width - 1) {
632+ if (console.cursor.Y < console.height - 1) {
633+ console.cursor.X = 1;
634+ console.cursor.Y++;
635+ }
636+ } else {
637+ console.cursor.X++;
638+ }
639+
640+ nhassert(console.cursor.X >= 0 && console.cursor.X < console.width);
641+ nhassert(console.cursor.Y >= 0 && console.cursor.Y < console.height);
552642 }
553643
554644 void
@@ -624,6 +714,9 @@ char ch;
624714
625715 cell.attribute = console.attr;
626716 cell.character = (console.has_unicode ? console.cpMap[ch] : ch);
717+#if 1 /*JP*//*常に1バイト文字*/
718+ cell.iskanji = 0;
719+#endif
627720
628721 buffer_write(console.back_buffer, &cell, console.cursor);
629722
@@ -666,6 +759,9 @@ int in_ch;
666759
667760 cell.attribute = console.attr;
668761 cell.character = (console.has_unicode ? cp437[ch] : ch);
762+#if 1 /*JP*//*常に1バイト文字*/
763+ cell.iskanji = 0;
764+#endif
669765
670766 buffer_write(console.back_buffer, &cell, console.cursor);
671767 }
Show on old repository browser