[ttssh2-commit] [10790] 文字出力時、DEC Special Graphics の扱いを整理

アーカイブの一覧に戻る
scmno****@osdn***** scmno****@osdn*****
2023年 7月 2日 (日) 01:01:47 JST


Revision: 10790
          https://osdn.net/projects/ttssh2/scm/svn/commits/10790
Author:   zmatsuo
Date:     2023-07-02 01:01:47 +0900 (Sun, 02 Jul 2023)
Log Message:
-----------
文字出力時、DEC Special Graphics の扱いを整理

- PutU32NoLog() 内
- 無効化していた PutChar() を削除

Modified Paths:
--------------
    trunk/teraterm/teraterm/vtterm.c

-------------- next part --------------
Modified: trunk/teraterm/teraterm/vtterm.c
===================================================================
--- trunk/teraterm/teraterm/vtterm.c	2023-07-01 16:01:39 UTC (rev 10789)
+++ trunk/teraterm/teraterm/vtterm.c	2023-07-01 16:01:47 UTC (rev 10790)
@@ -89,9 +89,10 @@
 #define DecLocatorButtonUp   8
 #define DecLocatorFiltered   16
 
-void RingBell(int type);
-void VisualBell();
-BOOL DecLocatorReport(int Event, int Button);
+static void RingBell(int type);
+static void VisualBell(void);
+static BOOL DecLocatorReport(int Event, int Button);
+static CharSetData *CharSetInitTerm(void);
 
 /* character attribute */
 static TCharAttr CharAttr;
@@ -137,7 +138,6 @@
 static TStatusBuff SBuff1, SBuff2, SBuff3;
 
 static BOOL ESCFlag, JustAfterESC;
-static BOOL Special;
 
 static int Param[NParamMax+1];
 static int SubParam[NParamMax+1][NSParamMax+1];
@@ -274,7 +274,6 @@
 
 	/* Attribute */
 	CharAttr = DefCharAttr;
-	Special = FALSE;
 	BuffSetCurCharAttr(CharAttr);
 
 	/* Various modes */
@@ -359,8 +358,6 @@
 	}
 }
 
