[Ttssh2-commit] [8329] REP 制御シーケンスに対応した。

scmno****@osdn***** scmno****@osdn*****
2019年 10月 24日 (木) 19:41:22 JST


Revision: 8329
          https://osdn.net/projects/ttssh2/scm/svn/commits/8329
Author:   doda
Date:     2019-10-24 19:41:21 +0900 (Thu, 24 Oct 2019)
Log Message:
-----------
REP 制御シーケンスに対応した。

Ticket: #39451

問題:
  REP 制御シーケンスに対応していない。
  ncurses-6.1 付属の terminfo の xterm エントリでは rep が定義されて
  いる為、これを参照および使用するプログラムの表示が正しく行われない
  可能性がある。

対処:
  REP 制御シーケンスに対応した。

備考:
  ・セキュリティ的な観点から、繰り返しの最大回数を一画面分(高さx幅)に
    制限している。
  ・制御文字(タブや改行を含む)の繰り返しには対応していない。
  ・現状では複数バイトになる文字(MBCSやUTF-8で2バイト以上になる文字)
    には対応していない。将来的に対応するかは要検討。

Ticket Links:
------------
    https://osdn.net/projects/ttssh2/tracker/detail/39451

Modified Paths:
--------------
    trunk/doc/en/html/about/ctrlseq.html
    trunk/doc/en/html/about/history.html
    trunk/doc/ja/html/about/ctrlseq.html
    trunk/doc/ja/html/about/history.html
    trunk/teraterm/teraterm/vtterm.c

