• R/O
  • SSH
  • HTTPS

ttssh2: Commit


Commit MetaInfo

Revision7472 (tree)
Time2019-03-10 23:33:21
Authorzmatsuo

Log Message

unicode表示対応

# Conflicts:
# teraterm/teraterm/CMakeLists.txt

Change Summary

Incremental Difference

--- branches/cmake/teraterm/common/ttlib.c (revision 7471)
+++ branches/cmake/teraterm/common/ttlib.c (revision 7472)
@@ -1145,14 +1145,26 @@
11451145 }
11461146 #endif
11471147
1148-void OutputDebugPrintf(const char *fmt, ...) {
1148+void OutputDebugPrintf(const char *fmt, ...)
1149+{
11491150 char tmp[1024];
11501151 va_list arg;
11511152 va_start(arg, fmt);
11521153 _vsnprintf(tmp, sizeof(tmp), fmt, arg);
1154+ va_end(arg);
11531155 OutputDebugStringA(tmp);
11541156 }
11551157
1158+void OutputDebugPrintfW(const wchar_t *fmt, ...)
1159+{
1160+ wchar_t tmp[1024];
1161+ va_list arg;
1162+ va_start(arg, fmt);
1163+ _vsnwprintf(tmp, _countof(tmp), fmt, arg);
1164+ va_end(arg);
1165+ OutputDebugStringW(tmp);
1166+}
1167+
11561168 #if (_MSC_VER < 1800)
11571169 BOOL vercmp(
11581170 DWORD cond_val,
--- branches/cmake/teraterm/common/ttlib.h (revision 7471)
+++ branches/cmake/teraterm/common/ttlib.h (revision 7472)
@@ -96,6 +96,7 @@
9696 DllExport BOOL doSelectFolderW(HWND hWnd, wchar_t *path, int pathlen, const wchar_t *def, const wchar_t *msg);
9797 #endif
9898 DllExport void OutputDebugPrintf(const char *fmt, ...);
99+DllExport void OutputDebugPrintfW(const wchar_t *fmt, ...);
99100 DllExport DWORD get_OPENFILENAME_SIZEA();
100101 DllExport DWORD get_OPENFILENAME_SIZEW();
101102 DllExport BOOL IsWindows95();
--- branches/cmake/teraterm/teraterm/CMakeLists.txt (revision 7471)
+++ branches/cmake/teraterm/teraterm/CMakeLists.txt (revision 7472)
@@ -3,22 +3,18 @@
33 include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_SFMT.cmake)
44 include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_oniguruma.cmake)
55
6-if (MSVC)
7- string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
8- string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
9- string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
10- string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
11-endif ()
6+# UNICODE API を使用して文字描画を行う
7+# - 内部文字コードを unicodeとする
8+# - unicode api時のみ有効
9+# - 描画に ExtTextOutW() API を使用する
10+option(USE_UNICODE_API_FOR_DISPLAY "unicode" ON)
1211
13-
1412 if(USE_UNICODE_API)
1513 add_definitions(-DUNICODE -D_UNICODE)
14+ if(USE_UNICODE_API_FOR_DISPLAY)
15+ add_definitions(-DUNICODE_DISPLAY=1)
16+ endif()
1617 endif()
17-if(LINK_UNICOWS)
18-# set(UNICOWS_LIB "${CMAKE_SOURCE_DIR}/libs/unicows_mingw/liblibunicows.a")
19- set(UNICOWS_LIB "${CMAKE_SOURCE_DIR}/libs/libunicows-1.1.2-msvc6/unicows.lib")
20-endif()
21-
2218 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/")
2319
2420 set(COMMON_SRC
@@ -26,6 +22,7 @@
2622 ../common/ttcommon.h
2723 ../common/ttddecmnd.h
2824 ../common/tttypes.h
25+ ../common/tektypes.h
2926 ../common/ttftypes.h
3027 ../common/ttplugin.h
3128 ../common/tt-version.h
@@ -35,6 +32,8 @@
3532 ../common/dlglib.c
3633 ../common/dlglib_cpp.cpp
3734 ../common/dlglib.h
35+ ../common/win16api.h
36+ ../common/win16api.c
3837 ../common/dlglib_tmpl.cpp
3938 ../common/compat_win.cpp
4039 ../common/compat_win.h
@@ -45,8 +44,13 @@
4544 ../common/i18n.h
4645 ../common/win16api.h
4746 ../common/win16api.c
47+ ../ttpcmn/language.h
4848 ../common/codeconv.h
4949 ../common/codeconv.cpp
50+ #
51+ ../teraterm/uni2sjis.map
52+ ../ttpcmn/sjis2uni.map
53+ ../teraterm/unisym2decsp.map
5054 )
5155
5256 source_group(
@@ -131,6 +135,8 @@
131135 ttutil.c
132136 ttutil.h
133137 #
138+ uni_combining.map
139+ #
134140 teraterm.manifest
135141 #
136142 ${CMAKE_CURRENT_BINARY_DIR}/svnversion.h
--- branches/cmake/teraterm/teraterm/buffer.c (revision 7471)
+++ branches/cmake/teraterm/teraterm/buffer.c (revision 7472)
@@ -1,6 +1,6 @@
11 /*
22 * Copyright (C) 1994-1998 T. Teranishi
3- * (C) 2004-2017 TeraTerm Project
3+ * (C) 2004-2019 TeraTerm Project
44 * All rights reserved.
55 *
66 * Redistribution and use in source and binary forms, with or without
@@ -36,6 +36,7 @@
3636 #include <string.h>
3737 #include <stdio.h>
3838 #include <windows.h>
39+#include <crtdbg.h>
3940
4041 #include "ttwinman.h"
4142 #include "teraprn.h"
@@ -43,9 +44,15 @@
4344 #include "clipboar.h"
4445 #include "telnet.h"
4546 #include "ttplug.h" /* TTPLUG */
47+#include "codeconv.h"
4648
4749 #include "buffer.h"
4850
51+#ifdef _DEBUG
52+#define malloc(l) _malloc_dbg((l), _NORMAL_BLOCK, __FILE__, __LINE__)
53+#define free(p) _free_dbg((p), _NORMAL_BLOCK)
54+#endif
55+
4956 // URLを強調する(石崎氏パッチ 2005/4/2)
5057 #define URL_EMPHASIS 1
5158
@@ -83,6 +90,10 @@
8390 static PCHAR AttrLine2;
8491 static PCHAR AttrLineFG;
8592 static PCHAR AttrLineBG;
93+#if 1
94+static wchar_t *CodeBuffW;
95+static wchar_t *CodeLineW;
96+#endif
8697 static LONG LinePtr;
8798 static LONG BufferSize;
8899 static int NumOfLinesInBuff;
@@ -101,6 +112,24 @@
101112 int SaveBuffX;
102113 int SaveBuffY;
103114
115+void memcpyW(wchar_t *dest, const wchar_t *src, size_t count)
116+{
117+ memcpy(dest, src, count * sizeof(wchar_t));
118+}
119+
120+void memsetW(wchar_t *dest, wchar_t ch, size_t count)
121+{
122+ size_t i;
123+ for (i=0; i<count; i++) {
124+ *dest++ = ch;
125+ }
126+}
127+
128+void memmoveW(wchar_t *dest, const wchar_t *src, size_t count)
129+{
130+ memmove(dest, src, count * sizeof(wchar_t));
131+}
132+
104133 LONG GetLinePtr(int Line)
105134 {
106135 LONG Ptr;
@@ -136,8 +165,10 @@
136165 LONG NewSize;
137166 int NxCopy, NyCopy, i;
138167 PCHAR CodeDest, AttrDest, AttrDest2, AttrDestFG, AttrDestBG;
168+ wchar_t *CodeDestW;
139169 LONG SrcPtr, DestPtr;
140170 WORD LockOld;
171+ wchar_t *CodeWNew;
141172
142173 if (Nx > BuffXMax) {
143174 Nx = BuffXMax;
@@ -160,6 +191,7 @@
160191 HAttr2New = NULL;
161192 HAttrFGNew = NULL;
162193 HAttrBGNew = NULL;
194+ CodeWNew = NULL;
163195
164196 if ((HCodeNew=GlobalAlloc(GMEM_MOVEABLE, NewSize)) == NULL || (CodeDest=GlobalLock(HCodeNew)) == NULL) {
165197 goto allocate_error;
@@ -176,8 +208,11 @@
176208 if ((HAttrBGNew=GlobalAlloc(GMEM_MOVEABLE, NewSize)) == NULL || (AttrDestBG=GlobalLock(HAttrBGNew)) == NULL) {
177209 goto allocate_error;
178210 }
211+ CodeWNew = malloc(NewSize * sizeof(wchar_t));
212+ CodeDestW = CodeWNew;
179213
180214 memset(&CodeDest[0], 0x20, NewSize);
215+ memsetW(&CodeDestW[0], 0x20, NewSize);
181216 memset(&AttrDest[0], AttrDefault, NewSize);
182217 memset(&AttrDest2[0], AttrDefault, NewSize);
183218 memset(&AttrDestFG[0], AttrDefaultFG, NewSize);
@@ -202,6 +237,7 @@
202237 DestPtr = 0;
203238 for (i = 1 ; i <= NyCopy ; i++) {
204239 memcpy(&CodeDest[DestPtr],&CodeBuff[SrcPtr],NxCopy);
240+ memcpyW(&CodeDestW[DestPtr],&CodeBuffW[SrcPtr],NxCopy);
205241 memcpy(&AttrDest[DestPtr],&AttrBuff[SrcPtr],NxCopy);
206242 memcpy(&AttrDest2[DestPtr],&AttrBuff2[SrcPtr],NxCopy);
207243 memcpy(&AttrDestFG[DestPtr],&AttrBuffFG[SrcPtr],NxCopy);
@@ -243,6 +279,7 @@
243279 HAttrBuff2 = HAttr2New;
244280 HAttrBuffFG = HAttrFGNew;
245281 HAttrBuffBG = HAttrBGNew;
282+ CodeBuffW = CodeWNew;
246283 BufferSize = NewSize;
247284 NumOfLinesInBuff = Ny;
248285 BuffStartAbs = 0;
@@ -265,6 +302,7 @@
265302 AttrBuffFG = (PCHAR)GlobalLock(HAttrBuffFG);
266303 AttrBuffBG = (PCHAR)GlobalLock(HAttrBuffBG);
267304 CodeLine = CodeBuff;
305+ CodeLineW = CodeBuffW;
268306 AttrLine = AttrBuff;
269307 AttrLine2 = AttrBuff2;
270308 AttrLineFG = AttrBuffFG;
@@ -288,6 +326,7 @@
288326 if (AttrDestFG) GlobalUnlock(HAttrFGNew);
289327 if (AttrDestBG) GlobalUnlock(HAttrBGNew);
290328 if (HCodeNew) GlobalFree(HCodeNew);
329+ if (CodeWNew) free(CodeWNew);
291330 if (HAttrNew) GlobalFree(HAttrNew);
292331 if (HAttr2New) GlobalFree(HAttr2New);
293332 if (HAttrFGNew) GlobalFree(HAttrFGNew);
@@ -343,6 +382,7 @@
343382 AttrLine2 = &AttrBuff2[LinePtr];
344383 AttrLineFG = &AttrBuffFG[LinePtr];
345384 AttrLineBG = &AttrBuffBG[LinePtr];
385+ CodeLineW = &CodeBuffW[LinePtr];
346386 }
347387
348388 void LockBuffer()
@@ -393,6 +433,10 @@
393433 GlobalFree(HCodeBuff);
394434 HCodeBuff = NULL;
395435 }
436+ if (CodeBuffW != NULL) {
437+ free(CodeBuffW);
438+ CodeBuffW = NULL;
439+ }
396440 if (HAttrBuff!=NULL) {
397441 GlobalFree(HAttrBuff);
398442 HAttrBuff = NULL;
@@ -499,11 +543,13 @@
499543 SrcPtr = GetLinePtr(PageStart+NumOfLines-1);
500544 for (i=NumOfLines-1; i>=Bottom+1; i--) {
501545 memcpy(&(CodeBuff[DestPtr]),&(CodeBuff[SrcPtr]),NumOfColumns);
546+ memcpyW(&(CodeBuffW[DestPtr]),&(CodeBuffW[SrcPtr]),NumOfColumns);
502547 memcpy(&(AttrBuff[DestPtr]),&(AttrBuff[SrcPtr]),NumOfColumns);
503548 memcpy(&(AttrBuff2[DestPtr]),&(AttrBuff2[SrcPtr]),NumOfColumns);
504549 memcpy(&(AttrBuffFG[DestPtr]),&(AttrBuffFG[SrcPtr]),NumOfColumns);
505550 memcpy(&(AttrBuffBG[DestPtr]),&(AttrBuffBG[SrcPtr]),NumOfColumns);
506551 memset(&(CodeBuff[SrcPtr]),0x20,NumOfColumns);
552+ memsetW(&(CodeBuffW[SrcPtr]),0x20,NumOfColumns);
507553 memset(&(AttrBuff[SrcPtr]),AttrDefault,NumOfColumns);
508554 memset(&(AttrBuff2[SrcPtr]),CurCharAttr.Attr2 & Attr2ColorMask, NumOfColumns);
509555 memset(&(AttrBuffFG[SrcPtr]),CurCharAttr.Fore,NumOfColumns);
@@ -515,6 +561,7 @@
515561 }
516562 for (i = 1 ; i <= n ; i++) {
517563 memset(&CodeBuff[DestPtr],0x20,NumOfColumns);
564+ memsetW(&CodeBuffW[DestPtr],0x20,NumOfColumns);
518565 memset(&AttrBuff[DestPtr],AttrDefault,NumOfColumns);
519566 memset(&AttrBuff2[DestPtr],CurCharAttr.Attr2 & Attr2ColorMask, NumOfColumns);
520567 memset(&AttrBuffFG[DestPtr],CurCharAttr.Fore,NumOfColumns);
@@ -561,6 +608,7 @@
561608 AttrLine2 = &AttrBuff2[LinePtr];
562609 AttrLineFG = &AttrBuffFG[LinePtr];
563610 AttrLineBG = &AttrBuffBG[LinePtr];
611+ CodeLineW = &CodeBuffW[LinePtr];
564612 }
565613
566614 void PrevLine()
@@ -571,6 +619,7 @@
571619 AttrLine2 = &AttrBuff2[LinePtr];
572620 AttrLineFG = &AttrBuffFG[LinePtr];
573621 AttrLineBG = &AttrBuffBG[LinePtr];
622+ CodeLineW = &CodeBuffW[LinePtr];
574623 }
575624
576625 void EraseKanji(int LR)
@@ -607,17 +656,21 @@
607656 pos = ptr + CursorLeftM-1;
608657 if (CursorLeftM>0 && (AttrBuff[pos] & AttrKanji)) {
609658 CodeBuff[pos] = 0x20;
659+ CodeBuffW[pos] = 0x20;
610660 AttrBuff[pos] &= ~AttrKanji;
611661 pos++;
612662 CodeBuff[pos] = 0x20;
663+ CodeBuffW[pos] = 0x20;
613664 AttrBuff[pos] &= ~AttrKanji;
614665 }
615666 pos = ptr + CursorRightM;
616667 if (CursorRightM < NumOfColumns-1 && (AttrBuff[pos] & AttrKanji)) {
617668 CodeBuff[pos] = 0x20;
669+ CodeBuffW[pos] = 0x20;
618670 AttrBuff[pos] &= ~AttrKanji;
619671 pos++;
620672 CodeBuff[pos] = 0x20;
673+ CodeBuffW[pos] = 0x20;
621674 AttrBuff[pos] &= ~AttrKanji;
622675 }
623676 ptr = NextLinePtr(ptr);
@@ -641,6 +694,7 @@
641694
642695 if (CursorRightM < NumOfColumns-1 && (AttrLine[CursorRightM] & AttrKanji)) {
643696 CodeLine[CursorRightM+1] = 0x20;
697+ CodeLineW[CursorRightM+1] = 0x20;
644698 AttrLine[CursorRightM+1] &= ~AttrKanji;
645699 extr = 1;
646700 }
@@ -652,6 +706,7 @@
652706
653707 if (MoveLen > 0) {
654708 memmove(&(CodeLine[CursorX+Count]), &(CodeLine[CursorX]), MoveLen);
709+ memmoveW(&(CodeLineW[CursorX+Count]), &(CodeLineW[CursorX]), MoveLen);
655710 memmove(&(AttrLine[CursorX+Count]), &(AttrLine[CursorX]), MoveLen);
656711 memmove(&(AttrLine2[CursorX+Count]), &(AttrLine2[CursorX]), MoveLen);
657712 memmove(&(AttrLineFG[CursorX+Count]), &(AttrLineFG[CursorX]), MoveLen);
@@ -658,6 +713,7 @@
658713 memmove(&(AttrLineBG[CursorX+Count]), &(AttrLineBG[CursorX]), MoveLen);
659714 }
660715 memset(&(CodeLine[CursorX]), 0x20, Count);
716+ memsetW(&(CodeLineW[CursorX]), 0x20, Count);
661717 memset(&(AttrLine[CursorX]), AttrDefault, Count);
662718 memset(&(AttrLine2[CursorX]), CurCharAttr.Attr2 & Attr2ColorMask, Count);
663719 memset(&(AttrLineFG[CursorX]), CurCharAttr.Fore, Count);
@@ -666,6 +722,7 @@
666722 if ((AttrLine[CursorRightM] & AttrKanji) != 0) {
667723 /* then delete it */
668724 CodeLine[CursorRightM] = 0x20;
725+ CodeLineW[CursorRightM] = 0x20;
669726 AttrLine[CursorRightM] &= ~AttrKanji;
670727 }
671728 BuffUpdateRect(CursorX, CursorY, CursorRightM+extr, CursorY);
@@ -690,6 +747,7 @@
690747 }
691748 for (i = CursorY ; i <= YEnd ; i++) {
692749 memset(&(CodeBuff[TmpPtr+offset]),0x20,NumOfColumns-offset);
750+ memsetW(&(CodeBuffW[TmpPtr+offset]),0x20,NumOfColumns-offset);
693751 memset(&(AttrBuff[TmpPtr+offset]),AttrDefault,NumOfColumns-offset);
694752 memset(&(AttrBuff2[TmpPtr+offset]),CurCharAttr.Attr2 & Attr2ColorMask, NumOfColumns-offset);
695753 memset(&(AttrBuffFG[TmpPtr+offset]),CurCharAttr.Fore,NumOfColumns-offset);
@@ -725,6 +783,7 @@
725783 offset = CursorX+1;
726784 }
727785 memset(&(CodeBuff[TmpPtr]),0x20,offset);
786+ memsetW(&(CodeBuffW[TmpPtr]),0x20,offset);
728787 memset(&(AttrBuff[TmpPtr]),AttrDefault,offset);
729788 memset(&(AttrBuff2[TmpPtr]),CurCharAttr.Attr2 & Attr2ColorMask, offset);
730789 memset(&(AttrBuffFG[TmpPtr]),CurCharAttr.Fore,offset);
@@ -759,6 +818,7 @@
759818 linelen = CursorRightM - CursorLeftM + 1;
760819 for (i= YEnd-Count ; i>=CursorY ; i--) {
761820 memcpy(&(CodeBuff[DestPtr]), &(CodeBuff[SrcPtr]), linelen);
821+ memcpyW(&(CodeBuffW[DestPtr]), &(CodeBuffW[SrcPtr]), linelen);
762822 memcpy(&(AttrBuff[DestPtr]), &(AttrBuff[SrcPtr]), linelen);
763823 memcpy(&(AttrBuff2[DestPtr]), &(AttrBuff2[SrcPtr]), linelen);
764824 memcpy(&(AttrBuffFG[DestPtr]), &(AttrBuffFG[SrcPtr]), linelen);
@@ -768,6 +828,7 @@
768828 }
769829 for (i = 1 ; i <= Count ; i++) {
770830 memset(&(CodeBuff[DestPtr]), 0x20, linelen);
831+ memsetW(&(CodeBuffW[DestPtr]), 0x20, linelen);
771832 memset(&(AttrBuff[DestPtr]), AttrDefault, linelen);
772833 memset(&(AttrBuff2[DestPtr]), CurCharAttr.Attr2 & Attr2ColorMask, linelen);
773834 memset(&(AttrBuffFG[DestPtr]), CurCharAttr.Fore, linelen);
@@ -797,6 +858,7 @@
797858
798859 NewLine(PageStart+CursorY);
799860 memset(&(CodeLine[XStart]),0x20,Count);
861+ memsetW(&(CodeLineW[XStart]),0x20,Count);
800862 memset(&(AttrLine[XStart]),AttrDefault,Count);
801863 memset(&(AttrLine2[XStart]),CurCharAttr.Attr2 & Attr2ColorMask, Count);
802864 memset(&(AttrLineFG[XStart]),CurCharAttr.Fore,Count);
@@ -838,6 +900,7 @@
838900 linelen = CursorRightM - CursorLeftM + 1;
839901 for (i=CursorY ; i<= YEnd-Count ; i++) {
840902 memcpy(&(CodeBuff[DestPtr]), &(CodeBuff[SrcPtr]), linelen);
903+ memcpyW(&(CodeBuffW[DestPtr]), &(CodeBuffW[SrcPtr]), linelen);
841904 memcpy(&(AttrBuff[DestPtr]), &(AttrBuff[SrcPtr]), linelen);
842905 memcpy(&(AttrBuff2[DestPtr]), &(AttrBuff2[SrcPtr]), linelen);
843906 memcpy(&(AttrBuffFG[DestPtr]), &(AttrBuffFG[SrcPtr]), linelen);
@@ -847,6 +910,7 @@
847910 }
848911 for (i = YEnd+1-Count ; i<=YEnd ; i++) {
849912 memset(&(CodeBuff[DestPtr]), 0x20, linelen);
913+ memsetW(&(CodeBuffW[DestPtr]), 0x20, linelen);
850914 memset(&(AttrBuff[DestPtr]), AttrDefault, linelen);
851915 memset(&(AttrBuff2[DestPtr]), CurCharAttr.Attr2 & Attr2ColorMask, linelen);
852916 memset(&(AttrBuffFG[DestPtr]), CurCharAttr.Fore, linelen);
@@ -878,6 +942,7 @@
878942
879943 if (CursorRightM < NumOfColumns-1 && (AttrLine[CursorRightM] & AttrKanji)) {
880944 CodeLine[CursorRightM] = 0x20;
945+ CodeLineW[CursorRightM] = 0x20;
881946 AttrLine[CursorRightM] &= ~AttrKanji;
882947 CodeLine[CursorRightM+1] = 0x20;
883948 AttrLine[CursorRightM+1] &= ~AttrKanji;
@@ -891,6 +956,7 @@
891956
892957 if (MoveLen > 0) {
893958 memmove(&(CodeLine[CursorX]), &(CodeLine[CursorX+Count]), MoveLen);
959+ memmoveW(&(CodeLineW[CursorX]), &(CodeLineW[CursorX+Count]), MoveLen);
894960 memmove(&(AttrLine[CursorX]), &(AttrLine[CursorX+Count]), MoveLen);
895961 memmove(&(AttrLine2[CursorX]), &(AttrLine2[CursorX+Count]), MoveLen);
896962 memmove(&(AttrLineFG[CursorX]), &(AttrLineFG[CursorX+Count]), MoveLen);
@@ -897,6 +963,7 @@
897963 memmove(&(AttrLineBG[CursorX]), &(AttrLineBG[CursorX+Count]), MoveLen);
898964 }
899965 memset(&(CodeLine[CursorX + MoveLen]), 0x20, Count);
966+ memsetW(&(CodeLineW[CursorX + MoveLen]), 0x20, Count);
900967 memset(&(AttrLine[CursorX + MoveLen]), AttrDefault, Count);
901968 memset(&(AttrLine2[CursorX + MoveLen]), CurCharAttr.Attr2 & Attr2ColorMask, Count);
902969 memset(&(AttrLineFG[CursorX + MoveLen]), CurCharAttr.Fore, Count);
@@ -920,6 +987,7 @@
920987 Count = NumOfColumns-CursorX;
921988 }
922989 memset(&(CodeLine[CursorX]),0x20,Count);
990+ memsetW(&(CodeLineW[CursorX]),0x20,Count);
923991 memset(&(AttrLine[CursorX]),AttrDefault,Count);
924992 memset(&(AttrLine2[CursorX]),CurCharAttr.Attr2 & Attr2ColorMask, Count);
925993 memset(&(AttrLineFG[CursorX]),CurCharAttr.Fore,Count);
@@ -938,6 +1006,7 @@
9381006 TmpPtr = GetLinePtr(PageStart);
9391007 for (i = 0 ; i <= NumOfLines-1-StatusLine ; i++) {
9401008 memset(&(CodeBuff[TmpPtr]),'E',NumOfColumns);
1009+ memsetW(&(CodeBuffW[TmpPtr]),'E',NumOfColumns);
9411010 memset(&(AttrBuff[TmpPtr]),AttrDefault,NumOfColumns);
9421011 memset(&(AttrBuff2[TmpPtr]),AttrDefault,NumOfColumns);
9431012 memset(&(AttrBuffFG[TmpPtr]),AttrDefaultFG,NumOfColumns);
@@ -977,6 +1046,7 @@
9771046 }
9781047 Ptr = GetLinePtr(PageStart+Y);
9791048 memset(&(CodeBuff[Ptr+CursorX]),'q',C);
1049+ memsetW(&(CodeBuffW[Ptr+CursorX]),'q',C);
9801050 memset(&(AttrBuff[Ptr+CursorX]),Attr.Attr,C);
9811051 memset(&(AttrBuff2[Ptr+CursorX]),Attr.Attr2,C);
9821052 memset(&(AttrBuffFG[Ptr+CursorX]),Attr.Fore,C);
@@ -1005,6 +1075,7 @@
10051075 }
10061076 for (i=1; i<=C; i++) {
10071077 CodeBuff[Ptr+X] = 'x';
1078+ CodeBuffW[Ptr+X] = 'x';
10081079 AttrBuff[Ptr+X] = Attr.Attr;
10091080 AttrBuff2[Ptr+X] = Attr.Attr2;
10101081 AttrBuffFG[Ptr+X] = Attr.Fore;
@@ -1040,6 +1111,7 @@
10401111 if ((XStart>0) &&
10411112 ((AttrBuff[Ptr+XStart-1] & AttrKanji) != 0)) {
10421113 CodeBuff[Ptr+XStart-1] = 0x20;
1114+ CodeBuffW[Ptr+XStart-1] = 0x20;
10431115 AttrBuff[Ptr+XStart-1] = CurCharAttr.Attr;
10441116 AttrBuff2[Ptr+XStart-1] = CurCharAttr.Attr2;
10451117 AttrBuffFG[Ptr+XStart-1] = CurCharAttr.Fore;
@@ -1048,6 +1120,7 @@
10481120 if ((XStart+C<NumOfColumns) &&
10491121 ((AttrBuff[Ptr+XStart+C-1] & AttrKanji) != 0)) {
10501122 CodeBuff[Ptr+XStart+C] = 0x20;
1123+ CodeBuffW[Ptr+XStart+C] = 0x20;
10511124 AttrBuff[Ptr+XStart+C] = CurCharAttr.Attr;
10521125 AttrBuff2[Ptr+XStart+C] = CurCharAttr.Attr2;
10531126 AttrBuffFG[Ptr+XStart+C] = CurCharAttr.Fore;
@@ -1054,6 +1127,7 @@
10541127 AttrBuffBG[Ptr+XStart+C] = CurCharAttr.Back;
10551128 }
10561129 memset(&(CodeBuff[Ptr+XStart]),0x20,C);
1130+ memsetW(&(CodeBuffW[Ptr+XStart]),0x20,C);
10571131 memset(&(AttrBuff[Ptr+XStart]),AttrDefault,C);
10581132 memset(&(AttrBuff2[Ptr+XStart]),CurCharAttr.Attr2 & Attr2ColorMask, C);
10591133 memset(&(AttrBuffFG[Ptr+XStart]),CurCharAttr.Fore,C);
@@ -1086,13 +1160,16 @@
10861160 if ((XStart>0) &&
10871161 ((AttrBuff[Ptr+XStart-1] & AttrKanji) != 0)) {
10881162 CodeBuff[Ptr+XStart-1] = 0x20;
1163+ CodeBuffW[Ptr+XStart-1] = 0x20;
10891164 AttrBuff[Ptr+XStart-1] ^= AttrKanji;
10901165 }
10911166 if ((XStart+Cols<NumOfColumns) &&
10921167 ((AttrBuff[Ptr+XStart+Cols-1] & AttrKanji) != 0)) {
10931168 CodeBuff[Ptr+XStart+Cols] = 0x20;
1169+ CodeBuffW[Ptr+XStart+Cols] = 0x20;
10941170 }
10951171 memset(&(CodeBuff[Ptr+XStart]), ch, Cols);
1172+ memsetW(&(CodeBuffW[Ptr+XStart]), ch, Cols);
10961173 memset(&(AttrBuff[Ptr+XStart]), CurCharAttr.Attr, Cols);
10971174 memset(&(AttrBuff2[Ptr+XStart]), CurCharAttr.Attr2, Cols);
10981175 memset(&(AttrBuffFG[Ptr+XStart]), CurCharAttr.Fore, Cols);
@@ -1148,6 +1225,7 @@
11481225 DPtr = GetLinePtr(PageStart+DstY);
11491226 for (i=0; i<L; i++) {
11501227 memcpy(&(CodeBuff[DPtr+DstX]), &(CodeBuff[SPtr+SrcXStart]), C);
1228+ memcpyW(&(CodeBuffW[DPtr+DstX]), &(CodeBuffW[SPtr+SrcXStart]), C);
11511229 memcpy(&(AttrBuff[DPtr+DstX]), &(AttrBuff[SPtr+SrcXStart]), C);
11521230 memcpy(&(AttrBuff2[DPtr+DstX]), &(AttrBuff2[SPtr+SrcXStart]), C);
11531231 memcpy(&(AttrBuffFG[DPtr+DstX]), &(AttrBuffFG[SPtr+SrcXStart]), C);
@@ -1161,6 +1239,7 @@
11611239 DPtr = GetLinePtr(PageStart+DstY+L-1);
11621240 for (i=L; i>0; i--) {
11631241 memcpy(&(CodeBuff[DPtr+DstX]), &(CodeBuff[SPtr+SrcXStart]), C);
1242+ memcpyW(&(CodeBuffW[DPtr+DstX]), &(CodeBuffW[SPtr+SrcXStart]), C);
11641243 memcpy(&(AttrBuff[DPtr+DstX]), &(AttrBuff[SPtr+SrcXStart]), C);
11651244 memcpy(&(AttrBuff2[DPtr+DstX]), &(AttrBuff2[SPtr+SrcXStart]), C);
11661245 memcpy(&(AttrBuffFG[DPtr+DstX]), &(AttrBuffFG[SPtr+SrcXStart]), C);
@@ -1174,6 +1253,7 @@
11741253 DPtr = GetLinePtr(PageStart+DstY);
11751254 for (i=0; i<L; i++) {
11761255 memmove(&(CodeBuff[DPtr+DstX]), &(CodeBuff[SPtr+SrcXStart]), C);
1256+ memmoveW(&(CodeBuffW[DPtr+DstX]), &(CodeBuffW[SPtr+SrcXStart]), C);
11771257 memmove(&(AttrBuff[DPtr+DstX]), &(AttrBuff[SPtr+SrcXStart]), C);
11781258 memmove(&(AttrBuff2[DPtr+DstX]), &(AttrBuff2[SPtr+SrcXStart]), C);
11791259 memmove(&(AttrBuffFG[DPtr+DstX]), &(AttrBuffFG[SPtr+SrcXStart]), C);
@@ -2005,6 +2085,194 @@
20052085 }
20062086 }
20072087
2088+// Put a kanji character in the buffer at the current position
2089+// b: character
2090+// Attr: attributes
2091+// Insert: Insert flag
2092+// @@
2093+void BuffPutUnicode(unsigned int uc, TCharAttr Attr, BOOL Insert)
2094+{
2095+ int XStart, LineEnd, MoveLen;
2096+ int extr = 0;
2097+ unsigned int w = uc;
2098+ int ret;
2099+ wchar_t wchar = (wchar_t)uc;
2100+ BYTE b1, b2;
2101+ unsigned int u32 = uc;
2102+ unsigned short u16_high;
2103+ unsigned short u16_low;
2104+ wchar_t wstr[2];
2105+ size_t wstr_len;
2106+
2107+ wstr_len = UTF32ToUTF16(u32, wstr, 2);
2108+ switch (wstr_len) {
2109+ case 0:
2110+ default:
2111+ u16_high = '?';
2112+ u16_low = 0;
2113+ break;
2114+ case 1:
2115+ u16_high = wstr[0];
2116+ u16_low = 0;
2117+ break;
2118+ case 2:
2119+ u16_high = wstr[0];
2120+ u16_low = wstr[1];
2121+ break;
2122+ }
2123+
2124+ if (uc < 0x80) {
2125+ b1 = (BYTE)uc;
2126+ b2 = 0;
2127+ ret = 1;
2128+ } else {
2129+ char mbchar[2];
2130+ ret = UTF32ToCP932(uc, mbchar, 2);
2131+ if (ret == 0) {
2132+ b1 = '?';
2133+ b2 = '?';
2134+ ret = 2;
2135+ } else if (ret == 1) {
2136+ b1 = mbchar[0];
2137+ b2 = 0;
2138+ } else { // ret == 2
2139+ b1 = mbchar[0];
2140+ b2 = mbchar[1];
2141+ ret = 2;
2142+ }
2143+ }
2144+
2145+#if 0
2146+ OutputDebugPrintf("BuffPutUnicode(%06x(%04x,%04x)(%02x,%02x)\n",
2147+ uc,
2148+ u16_high, u16_low, b1, b2);
2149+#endif
2150+
2151+ if (ts.EnableContinuedLineCopy && CursorX == 0 && (AttrLine[0] & AttrLineContinued)) {
2152+ Attr.Attr |= AttrLineContinued;
2153+ }
2154+
2155+ if (Insert) {
2156+ if (CursorX > CursorRightM)
2157+ LineEnd = NumOfColumns - 1;
2158+ else
2159+ LineEnd = CursorRightM;
2160+
2161+ if (LineEnd < NumOfColumns - 1 && (AttrLine[LineEnd] & AttrKanji)) {
2162+ CodeLine[LineEnd] = 0x20;
2163+ CodeLineW[LineEnd] = 0x20;
2164+ AttrLine[LineEnd] &= ~AttrKanji;
2165+ CodeLine[LineEnd+1] = 0x20;
2166+ AttrLine[LineEnd+1] &= ~AttrKanji;
2167+ extr = 1;
2168+ }
2169+
2170+ MoveLen = LineEnd - CursorX - 1;
2171+ if (MoveLen > 0) {
2172+ memmove(&CodeLine[CursorX+2], &CodeLine[CursorX], MoveLen);
2173+ memmove(&CodeLineW[CursorX+2], &CodeLineW[CursorX], MoveLen * sizeof(wchar_t));
2174+ memmove(&AttrLine[CursorX+2], &AttrLine[CursorX], MoveLen);
2175+ memmove(&AttrLine2[CursorX+2], &AttrLine2[CursorX], MoveLen);
2176+ memmove(&AttrLineFG[CursorX+2], &AttrLineFG[CursorX], MoveLen);
2177+ memmove(&AttrLineBG[CursorX+2], &AttrLineBG[CursorX], MoveLen);
2178+ }
2179+
2180+ CodeLine[CursorX] = HIBYTE(w);
2181+ CodeLineW[CursorX] = u16_high;
2182+ AttrLine[CursorX] = Attr.Attr;
2183+ AttrLine2[CursorX] = Attr.Attr2;
2184+ AttrLineFG[CursorX] = Attr.Fore;
2185+ AttrLineBG[CursorX] = Attr.Back;
2186+ if (CursorX < LineEnd) {
2187+ CodeLine[CursorX+1] = LOBYTE(w);
2188+ CodeLineW[CursorX+1] = u16_low;
2189+// CodeLineW[CursorX+1] = 0;
2190+ AttrLine[CursorX+1] = Attr.Attr;
2191+ AttrLine2[CursorX+1] = Attr.Attr2;
2192+ AttrLineFG[CursorX+1] = Attr.Fore;
2193+ AttrLineBG[CursorX+1] = Attr.Back;
2194+ }
2195+ /* begin - ishizaki */
2196+ markURL(CursorX);
2197+ markURL(CursorX+1);
2198+ /* end - ishizaki */
2199+
2200+ /* last char in current line is kanji first? */
2201+ if ((AttrLine[LineEnd] & AttrKanji) != 0) {
2202+ /* then delete it */
2203+ CodeLine[LineEnd] = 0x20;
2204+ CodeLineW[LineEnd] = 0x20;
2205+ AttrLine[LineEnd] = CurCharAttr.Attr;
2206+ AttrLine2[LineEnd] = CurCharAttr.Attr2;
2207+ AttrLineFG[LineEnd] = CurCharAttr.Fore;
2208+ AttrLineBG[LineEnd] = CurCharAttr.Back;
2209+ }
2210+
2211+ if (StrChangeCount==0) {
2212+ XStart = CursorX;
2213+ }
2214+ else {
2215+ XStart = StrChangeStart;
2216+ }
2217+ StrChangeCount = 0;
2218+ BuffUpdateRect(XStart, CursorY, LineEnd+extr, CursorY);
2219+ }
2220+ else {
2221+ CodeLine[CursorX] = b1;
2222+ CodeLineW[CursorX] = u16_high;
2223+ AttrLine[CursorX] = Attr.Attr; // | AttrKanji; /* DBCS first byte */
2224+ AttrLine2[CursorX] = Attr.Attr2;
2225+ AttrLineFG[CursorX] = Attr.Fore;
2226+ AttrLineBG[CursorX] = Attr.Back;
2227+#if 0
2228+ if (b2 != 0) {
2229+ if (CursorX < NumOfColumns-1) {
2230+ CodeLine[CursorX+1] = b2;
2231+ CodeLineW[CursorX+1] = 0;
2232+ AttrLine[CursorX+1] = Attr.Attr;
2233+ AttrLine2[CursorX+1] = Attr.Attr2;
2234+ AttrLineFG[CursorX+1] = Attr.Fore;
2235+ AttrLineBG[CursorX+1] = Attr.Back;
2236+ }
2237+ }
2238+#else
2239+ if (CursorX < NumOfColumns-1) {
2240+ CodeLine[CursorX+1] = b2;
2241+ CodeLineW[CursorX+1] = u16_low;
2242+ AttrLine[CursorX+1] = Attr.Attr;
2243+ AttrLine2[CursorX+1] = Attr.Attr2;
2244+ AttrLineFG[CursorX+1] = Attr.Fore;
2245+ AttrLineBG[CursorX+1] = Attr.Back;
2246+ }
2247+#endif
2248+ /* begin - ishizaki */
2249+// markURL(CursorX);
2250+// markURL(CursorX+1);
2251+ /* end - ishizaki */
2252+
2253+ if (StrChangeCount==0) {
2254+ StrChangeStart = CursorX;
2255+ }
2256+ StrChangeCount = StrChangeCount + (b2 == 0 ? 1 : 2);
2257+#if 0
2258+ {
2259+ char ba[128];
2260+ memcpy(ba, &CodeLine[0], _countof(ba)-1);
2261+ ba[127] = 0;
2262+ OutputDebugPrintf("A '%s'\n", ba);
2263+ wchar_t bb[128];
2264+ memcpy(bb, &CodeLineW[0], _countof(bb)-1);
2265+ bb[127] = 0;
2266+ OutputDebugPrintfW(L"W '%s'\n", bb);
2267+ }
2268+#endif
2269+ }
2270+
2271+#if 0
2272+ OutputDebugPrintf("BuffPutUnicode leave\n");
2273+#endif
2274+}
2275+
20082276 BOOL CheckSelect(int x, int y)
20092277 // subroutine called by BuffUpdateRect
20102278 {
@@ -2027,6 +2295,7 @@
20272295 }
20282296 }
20292297
2298+// @@
20302299 void BuffUpdateRect
20312300 (int XStart, int YStart, int XEnd, int YEnd)
20322301 // Display text in a rectangular region in the screen
@@ -2041,6 +2310,10 @@
20412310 LONG TmpPtr;
20422311 TCharAttr CurAttr, TempAttr;
20432312 BOOL CurSel, TempSel, Caret;
2313+ char bufA[128];
2314+ wchar_t bufW[128];
2315+ int lenW = 0;
2316+ int lenA = 0;
20442317
20452318 if (XStart >= WinOrgX+WinWidth) {
20462319 return;
@@ -2068,6 +2341,13 @@
20682341 YEnd = WinOrgY+WinHeight-1;
20692342 }
20702343
2344+#if 0
2345+ OutputDebugPrintf("BuffUpdateRect (%d,%d)-(%d,%d) [%d,%d]\n",
2346+ XStart, YStart,
2347+ XEnd, YEnd,
2348+ XEnd - XStart + 1, YEnd - YStart + 1);
2349+#endif
2350+
20712351 TempAttr = DefCharAttr;
20722352 TempSel = FALSE;
20732353
@@ -2095,6 +2375,15 @@
20952375 CurAttr.Fore = AttrBuffFG[TmpPtr+i];
20962376 CurAttr.Back = AttrBuffBG[TmpPtr+i];
20972377 CurSel = CheckSelect(i,j);
2378+ {
2379+ bufA[lenA] = CodeBuff[TmpPtr + i];
2380+ lenA++;
2381+ wchar_t wc = CodeBuffW[TmpPtr + i];
2382+ if (wc != 0) {
2383+ bufW[lenW] = wc;
2384+ lenW++;
2385+ }
2386+ }
20982387 count = 1;
20992388 while ( (i+count <= IEnd) &&
21002389 (CurAttr.Attr == (AttrBuff[TmpPtr+i+count] & ~ AttrKanji)) &&
@@ -2104,6 +2393,15 @@
21042393 (CurSel==CheckSelect(i+count,j)) ||
21052394 (i+count<NumOfColumns) &&
21062395 ((AttrBuff[TmpPtr+i+count-1] & AttrKanji) != 0) ) {
2396+ {
2397+ bufA[lenA] = CodeBuff[TmpPtr + i + count];
2398+ lenA++;
2399+ wchar_t wc = CodeBuffW[TmpPtr + i + count];
2400+ if (wc != 0) {
2401+ bufW[lenW] = wc;
2402+ lenW++;
2403+ }
2404+ }
21072405 count++;
21082406 }
21092407
@@ -2112,7 +2410,22 @@
21122410 TempAttr = CurAttr;
21132411 TempSel = CurSel;
21142412 }
2115- DispStr(&CodeBuff[TmpPtr+i],count,Y, &X);
2413+#if 1
2414+ {
2415+ OutputDebugPrintf("(%d,%d)[%d],%d\n", i, j - PageStart, count, CurAttr.Attr);
2416+ bufA[lenA] = 0;
2417+ OutputDebugPrintf("A[%d] '%s'\n", lenA, bufA);
2418+ bufW[lenW] = 0;
2419+ OutputDebugPrintfW(L"W[%d] '%s'\n", lenW, bufW);
2420+ }
2421+#endif
2422+ lenA = 0;
2423+ lenW = 0;
2424+#if defined(UNICODE_DISPLAY)
2425+ DispStrW(&CodeBuffW[TmpPtr + i], count, Y, &X);
2426+#else
2427+ DispStr(&CodeBuff[TmpPtr + i], count, Y, &X);
2428+#endif
21162429 i = i+count;
21172430 }
21182431 while (i<=IEnd);
@@ -2122,6 +2435,9 @@
21222435 if (Caret) {
21232436 CaretOn();
21242437 }
2438+#if 0
2439+ OutputDebugPrintf("BuffUpdateRect leave\n");
2440+#endif
21252441 }
21262442
21272443 void UpdateStr()
@@ -2159,7 +2475,11 @@
21592475 len++;
21602476 }
21612477 DispSetupDC(TempAttr, FALSE);
2478+#if defined(UNICODE_DISPLAY)
2479+ DispStrW(&CodeLineW[StrChangeStart], len, Y, &X);
2480+#else
21622481 DispStr(&CodeLine[StrChangeStart], len, Y, &X);
2482+#endif
21632483
21642484 /* 残りの文字列があれば、ふつうに描画を行う。*/
21652485 if (len < StrChangeCount) {
@@ -2169,42 +2489,24 @@
21692489 TempAttr.Back = AttrLineBG[StrChangeStart + pos];
21702490
21712491 DispSetupDC(TempAttr, FALSE);
2492+#if defined(UNICODE_DISPLAY)
2493+ DispStrW(&CodeLineW[StrChangeStart + pos], (StrChangeCount - len), Y, &X);
2494+#else
21722495 DispStr(&CodeLine[StrChangeStart + pos], (StrChangeCount - len), Y, &X);
2496+#endif
21732497 }
21742498 } else {
21752499 DispSetupDC(TempAttr, FALSE);
2500+#if defined(UNICODE_DISPLAY)
2501+ DispStrW(&CodeLineW[StrChangeStart],StrChangeCount,Y, &X);
2502+#else
21762503 DispStr(&CodeLine[StrChangeStart],StrChangeCount,Y, &X);
2504+#endif
21772505 }
21782506
21792507 StrChangeCount = 0;
21802508 }
21812509
2182-#if 0
2183-void UpdateStrUnicode(void)
2184-// Display not-yet-displayed string
2185-{
2186- int X, Y;
2187- TCharAttr TempAttr;
2188-
2189- if (StrChangeCount==0) return;
2190- X = StrChangeStart;
2191- Y = CursorY;
2192- if (! IsLineVisible(&X, &Y))
2193- {
2194- StrChangeCount = 0;
2195- return;
2196- }
2197-
2198- TempAttr.Attr = AttrLine[StrChangeStart];
2199- TempAttr.Attr2 = AttrLine2[StrChangeStart];
2200- TempAttr.Fore = AttrLineFG[StrChangeStart];
2201- TempAttr.Back = AttrLineBG[StrChangeStart];
2202- DispSetupDC(TempAttr, FALSE);
2203- DispStr(&CodeLine[StrChangeStart],StrChangeCount,Y, &X);
2204- StrChangeCount = 0;
2205-}
2206-#endif
2207-
22082510 void MoveCursor(int Xnew, int Ynew)
22092511 {
22102512 UpdateStr();
@@ -2264,6 +2566,7 @@
22642566 for (i = CursorBottom-1 ; i >= CursorTop ; i--) {
22652567 SrcPtr = PrevLinePtr(DestPtr);
22662568 memcpy(&(CodeBuff[DestPtr]), &(CodeBuff[SrcPtr]), linelen);
2569+ memcpyW(&(CodeBuffW[DestPtr]), &(CodeBuffW[SrcPtr]), linelen);
22672570 memcpy(&(AttrBuff[DestPtr]), &(AttrBuff[SrcPtr]), linelen);
22682571 memcpy(&(AttrBuff2[DestPtr]), &(AttrBuff2[SrcPtr]), linelen);
22692572 memcpy(&(AttrBuffFG[DestPtr]), &(AttrBuffFG[SrcPtr]), linelen);
@@ -2271,6 +2574,7 @@
22712574 DestPtr = SrcPtr;
22722575 }
22732576 memset(&(CodeBuff[SrcPtr]), 0x20, linelen);
2577+ memsetW(&(CodeBuffW[SrcPtr]), 0x20, linelen);
22742578 memset(&(AttrBuff[SrcPtr]), AttrDefault, linelen);
22752579 memset(&(AttrBuff2[SrcPtr]), CurCharAttr.Attr2 & Attr2ColorMask, linelen);
22762580 memset(&(AttrBuffFG[SrcPtr]), CurCharAttr.Fore, linelen);
@@ -2335,6 +2639,7 @@
23352639 SrcPtr = GetLinePtr(PageStart+CursorTop+n) + (LONG)CursorLeftM;
23362640 for (i = CursorTop+n ; i<=CursorBottom ; i++) {
23372641 memmove(&(CodeBuff[DestPtr]), &(CodeBuff[SrcPtr]), linelen);
2642+ memmoveW(&(CodeBuffW[DestPtr]), &(CodeBuffW[SrcPtr]), linelen);
23382643 memmove(&(AttrBuff[DestPtr]), &(AttrBuff[SrcPtr]), linelen);
23392644 memmove(&(AttrBuff2[DestPtr]), &(AttrBuff2[SrcPtr]), linelen);
23402645 memmove(&(AttrBuffFG[DestPtr]), &(AttrBuffFG[SrcPtr]), linelen);
@@ -2348,6 +2653,7 @@
23482653 }
23492654 for (i = CursorBottom+1-n ; i<=CursorBottom; i++) {
23502655 memset(&(CodeBuff[DestPtr]), 0x20, linelen);
2656+ memsetW(&(CodeBuffW[DestPtr]), 0x20, linelen);
23512657 memset(&(AttrBuff[DestPtr]), AttrDefault, linelen);
23522658 memset(&(AttrBuff2[DestPtr]), CurCharAttr.Attr2 & Attr2ColorMask, linelen);
23532659 memset(&(AttrBuffFG[DestPtr]), CurCharAttr.Fore, linelen);
@@ -2396,6 +2702,7 @@
23962702 SrcPtr = GetLinePtr(PageStart+CursorTop+n) + CursorLeftM;
23972703 for (i = CursorTop+n ; i<=CursorBottom ; i++) {
23982704 memmove(&(CodeBuff[DestPtr]), &(CodeBuff[SrcPtr]), linelen);
2705+ memmoveW(&(CodeBuffW[DestPtr]), &(CodeBuffW[SrcPtr]), linelen);
23992706 memmove(&(AttrBuff[DestPtr]), &(AttrBuff[SrcPtr]), linelen);
24002707 memmove(&(AttrBuff2[DestPtr]), &(AttrBuff2[SrcPtr]), linelen);
24012708 memmove(&(AttrBuffFG[DestPtr]), &(AttrBuffFG[SrcPtr]), linelen);
@@ -2409,6 +2716,7 @@
24092716 }
24102717 for (i = CursorBottom+1-n ; i<=CursorBottom; i++) {
24112718 memset(&(CodeBuff[DestPtr]), 0x20, linelen);
2719+ memsetW(&(CodeBuffW[DestPtr]), 0x20, linelen);
24122720 memset(&(AttrBuff[DestPtr]), AttrDefault, linelen);
24132721 memset(&(AttrBuff2[DestPtr]), CurCharAttr.Attr2 & Attr2ColorMask, linelen);
24142722 memset(&(AttrBuffFG[DestPtr]), CurCharAttr.Fore, linelen);
@@ -2448,6 +2756,7 @@
24482756 SrcPtr = GetLinePtr(PageStart+CursorBottom-n) + CursorLeftM;
24492757 for (i=CursorBottom-n ; i>=CursorTop ; i--) {
24502758 memmove(&(CodeBuff[DestPtr]), &(CodeBuff[SrcPtr]), linelen);
2759+ memmoveW(&(CodeBuffW[DestPtr]), &(CodeBuffW[SrcPtr]), linelen);
24512760 memmove(&(AttrBuff[DestPtr]), &(AttrBuff[SrcPtr]), linelen);
24522761 memmove(&(AttrBuff2[DestPtr]), &(AttrBuff2[SrcPtr]), linelen);
24532762 memmove(&(AttrBuffFG[DestPtr]), &(AttrBuffFG[SrcPtr]), linelen);
@@ -2461,6 +2770,7 @@
24612770 }
24622771 for (i = CursorTop+n-1; i>=CursorTop; i--) {
24632772 memset(&(CodeBuff[DestPtr]), 0x20, linelen);
2773+ memsetW(&(CodeBuffW[DestPtr]), 0x20, linelen);
24642774 memset(&(AttrBuff[DestPtr]), AttrDefault, linelen);
24652775 memset(&(AttrBuff2[DestPtr]), CurCharAttr.Attr2 & Attr2ColorMask, linelen);
24662776 memset(&(AttrBuffFG[DestPtr]), CurCharAttr.Fore, linelen);
@@ -3476,6 +3786,7 @@
34763786
34773787 NewLine(0);
34783788 memset(&CodeBuff[0],0x20,BufferSize);
3789+ memsetW(&CodeBuffW[0],0x20,BufferSize);
34793790 memset(&AttrBuff[0],AttrDefault,BufferSize);
34803791 memset(&AttrBuff2[0],CurCharAttr.Attr2 & Attr2ColorMask, BufferSize);
34813792 memset(&AttrBuffFG[0],CurCharAttr.Fore,BufferSize);
@@ -3700,6 +4011,7 @@
37004011 void BuffSaveScreen()
37014012 {
37024013 PCHAR CodeDest, AttrDest, AttrDest2, AttrDestFG, AttrDestBG;
4014+ wchar_t *CodeDestW;
37034015 LONG ScrSize;
37044016 LONG SrcPtr, DestPtr;
37054017 int i;
@@ -3706,12 +4018,13 @@
37064018
37074019 if (SaveBuff == NULL) {
37084020 ScrSize = NumOfColumns * NumOfLines;
3709- if ((SaveBuff=GlobalAlloc(GMEM_MOVEABLE, ScrSize * 5)) != NULL) {
4021+ if ((SaveBuff=GlobalAlloc(GMEM_MOVEABLE, ScrSize * (5+2))) != NULL) {
37104022 if ((CodeDest=GlobalLock(SaveBuff)) != NULL) {
37114023 AttrDest = CodeDest + ScrSize;
37124024 AttrDest2 = AttrDest + ScrSize;
37134025 AttrDestFG = AttrDest2 + ScrSize;
37144026 AttrDestBG = AttrDestFG + ScrSize;
4027+ CodeDestW = (wchar_t *)(AttrDestBG + ScrSize);
37154028
37164029 SaveBuffX = NumOfColumns;
37174030 SaveBuffY = NumOfLines;
@@ -3721,6 +4034,7 @@
37214034
37224035 for (i=0; i<NumOfLines; i++) {
37234036 memcpy(&CodeDest[DestPtr], &CodeBuff[SrcPtr], NumOfColumns);
4037+ memcpyW(&CodeDestW[DestPtr], &CodeBuffW[SrcPtr], NumOfColumns);
37244038 memcpy(&AttrDest[DestPtr], &AttrBuff[SrcPtr], NumOfColumns);
37254039 memcpy(&AttrDest2[DestPtr], &AttrBuff2[SrcPtr], NumOfColumns);
37264040 memcpy(&AttrDestFG[DestPtr], &AttrBuffFG[SrcPtr], NumOfColumns);
@@ -3741,6 +4055,7 @@
37414055 void BuffRestoreScreen()
37424056 {
37434057 PCHAR CodeSrc, AttrSrc, AttrSrc2, AttrSrcFG, AttrSrcBG;
4058+ wchar_t *CodeSrcW;
37444059 LONG ScrSize;
37454060 LONG SrcPtr, DestPtr;
37464061 int i, CopyX, CopyY;
@@ -3753,6 +4068,7 @@
37534068 AttrSrc2 = AttrSrc + ScrSize;
37544069 AttrSrcFG = AttrSrc2 + ScrSize;
37554070 AttrSrcBG = AttrSrcFG + ScrSize;
4071+ CodeSrcW = (wchar_t *)(AttrSrcBG + ScrSize);
37564072
37574073 CopyX = (SaveBuffX > NumOfColumns) ? NumOfColumns : SaveBuffX;
37584074 CopyY = (SaveBuffY > NumOfLines) ? NumOfLines : SaveBuffY;
@@ -3762,6 +4078,7 @@
37624078
37634079 for (i=0; i<CopyY; i++) {
37644080 memcpy(&CodeBuff[DestPtr], &CodeSrc[SrcPtr], CopyX);
4081+ memcpyW(&CodeBuffW[DestPtr], &CodeSrcW[SrcPtr], CopyX);
37654082 memcpy(&AttrBuff[DestPtr], &AttrSrc[SrcPtr], CopyX);
37664083 memcpy(&AttrBuff2[DestPtr], &AttrSrc2[SrcPtr], CopyX);
37674084 memcpy(&AttrBuffFG[DestPtr], &AttrSrcFG[SrcPtr], CopyX);
@@ -3768,6 +4085,7 @@
37684085 memcpy(&AttrBuffBG[DestPtr], &AttrSrcBG[SrcPtr], CopyX);
37694086 if (AttrBuff[DestPtr+CopyX-1] & AttrKanji) {
37704087 CodeBuff[DestPtr+CopyX-1] = ' ';
4088+ CodeBuffW[DestPtr+CopyX-1] = ' ';
37714089 AttrBuff[DestPtr+CopyX-1] ^= AttrKanji;
37724090 }
37734091 SrcPtr += SaveBuffX;
@@ -3812,6 +4130,7 @@
38124130 for (j = TmpPtr + offset; j < TmpPtr + NumOfColumns - offset; j++) {
38134131 if (!(AttrBuff2[j] & Attr2Protect)) {
38144132 CodeBuff[j] = 0x20;
4133+ CodeBuffW[j] = 0x20;
38154134 AttrBuff[j] &= AttrSgrMask;
38164135 }
38174136 }
@@ -3850,6 +4169,7 @@
38504169 for (j = TmpPtr; j < TmpPtr + offset; j++) {
38514170 if (!(AttrBuff2[j] & Attr2Protect)) {
38524171 CodeBuff[j] = 0x20;
4172+ CodeBuffW[j] = 0x20;
38534173 AttrBuff[j] &= AttrSgrMask;
38544174 }
38554175 }
@@ -3890,6 +4210,7 @@
38904210 ((AttrBuff[Ptr+XStart-1] & AttrKanji) != 0) &&
38914211 ((AttrBuff2[Ptr+XStart-1] & Attr2Protect) == 0)) {
38924212 CodeBuff[Ptr+XStart-1] = 0x20;
4213+ CodeBuffW[Ptr+XStart-1] = 0x20;
38934214 AttrBuff[Ptr+XStart-1] &= AttrSgrMask;
38944215 }
38954216 if ((XStart+C<NumOfColumns) &&
@@ -3896,11 +4217,13 @@
38964217 ((AttrBuff[Ptr+XStart+C-1] & AttrKanji) != 0) &&
38974218 ((AttrBuff2[Ptr+XStart+C-1] & Attr2Protect) == 0)) {
38984219 CodeBuff[Ptr+XStart+C] = 0x20;
4220+ CodeBuffW[Ptr+XStart+C] = 0x20;
38994221 AttrBuff[Ptr+XStart+C] &= AttrSgrMask;
39004222 }
39014223 for (j=Ptr+XStart; j<Ptr+XStart+C; j++) {
39024224 if (!(AttrBuff2[j] & Attr2Protect)) {
39034225 CodeBuff[j] = 0x20;
4226+ CodeBuffW[j] = 0x20;
39044227 AttrBuff[j] &= AttrSgrMask;
39054228 }
39064229 }
@@ -3962,22 +4285,27 @@
39624285
39634286 if (AttrBuff[LPtr+CursorRightM] & AttrKanji) {
39644287 CodeBuff[LPtr+CursorRightM] = 0x20;
4288+ CodeBuffW[LPtr+CursorRightM] = 0x20;
39654289 AttrBuff[LPtr+CursorRightM] &= ~AttrKanji;
39664290 if (CursorRightM < NumOfColumns-1) {
39674291 CodeBuff[LPtr+CursorRightM+1] = 0x20;
4292+ CodeBuffW[LPtr+CursorRightM+1] = 0x20;
39684293 }
39694294 }
39704295
39714296 if (AttrBuff[Ptr+count-1] & AttrKanji) {
39724297 CodeBuff[Ptr+count] = 0x20;
4298+ CodeBuffW[Ptr+count] = 0x20;
39734299 }
39744300
39754301 if (CursorLeftM > 0 && AttrBuff[Ptr-1] & AttrKanji) {
39764302 CodeBuff[Ptr-1] = 0x20;
4303+ CodeBuffW[Ptr-1] = 0x20;
39774304 AttrBuff[Ptr-1] &= ~AttrKanji;
39784305 }
39794306
39804307 memmove(&(CodeBuff[Ptr]), &(CodeBuff[Ptr+count]), MoveLen);
4308+ memmoveW(&(CodeBuffW[Ptr]), &(CodeBuffW[Ptr+count]), MoveLen);
39814309 memmove(&(AttrBuff[Ptr]), &(AttrBuff[Ptr+count]), MoveLen);
39824310 memmove(&(AttrBuff2[Ptr]), &(AttrBuff2[Ptr+count]), MoveLen);
39834311 memmove(&(AttrBuffFG[Ptr]), &(AttrBuffFG[Ptr+count]), MoveLen);
@@ -3984,6 +4312,7 @@
39844312 memmove(&(AttrBuffBG[Ptr]), &(AttrBuffBG[Ptr+count]), MoveLen);
39854313
39864314 memset(&(CodeBuff[Ptr+MoveLen]), 0x20, count);
4315+ memsetW(&(CodeBuffW[Ptr+MoveLen]), 0x20, count);
39874316 memset(&(AttrBuff[Ptr+MoveLen]), AttrDefault, count);
39884317 memset(&(AttrBuff2[Ptr+MoveLen]), CurCharAttr.Attr2 & Attr2ColorMask, count);
39894318 memset(&(AttrBuffFG[Ptr+MoveLen]), CurCharAttr.Fore, count);
@@ -4009,15 +4338,19 @@
40094338
40104339 if (CursorRightM < NumOfColumns-1 && AttrBuff[LPtr+CursorRightM] & AttrKanji) {
40114340 CodeBuff[LPtr+CursorRightM+1] = 0x20;
4341+ CodeBuffW[LPtr+CursorRightM+1] = 0x20;
40124342 }
40134343
40144344 if (CursorLeftM > 0 && AttrBuff[Ptr-1] & AttrKanji) {
40154345 CodeBuff[Ptr-1] = 0x20;
4346+ CodeBuffW[Ptr-1] = 0x20;
40164347 AttrBuff[Ptr-1] &= ~AttrKanji;
40174348 CodeBuff[Ptr] = 0x20;
4349+ CodeBuffW[Ptr] = 0x20;
40184350 }
40194351
40204352 memmove(&(CodeBuff[Ptr+count]), &(CodeBuff[Ptr]), MoveLen);
4353+ memmoveW(&(CodeBuffW[Ptr+count]), &(CodeBuffW[Ptr]), MoveLen);
40214354 memmove(&(AttrBuff[Ptr+count]), &(AttrBuff[Ptr]), MoveLen);
40224355 memmove(&(AttrBuff2[Ptr+count]), &(AttrBuff2[Ptr]), MoveLen);
40234356 memmove(&(AttrBuffFG[Ptr+count]), &(AttrBuffFG[Ptr]), MoveLen);
@@ -4024,6 +4357,7 @@
40244357 memmove(&(AttrBuffBG[Ptr+count]), &(AttrBuffBG[Ptr]), MoveLen);
40254358
40264359 memset(&(CodeBuff[Ptr]), 0x20, count);
4360+ memsetW(&(CodeBuffW[Ptr]), 0x20, count);
40274361 memset(&(AttrBuff[Ptr]), AttrDefault, count);
40284362 memset(&(AttrBuff2[Ptr]), CurCharAttr.Attr2 & Attr2ColorMask, count);
40294363 memset(&(AttrBuffFG[Ptr]), CurCharAttr.Fore, count);
@@ -4031,6 +4365,7 @@
40314365
40324366 if (AttrBuff[LPtr+CursorRightM] & AttrKanji) {
40334367 CodeBuff[LPtr+CursorRightM] = 0x20;
4368+ CodeBuffW[LPtr+CursorRightM] = 0x20;
40344369 AttrBuff[LPtr+CursorRightM] &= ~AttrKanji;
40354370 }
40364371
--- branches/cmake/teraterm/teraterm/buffer.h (revision 7471)
+++ branches/cmake/teraterm/teraterm/buffer.h (revision 7472)
@@ -1,6 +1,6 @@
11 /*
22 * Copyright (C) 1994-1998 T. Teranishi
3- * (C) 2005-2017 TeraTerm Project
3+ * (C) 2005-2019 TeraTerm Project
44 * All rights reserved.
55 *
66 * Redistribution and use in source and binary forms, with or without
@@ -63,9 +63,9 @@
6363 void BuffDumpCurrentLine(BYTE TERM);
6464 void BuffPutChar(BYTE b, TCharAttr Attr, BOOL Insert);
6565 void BuffPutKanji(WORD w, TCharAttr Attr, BOOL Insert);
66+void BuffPutUnicode(unsigned int uc, TCharAttr Attr, BOOL Insert);
6667 void BuffUpdateRect(int XStart, int YStart, int XEnd, int YEnd);
6768 void UpdateStr();
68-void UpdateStrUnicode(void);
6969 void MoveCursor(int Xnew, int Ynew);
7070 void MoveRight();
7171 void BuffSetCaretWidth();
--- branches/cmake/teraterm/teraterm/vtdisp.c (revision 7471)
+++ branches/cmake/teraterm/teraterm/vtdisp.c (revision 7472)
@@ -2717,9 +2717,37 @@
27172717 }
27182718 }
27192719
2720-#if 1
2721-// 当面はこちらの関数を使う。(2004.11.4 yutaka)
2722-void DispStr(PCHAR Buff, int Count, int Y, int* X)
2720+static void DrawTextBGImage(HDC hdcBGBuffer, int X, int Y, int width, int height)
2721+{
2722+ RECT rect;
2723+ SetRect(&rect,0,0,width,height);
2724+
2725+ //窓の移動、リサイズ中は背景を BGBrushInSizeMove で塗りつぶす
2726+ if(BGInSizeMove)
2727+ FillRect(hdcBGBuffer,&rect,BGBrushInSizeMove);
2728+
2729+ BitBlt(hdcBGBuffer,0,0,width,height,hdcBG,X,Y,SRCCOPY);
2730+
2731+ if(BGReverseText == TRUE)
2732+ {
2733+ if(BGReverseTextAlpha < 255)
2734+ {
2735+ BLENDFUNCTION bf;
2736+ HBRUSH hbr;
2737+
2738+ hbr = CreateSolidBrush(GetBkColor(hdcBGBuffer));
2739+ FillRect(hdcBGWork,&rect,hbr);
2740+ DeleteObject(hbr);
2741+
2742+ ZeroMemory(&bf,sizeof(bf));
2743+ bf.BlendOp = AC_SRC_OVER;
2744+ bf.SourceConstantAlpha = BGReverseTextAlpha;
2745+
2746+ BGAlphaBlend(hdcBGBuffer,0,0,width,height,hdcBGWork,0,0,width,height,bf);
2747+ }
2748+ }
2749+}
2750+
27232751 // Display a string
27242752 // Buff: points the string
27252753 // Y: vertical position in window cordinate
@@ -2726,159 +2754,124 @@
27262754 // *X: horizontal position
27272755 // Return:
27282756 // *X: horizontal position shifted by the width of the string
2757+void DispStr(PCHAR Buff, int Count, int Y, int* X)
27292758 {
2730- RECT RText;
2759+#ifdef ALPHABLEND_TYPE2
2760+ const BOOL draw_bg_enable = BGEnable;
2761+#else
2762+ const BOOL draw_bg_enable = FALSE;
2763+#endif
27312764
2732- if ((ts.Language==IdRussian) &&
2733- (ts.RussClient!=ts.RussFont))
2734- RussConvStr(ts.RussClient,ts.RussFont,Buff,Count);
2765+ if ((ts.Language==IdRussian) &&
2766+ (ts.RussClient!=ts.RussFont))
2767+ RussConvStr(ts.RussClient,ts.RussFont,Buff,Count);
27352768
2736- RText.top = Y;
2737- RText.bottom = Y+FontHeight;
2738- RText.left = *X;
2739- RText.right = *X + Count*FontWidth;
2769+ if(!draw_bg_enable)
2770+ {
2771+ RECT RText;
2772+ RText.top = Y;
2773+ RText.bottom = Y+FontHeight;
2774+ RText.left = *X;
2775+ RText.right = *X + Count*FontWidth;
27402776
2777+ ExtTextOutA(VTDC,*X+ts.FontDX,Y+ts.FontDY,
2778+ ETO_CLIPPED | ETO_OPAQUE,
2779+ &RText,Buff,Count,&Dx[0]);
2780+ }
27412781 #ifdef ALPHABLEND_TYPE2
2742-//<!--by AKASI
2743- if(!BGEnable)
2744- {
2745- ExtTextOutA(VTDC,*X+ts.FontDX,Y+ts.FontDY,
2746- ETO_CLIPPED | ETO_OPAQUE,
2747- &RText,Buff,Count,&Dx[0]);
2748- }else{
2782+ else {
2783+ HFONT hPrevFont;
2784+ RECT rect;
2785+ int eto_options;
2786+ const int width = Count*FontWidth;
2787+ const int height = FontHeight;
2788+ SetRect(&rect,0,0,width,height);
27492789
2750- int width;
2751- int height;
2752- int eto_options = ETO_CLIPPED;
2753- RECT rect;
2754- HFONT hPrevFont;
2790+ //hdcBGBuffer の属性を設定
2791+ hPrevFont = SelectObject(hdcBGBuffer,GetCurrentObject(VTDC,OBJ_FONT));
2792+ SetTextColor(hdcBGBuffer,GetTextColor(VTDC));
2793+ SetBkColor(hdcBGBuffer,GetBkColor(VTDC));
27552794
2756- width = Count*FontWidth;
2757- height = FontHeight;
2758- SetRect(&rect,0,0,width,height);
2795+ // 文字の背景を描画
2796+ DrawTextBGImage(hdcBGBuffer, *X, Y, width, height);
27592797
2760- //hdcBGBuffer の属性を設定
2761- hPrevFont = SelectObject(hdcBGBuffer,GetCurrentObject(VTDC,OBJ_FONT));
2762- SetTextColor(hdcBGBuffer,GetTextColor(VTDC));
2763- SetBkColor(hdcBGBuffer,GetBkColor(VTDC));
2798+ // 文字を描画
2799+ eto_options = ETO_CLIPPED;
2800+ if(BGReverseText == TRUE && BGReverseTextAlpha < 255) {
2801+ eto_options |= ETO_OPAQUE;
2802+ }
2803+ ExtTextOutA(hdcBGBuffer,ts.FontDX,ts.FontDY,eto_options,&rect,Buff,Count,&Dx[0]);
27642804
2765- //窓の移動、リサイズ中は背景を BGBrushInSizeMove で塗りつぶす
2766- if(BGInSizeMove)
2767- FillRect(hdcBGBuffer,&rect,BGBrushInSizeMove);
2805+ // Windowに貼り付け
2806+ BitBlt(VTDC,*X,Y,width,height,hdcBGBuffer,0,0,SRCCOPY);
27682807
2769- BitBlt(hdcBGBuffer,0,0,width,height,hdcBG,*X,Y,SRCCOPY);
2808+ SelectObject(hdcBGBuffer,hPrevFont);
2809+ }
2810+#endif
27702811
2771- if(BGReverseText == TRUE)
2772- {
2773- if(BGReverseTextAlpha < 255)
2774- {
2775- BLENDFUNCTION bf;
2776- HBRUSH hbr;
2812+ *X += Count*FontWidth;
27772813
2778- hbr = CreateSolidBrush(GetBkColor(hdcBGBuffer));
2779- FillRect(hdcBGWork,&rect,hbr);
2780- DeleteObject(hbr);
2781-
2782- ZeroMemory(&bf,sizeof(bf));
2783- bf.BlendOp = AC_SRC_OVER;
2784- bf.SourceConstantAlpha = BGReverseTextAlpha;
2785-
2786- BGAlphaBlend(hdcBGBuffer,0,0,width,height,hdcBGWork,0,0,width,height,bf);
2787- }else{
2788- eto_options |= ETO_OPAQUE;
2789- }
2790- }
2791-
2792- ExtTextOutA(hdcBGBuffer,ts.FontDX,ts.FontDY,eto_options,&rect,Buff,Count,&Dx[0]);
2793- BitBlt(VTDC,*X,Y,width,height,hdcBGBuffer,0,0,SRCCOPY);
2794-
2795- SelectObject(hdcBGBuffer,hPrevFont);
2796- }
2797-//-->
2798-#else
2799- ExtTextOut(VTDC,*X+ts.FontDX,Y+ts.FontDY,
2800- ETO_CLIPPED | ETO_OPAQUE,
2801- &RText,Buff,Count,&Dx[0]);
2802-#endif
2803- *X = RText.right;
2804-
2805- if ((ts.Language==IdRussian) &&
2806- (ts.RussClient!=ts.RussFont))
2807- RussConvStr(ts.RussFont,ts.RussClient,Buff,Count);
2814+ if ((ts.Language==IdRussian) && (ts.RussClient!=ts.RussFont))
2815+ RussConvStr(ts.RussFont,ts.RussClient,Buff,Count);
28082816 }
28092817
2818+// DispStr() の wchar_t版
2819+#if defined(UNICODE)
2820+void DispStrW(const wchar_t *Buff, int Count, int Y, int* X)
2821+{
2822+#ifdef ALPHABLEND_TYPE2
2823+ const BOOL draw_bg_enable = BGEnable;
28102824 #else
2811-void DispStr(PCHAR Buff, int Count, int Y, int* X)
2812-// Display a string
2813-// Buff: points the string
2814-// Y: vertical position in window cordinate
2815-// *X: horizontal position
2816-// Return:
2817-// *X: horizontal position shifted by the width of the string
2818-{
2819- RECT RText;
2820- wchar_t *wc;
2821- int len, wclen;
2822- CHAR ch;
2823-
2824-#if 0
2825-#include <crtdbg.h>
2826- _CrtSetBreakAlloc(52);
2827- Buff[0] = 0x82;
2828- Buff[1] = 0xe4;
2829- Buff[2] = 0x82;
2830- Buff[3] = 0xbd;
2831- Buff[4] = 0x82;
2832- Buff[5] = 0xa9;
2833- Count = 6;
2825+ const BOOL draw_bg_enable = FALSE;
28342826 #endif
28352827
2836- setlocale(LC_ALL, ts.Locale); // TODO コード変換ここでする?,無効化されたコード
2828+ if(!draw_bg_enable)
2829+ {
2830+ RECT RText;
2831+ RText.top = Y;
2832+ RText.bottom = Y+FontHeight;
2833+ RText.left = *X;
2834+ RText.right = *X + Count*FontWidth;
28372835
2838- ch = Buff[Count];
2839- Buff[Count] = 0;
2840- len = mbstowcs(NULL, Buff, 0);
2836+ ExtTextOutW(VTDC,*X+ts.FontDX,Y+ts.FontDY,
2837+ ETO_CLIPPED | ETO_OPAQUE,
2838+ &RText,Buff,Count,&Dx[0]);
2839+ }
2840+#ifdef ALPHABLEND_TYPE2
2841+ else {
2842+ HFONT hPrevFont;
2843+ RECT rect;
2844+ int eto_options;
2845+ const int width = Count*FontWidth;
2846+ const int height = FontHeight;
2847+ SetRect(&rect,0,0,width,height);
28412848
2842- wc = malloc(sizeof(wchar_t) * (len + 1));
2843- if (wc == NULL)
2844- return;
2845- wclen = mbstowcs(wc, Buff, len + 1);
2846- Buff[Count] = ch;
2849+ //hdcBGBuffer の属性を設定
2850+ hPrevFont = SelectObject(hdcBGBuffer,GetCurrentObject(VTDC,OBJ_FONT));
2851+ SetTextColor(hdcBGBuffer,GetTextColor(VTDC));
2852+ SetBkColor(hdcBGBuffer,GetBkColor(VTDC));
28472853
2848- if ((ts.Language==IdRussian) &&
2849- (ts.RussClient!=ts.RussFont))
2850- RussConvStr(ts.RussClient,ts.RussFont,Buff,Count);
2854+ // 文字の背景を描画
2855+ DrawTextBGImage(hdcBGBuffer, *X, Y, width, height);
28512856
2852- RText.top = Y;
2853- RText.bottom = Y+FontHeight;
2854- RText.left = *X;
2855- RText.right = *X + Count*FontWidth; //
2857+ // 文字を描画
2858+ eto_options = ETO_CLIPPED;
2859+ if(BGReverseText == TRUE && BGReverseTextAlpha < 255) {
2860+ eto_options |= ETO_OPAQUE;
2861+ }
2862+ ExtTextOutW(hdcBGBuffer,ts.FontDX,ts.FontDY,eto_options,&rect,Buff,Count,&Dx[0]);
28562863
2857- // Unicodeで出力する。
2858-#if 1
2859- // UTF-8環境において、tcshがEUC出力した場合、画面に何も表示されないことがある。
2860- // マウスでドラッグしたり、ログファイルへ保存してみると、文字化けした文字列を
2861- // 確認することができる。(2004.8.6 yutaka)
2862- ExtTextOutW(VTDC,*X+ts.FontDX,Y+ts.FontDY,
2863- ETO_CLIPPED | ETO_OPAQUE,
2864- &RText, wc, wclen, NULL);
2865-// &RText, wc, wclen, &Dx[0]);
2866-#else
2867- TextOutW(VTDC, *X+ts.FontDX, Y+ts.FontDY, wc, wclen);
2864+ // Windowに貼り付け
2865+ BitBlt(VTDC,*X,Y,width,height,hdcBGBuffer,0,0,SRCCOPY);
28682866
2867+ SelectObject(hdcBGBuffer,hPrevFont);
2868+ }
28692869 #endif
28702870
2871- *X = RText.right;
2872-
2873- if ((ts.Language==IdRussian) &&
2874- (ts.RussClient!=ts.RussFont))
2875- RussConvStr(ts.RussFont,ts.RussClient,Buff,Count);
2876-
2877- free(wc);
2871+ *X += Count*FontWidth;
28782872 }
28792873 #endif
28802874
2881-
28822875 void DispEraseCurToEnd(int YEnd)
28832876 {
28842877 RECT R;
--- branches/cmake/teraterm/teraterm/vtdisp.h (revision 7471)
+++ branches/cmake/teraterm/teraterm/vtdisp.h (revision 7472)
@@ -80,6 +80,7 @@
8080 void DispReleaseDC();
8181 void DispSetupDC(TCharAttr Attr, BOOL Reverse);
8282 void DispStr(PCHAR Buff, int Count, int Y, int* X);
83+void DispStrW(const wchar_t *Buff, int Count, int Y, int* X);
8384 void DispEraseCurToEnd(int YEnd);
8485 void DispEraseHomeToCur(int YHome);
8586 void DispEraseCharsInLine(int XStart, int Count);
--- branches/cmake/teraterm/teraterm/vtterm.c (revision 7471)
+++ branches/cmake/teraterm/teraterm/vtterm.c (revision 7472)
@@ -662,7 +662,8 @@
662662 else
663663 CharAttrTmp.Attr |= CharAttr.Attr;
664664
665- BuffPutChar(b, CharAttrTmp, InsertMode);
665+ //BuffPutChar(b, CharAttrTmp, InsertMode);
666+ BuffPutUnicode(b, CharAttrTmp, InsertMode);
666667
667668 if (CursorX == CursorRightM || CursorX >= NumOfColumns-1) {
668669 UpdateStr();
@@ -849,7 +850,7 @@
849850 }
850851 }
851852
852-void PrnParseControl(BYTE b) // printer mode
853+static void PrnParseControl(BYTE b) // printer mode
853854 {
854855 switch (b) {
855856 case NUL:
@@ -898,7 +899,7 @@
898899 WriteToPrnFile(b, TRUE);
899900 }
900901
901-void ParseControl(BYTE b)
902+static void ParseControl(BYTE b)
902903 {
903904 if (PrinterMode) { // printer mode
904905 PrnParseControl(b);
@@ -5467,8 +5468,58 @@
54675468 }
54685469
54695470 // unicode(UTF-32,wchar_t)をバッファへ書き込む
5471+// TODO @@
5472+#if defined(UNICODE_DISPLAY)
5473+// 内部コード unicode版
54705474 static void UnicodeToCP932(unsigned int code)
54715475 {
5476+ unsigned short cset;
5477+
5478+ TCharAttr CharAttrTmp;
5479+ CharAttrTmp = CharAttr;
5480+ if (code <= US) {
5481+ // C0
5482+ ParseControl(code);
5483+#if 0
5484+ } else if ((0x80<=code) && (code<=0x9F)) {
5485+ // C1
5486+ ParseControl(code);
5487+ } else if (code < 0x20) {
5488+ PutChar(code);
5489+#endif
5490+#if 0
5491+ } else if (code <= 0xff) {
5492+ PutChar(code);
5493+#endif
5494+ } else {
5495+ // UnicodeからDEC特殊文字へのマッピング
5496+ if (ts.UnicodeDecSpMapping) {
5497+ cset = UTF32ToDecSp(code);
5498+ if (((cset >> 8) & ts.UnicodeDecSpMapping) != 0) {
5499+ code = cset & 0xff;
5500+ CharAttrTmp.Attr |= AttrSpecial;
5501+ }
5502+ }
5503+
5504+ BuffPutUnicode(code, CharAttrTmp, InsertMode);
5505+ if (CursorX == CursorRightM || CursorX >= NumOfColumns - 1) {
5506+ UpdateStr();
5507+ Wrap = AutoWrapMode;
5508+ }
5509+ else {
5510+ if (code >= 0x80) {
5511+ MoveRight();
5512+ }
5513+ MoveRight();
5514+ }
5515+ }
5516+}
5517+
5518+#else
5519+
5520+// 従来版
5521+static void UnicodeToCP932(unsigned int code)
5522+{
54725523 int ret;
54735524 char mbchar[2];
54745525 unsigned short cset;
@@ -5512,9 +5563,28 @@
55125563 }
55135564 }
55145565
5566+#endif
5567+
55155568 // UTF-8で受信データを処理する
5569+
5570+static BOOL ParseFirstUTF8Sub(BYTE b)
5571+{
5572+ if (b<=US)
5573+ ParseControl(b);
5574+ else if ((b>=0x20) && (b<=0x7E))
5575+ PutChar(b);
5576+ else if ((b>=0x80) && (b<=0x9F))
5577+ ParseControl(b);
5578+ else if (b>=0xA0)
5579+ PutChar(b);
5580+ return TRUE;
5581+}
5582+
5583+
5584+// UTF-8で受信データを処理する
55165585 // returns TRUE if b is processed
55175586 // (actually allways returns TRUE)
5587+// TODO:@@
55185588 static BOOL ParseFirstUTF8(BYTE b, int proc_combining)
55195589 {
55205590 static BYTE buf[4];
@@ -5540,10 +5610,14 @@
55405610 }
55415611
55425612 if (count == 1) {
5543- ParseASCII(buf[0]);
5613+ ParseFirstUTF8Sub(buf[0]);
5614+ //ParseASCII(buf[0]);
5615+
55445616 }
5545- ParseASCII(b);
5617+ //ParseASCII(b);
55465618
5619+ ParseFirstUTF8Sub(b);
5620+ //UnicodeToCP932(b);
55475621 count = 0; // reset counter
55485622 return TRUE;
55495623 }
Show on old repository browser