[Ttssh2-commit] [5316] Beepが多量に鳴らされた時に抑制するようにした。

svnno****@sourc***** svnno****@sourc*****
2013年 6月 12日 (水) 03:04:01 JST


Revision: 5316
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/5316
Author:   doda
Date:     2013-06-12 03:03:59 +0900 (Wed, 12 Jun 2013)
Log Message:
-----------
Beepが多量に鳴らされた時に抑制するようにした。

Modified Paths:
--------------
    trunk/installer/release/TERATERM.INI
    trunk/teraterm/common/tttypes.h
    trunk/teraterm/teraterm/vtterm.c
    trunk/teraterm/ttpset/ttset.c

-------------- next part --------------
Modified: trunk/installer/release/TERATERM.INI
===================================================================
--- trunk/installer/release/TERATERM.INI	2013-06-11 08:56:32 UTC (rev 5315)
+++ trunk/installer/release/TERATERM.INI	2013-06-11 18:03:59 UTC (rev 5316)
@@ -414,6 +414,11 @@
 ; Beep by BEL (on/off/visual)
 Beep=on
 
+; Beep over-used
+BeepOverUsedTime=2
+BeepOverUsedCount=5
+BeepSuppressTime=5
+
 ; Beep on connection & disconnection
 BeepOnConnect=off
 

Modified: trunk/teraterm/common/tttypes.h
===================================================================
--- trunk/teraterm/common/tttypes.h	2013-06-11 08:56:32 UTC (rev 5315)
+++ trunk/teraterm/common/tttypes.h	2013-06-11 18:03:59 UTC (rev 5316)
@@ -566,6 +566,9 @@
 	WORD LogRotateSizeType;
 	WORD LogRotateStep;
 	WORD DeferredLogWriteMode;
+	DWORD BeepOverUsedCount;
+	DWORD BeepOverUsedTime;
+	DWORD BeepSuppressTime;
 };
 
 typedef struct tttset TTTSet, *PTTSet;
@@ -1031,9 +1034,10 @@
  *
  * - At version 4.79, ttset_memfilemap was replaced with ttset_memfilemap_21.
  *   added TMap.WinUndoFlag
- *
- * - At version 4.78,
  *   added tttset.FTHideDialog
+ *   added tttset.BeepOverUsedCount
+ *   added tttset.BeepOverUsedTime
+ *   added tttset.BeepSuppressTime
  *
  * - At version 4.78, ttset_memfilemap was replaced with ttset_memfilemap_20.
  *   added tttset.LogRotate

Modified: trunk/teraterm/teraterm/vtterm.c
===================================================================
--- trunk/teraterm/teraterm/vtterm.c	2013-06-11 08:56:32 UTC (rev 5315)
+++ trunk/teraterm/teraterm/vtterm.c	2013-06-11 18:03:59 UTC (rev 5316)
@@ -55,6 +55,7 @@
 #define DecLocatorButtonUp   8
 #define DecLocatorFiltered   16
 
+void RingBell(int type);
 void VisualBell();
 BOOL DecLocatorReport(int Event, int Button);
 
@@ -160,6 +161,11 @@
 /* IME Status */
 BOOL IMEstat;
 
+/* Beep over-used */
+static DWORD BeepStartTime = 0;
+static DWORD BeepSuppressTime = 0;
+static DWORD BeepOverUsedCount = 0;
+
 /* OSC String buffer */
 #define MAXOSCBUFFSIZE 4096
 static char *OSCStrBuff;
@@ -293,6 +299,12 @@
   // previous received character
   PrevCharacter = -1;	// none
   PrevCRorLFGeneratedCRLF = FALSE;
+
+  // Beep over-used
+  BeepStartTime = GetTickCount();
+  BeepSuppressTime = BeepStartTime - ts.BeepSuppressTime * 1000;
+  BeepStartTime -= (ts.BeepOverUsedTime * 1000);
+  BeepOverUsedCount = ts.BeepOverUsedCount;
 }
 
 void ResetCharSet()
@@ -871,16 +883,8 @@
       CommBinaryOut(&cv,&(ts.Answerback[0]),ts.AnswerbackLen);
       break;
     case BEL:
-      switch (ts.Beep) {
-      case IdBeepOff:
-	/* nothing to do */
-        break;
-      case IdBeepOn:
-        MessageBeep(0);
-        break;
-      case IdBeepVisual:
-	VisualBell();
-        break;
+      if (ts.Beep != IdBeepOff) {
+	RingBell(ts.Beep);
       }
       break;
     case BS: BackSpace(); break;
@@ -1370,7 +1374,7 @@
 	    CommResetSerial(&ts, &cv, TRUE);
 	  break;
 	case 'g': /* Visual Bell (screen original?) */
-	  VisualBell();
+	  RingBell(IdBeepVisual);
 	  break;
 	case 'n': Glr[0] = 2; break; /* LS2 */
 	case 'o': Glr[0] = 3; break; /* LS3 */
@@ -5131,6 +5135,41 @@
 	CSQExchangeColor();
 }
 
+void RingBell(int type) {
+	DWORD now;
+
+	now = GetTickCount();
+	if (now - BeepSuppressTime < ts.BeepSuppressTime * 1000) {
+		BeepSuppressTime = now;
+	}
+	else {
+		if (now - BeepStartTime < ts.BeepOverUsedTime * 1000) {
+			if (BeepOverUsedCount <= 1) {
+				BeepSuppressTime = now;
+			}
+			else {
+				BeepOverUsedCount--;
+			}
+		}
+		else {
+			BeepStartTime = now;
+			BeepOverUsedCount = ts.BeepOverUsedCount;
+		}
+
+		switch (ts.Beep) {
+		  case IdBeepOff:
+			/* nothing to do */
+			break;
+		  case IdBeepOn:
+			MessageBeep(0);
+			break;
+		  case IdBeepVisual:
+			VisualBell();
+			break;
+		}
+	}
+}
+
 void EndTerm() {
 	if (CLocale) {
 		_free_locale(CLocale);

Modified: trunk/teraterm/ttpset/ttset.c
===================================================================
--- trunk/teraterm/ttpset/ttset.c	2013-06-11 08:56:32 UTC (rev 5315)
+++ trunk/teraterm/ttpset/ttset.c	2013-06-11 18:03:59 UTC (rev 5316)
@@ -1515,6 +1515,14 @@
 		ts->FontQuality = CLEARTYPE_QUALITY;
 	else
 		ts->FontQuality = DEFAULT_QUALITY;
+
+	// Beep Over Used
+	ts->BeepOverUsedCount =
+		GetPrivateProfileInt(Section, "BeepOverUsedCount", 5, FName);
+	ts->BeepOverUsedTime =
+		GetPrivateProfileInt(Section, "BeepOverUsedTime", 2, FName);
+	ts->BeepSuppressTime =
+		GetPrivateProfileInt(Section, "BeepSuppressTime", 5, FName);
 }
 
 void FAR PASCAL WriteIniFile(PCHAR FName, PTTSet ts)
@@ -2666,6 +2674,11 @@
 	else
 		strncpy_s(Temp, sizeof(Temp), "default", _TRUNCATE);
 	WritePrivateProfileString(Section, "FontQuality", Temp, FName);
+
+	// Beep Over Used
+	WriteInt(Section, "BeepOverUsedCount", FName, ts->BeepOverUsedCount);
+	WriteInt(Section, "BeepOverUsedTime", FName, ts->BeepOverUsedTime);
+	WriteInt(Section, "BeepSuppressTime", FName, ts->BeepSuppressTime);
 }
 
 #define VTEditor "VT editor keypad"



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