| 41 |
#include <stdlib.h> |
#include <stdlib.h> |
| 42 |
#include <crtdbg.h> |
#include <crtdbg.h> |
| 43 |
#include <tchar.h> |
#include <tchar.h> |
| 44 |
|
#include <assert.h> |
| 45 |
|
|
| 46 |
#include "buffer.h" |
#include "buffer.h" |
| 47 |
#include "ttwinman.h" |
#include "ttwinman.h" |
| 60 |
|
|
| 61 |
#include "vtterm.h" |
#include "vtterm.h" |
| 62 |
|
|
| 63 |
|
#include "unicode_test.h" |
| 64 |
|
|
| 65 |
void ParseFirst(BYTE b); |
void ParseFirst(BYTE b); |
| 66 |
|
|
| 67 |
#define MAPSIZE(x) (sizeof(x)/sizeof((x)[0])) |
#define MAPSIZE(x) (sizeof(x)/sizeof((x)[0])) |
| 214 |
|
|
| 215 |
static _locale_t CLocale = NULL; |
static _locale_t CLocale = NULL; |
| 216 |
|
|
| 217 |
|
#if UNICODE_INTERNAL_BUFF |
| 218 |
|
// 内部コード unicode版 |
| 219 |
|
static void UnicodeToCP932(unsigned int code); |
| 220 |
|
#endif |
| 221 |
|
|
| 222 |
void ClearParams() |
void ClearParams() |
| 223 |
{ |
{ |
| 224 |
ICount = 0; |
ICount = 0; |
| 570 |
} |
} |
| 571 |
} |
} |
| 572 |
|
|
| 573 |
void CarriageReturn(BOOL logFlag) |
static void CarriageReturn(BOOL logFlag) |
| 574 |
{ |
{ |
| 575 |
if (!ts.EnableContinuedLineCopy || logFlag) |
if (!ts.EnableContinuedLineCopy || logFlag) |
| 576 |
if (cv.HLogBuf!=0) Log1Byte(CR); |
if (cv.HLogBuf!=0) Log1Byte(CR); |
| 583 |
Fallbacked = FALSE; |
Fallbacked = FALSE; |
| 584 |
} |
} |
| 585 |
|
|
| 586 |
void LineFeed(BYTE b, BOOL logFlag) |
static void LineFeed(BYTE b, BOOL logFlag) |
| 587 |
{ |
{ |
| 588 |
/* for auto print mode */ |
/* for auto print mode */ |
| 589 |
if ((AutoPrintMode) && |
if ((AutoPrintMode) && |
| 695 |
} |
} |
| 696 |
|
|
| 697 |
if (Wrap) { |
if (Wrap) { |
| 698 |
|
#if UNICODE_INTERNAL_BUFF |
| 699 |
|
TCharAttr t = BuffGetCursorCharAttr(CursorX, CursorY); |
| 700 |
|
t.Attr |= AttrLineContinued; |
| 701 |
|
t.AttrEx = t.Attr; |
| 702 |
|
BuffSetCursorCharAttr(CursorX, CursorY, t); |
| 703 |
|
#endif |
| 704 |
CarriageReturn(FALSE); |
CarriageReturn(FALSE); |
| 705 |
LineFeed(LF,FALSE); |
LineFeed(LF,FALSE); |
| 706 |
|
#if !UNICODE_INTERNAL_BUFF |
| 707 |
CharAttrTmp.Attr |= ts.EnableContinuedLineCopy ? AttrLineContinued : 0; |
CharAttrTmp.Attr |= ts.EnableContinuedLineCopy ? AttrLineContinued : 0; |
| 708 |
|
#else |
| 709 |
|
CharAttrTmp.Attr |= AttrLineContinued; |
| 710 |
|
t.AttrEx = t.Attr; |
| 711 |
|
#endif |
| 712 |
} |
} |
| 713 |
|
|
| 714 |
if (cv.HLogBuf !=0) { |
if (cv.HLogBuf !=0) { |
| 752 |
else |
else |
| 753 |
CharAttrTmp.Attr |= CharAttr.Attr; |
CharAttrTmp.Attr |= CharAttr.Attr; |
| 754 |
|
|
| 755 |
|
#if 0 |
| 756 |
|
if (CursorX == CursorRightM || CursorX >= NumOfColumns - 1) { |
| 757 |
|
CharAttrTmp.Attr |= AttrLineContinued; |
| 758 |
|
} |
| 759 |
|
#endif |
| 760 |
|
|
| 761 |
|
#if UNICODE_INTERNAL_BUFF |
| 762 |
|
CharAttrTmp.AttrEx = CharAttrTmp.Attr; |
| 763 |
|
if (ts.Language == IdJapanese) { |
| 764 |
|
unsigned long u32; |
| 765 |
|
switch (ts.KanjiCode) { |
| 766 |
|
// case IdJIS: |
| 767 |
|
// b = JIS2SJIS(b); |
| 768 |
|
case IdSJIS: |
| 769 |
|
u32 = MBCP_UTF32(b, 932); |
| 770 |
|
BuffPutUnicode(u32, CharAttrTmp, InsertMode); |
| 771 |
|
break; |
| 772 |
|
case IdUTF8: |
| 773 |
|
BuffPutUnicode(b, CharAttrTmp, InsertMode); |
| 774 |
|
break; |
| 775 |
|
default: |
| 776 |
|
BuffPutUnicode(b, CharAttrTmp, InsertMode); |
| 777 |
|
break; |
| 778 |
|
} |
| 779 |
|
} else if (ts.Language == IdRussian) { |
| 780 |
|
BYTE c = RussConv(ts.RussHost, IdWindows, b); |
| 781 |
|
unsigned long u32 = MBCP_UTF32(c, 1251); |
| 782 |
|
BuffPutUnicode(u32, CharAttrTmp, InsertMode); |
| 783 |
|
} else { |
| 784 |
|
BuffPutUnicode(b, CharAttrTmp, InsertMode); |
| 785 |
|
} |
| 786 |
|
#else |
| 787 |
BuffPutChar(b, CharAttrTmp, InsertMode); |
BuffPutChar(b, CharAttrTmp, InsertMode); |
| 788 |
|
#endif |
| 789 |
|
|
| 790 |
if (CursorX == CursorRightM || CursorX >= NumOfColumns-1) { |
if (CursorX == CursorRightM || CursorX >= NumOfColumns-1) { |
| 791 |
UpdateStr(); |
UpdateStr(); |
| 796 |
} |
} |
| 797 |
} |
} |
| 798 |
|
|
| 799 |
void PutDecSp(BYTE b) |
static void PutDecSp(BYTE b) |
| 800 |
{ |
{ |
| 801 |
TCharAttr CharAttrTmp; |
TCharAttr CharAttrTmp; |
| 802 |
|
|
| 830 |
} |
} |
| 831 |
|
|
| 832 |
CharAttrTmp.Attr |= AttrSpecial; |
CharAttrTmp.Attr |= AttrSpecial; |
| 833 |
|
#if UNICODE_INTERNAL_BUFF |
| 834 |
|
CharAttrTmp.AttrEx = CharAttrTmp.Attr; |
| 835 |
|
#endif |
| 836 |
BuffPutChar(b, CharAttrTmp, InsertMode); |
BuffPutChar(b, CharAttrTmp, InsertMode); |
| 837 |
|
|
| 838 |
if (CursorX == CursorRightM || CursorX >= NumOfColumns-1) { |
if (CursorX == CursorRightM || CursorX >= NumOfColumns-1) { |
| 844 |
} |
} |
| 845 |
} |
} |
| 846 |
|
|
| 847 |
void PutKanji(BYTE b) |
static void PutKanji(BYTE b) |
| 848 |
{ |
{ |
| 849 |
int LineEnd; |
int LineEnd; |
| 850 |
TCharAttr CharAttrTmp; |
TCharAttr CharAttrTmp; |
| 875 |
if (Wrap) { |
if (Wrap) { |
| 876 |
CarriageReturn(FALSE); |
CarriageReturn(FALSE); |
| 877 |
LineFeed(LF,FALSE); |
LineFeed(LF,FALSE); |
| 878 |
|
#if !UNICODE_INTERNAL_BUFF |
| 879 |
if (ts.EnableContinuedLineCopy) |
if (ts.EnableContinuedLineCopy) |
| 880 |
CharAttrTmp.Attr |= AttrLineContinued; |
CharAttrTmp.Attr |= AttrLineContinued; |
| 881 |
|
#else |
| 882 |
|
if (ts.EnableContinuedLineCopy) { |
| 883 |
|
CharAttrTmp.Attr |= AttrLineContinued; |
| 884 |
|
CharAttrTmp.AttrEx = CharAttrTmp.Attr; |
| 885 |
|
} |
| 886 |
|
#endif |
| 887 |
} |
} |
| 888 |
else if (CursorX > LineEnd - 1) { |
else if (CursorX > LineEnd - 1) { |
| 889 |
if (AutoWrapMode) { |
if (AutoWrapMode) { |
| 890 |
if (ts.EnableContinuedLineCopy) { |
if (ts.EnableContinuedLineCopy) { |
| 891 |
CharAttrTmp.Attr |= AttrLineContinued; |
CharAttrTmp.Attr |= AttrLineContinued; |
| 892 |
|
#if UNICODE_INTERNAL_BUFF |
| 893 |
|
CharAttrTmp.AttrEx = CharAttrTmp.Attr; |
| 894 |
|
#endif |
| 895 |
if (CursorX == LineEnd) |
if (CursorX == LineEnd) |
| 896 |
BuffPutChar(0x20, CharAttr, FALSE); |
BuffPutChar(0x20, CharAttr, FALSE); |
| 897 |
} |
} |
| 915 |
Special = FALSE; |
Special = FALSE; |
| 916 |
} |
} |
| 917 |
|
|
| 918 |
|
#if UNICODE_INTERNAL_BUFF |
| 919 |
|
{ |
| 920 |
|
// codepage一覧 |
| 921 |
|
// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-ucoderef/28fefe92-d66c-4b03-90a9-97b473223d43 |
| 922 |
|
unsigned long u32 = 0; |
| 923 |
|
if (ts.Language == IdKorean && ts.CodePage == 51949) { |
| 924 |
|
#if 0 |
| 925 |
|
unsigned char buf[2]; |
| 926 |
|
int ret; |
| 927 |
|
wchar_t wchar; |
| 928 |
|
buf[0] = Kanji >> 8; |
| 929 |
|
buf[1] = Kanji & 0xff; |
| 930 |
|
ret = MultiByteToWideChar(51949, MB_ERR_INVALID_CHARS, (char *)buf, 2, &wchar, 1); |
| 931 |
|
u32 = wchar; |
| 932 |
|
#endif |
| 933 |
|
u32 = MBCP_UTF32(Kanji, ts.CodePage); |
| 934 |
|
} else if (ts.Language == IdJapanese && ts.CodePage == 932) { |
| 935 |
|
// ここに来た時点でCP932になっている |
| 936 |
|
//} else if (ts.KanjiCode == IdSJIS || ts.KanjiCode == IdEUC || ts.KanjiCode == IdJIS) { |
| 937 |
|
u32 = CP932ToUTF32(Kanji); |
| 938 |
|
} else { |
| 939 |
|
u32 = MBCP_UTF32(Kanji, ts.CodePage); |
| 940 |
|
} |
| 941 |
|
CharAttrTmp.AttrEx = CharAttrTmp.Attr; |
| 942 |
|
BuffPutUnicode(u32, CharAttrTmp, InsertMode); |
| 943 |
|
} |
| 944 |
|
#else |
| 945 |
BuffPutKanji(Kanji, CharAttrTmp, InsertMode); |
BuffPutKanji(Kanji, CharAttrTmp, InsertMode); |
| 946 |
|
#endif |
| 947 |
|
|
| 948 |
if (CursorX < LineEnd - 1) { |
if (CursorX < LineEnd - 1) { |
| 949 |
MoveRight(); |
MoveRight(); |
| 1016 |
} |
} |
| 1017 |
} |
} |
| 1018 |
|
|
| 1019 |
void PrnParseControl(BYTE b) // printer mode |
static void PrnParseControl(BYTE b) // printer mode |
| 1020 |
{ |
{ |
| 1021 |
switch (b) { |
switch (b) { |
| 1022 |
case NUL: |
case NUL: |
| 1065 |
WriteToPrnFile(b, TRUE); |
WriteToPrnFile(b, TRUE); |
| 1066 |
} |
} |
| 1067 |
|
|
| 1068 |
void ParseControl(BYTE b) |
static void ParseControl(BYTE b) |
| 1069 |
{ |
{ |
| 1070 |
if (PrinterMode) { // printer mode |
if (PrinterMode) { // printer mode |
| 1071 |
PrnParseControl(b); |
PrnParseControl(b); |
| 1717 |
} \ |
} \ |
| 1718 |
} |
} |
| 1719 |
|
|
| 1720 |
void CSInsertCharacter() // ICH |
// ICH |
| 1721 |
|
static void CSInsertCharacter(void) |
| 1722 |
{ |
{ |
| 1723 |
// Insert space characters at cursor |
// Insert space characters at cursor |
| 1724 |
CheckParamVal(Param[1], NumOfColumns); |
CheckParamVal(Param[1], NumOfColumns); |
| 1891 |
} |
} |
| 1892 |
} |
} |
| 1893 |
|
|
| 1894 |
void CSQSelLineErase() |
static void CSQSelLineErase(void) |
| 1895 |
{ |
{ |
| 1896 |
BuffUpdateScroll(); |
BuffUpdateScroll(); |
| 1897 |
switch (Param[1]) { |
switch (Param[1]) { |
| 1931 |
BuffDeleteLines(Count,YEnd); |
BuffDeleteLines(Count,YEnd); |
| 1932 |
} |
} |
| 1933 |
|
|
| 1934 |
void CSDeleteCharacter() // DCH |
// DCH |
| 1935 |
|
static void CSDeleteCharacter(void) |
| 1936 |
{ |
{ |
| 1937 |
// Delete characters in current line from cursor |
// Delete characters in current line from cursor |
| 1938 |
CheckParamVal(Param[1], NumOfColumns); |
CheckParamVal(Param[1], NumOfColumns); |
| 1941 |
BuffDeleteChars(Param[1]); |
BuffDeleteChars(Param[1]); |
| 1942 |
} |
} |
| 1943 |
|
|
| 1944 |
void CSEraseCharacter() // ECH |
// ECH |
| 1945 |
|
static void CSEraseCharacter(void) |
| 1946 |
{ |
{ |
| 1947 |
CheckParamVal(Param[1], NumOfColumns); |
CheckParamVal(Param[1], NumOfColumns); |
| 1948 |
|
|
| 2234 |
case 0: /* Clear all */ |
case 0: /* Clear all */ |
| 2235 |
attr->Attr = DefCharAttr.Attr; |
attr->Attr = DefCharAttr.Attr; |
| 2236 |
attr->Attr2 = DefCharAttr.Attr2 | (attr->Attr2&Attr2Protect); |
attr->Attr2 = DefCharAttr.Attr2 | (attr->Attr2&Attr2Protect); |
| 2237 |
|
#if UNICODE_INTERNAL_BUFF |
| 2238 |
|
attr->AttrEx = attr->Attr; |
| 2239 |
|
#endif |
| 2240 |
attr->Fore = DefCharAttr.Fore; |
attr->Fore = DefCharAttr.Fore; |
| 2241 |
attr->Back = DefCharAttr.Back; |
attr->Back = DefCharAttr.Back; |
| 2242 |
mask->Attr = AttrSgrMask; |
mask->Attr = AttrSgrMask; |
| 3731 |
attr.Attr &= AttrSgrMask; |
attr.Attr &= AttrSgrMask; |
| 3732 |
mask.Attr &= AttrSgrMask; |
mask.Attr &= AttrSgrMask; |
| 3733 |
attr.Attr2 &= Attr2ColorMask; |
attr.Attr2 &= Attr2ColorMask; |
| 3734 |
|
#if UNICODE_INTERNAL_BUFF |
| 3735 |
|
attr.AttrEx = attr.Attr; |
| 3736 |
|
#endif |
| 3737 |
mask.Attr2 &= Attr2ColorMask; |
mask.Attr2 &= Attr2ColorMask; |
| 3738 |
if (RectangleMode) { |
if (RectangleMode) { |
| 3739 |
BuffChangeAttrBox(Param[2]-1, Param[1]-1, Param[4]-1, Param[3]-1, &attr, &mask); |
BuffChangeAttrBox(Param[2]-1, Param[1]-1, Param[4]-1, Param[3]-1, &attr, &mask); |
| 5327 |
} |
} |
| 5328 |
} |
} |
| 5329 |
|
|
| 5330 |
BOOL CheckKanji(BYTE b) |
/** |
| 5331 |
|
* dbcsの1byte目チェック? |
| 5332 |
|
*/ |
| 5333 |
|
static BOOL CheckKanji(BYTE b) |
| 5334 |
{ |
{ |
| 5335 |
BOOL Check; |
BOOL Check; |
| 5336 |
|
|
| 5337 |
|
#if UNICODE_INTERNAL_BUFF |
| 5338 |
|
if (ts.CodePage != 932) { |
| 5339 |
|
// TODO ちゃんとチェックする |
| 5340 |
|
// IsDBCSLeadByteEx() が妥当? |
| 5341 |
|
if (ts.CodePage == 936) { |
| 5342 |
|
// chs |
| 5343 |
|
return ((0x81 <= b) && (b <= 0xfe)); |
| 5344 |
|
} |
| 5345 |
|
if (ts.CodePage == 950) { |
| 5346 |
|
// cht |
| 5347 |
|
return ((0x88 <= b) && (b <= 0xfe)); |
| 5348 |
|
} |
| 5349 |
|
|
| 5350 |
|
} |
| 5351 |
|
#endif |
| 5352 |
if (ts.Language!=IdJapanese) |
if (ts.Language!=IdJapanese) |
| 5353 |
return FALSE; |
return FALSE; |
| 5354 |
|
|
| 5404 |
return Check; |
return Check; |
| 5405 |
} |
} |
| 5406 |
|
|
| 5407 |
BOOL ParseFirstJP(BYTE b) |
static BOOL ParseFirstJP(BYTE b) |
| 5408 |
// returns TRUE if b is processed |
// returns TRUE if b is processed |
| 5409 |
// (actually allways returns TRUE) |
// (actually allways returns TRUE) |
| 5410 |
{ |
{ |
| 5465 |
if ((Gn[Glr[0]] == IdKatakana) || EUCkanaIn) { |
if ((Gn[Glr[0]] == IdKatakana) || EUCkanaIn) { |
| 5466 |
b = b | 0x80; |
b = b | 0x80; |
| 5467 |
EUCkanaIn = FALSE; |
EUCkanaIn = FALSE; |
| 5468 |
|
#if UNICODE_INTERNAL_BUFF |
| 5469 |
|
{ |
| 5470 |
|
// bはsjisの半角カタカナ |
| 5471 |
|
unsigned long u32 = CP932ToUTF32(b); |
| 5472 |
|
UnicodeToCP932(u32); |
| 5473 |
|
} |
| 5474 |
|
return TRUE; |
| 5475 |
|
#endif |
| 5476 |
} |
} |
| 5477 |
PutChar(b); |
PutChar(b); |
| 5478 |
} |
} |
| 5531 |
(ts.KanjiCode==IdSJIS) || |
(ts.KanjiCode==IdSJIS) || |
| 5532 |
(ts.KanjiCode==IdJIS) && |
(ts.KanjiCode==IdJIS) && |
| 5533 |
(ts.JIS7Katakana==0) && |
(ts.JIS7Katakana==0) && |
| 5534 |
((ts.TermFlag & TF_FIXEDJIS)!=0)) |
((ts.TermFlag & TF_FIXEDJIS)!=0)) { |
| 5535 |
|
#if UNICODE_INTERNAL_BUFF |
| 5536 |
|
// bはsjisの半角カタカナ |
| 5537 |
|
unsigned long u32 = CP932ToUTF32(b); |
| 5538 |
|
UnicodeToCP932(u32); |
| 5539 |
|
#else |
| 5540 |
PutChar(b); // katakana |
PutChar(b); // katakana |
| 5541 |
else { |
#endif |
| 5542 |
|
} else { |
| 5543 |
if (Gn[Glr[1]] == IdASCII) { |
if (Gn[Glr[1]] == IdASCII) { |
| 5544 |
b = b & 0x7f; |
b = b & 0x7f; |
| 5545 |
} |
} |
| 5619 |
|
|
| 5620 |
static void ParseASCII(BYTE b) |
static void ParseASCII(BYTE b) |
| 5621 |
{ |
{ |
| 5622 |
|
#if !UNICODE_INTERNAL_BUFF |
| 5623 |
if (ts.Language == IdJapanese) { |
if (ts.Language == IdJapanese) { |
| 5624 |
ParseFirstJP(b); |
ParseFirstJP(b); |
| 5625 |
return; |
return; |
| 5626 |
} |
} |
| 5627 |
|
#endif |
| 5628 |
|
|
| 5629 |
if (SSflag) { |
if (SSflag) { |
| 5630 |
PutChar(b); |
PutChar(b); |
| 5702 |
return (index); |
return (index); |
| 5703 |
} |
} |
| 5704 |
|
|
| 5705 |
|
// unicode(UTF-32,wchar_t)をバッファへ書き込む |
| 5706 |
|
// TODO @@ |
| 5707 |
|
#if UNICODE_INTERNAL_BUFF |
| 5708 |
|
// 内部コード unicode版 |
| 5709 |
|
static void UnicodeToCP932(unsigned int code) |
| 5710 |
|
{ |
| 5711 |
|
unsigned short cset; |
| 5712 |
|
int LineEnd; |
| 5713 |
|
|
| 5714 |
|
TCharAttr CharAttrTmp; |
| 5715 |
|
CharAttrTmp = CharAttr; |
| 5716 |
|
if (code <= US) { |
| 5717 |
|
// C0 |
| 5718 |
|
ParseControl(code); |
| 5719 |
|
#if 0 |
| 5720 |
|
} else if ((0x80<=code) && (code<=0x9F)) { |
| 5721 |
|
// C1 |
| 5722 |
|
ParseControl(code); |
| 5723 |
|
} else if (code < 0x20) { |
| 5724 |
|
PutChar(code); |
| 5725 |
|
#endif |
| 5726 |
|
#if 0 |
| 5727 |
|
} else if (code <= 0xff) { |
| 5728 |
|
PutChar(code); |
| 5729 |
|
#endif |
| 5730 |
|
} else { |
| 5731 |
|
int r; |
| 5732 |
|
BOOL is_update; |
| 5733 |
|
|
| 5734 |
|
// UnicodeからDEC特殊文字へのマッピング |
| 5735 |
|
if (ts.UnicodeDecSpMapping) { |
| 5736 |
|
cset = UTF32ToDecSp(code); |
| 5737 |
|
if (((cset >> 8) & ts.UnicodeDecSpMapping) != 0) { |
| 5738 |
|
code = cset & 0xff; |
| 5739 |
|
CharAttrTmp.Attr |= AttrSpecial; |
| 5740 |
|
} |
| 5741 |
|
} |
| 5742 |
|
|
| 5743 |
|
if ((CharAttrTmp.Attr & AttrSpecial) == 0) { |
| 5744 |
|
if (Special) { |
| 5745 |
|
UpdateStr(); |
| 5746 |
|
Special = FALSE; |
| 5747 |
|
} |
| 5748 |
|
} else { |
| 5749 |
|
if (!Special) { |
| 5750 |
|
UpdateStr(); |
| 5751 |
|
Special = TRUE; |
| 5752 |
|
} |
| 5753 |
|
} |
| 5754 |
|
|
| 5755 |
|
if (CursorX > CursorRightM) |
| 5756 |
|
LineEnd = NumOfColumns - 1; |
| 5757 |
|
else |
| 5758 |
|
LineEnd = CursorRightM; |
| 5759 |
|
|
| 5760 |
|
|
| 5761 |
|
if (Wrap) { |
| 5762 |
|
TCharAttr t = BuffGetCursorCharAttr(CursorX, CursorY); |
| 5763 |
|
t.Attr |= AttrLineContinued; |
| 5764 |
|
t.AttrEx = t.Attr; |
| 5765 |
|
BuffSetCursorCharAttr(CursorX, CursorY, t); |
| 5766 |
|
CarriageReturn(FALSE); |
| 5767 |
|
LineFeed(LF,FALSE); |
| 5768 |
|
CharAttrTmp.Attr |= AttrLineContinued; |
| 5769 |
|
CharAttrTmp.AttrEx = CharAttrTmp.Attr; |
| 5770 |
|
} |
| 5771 |
|
|
| 5772 |
|
// BuffPutUnicode()した戻り値で文字のセル数を知ることができる |
| 5773 |
|
// エラー時はカーソル位置を検討する |
| 5774 |
|
Wrap = FALSE; |
| 5775 |
|
is_update = FALSE; |
| 5776 |
|
CharAttrTmp.AttrEx = CharAttrTmp.Attr; |
| 5777 |
|
retry: |
| 5778 |
|
r = BuffPutUnicode(code, CharAttrTmp, InsertMode); |
| 5779 |
|
if (r == -1) { |
| 5780 |
|
// 文字全角で行末、入力できない |
| 5781 |
|
|
| 5782 |
|
if (AutoWrapMode) { |
| 5783 |
|
// 自動改行 |
| 5784 |
|
// 、wrap処理 |
| 5785 |
|
CharAttrTmp = CharAttr; |
| 5786 |
|
CharAttrTmp.Attr |= AttrLineContinued; |
| 5787 |
|
CharAttrTmp.AttrEx = CharAttrTmp.Attr | AttrPadding; |
| 5788 |
|
// AutoWrapMode |
| 5789 |
|
// ts.EnableContinuedLineCopy |
| 5790 |
|
//if (CursorX != LineEnd){ |
| 5791 |
|
//&& BuffIsHalfWidthFromCode(&ts, code)) { |
| 5792 |
|
|
| 5793 |
|
// full width出力が半分出力にならないように0x20を出力 |
| 5794 |
|
BuffPutUnicode(0x20, CharAttrTmp, FALSE); |
| 5795 |
|
CharAttrTmp.AttrEx = CharAttrTmp.AttrEx & ~AttrPadding; |
| 5796 |
|
|
| 5797 |
|
CarriageReturn(FALSE); |
| 5798 |
|
LineFeed(LF,FALSE); |
| 5799 |
|
} |
| 5800 |
|
else { |
| 5801 |
|
// 行頭に戻す |
| 5802 |
|
CursorX = 0; |
| 5803 |
|
} |
| 5804 |
|
|
| 5805 |
|
//CharAttrTmp.Attr &= ~AttrLineContinued; |
| 5806 |
|
goto retry; |
| 5807 |
|
} |
| 5808 |
|
else if (r == 0) { |
| 5809 |
|
// カーソルの移動なし,合字など |
| 5810 |
|
; |
| 5811 |
|
} else if (r == 1) { |
| 5812 |
|
// 半角(1セル) |
| 5813 |
|
if (CursorX + 0 == CursorRightM || CursorX >= NumOfColumns - 1) { |
| 5814 |
|
UpdateStr(); |
| 5815 |
|
Wrap = AutoWrapMode; |
| 5816 |
|
} else { |
| 5817 |
|
MoveRight(); |
| 5818 |
|
} |
| 5819 |
|
} else if (r == 2) { |
| 5820 |
|
// 全角(2セル) |
| 5821 |
|
if (CursorX + 1 == CursorRightM || CursorX + 1 >= NumOfColumns - 1) { |
| 5822 |
|
MoveRight(); // 全角の右側にカーソル移動 |
| 5823 |
|
UpdateStr(); |
| 5824 |
|
Wrap = AutoWrapMode; |
| 5825 |
|
} else { |
| 5826 |
|
MoveRight(); |
| 5827 |
|
MoveRight(); |
| 5828 |
|
} |
| 5829 |
|
} |
| 5830 |
|
else { |
| 5831 |
|
assert(FALSE); |
| 5832 |
|
} |
| 5833 |
|
} |
| 5834 |
|
} |
| 5835 |
|
|
| 5836 |
|
#else |
| 5837 |
|
|
| 5838 |
// unicode(UTF-32)をバッファ(t.CodePage)へ書き込む |
// unicode(UTF-32)をバッファ(t.CodePage)へ書き込む |
| 5839 |
static void UnicodeToCP932(unsigned int code) |
static void UnicodeToCP932(unsigned int code) |
| 5840 |
{ |
{ |
| 5880 |
} |
} |
| 5881 |
} |
} |
| 5882 |
|
|
| 5883 |
|
#endif |
| 5884 |
|
|
| 5885 |
|
// UTF-8で受信データを処理する(sub) |
| 5886 |
|
#if UNICODE_INTERNAL_BUFF |
| 5887 |
|
static BOOL ParseFirstUTF8Sub(BYTE b) |
| 5888 |
|
{ |
| 5889 |
|
if (b<=US) |
| 5890 |
|
ParseControl(b); |
| 5891 |
|
else if ((b>=0x20) && (b<=0x7E)) |
| 5892 |
|
PutChar(b); |
| 5893 |
|
else if ((b>=0x80) && (b<=0x9F)) |
| 5894 |
|
ParseControl(b); |
| 5895 |
|
else if (b>=0xA0) |
| 5896 |
|
PutChar(b); |
| 5897 |
|
return TRUE; |
| 5898 |
|
} |
| 5899 |
|
#endif |
| 5900 |
|
|
| 5901 |
// UTF-8で受信データを処理する |
// UTF-8で受信データを処理する |
| 5902 |
// returns TRUE if b is processed |
// returns TRUE if b is processed |
| 5903 |
// (actually allways returns TRUE) |
// (actually allways returns TRUE) |
| 5926 |
} |
} |
| 5927 |
|
|
| 5928 |
if (count == 1) { |
if (count == 1) { |
| 5929 |
|
//#if UNICODE_INTERNAL_BUFF |
| 5930 |
|
#if 0 |
| 5931 |
|
ParseFirstUTF8Sub(buf[0]); |
| 5932 |
|
#else |
| 5933 |
ParseASCII(buf[0]); |
ParseASCII(buf[0]); |
| 5934 |
|
#endif |
| 5935 |
} |
} |
| 5936 |
|
//#if UNICODE_INTERNAL_BUFF |
| 5937 |
|
#if 0 |
| 5938 |
|
ParseFirstUTF8Sub(b); |
| 5939 |
|
#else |
| 5940 |
ParseASCII(b); |
ParseASCII(b); |
| 5941 |
|
#endif |
| 5942 |
count = 0; // reset counter |
count = 0; // reset counter |
| 5943 |
return TRUE; |
return TRUE; |
| 5944 |
} |
} |
| 6063 |
} |
} |
| 6064 |
|
|
| 6065 |
|
|
| 6066 |
BOOL ParseFirstRus(BYTE b) |
static BOOL ParseFirstRus(BYTE b) |
| 6067 |
// returns if b is processed |
// returns if b is processed |
| 6068 |
{ |
{ |
| 6069 |
if (b>=128) { |
if (b>=128) { |
| 6070 |
|
#if !UNICODE_INTERNAL_BUFF |
| 6071 |
b = RussConv(ts.RussHost,ts.RussClient,b); |
b = RussConv(ts.RussHost,ts.RussClient,b); |
| 6072 |
PutChar(b); |
PutChar(b); |
| 6073 |
|
#else |
| 6074 |
|
PutChar(b); |
| 6075 |
|
#endif |
| 6076 |
return TRUE; |
return TRUE; |
| 6077 |
} |
} |
| 6078 |
return FALSE; |
return FALSE; |
| 6167 |
LockBuffer(); |
LockBuffer(); |
| 6168 |
|
|
| 6169 |
while ((c>0) && (ChangeEmu==0)) { |
while ((c>0) && (ChangeEmu==0)) { |
| 6170 |
|
#if UNICODE_DEBUG |
| 6171 |
|
{ |
| 6172 |
|
static DWORD prev_tick; |
| 6173 |
|
DWORD now = GetTickCount(); |
| 6174 |
|
if (prev_tick == 0) prev_tick = now; |
| 6175 |
|
if (now - prev_tick > 1*1000) { |
| 6176 |
|
printf("\n"); |
| 6177 |
|
prev_tick = now; |
| 6178 |
|
} |
| 6179 |
|
printf("%02x(%c) ", b, isprint(b) ? b : '.'); |
| 6180 |
|
} |
| 6181 |
|
#endif |
| 6182 |
if (DebugFlag!=DEBUG_FLAG_NONE) |
if (DebugFlag!=DEBUG_FLAG_NONE) |
| 6183 |
PutDebugChar(b); |
PutDebugChar(b); |
| 6184 |
else { |
else { |