Revision: 8822 https://osdn.net/projects/ttssh2/scm/svn/commits/8822 Author: zmatsuo Date: 2020-07-03 00:41:37 +0900 (Fri, 03 Jul 2020) Log Message: ----------- ログが取れなくなっていたので修正 - 文字コードは UTF-8 固定 - 改行コードは CR+LF 固定 Modified Paths: -------------- trunk/teraterm/teraterm/filesys.cpp trunk/teraterm/teraterm/filesys.h trunk/teraterm/teraterm/vtterm.c trunk/teraterm/teraterm/vtterm.h -------------- next part -------------- Modified: trunk/teraterm/teraterm/filesys.cpp =================================================================== --- trunk/teraterm/teraterm/filesys.cpp 2020-07-02 14:56:21 UTC (rev 8821) +++ trunk/teraterm/teraterm/filesys.cpp 2020-07-02 15:41:37 UTC (rev 8822) @@ -1,6 +1,6 @@ /* * Copyright (C) 1994-1998 T. Teranishi - * (C) 2005-2019 TeraTerm Project + * (C) 2005-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -65,7 +65,6 @@ static PCHAR ProtoVar = NULL; static int ProtoId; -static BYTE LogLast = 0; BOOL FileLog = FALSE; BOOL BinLog = FALSE; BOOL DDELog = FALSE; @@ -751,7 +750,6 @@ void LogPut1(BYTE b) { - LogLast = b; cv.LogBuf[cv.LogPtr] = b; cv.LogPtr++; if (cv.LogPtr>=InBuffSize) @@ -791,18 +789,6 @@ } } -void Log1Byte(BYTE b) -{ - if (b==0x0d) - { - LogLast = b; - return; - } - if ((b==0x0a) && (LogLast==0x0d)) - LogPut1(0x0d); - LogPut1(b); -} - static BOOL Get1(PCHAR Buf, int *Start, int *Count, PBYTE b) { if (*Count<=0) return FALSE; Modified: trunk/teraterm/teraterm/filesys.h =================================================================== --- trunk/teraterm/teraterm/filesys.h 2020-07-02 14:56:21 UTC (rev 8821) +++ trunk/teraterm/teraterm/filesys.h 2020-07-02 15:41:37 UTC (rev 8822) @@ -1,6 +1,6 @@ /* * Copyright (C) 1994-1998 T. Teranishi - * (C) 2007-2017 TeraTerm Project + * (C) 2007-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -75,7 +75,7 @@ void FreeFileVar(PFileVar *FV); BOOL LogStart(); -void Log1Byte(BYTE b); +void LogPut1(BYTE b); void LogToFile(); BOOL CreateLogBuf(); void FreeLogBuf(); @@ -108,4 +108,3 @@ #ifdef __cplusplus } #endif - Modified: trunk/teraterm/teraterm/vtterm.c =================================================================== --- trunk/teraterm/teraterm/vtterm.c 2020-07-02 14:56:21 UTC (rev 8821) +++ trunk/teraterm/teraterm/vtterm.c 2020-07-02 15:41:37 UTC (rev 8822) @@ -40,7 +40,6 @@ #endif #include <stdlib.h> #include <crtdbg.h> -#include <tchar.h> #include <assert.h> #include "buffer.h" @@ -109,14 +108,14 @@ static BOOL RectangleMode; static BOOL BracketedPaste; -char BracketStart[] = "\033[200~"; -char BracketEnd[] = "\033[201~"; -int BracketStartLen = (sizeof(BracketStart)-1); -int BracketEndLen = (sizeof(BracketEnd)-1); +static char BracketStart[] = "\033[200~"; +static char BracketEnd[] = "\033[201~"; +static int BracketStartLen = (sizeof(BracketStart)-1); +static int BracketEndLen = (sizeof(BracketEnd)-1); static int VTlevel; -BOOL AcceptWheelToCursor; +static BOOL AcceptWheelToCursor; // save/restore cursor typedef struct { @@ -129,16 +128,16 @@ typedef TStatusBuff *PStatusBuff; // currently only used for AUTO CR/LF receive mode -BYTE PrevCharacter; -BOOL PrevCRorLFGeneratedCRLF; // indicates that previous CR or LF really generated a CR+LF +static BYTE PrevCharacter; +static BOOL PrevCRorLFGeneratedCRLF; // indicates that previous CR or LF really generated a CR+LF -BYTE LastPutCharacter; +static BYTE LastPutCharacter; // status buffer for main screen & status line static TStatusBuff SBuff1, SBuff2, SBuff3; static BOOL ESCFlag, JustAfterESC; -static BOOL KanjiIn; +static BOOL KanjiIn; // TRUE = MBCS\x82\xCC1byte\x96ڂ\xF0\x8E\xF3\x90M\x82\xB5\x82Ă\xA2\x82\xE9 static BOOL EUCkanaIn, EUCsupIn; static int EUCcount; static BOOL Special; @@ -158,7 +157,7 @@ struct tstack *next; } TStack; typedef TStack *PTStack; -PTStack TitleStack = NULL; +static PTStack TitleStack = NULL; /* user defined keys */ static BOOL WaitKeyId, WaitHi; @@ -214,11 +213,14 @@ static _locale_t CLocale = NULL; -#if UNICODE_INTERNAL_BUFF -// \x93\xE0\x95\x94\x83R\x81[\x83h unicode\x94\xC5 -static void UnicodeToCP932(unsigned int code); -#endif +typedef struct { + BOOL log_cr_hold; + int log_code; + int log_cr_type; +} vtterm_work_t; +static vtterm_work_t vtterm_work; + void ClearParams() { ICount = 0; @@ -356,6 +358,13 @@ BeepSuppressTime = BeepStartTime - ts.BeepSuppressTime * 1000; BeepStartTime -= (ts.BeepOverUsedTime * 1000); BeepOverUsedCount = ts.BeepOverUsedCount; + + { + vtterm_work_t *vtterm = &vtterm_work; + vtterm->log_cr_hold = FALSE; + vtterm->log_code = 0; + vtterm->log_cr_type = 0; + } } void ResetCharSet() @@ -442,6 +451,123 @@ MoveCursor(MainX, MainY); // move to main screen } +static void Log1Byte(BYTE b) +{ + LogPut1(b); +} + +static void Log1UTF32(vtterm_work_t *vtterm, unsigned int u32) +{ + switch(vtterm->log_code) { + default: + case 0: { + // UTF-8 + char u8[4]; + size_t u8_len = UTF32ToUTF8(u32, u8, _countof(u8)); + size_t i; + for (i = 0; i < u8_len; i++) { + Log1Byte(u8[i]); + } + break; + } + case 1: + case 2: { + // UTF-16 + wchar_t u16[2]; + size_t u16_len = UTF32ToUTF16(u32, u16, _countof(u16)); + size_t i; + for (i = 0; i < u16_len; i++) { + if (vtterm->log_code == 1) { + // UTF-16LE + Log1Byte(u16[i] & 0xff); + Log1Byte((u16[i] >> 8) & 0xff); + } + else { + // UTF-16BE + Log1Byte(u16[i] & 0xff); + Log1Byte((u16[i] >> 8) & 0xff); + } + } + } + } +} + +static void Log1NewLine(vtterm_work_t *vtterm) +{ + switch(vtterm->log_cr_type) { + case 0: + // CR + LF + Log1UTF32(vtterm, CR); + Log1UTF32(vtterm, LF); + break; + case 1: + // CR + Log1UTF32(vtterm, CR); + break; + case 2: + // LF + Log1UTF32(vtterm, LF); + break; + } +} + +static void OutputLogUTF32(unsigned int u32) +{ + vtterm_work_t *vtterm = &vtterm_work; + + if (cv.HLogBuf == 0) { + // \x83\x8D\x83O\x82͎\xE6\x82\xC1\x82Ă\xA2\x82Ȃ\xA2, \x89\xBD\x82\xE0\x82\xB5\x82Ȃ\xA2 + return; + } + + // \x89\xFC\x8Ds\x83R\x81[\x83h\x82\xF0\x83`\x83F\x83b\x83N + // CR hold \x93\xFC\x97\xCD \x89\xFC\x8Ds\x8Fo\x97\xCD CR hold \x95ύX + // ------------+-------+-----------+------------ + // \x82Ȃ\xB5 CR 0 \x83Z\x83b\x83g\x82\xB7\x82\xE9 + // \x82Ȃ\xB5 LF 1 \x95ω\xBB\x82Ȃ\xB5 + // \x82Ȃ\xB5 \x82\xBB\x82̑\xBC 0 \x95ω\xBB\x82Ȃ\xB5 + // \x82\xA0\x82\xE8 CR 1 \x95ω\xBB\x82Ȃ\xB5(\x83z\x81[\x83\x8B\x83h\x82\xB5\x82\xBD\x82܂\xDC) + // \x82\xA0\x82\xE8 LF 1 \x83N\x83\x8A\x83A\x82\xB7\x82\xE9 + // \x82\xA0\x82\xE8 \x82\xBB\x82̑\xBC 1 \x83N\x83\x8A\x83A\x82\xB7\x82\xE9 + if (vtterm->log_cr_hold == FALSE) { + if (u32 == CR) { + vtterm->log_cr_hold = TRUE; + return; + } + else if (u32 == LF) { + Log1NewLine(vtterm); + return; + } + else { + // \x89\xFC\x8Ds\x93\xC1\x82ɂȂ\xB5 + } + } + else { + if (u32 == CR) { + Log1NewLine(vtterm); + return; + } + else if (u32 == LF) { + vtterm->log_cr_hold = FALSE; + Log1NewLine(vtterm); + return; + } + else { + vtterm->log_cr_hold = FALSE; + Log1NewLine(vtterm); + } + } + + Log1UTF32(vtterm, u32); +} + +static void OutputLogByte(BYTE b) +{ + if (cv.HLogBuf!=0) { + OutputLogUTF32(b); + } +} + void MoveToStatusLine() { MainX = CursorX; @@ -561,12 +687,12 @@ if (CursorX == CursorLeftM || CursorX == 0) { if (CursorY > 0 && (ts.TermFlag & TF_BACKWRAP)) { MoveCursor(CursorRightM, CursorY-1); - if (cv.HLogBuf!=0 && !ts.LogTypePlainText) Log1Byte(BS); + if (cv.HLogBuf!=0 && !ts.LogTypePlainText) OutputLogByte(BS); } } else if (CursorX > 0) { MoveCursor(CursorX-1, CursorY); - if (cv.HLogBuf!=0 && !ts.LogTypePlainText) Log1Byte(BS); + if (cv.HLogBuf!=0 && !ts.LogTypePlainText) OutputLogByte(BS); } } @@ -573,7 +699,7 @@ static void CarriageReturn(BOOL logFlag) { if (!ts.EnableContinuedLineCopy || logFlag) - if (cv.HLogBuf!=0) Log1Byte(CR); + if (cv.HLogBuf!=0) OutputLogByte(CR); if (RelativeOrgMode || CursorX > CursorLeftM) MoveCursor(CursorLeftM, CursorY); @@ -591,7 +717,7 @@ BuffDumpCurrentLine(b); if (!ts.EnableContinuedLineCopy || logFlag) - if (cv.HLogBuf!=0) Log1Byte(LF); + if (cv.HLogBuf!=0) OutputLogByte(LF); if (CursorY < CursorBottom) MoveCursor(CursorX,CursorY+1); @@ -617,7 +743,7 @@ Wrap = FALSE; } CursorForwardTab(1, AutoWrapMode); - if (cv.HLogBuf!=0) Log1Byte(HT); + if (cv.HLogBuf!=0) OutputLogByte(HT); } void RepeatChar(BYTE b, int count) @@ -681,7 +807,7 @@ } } -void PutChar(BYTE b) +static void PutChar(BYTE b) { BOOL SpecialNew; TCharAttr CharAttrTmp; @@ -718,10 +844,10 @@ if (__isascii(b) && !isprint(b)) { // ASCII\x95\xB6\x8E\x9A\x82ŁA\x94\xF1\x95\\x8E\xA6\x82ȕ\xB6\x8E\x9A\x82̓\x8D\x83O\x8D̎悵\x82Ȃ\xA2\x81B } else { - Log1Byte(b); + OutputLogByte(b); } } else { - Log1Byte(b); + OutputLogByte(b); } } @@ -814,12 +940,12 @@ CharAttrTmp.Attr |= ts.EnableContinuedLineCopy ? AttrLineContinued : 0; } - if (cv.HLogBuf!=0) Log1Byte(b); + if (cv.HLogBuf!=0) OutputLogByte(b); /* if (ts.LogTypePlainText && __isascii(b) && !isprint(b)) { // ASCII\x95\xB6\x8E\x9A\x82ŁA\x94\xF1\x95\\x8E\xA6\x82ȕ\xB6\x8E\x9A\x82̓\x8D\x83O\x8D̎悵\x82Ȃ\xA2\x81B } else { - if (cv.HLogBuf!=0) Log1Byte(b); + if (cv.HLogBuf!=0) OutputLogByte(b); } */ @@ -845,6 +971,9 @@ } } +/** + * mbcs\x82\xF0\x8Fo\x97\xCD + */ static void PutKanji(BYTE b) { int LineEnd; @@ -907,8 +1036,8 @@ Wrap = FALSE; if (cv.HLogBuf!=0) { - Log1Byte(HIBYTE(Kanji)); - Log1Byte(LOBYTE(Kanji)); + OutputLogByte(HIBYTE(Kanji)); + OutputLogByte(LOBYTE(Kanji)); } if (Special) { @@ -4960,7 +5089,7 @@ } } -void XsProcClipboard(PCHAR buff) +static void XsProcClipboard(PCHAR buff) { int len, blen; char *p, *cbbuff, hdr[20], notify_buff[256], notify_title[MAX_UIMSG]; @@ -5118,7 +5247,7 @@ } } -void XSequence(BYTE b) +static void XSequence(BYTE b) { static char *StrBuff = NULL; static unsigned int StrLen = 0, StrBuffSize = 0; @@ -5408,6 +5537,156 @@ } /** + * unicode(UTF-32,wchar_t)\x82\xF0\x83o\x83b\x83t\x83@\x82֏\x91\x82\xAB\x8D\x9E\x82\xDE + * \x83\x8D\x83O\x82ɂ\xE0\x8F\x91\x82\xAB\x8D\x9E\x82\xDE + * + * \x8C\xB3\x82\xCD UnicodeToCP932() \x82\xBE\x82\xC1\x82\xBD + * + * PutChar() \x82\xCC UTF-32\x94\xC5 + */ +static void PutU32(unsigned int code) +{ + unsigned short cset; + int LineEnd; + + TCharAttr CharAttrTmp; + CharAttrTmp = CharAttr; + if (code <= US) { + // U+0000 .. U+001f + // C0\x90\xA7\x8C䕶\x8E\x9A, C0 Coontrols + ParseControl(code); + return; + } else if ((0x80<=code) && (code<=0x9F)) { + // U+0080 .. u+009f + // C1\x90\xA7\x8C䕶\x8E\x9A, C1 Controls + ParseControl(code); + return; + } + + { + int r; + BOOL is_update; + + // Unicode\x82\xA9\x82\xE7DEC\x93\xC1\x8Eꕶ\x8E\x9A\x82ւ̃}\x83b\x83s\x83\x93\x83O + if (ts.UnicodeDecSpMapping) { + cset = UTF32ToDecSp(code); + if (((cset >> 8) & ts.UnicodeDecSpMapping) != 0) { + code = cset & 0xff; + CharAttrTmp.Attr |= AttrSpecial; + } + } + + if ((CharAttrTmp.Attr & AttrSpecial) == 0) { + if (Special) { + UpdateStr(); + Special = FALSE; + } + } else { + if (!Special) { + UpdateStr(); + Special = TRUE; + } + } + + if (CursorX > CursorRightM) + LineEnd = NumOfColumns - 1; + else + LineEnd = CursorRightM; + + // Wrap\x8F\x88\x97\x9D\x81A\x83J\x81[\x83\\x83\x8B\x88ړ\xAE + if (Wrap) { + // \x8C\xBB\x8D\xDD Wrap \x8F\xF3\x91\xD4 + if (!BuffIsCombiningCharacter(CursorX, CursorY, code)) { + // \x95\xB6\x8E\x9A\x83R\x81[\x83h\x82\xAA\x8C\x8B\x8D\x87\x95\xB6\x8E\x9A\x82ł͂Ȃ\xA2 = \x83J\x81[\x83\\x83\x8B\x82\xAA\x88ړ\xAE\x82\xB7\x82\xE9 + + // \x83J\x81[\x83\\x83\x8B\x88ʒu\x82ɍs\x8Cp\x91\xB1\x83A\x83g\x83\x8A\x83r\x83\x85\x81[\x83g\x82\xF0\x92lj\xC1 + TCharAttr t = BuffGetCursorCharAttr(CursorX, CursorY); + t.Attr |= AttrLineContinued; + t.AttrEx = t.Attr; + BuffSetCursorCharAttr(CursorX, CursorY, t); + + // \x8Ds\x8Cp\x91\xB1\x83A\x83g\x83\x8A\x83r\x83\x85\x81[\x83g\x82\xF0\x82\xAF\x82\xE9 + CharAttrTmp.Attr |= AttrLineContinued; + CharAttrTmp.AttrEx = CharAttrTmp.Attr; + + // \x8E\x9F\x82̍s\x82̍s\x93\xAA\x82\xD6 + CarriageReturn(FALSE); + LineFeed(LF,FALSE); + } + } + + // \x83o\x83b\x83t\x83@\x82ɕ\xB6\x8E\x9A\x82\xF0\x93\xFC\x82\xEA\x82\xE9 + // BuffPutUnicode()\x82\xB5\x82\xBD\x96߂\xE8\x92l\x82ŕ\xB6\x8E\x9A\x82̃Z\x83\x8B\x90\x94\x82\xF0\x92m\x82邱\x82Ƃ\xAA\x82ł\xAB\x82\xE9 + // \x83G\x83\x89\x81[\x8E\x9E\x82̓J\x81[\x83\\x83\x8B\x88ʒu\x82\xF0\x8C\x9F\x93\xA2\x82\xB7\x82\xE9 + is_update = FALSE; + CharAttrTmp.AttrEx = CharAttrTmp.Attr; + retry: + r = BuffPutUnicode(code, CharAttrTmp, InsertMode); + if (r == -1) { + // \x95\xB6\x8E\x9A\x91S\x8Ap\x82ōs\x96\x96\x81A\x93\xFC\x97͂ł\xAB\x82Ȃ\xA2 + + if (AutoWrapMode) { + // \x8E\xA9\x93\xAE\x89\xFC\x8Ds + // \x81Awrap\x8F\x88\x97\x9D + CharAttrTmp = CharAttr; + CharAttrTmp.Attr |= AttrLineContinued; + CharAttrTmp.AttrEx = CharAttrTmp.Attr | AttrPadding; + // AutoWrapMode + // ts.EnableContinuedLineCopy + //if (CursorX != LineEnd){ + //&& BuffIsHalfWidthFromCode(&ts, code)) { + + // full width\x8Fo\x97͂\xAA\x94\xBC\x95\xAA\x8Fo\x97͂ɂȂ\xE7\x82Ȃ\xA2\x82悤\x82\xC90x20\x82\xF0\x8Fo\x97\xCD + BuffPutUnicode(0x20, CharAttrTmp, FALSE); + CharAttrTmp.AttrEx = CharAttrTmp.AttrEx & ~AttrPadding; + + // \x8E\x9F\x82̍s\x82̍s\x93\xAA\x82\xD6 + CarriageReturn(FALSE); + LineFeed(LF,FALSE); + } + else { + // \x8Ds\x93\xAA\x82ɖ߂\xB7 + CursorX = 0; + } + + //CharAttrTmp.Attr &= ~AttrLineContinued; + goto retry; + } + else if (r == 0) { + // \x83J\x81[\x83\\x83\x8B\x82̈ړ\xAE\x82Ȃ\xB5,\x8C\x8B\x8D\x87\x95\xB6\x8E\x9A,\x8D\x87\x8E\x9A\x82Ȃ\xC7 + // Wrap \x82͕ω\xBB\x82\xB5\x82Ȃ\xA2 + UpdateStr(); // \x81u\x82فv->\x81u\x82ہv\x82ȂǁA\x95ω\xBB\x82\xB7\x82邱\x82Ƃ\xAA\x82\xA0\x82\xE9\x82̂ŕ`\x89悷\x82\xE9 + } else if (r == 1) { + // \x94\xBC\x8Ap(1\x83Z\x83\x8B) + if (CursorX + 0 == CursorRightM || CursorX >= NumOfColumns - 1) { + UpdateStr(); + Wrap = AutoWrapMode; + } else { + MoveRight(); + Wrap = FALSE; + } + } else if (r == 2) { + // \x91S\x8Ap(2\x83Z\x83\x8B) + if (CursorX + 1 == CursorRightM || CursorX + 1 >= NumOfColumns - 1) { + MoveRight(); // \x91S\x8Ap\x82̉E\x91\xA4\x82ɃJ\x81[\x83\\x83\x8B\x88ړ\xAE + UpdateStr(); + Wrap = AutoWrapMode; + } else { + MoveRight(); + MoveRight(); + Wrap = FALSE; + } + } + else { + assert(FALSE); + } + } + + // \x83\x8D\x83O\x82\xF0\x8Fo\x97\xCD + OutputLogUTF32(code); +} + +/** * IsDBCSLeadByteEx() \x82Ƃقړ\xAF\x82\xB6 * ismbblead() \x82̊g\x92\xA3 */ @@ -5613,7 +5892,7 @@ { // b\x82\xCDsjis\x82̔\xBC\x8Ap\x83J\x83^\x83J\x83i unsigned long u32 = CP932ToUTF32(b); - UnicodeToCP932(u32); + PutU32(u32); } return TRUE; #endif @@ -5679,7 +5958,7 @@ #if UNICODE_INTERNAL_BUFF // b\x82\xCDsjis\x82̔\xBC\x8Ap\x83J\x83^\x83J\x83i unsigned long u32 = CP932ToUTF32(b); - UnicodeToCP932(u32); + PutU32(u32); #else PutChar(b); // katakana #endif @@ -5856,216 +6135,6 @@ } } -// unicode(UTF-32,wchar_t)\x82\xF0\x83o\x83b\x83t\x83@\x82֏\x91\x82\xAB\x8D\x9E\x82\xDE -// TODO @@ -#if UNICODE_INTERNAL_BUFF -// \x93\xE0\x95\x94\x83R\x81[\x83h unicode\x94\xC5 -static void UnicodeToCP932(unsigned int code) -{ - unsigned short cset; - int LineEnd; - - TCharAttr CharAttrTmp; - CharAttrTmp = CharAttr; - if (code <= US) { - // C0 - ParseControl(code); -#if 0 - } else if ((0x80<=code) && (code<=0x9F)) { - // C1 - ParseControl(code); - } else if (code < 0x20) { - PutChar(code); -#endif -#if 0 - } else if (code <= 0xff) { - PutChar(code); -#endif - } else { - int r; - BOOL is_update; - - // Unicode\x82\xA9\x82\xE7DEC\x93\xC1\x8Eꕶ\x8E\x9A\x82ւ̃}\x83b\x83s\x83\x93\x83O - if (ts.UnicodeDecSpMapping) { - cset = UTF32ToDecSp(code); - if (((cset >> 8) & ts.UnicodeDecSpMapping) != 0) { - code = cset & 0xff; - CharAttrTmp.Attr |= AttrSpecial; - } - } - - if ((CharAttrTmp.Attr & AttrSpecial) == 0) { - if (Special) { - UpdateStr(); - Special = FALSE; - } - } else { - if (!Special) { - UpdateStr(); - Special = TRUE; - } - } - - if (CursorX > CursorRightM) - LineEnd = NumOfColumns - 1; - else - LineEnd = CursorRightM; - - // Wrap\x8F\x88\x97\x9D\x81A\x83J\x81[\x83\\x83\x8B\x88ړ\xAE - if (Wrap) { - // \x8C\xBB\x8D\xDD Wrap \x8F\xF3\x91\xD4 - if (!BuffIsCombiningCharacter(CursorX, CursorY, code)) { - // \x95\xB6\x8E\x9A\x83R\x81[\x83h\x82\xAA\x8C\x8B\x8D\x87\x95\xB6\x8E\x9A\x82ł͂Ȃ\xA2 = \x83J\x81[\x83\\x83\x8B\x82\xAA\x88ړ\xAE\x82\xB7\x82\xE9 - - // \x83J\x81[\x83\\x83\x8B\x88ʒu\x82ɍs\x8Cp\x91\xB1\x83A\x83g\x83\x8A\x83r\x83\x85\x81[\x83g\x82\xF0\x92lj\xC1 - TCharAttr t = BuffGetCursorCharAttr(CursorX, CursorY); - t.Attr |= AttrLineContinued; - t.AttrEx = t.Attr; - BuffSetCursorCharAttr(CursorX, CursorY, t); - - // \x8Ds\x8Cp\x91\xB1\x83A\x83g\x83\x8A\x83r\x83\x85\x81[\x83g\x82\xF0\x82\xAF\x82\xE9 - CharAttrTmp.Attr |= AttrLineContinued; - CharAttrTmp.AttrEx = CharAttrTmp.Attr; - - // \x8E\x9F\x82̍s\x82̍s\x93\xAA\x82\xD6 - CarriageReturn(FALSE); - LineFeed(LF,FALSE); - } - } - - // \x83o\x83b\x83t\x83@\x82ɕ\xB6\x8E\x9A\x82\xF0\x93\xFC\x82\xEA\x82\xE9 - // BuffPutUnicode()\x82\xB5\x82\xBD\x96߂\xE8\x92l\x82ŕ\xB6\x8E\x9A\x82̃Z\x83\x8B\x90\x94\x82\xF0\x92m\x82邱\x82Ƃ\xAA\x82ł\xAB\x82\xE9 - // \x83G\x83\x89\x81[\x8E\x9E\x82̓J\x81[\x83\\x83\x8B\x88ʒu\x82\xF0\x8C\x9F\x93\xA2\x82\xB7\x82\xE9 - is_update = FALSE; - CharAttrTmp.AttrEx = CharAttrTmp.Attr; - retry: - r = BuffPutUnicode(code, CharAttrTmp, InsertMode); - if (r == -1) { - // \x95\xB6\x8E\x9A\x91S\x8Ap\x82ōs\x96\x96\x81A\x93\xFC\x97͂ł\xAB\x82Ȃ\xA2 - - if (AutoWrapMode) { - // \x8E\xA9\x93\xAE\x89\xFC\x8Ds - // \x81Awrap\x8F\x88\x97\x9D - CharAttrTmp = CharAttr; - CharAttrTmp.Attr |= AttrLineContinued; - CharAttrTmp.AttrEx = CharAttrTmp.Attr | AttrPadding; - // AutoWrapMode - // ts.EnableContinuedLineCopy - //if (CursorX != LineEnd){ - //&& BuffIsHalfWidthFromCode(&ts, code)) { - - // full width\x8Fo\x97͂\xAA\x94\xBC\x95\xAA\x8Fo\x97͂ɂȂ\xE7\x82Ȃ\xA2\x82悤\x82\xC90x20\x82\xF0\x8Fo\x97\xCD - BuffPutUnicode(0x20, CharAttrTmp, FALSE); - CharAttrTmp.AttrEx = CharAttrTmp.AttrEx & ~AttrPadding; - - // \x8E\x9F\x82̍s\x82̍s\x93\xAA\x82\xD6 - CarriageReturn(FALSE); - LineFeed(LF,FALSE); - } - else { - // \x8Ds\x93\xAA\x82ɖ߂\xB7 - CursorX = 0; - } - - //CharAttrTmp.Attr &= ~AttrLineContinued; - goto retry; - } - else if (r == 0) { - // \x83J\x81[\x83\\x83\x8B\x82̈ړ\xAE\x82Ȃ\xB5,\x8C\x8B\x8D\x87\x95\xB6\x8E\x9A,\x8D\x87\x8E\x9A\x82Ȃ\xC7 - // Wrap \x82͕ω\xBB\x82\xB5\x82Ȃ\xA2 - UpdateStr(); // \x81u\x82فv->\x81u\x82ہv\x82ȂǁA\x95ω\xBB\x82\xB7\x82邱\x82Ƃ\xAA\x82\xA0\x82\xE9\x82̂ŕ`\x89悷\x82\xE9 - } else if (r == 1) { - // \x94\xBC\x8Ap(1\x83Z\x83\x8B) - if (CursorX + 0 == CursorRightM || CursorX >= NumOfColumns - 1) { - UpdateStr(); - Wrap = AutoWrapMode; - } else { - MoveRight(); - Wrap = FALSE; - } - } else if (r == 2) { - // \x91S\x8Ap(2\x83Z\x83\x8B) - if (CursorX + 1 == CursorRightM || CursorX + 1 >= NumOfColumns - 1) { - MoveRight(); // \x91S\x8Ap\x82̉E\x91\xA4\x82ɃJ\x81[\x83\\x83\x8B\x88ړ\xAE - UpdateStr(); - Wrap = AutoWrapMode; - } else { - MoveRight(); - MoveRight(); - Wrap = FALSE; - } - } - else { - assert(FALSE); - } - } -} - -#else - -// unicode(UTF-32)\x82\xF0\x83o\x83b\x83t\x83@(t.CodePage)\x82֏\x91\x82\xAB\x8D\x9E\x82\xDE -static void UnicodeToCP932(unsigned int code) -{ - size_t mblen; - char mbchar[2]; - - // Unicode\x82\xA9\x82\xE7DEC\x93\xC1\x8Eꕶ\x8E\x9A\x82ւ̃}\x83b\x83s\x83\x93\x83O - if (ts.UnicodeDecSpMapping) { - unsigned short cset; - cset = UTF32ToDecSp(code); - if (((cset >> 8) & ts.UnicodeDecSpMapping) != 0) { - PutDecSp(cset & 0xff); - return; - } - } - - // Unicode -> \x93\xE0\x95\x94\x83R\x81[\x83h(ts.CodePage)\x82֕ϊ\xB7\x82\xB5\x82ďo\x97\xCD - mblen = UTF32ToMBCP(code, ts.CodePage, mbchar, 2); -#if 1 // U+203e OVERLINE \x93\xC1\x95ʏ\x88\x97\x9D - if (code == 0x203e && ts.CodePage == 932) { - // U+203e\x82\xCD0x7e'~'\x82ɕϊ\xB7\x82\xB3\x82\xEA\x82\xE9 - // \x96\xB3\x97\x9D\x82\xE2\x82芿\x8E\x9A\x8Fo\x97͂\xB7\x82\xE9 - mbchar[0] = 0; // \x82\xB1\x82\xCC0\x82̂\xBD\x82߁A\x83N\x83\x8A\x83b\x83v\x83{\x81[\x83h\x82ɕ\xB6\x8E\x9A\x97\xA4\x82܂\xAD\x93\xFC\x82\xE7\x82Ȃ\xA2 - mbchar[1] = 0x7e; - mblen = 2; - } -#endif - switch (mblen) { - case 0: - PutChar('?'); - if (ts.UnknownUnicodeCharaAsWide) { - PutChar('?'); - } - break; - case 1: - PutChar(mbchar[0]); - break; - case 2: - default: - Kanji = mbchar[0] << 8; - PutKanji(mbchar[1]); - break; - } -} - -#endif - -// UTF-8\x82Ŏ\xF3\x90M\x83f\x81[\x83^\x82\xF0\x8F\x88\x97\x9D\x82\xB7\x82\xE9(sub) -#if UNICODE_INTERNAL_BUFF -static BOOL ParseFirstUTF8Sub(BYTE b) -{ - if (b<=US) - ParseControl(b); - else if ((b>=0x20) && (b<=0x7E)) - PutChar(b); - else if ((b>=0x80) && (b<=0x9F)) - ParseControl(b); - else if (b>=0xA0) - PutChar(b); - return TRUE; -} -#endif - // UTF-8\x82Ŏ\xF3\x90M\x83f\x81[\x83^\x82\xF0\x8F\x88\x97\x9D\x82\xB7\x82\xE9 // returns TRUE if b is processed // (actually allways returns TRUE) @@ -6089,24 +6158,14 @@ // 1\x83o\x83C\x83g\x96ڂ\xAAC1\x90\xA7\x8C䕶\x8E\x9A(0x80-0x9f)\x82̏ꍇ\x82\xE0\x93\xAF\x97l\x81B if (count == 0 || count == 1) { if (proc_combining == 1 && can_combining == 1) { - UnicodeToCP932(first_code); + PutU32(first_code); can_combining = 0; } if (count == 1) { -//#if UNICODE_INTERNAL_BUFF -#if 0 - ParseFirstUTF8Sub(buf[0]); -#else ParseASCII(buf[0]); -#endif } -//#if UNICODE_INTERNAL_BUFF -#if 0 - ParseFirstUTF8Sub(b); -#else ParseASCII(b); -#endif count = 0; // reset counter return TRUE; } @@ -6122,7 +6181,7 @@ if ((buf[1] & 0xc0) == 0x80) { if (proc_combining == 1 && can_combining == 1) { - UnicodeToCP932(first_code); + PutU32(first_code); can_combining = 0; } @@ -6129,7 +6188,7 @@ code = ((buf[0] & 0x1f) << 6); code |= ((buf[1] & 0x3f)); - UnicodeToCP932(code); + PutU32(code); } else { ParseASCII(buf[0]); @@ -6176,7 +6235,7 @@ first_code_index = UnicodeGetIndexOfCombiningFirstCode(code); if (first_code_index != -1) { // 1\x82߂̕\xB6\x8E\x9A\x82͂\xBB\x82̂܂o\x97͂\xB7\x82\xE9 - UnicodeToCP932(first_code); + PutU32(first_code); can_combining = 1; first_code = code; @@ -6184,8 +6243,8 @@ return (TRUE); } - UnicodeToCP932(first_code); - UnicodeToCP932(code); + PutU32(first_code); + PutU32(code); count = 0; return (TRUE); } @@ -6192,7 +6251,7 @@ } } - UnicodeToCP932(code); + PutU32(code); skip: count = 0; @@ -6213,7 +6272,7 @@ code |= ((buf[2] & 0x3f) << 6); code |= (buf[3] & 0x3f); - UnicodeToCP932(code); + PutU32(code); count = 0; return TRUE; } else { Modified: trunk/teraterm/teraterm/vtterm.h =================================================================== --- trunk/teraterm/teraterm/vtterm.h 2020-07-02 14:56:21 UTC (rev 8821) +++ trunk/teraterm/teraterm/vtterm.h 2020-07-02 15:41:37 UTC (rev 8822) @@ -54,7 +54,3 @@ } #endif -extern int BracketStartLen; -extern int BracketEndLen; -extern char BracketStart[]; -extern char BracketEnd[];