-------------- next part --------------
Modified: trunk/doc/en/html/about/ctrlseq.html
===================================================================
--- trunk/doc/en/html/about/ctrlseq.html	2019-10-23 14:58:10 UTC (rev 8328)
+++ trunk/doc/en/html/about/ctrlseq.html	2019-10-24 10:41:21 UTC (rev 8329)
@@ -169,6 +169,7 @@
 <tr><td>CSI <i>Ps</i> Z</td>	<td>CBT</td>	<td> Moves cursor to the <i>Ps</i> tabs backward. The default value of <i>Ps</i> is 1. </td></tr>
 <tr><td>CSI <i>Ps</i> `</td>	<td>HPA</td>	<td> Moves cursor to the <i>Ps</i>-th column of the active line. The default value of <i>Ps</i> is 1. </td></tr>
 <tr><td>CSI <i>Ps</i> a</td>	<td>HPR</td>	<td> Moves cursor to the right <i>Ps</i> columns. The default value of <i>Ps</i> is 1. </td></tr>
+<tr><td>CSI <i>Ps</i> b</td>	<td>REP</td>	<td> Repeat the last output character <i>Ps</i> times. The default value of <i>Ps</i> is 1. </td></tr>
 <tr><td>CSI <i>Ps</i> c</td>	<td>DA</td>	<td> Primary Device Attribute. The default value of <i>Ps</i> is 0.
 <pre>
 <i>Ps</i> = 0    Asks for the terminal's architectural class and basic attributes.

Modified: trunk/doc/en/html/about/history.html
===================================================================
--- trunk/doc/en/html/about/history.html	2019-10-23 14:58:10 UTC (rev 8328)
+++ trunk/doc/en/html/about/history.html	2019-10-24 10:41:21 UTC (rev 8329)
@@ -42,7 +42,8 @@
       <li>Added slider for specify the opacity values on the Visual tab of the <a href="../menu/setup-additional.html">Additional settings dialog</a>. When transparency is not available, made opacity not changeable.</li>
       <li>Eterm look-feel: Added the <a href="../menu/setup-additional.html#MixedThemeFile">Mixed ThemeFile to Background</a> configuration. Also, added the the <a href="../setup/teraterm-ini.html#BGIgnoreThemeFile">BGIgnoreThemeFile</a> entry in the teraterm.ini file. The default value is off.</li>
       <li>When the opacity values of the <a href="../menu/setup-additional.html">Additional settings dialog</a> is input over than 255, the value is automatically changed to 255 over the dialog.</li>
-      
+      <li>Added support for REP control sequence.</li>
+
       <li>Serial port connection
         <ul>
           <li>Added support for hardware flow control DSR/DTR with serial connection.
@@ -59,7 +60,6 @@
           <li>Added <a href="../commandline/teraterm.html#cdatabit">/CDATABIT=</a>,  <a href="../commandline/teraterm.html#cparity">/CPARITY=</a>, <a href="../commandline/teraterm.html#cstopbit">/CSTOPBIT=</a>, <a href="../commandline/teraterm.html#cflowctrl">/CFLOWCTRL=</a>, <a href="../commandline/teraterm.html#cdelayperchar">/CDELAYPERCHAR=</a>, <a href="../commandline/teraterm.html#cdelayperline">/CDELAYPERLINE=</a> command line options.</li>
         </ul>
       </li>
-      
     </ul>
   </li>
 

Modified: trunk/doc/ja/html/about/ctrlseq.html
===================================================================
--- trunk/doc/ja/html/about/ctrlseq.html	2019-10-23 14:58:10 UTC (rev 8328)
+++ trunk/doc/ja/html/about/ctrlseq.html	2019-10-24 10:41:21 UTC (rev 8329)
@@ -162,6 +162,7 @@
 <tr><td>CSI <i>Ps</i> Z</td>	<td>CBT</td>	<td>\x83J\x81[\x83\\x83\x8B\x82\xF0 <i>Ps</i> \x8C‘O\x82̃^\x83u\x83X\x83g\x83b\x83v\x82Ɉړ\xAE\x82\xB7\x82\xE9\x81B<i>Ps</i> \x82̏ȗ\xAA\x8E\x9E\x82̒l\x82\xCD 1\x81B</td></tr>
 <tr><td>CSI <i>Ps</i> `</td>	<td>HPA</td>	<td>\x83J\x81[\x83\\x83\x8B\x82\xF0\x8C\xBB\x8D݂̍s\x82\xCC <i>Ps</i> \x8C\x85\x96ڂɈړ\xAE\x82\xB7\x82\xE9\x81B<i>Ps</i> \x82̏ȗ\xAA\x8E\x9E\x82̒l\x82\xCD 1\x81B</td></tr>
 <tr><td>CSI <i>Ps</i> a</td>	<td>HPR</td>	<td>\x83J\x81[\x83\\x83\x8B\x82\xF0 <i>Ps</i> \x8C\x85\x89E\x82Ɉړ\xAE\x82\xB7\x82\xE9\x81B<i>Ps</i> \x82̏ȗ\xAA\x8E\x9E\x82̒l\x82\xCD 1\x81B</td></tr>
+<tr><td>CSI <i>Ps</i> b</td>	<td>REP</td>	<td>\x8DŌ\xE3\x82ɏo\x97͂\xB5\x82\xBD\x95\xB6\x8E\x9A\x82\xF0 <i>Ps</i> \x89\xF1\x8CJ\x82\xE8\x95Ԃ\xB7\x81B<i>Ps</i> \x82̏ȗ\xAA\x8E\x9E\x82̒l\x82\xCD 1\x81B</td></tr>
 <tr><td>CSI <i>Ps</i> c</td>	<td>DA</td>	<td>\x92[\x96\x96\x93\xC1\x90\xAB\x95񍐁B\x8Fȗ\xAA\x8E\x9E\x82\xCC <i>Ps</i> \x82̒l\x82\xCD 0\x81B
 <pre>
 <i>Ps</i> = 0    \x92[\x96\x96\x93\xC1\x90\xAB\x82\xF0\x97v\x8B\x81\x82\xB7\x82\xE9\x81B

Modified: trunk/doc/ja/html/about/history.html
===================================================================
--- trunk/doc/ja/html/about/history.html	2019-10-23 14:58:10 UTC (rev 8328)
+++ trunk/doc/ja/html/about/history.html	2019-10-24 10:41:21 UTC (rev 8329)
@@ -42,7 +42,8 @@
       <li>\x83\x8A\x83T\x83C\x83Y\x92\x86\x82̏c\x89\xA1\x83T\x83C\x83Y\x83c\x81[\x83\x8B\x83`\x83b\x83v\x82̕\\x8E\xA6\x88ʒu\x82\xF0\x83\x8A\x83T\x83C\x83Y\x8C\xE3\x82̍\xC0\x95W\x82ɒǏ]\x82\xB7\x82\xE9\x82悤\x82ɂ\xB5\x82\xBD\x81B</li>
       <li>Eterm look-feel: <a href="../menu/setup-additional.html#MixedThemeFile">\x95ǎ\x86\x82Ɖ摜\x82\xF0\x8D\xAC\x8D\x87\x82\xB7\x82\xE9</a>\x82\xF0\x90ݒ\xE8\x82ł\xAB\x82\xE9\x82悤\x82ɂ\xB5\x82\xBD\x81Bteraterm.ini \x82\xC9 <a href="../setup/teraterm-ini.html#BGIgnoreThemeFile">BGIgnoreThemeFile</a> \x83G\x83\x93\x83g\x83\x8A\x82\xF0\x92lj\xC1\x82\xB5\x82\xBD\x81B\x83f\x83t\x83H\x83\x8B\x83g\x82\xCDoff\x81B</li>
       <li><a href="../menu/setup-additional.html">Additional settings\x83_\x83C\x83A\x83\x8D\x83O</a>\x82\xCCVisual\x83^\x83u\x82ŕs\x93\xA7\x96\xBE\x93x\x82̒l\x82\xC9256\x88ȏ\xE3\x82\xF0\x93\xFC\x97͂\xB5\x82\xBD\x82Ƃ\xAB\x81A\x83_\x83C\x83A\x83\x8D\x83O\x8F\xE3\x82\xC5255\x82ɕύX\x82\xB7\x82\xE9\x82悤\x82ɂ\xB5\x82\xBD\x81B</li>
-      
+      <li>REP \x90\xA7\x8C\xE4\x83V\x81[\x83P\x83\x93\x83X\x82ɑΉ\x9E\x82\xB5\x82\xBD\x81B</li>
+
       <li>\x83V\x83\x8A\x83A\x83\x8B\x83|\x81[\x83g\x90ڑ\xB1
         <ul>
           <li>\x83V\x83\x8A\x83A\x83\x8B\x90ڑ\xB1\x82Ńn\x81[\x83h\x83E\x83F\x83A\x83t\x83\x8D\x81[\x90\xA7\x8C\xE4DSR/DTR\x82\xF0\x83T\x83|\x81[\x83g\x82\xB5\x82\xBD\x81B
@@ -59,7 +60,6 @@
           <li><a href="../commandline/teraterm.html#cdatabit">/CDATABIT=</a>,  <a href="../commandline/teraterm.html#cparity">/CPARITY=</a>, <a href="../commandline/teraterm.html#cstopbit">/CSTOPBIT=</a>, <a href="../commandline/teraterm.html#cflowctrl">/CFLOWCTRL=</a>, <a href="../commandline/teraterm.html#cdelayperchar">/CDELAYPERCHAR=</a>, <a href="../commandline/teraterm.html#cdelayperline">/CDELAYPERLINE=</a> \x83R\x83}\x83\x93\x83h\x83\x89\x83C\x83\x93\x83I\x83v\x83V\x83\x87\x83\x93\x82\xF0\x92lj\xC1\x82\xB5\x82\xBD\x81B</li>
         </ul>
       </li>
-      
     </ul>
   </li>
 

Modified: trunk/teraterm/teraterm/vtterm.c
===================================================================
--- trunk/teraterm/teraterm/vtterm.c	2019-10-23 14:58:10 UTC (rev 8328)
+++ trunk/teraterm/teraterm/vtterm.c	2019-10-24 10:41:21 UTC (rev 8329)
@@ -134,6 +134,8 @@
 BYTE PrevCharacter;
 BOOL PrevCRorLFGeneratedCRLF;	  // indicates that previous CR or LF really generated a CR+LF
 
+BYTE LastPutCharacter;
+
 // status buffer for main screen & status line
 static TStatusBuff SBuff1, SBuff2, SBuff3;
 
@@ -341,6 +343,8 @@
 	PrevCharacter = -1;	// none
 	PrevCRorLFGeneratedCRLF = FALSE;
 
+	LastPutCharacter = 0;
+
 	// Beep over-used
 	BeepStartTime = GetTickCount();
 	BeepSuppressTime = BeepStartTime - ts.BeepSuppressTime * 1000;
@@ -610,6 +614,66 @@
 	if (cv.HLogBuf!=0) Log1Byte(HT);
 }
 
+void RepeatChar(BYTE b, int count)
+{
+	int i;
+	BOOL SpecialNew;
+	TCharAttr CharAttrTmp, CharAttrWrap;
+
+	if (b <= US || b == DEL)
+		return;
+
+	CharAttrTmp = CharAttr;
+	LastPutCharacter = 0;
+
+	SpecialNew = FALSE;
+	if ((b>0x5F) && (b<0x80)) {
+		if (SSflag)
+			SpecialNew = (Gn[GLtmp]==IdSpecial);
+		else
+			SpecialNew = (Gn[Glr[0]]==IdSpecial);
+	}
+	else if (b>0xDF) {
+		if (SSflag)
+			SpecialNew = (Gn[GLtmp]==IdSpecial);
+		else
+			SpecialNew = (Gn[Glr[1]]==IdSpecial);
+	}
+
+	if (SpecialNew != Special) {
+		UpdateStr();
+		Special = SpecialNew;
+	}
+
+	if (Special) {
+		b = b & 0x7F;
+		CharAttrTmp.Attr |= AttrSpecial;
+	}
+	else
+		CharAttrTmp.Attr |= CharAttr.Attr;
+
+	CharAttrWrap = CharAttrTmp;
+	CharAttrWrap.Attr |= ts.EnableContinuedLineCopy ? AttrLineContinued : 0;
+
+	for (i=0; i<count; i++) {
+		if (Wrap) {
+			CarriageReturn(FALSE);
+			LineFeed(LF,FALSE);
+		}
+
+		BuffPutChar(b, Wrap ? CharAttrWrap : CharAttrTmp, InsertMode);
+
+		if (CursorX == CursorRightM || CursorX >= NumOfColumns-1) {
+			UpdateStr();
+			Wrap = AutoWrapMode;
+		}
+		else {
+			Wrap = FALSE;
+			MoveRight();
+		}
+	}
+}
+
 void PutChar(BYTE b)
 {
 	BOOL SpecialNew;
@@ -617,6 +681,8 @@
 
 	CharAttrTmp = CharAttr;
 
+	LastPutCharacter = b;
+
 	if (PrinterMode) { // printer mode
 		WriteToPrnFile(b,TRUE);
 		return;
@@ -1778,6 +1844,14 @@
 	BuffEraseChars(Param[1]);
 }
 
+void CSRepeatCharacter()
+{
+	CheckParamVal(Param[1], NumOfColumns * NumOfLines);
+
+	BuffUpdateScroll();
+	RepeatChar(LastPutCharacter, Param[1]);
+}
+
 void CSScrollUp()
 {
 	// TODO: \x83X\x83N\x83\x8D\x81[\x83\x8B\x82̍ő\xE5\x92l\x82\xF0\x92[\x96\x96\x8Ds\x90\x94\x82ɐ\xA7\x8C\xC0\x82\xB7\x82ׂ\xAB\x82\xA9\x97v\x8C\x9F\x93\xA2
@@ -3938,7 +4012,7 @@
 //			  case '^': break;                        // SIMD -- Not support
 			  case '`': CSMoveToColumnN(); break;     // HPA
 			  case 'a': CSCursorRight(FALSE); break;  // HPR
-//			  case 'b': break;                        // REP  -- Not support
+			  case 'b': CSRepeatCharacter(); break;   // REP
 			  case 'c': AnswerTerminalType(); break;  // DA
 			  case 'd': CSMoveToLineN(); break;       // VPA
 			  case 'e': CSCursorDown(FALSE); break;   // VPR
@@ -5814,6 +5888,10 @@
 
 		PrevCharacter = b;		// memorize previous character for AUTO CR/LF-receive mode
 
+		if (LastPutCharacter != b && !(ParseMode == ModeESC || ParseMode == ModeCSI)) {
+			LastPutCharacter = 0;
+		}
+
 		if (ChangeEmu==0)
 			c = CommRead1Byte(&cv,&b);
 	}


Ttssh2-commit メーリングリストの案内