-static CharSetData *CharSetInitTerm(void);
-
 void ResetCharSet()
 {
 	if (ts.Language != IdJapanese) {
@@ -738,137 +735,126 @@
  */
 static void PutU32NoLog(unsigned int code)
 {
-	unsigned short cset;
 	int LineEnd;
+	TCharAttr CharAttrTmp;
+	BOOL dec_special = FALSE;
+	int r;
 
-	TCharAttr CharAttrTmp;
 	CharAttrTmp = CharAttr;
 	LastPutCharacter = code;
 
-	{
-		int r;
-		BOOL SpecialNew = FALSE;
+	if (code <= 0xff) {
+		dec_special = CharSetIsSpecial(charset_data, code);
+	}
 
-		if (code <= 0xff) {
-			SpecialNew = CharSetIsSpecial(charset_data, code);
-			if (SpecialNew) {
-				code = code & 0x7F;
-			}
+	// Unicode\x82\xA9\x82\xE7DEC\x93\xC1\x8Eꕶ\x8E\x9A\x82ւ̃}\x83b\x83s\x83\x93\x83O
+	if (dec_special == FALSE && ts.UnicodeDecSpMapping) {
+		unsigned short cset;
+		cset = UTF32ToDecSp(code);
+		if (((cset >> 8) & ts.UnicodeDecSpMapping) != 0) {
+			dec_special = TRUE;
+			code = cset & 0xff;
 		}
+	}
 
-		// Unicode\x82\xA9\x82\xE7DEC\x93\xC1\x8Eꕶ\x8E\x9A\x82ւ̃}\x83b\x83s\x83\x93\x83O
-		if (SpecialNew == FALSE && ts.UnicodeDecSpMapping) {
-			cset = UTF32ToDecSp(code);
-			if (((cset >> 8) & ts.UnicodeDecSpMapping) != 0) {
-				SpecialNew = TRUE;
-				code = cset & 0xff;
-			}
-		}
+	if (dec_special) {
+		CharAttrTmp.Attr |= AttrSpecial;
+	}
+	else {
+		CharAttrTmp.Attr |= CharAttr.Attr;
+	}
 
-		if (SpecialNew != Special) {
-			UpdateStr();
-			Special = SpecialNew;
-		}
+	if (CursorX > CursorRightM)
+		LineEnd = NumOfColumns - 1;
+	else
+		LineEnd = CursorRightM;
 
-		if (Special) {
-			CharAttrTmp.Attr |= AttrSpecial;
-		}
-		else {
-			CharAttrTmp.Attr |= CharAttr.Attr;
-		}
+	// 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
 
-		if (CursorX > CursorRightM)
-			LineEnd = NumOfColumns - 1;
-		else
-			LineEnd = CursorRightM;
+			// \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);
 
-		// 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
+			// \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;
 
-				// \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);
-			}
+			// \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
-		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
+	// \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
+	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)) {
+		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;
+			// 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;
+			// \x8E\x9F\x82̍s\x82̍s\x93\xAA\x82\xD6
+			CarriageReturn(FALSE);
+			LineFeed(LF,FALSE);
 		}
-		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);
+			// \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);
+	}
 }
 
 /**
@@ -897,107 +883,8 @@
 	}
 }
 
-#if 0
 static void PutChar(BYTE b)
 {
-	BOOL SpecialNew;
-	TCharAttr CharAttrTmp;
-
-	CharAttrTmp = CharAttr;
-
-	LastPutCharacter = b;
-
-	if (PrinterMode) { // printer mode
-		WriteToPrnFile(PrintFile_, b,TRUE);
-		return;
-	}
-
-	if (Wrap) {
-		TCharAttr t = BuffGetCursorCharAttr(CursorX, CursorY);
-		t.Attr |= AttrLineContinued;
-		t.AttrEx = t.Attr;
-		BuffSetCursorCharAttr(CursorX, CursorY, t);
-		CarriageReturn(FALSE);
-		LineFeed(LF,FALSE);
-		CharAttrTmp.Attr |= AttrLineContinued;
-		t.AttrEx = t.Attr;
-	}
-
-	if (NeedsOutputBufs()) {
-		// (2005.2.20 yutaka)
-		if (ts.LogTypePlainText) {
-			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 {
-				OutputLogByte(b);
-			}
-		} else {
-			OutputLogByte(b);
-		}
-	}
-
-	Wrap = FALSE;
-
-	SpecialNew = CharSetIsSpecial(b);
-	if (SpecialNew != Special) {
-		UpdateStr();
-		Special = SpecialNew;
-	}
-
-	if (Special) {
-		b = b & 0x7F;
-		CharAttrTmp.Attr |= AttrSpecial;
-	}
-	else
-		CharAttrTmp.Attr |= CharAttr.Attr;
-
-#if 0
-	if (CursorX == CursorRightM || CursorX >= NumOfColumns - 1) {
-		CharAttrTmp.Attr |= AttrLineContinued;
-	}
-#endif
-
-	CharAttrTmp.AttrEx = CharAttrTmp.Attr;
-	if (ts.Language == IdJapanese) {
-		unsigned long u32;
-		switch (ts.KanjiCode) {
-//		case IdJIS:
-//			b = JIS2SJIS(b);
-		case IdSJIS:
-			u32 = MBCP_UTF32(b, 932);
-			BuffPutUnicode(u32, CharAttrTmp, InsertMode);
-			break;
-		case IdUTF8:
-			BuffPutUnicode(b, CharAttrTmp, InsertMode);
-			break;
-		default:
-			BuffPutUnicode(b, CharAttrTmp, InsertMode);
-			break;
-		}
-#if 0
-	} else if (ts.Language == IdRussian) {
-		assert(FALSE);
-		// CP1251\x82ɕϊ\xB7
-		BYTE c = RussConv(ts.KanjiCode, IdWindows, b);
-		// CP1251->Unicode
-		unsigned long u32 = MBCP_UTF32(c, 1251);
-		BuffPutUnicode(u32, CharAttrTmp, InsertMode);
-#endif
-	} else {
-		BuffPutUnicode(b, CharAttrTmp, InsertMode);
-	}
-
-	if (CursorX == CursorRightM || CursorX >= NumOfColumns-1) {
-		UpdateStr();
-		Wrap = AutoWrapMode;
-	}
-	else {
-		MoveRight();
-	}
-}
-#endif
-static void PutChar(BYTE b)
-{
 	PutU32(b);
 }
 
@@ -3294,7 +3181,6 @@
 
 	/* Attribute */
 	CharAttr = DefCharAttr;
-	Special = FALSE;
 	BuffSetCurCharAttr(CharAttr);
 
 	// status buffers
@@ -5475,7 +5361,8 @@
 	}
 }
 
-BOOL DecLocatorReport(int Event, int Button) {
+static BOOL DecLocatorReport(int Event, int Button)
+{
 	int x, y, MaxX, MaxY, len = 0;
 	char buff[24];
 
@@ -5757,13 +5644,15 @@
 	}
 }
 
-void VisualBell() {
+static void VisualBell(void)
+{
 	CSQExchangeColor();
 	Sleep(10);
 	CSQExchangeColor();
 }
 
-void RingBell(int type) {
+static void RingBell(int type)
+{
 	DWORD now;
 
 	now = GetTickCount();


ttssh2-commit メーリングリストの案内
アーカイブの一覧に戻る