From a96b94028d732b4ad3fb173d6bea155e638ebfd5 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Tue, 12 May 2020 19:06:07 +0000
Subject: [PATCH] As part of the rev 1.147 (add mouse hot sport support)
 commit, I made what I thought was a harmless change to the JS console.clear()
 implementation, I changed the call to sbbs->CLS to sbbs->clearscreen(). The
 sbbs->CLS macro calls outchar(FF) which check the line-counter and does the
 auto-pause before screen-clear. A direct call to sbbs->clearscreen() does
 not. Just in case someone actually wants the new (but unexpected behavior), I
 added an optional boolean parameter to console.clear(), autopause (default to
 true). Pass false if you want to defeat the autopause functionality. This
 should be effectively the same as setting the console.line_counter = 0 before
 calling console.clear(), but it also totally bypasses sbbs_t::outchar, so
 there could be other differences I'm not thinking of. Anyway, this fixes the
 lack of auto-screen pauses in JS mods recently introduced.

---
 src/sbbs3/js_console.cpp | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/sbbs3/js_console.cpp b/src/sbbs3/js_console.cpp
index f8bb09cd3a..a4ef697519 100644
--- a/src/sbbs3/js_console.cpp
+++ b/src/sbbs3/js_console.cpp
@@ -1059,6 +1059,7 @@ js_clear(JSContext *cx, uintN argc, jsval *arglist)
 {
 	jsval *argv=JS_ARGV(cx, arglist);
 	sbbs_t*		sbbs;
+	bool		autopause = true;
 	jsrefcount	rc;
 
 	if((sbbs=(sbbs_t*)js_GetClassPrivate(cx, JS_THIS_OBJECT(cx, arglist), &js_console_class))==NULL)
@@ -1066,13 +1067,21 @@ js_clear(JSContext *cx, uintN argc, jsval *arglist)
 
 	JS_SET_RVAL(cx, arglist, JSVAL_VOID);
 
-	if(argc) {
-		if(!js_set_attr(cx, sbbs, argv[0]))
+	uintN argn = 0;
+	if(argc > argn && !JSVAL_IS_BOOLEAN(argv[argn])) {
+		if(!js_set_attr(cx, sbbs, argv[argn]))
 			return JS_FALSE;
+		argn++;
+	}
+	if(argc > argn && JSVAL_IS_BOOLEAN(argv[argn])) {
+		autopause = JSVAL_TO_BOOLEAN(argv[argn]);
+		argn++;
 	}
-
 	rc=JS_SUSPENDREQUEST(cx);
-	sbbs->clearscreen(sbbs->term_supports());
+	if(autopause)
+		sbbs->CLS;
+	else
+		sbbs->clearscreen(sbbs->term_supports());
 	JS_RESUMEREQUEST(cx, rc);
     return(JS_TRUE);
 }
@@ -2121,7 +2130,7 @@ static jsSyncMethodSpec js_console_functions[] = {
 	,JSDOCSTR("print a mnemonics string, command keys highlighted with tilde (~) characters")
 	,310
 	},
-	{"clear",           js_clear,			0, JSTYPE_VOID,		JSDOCSTR("[attribute]")
+	{"clear",           js_clear,			0, JSTYPE_VOID,		JSDOCSTR("[attribute] [,autopause=<tt>true</tt>]")
 	,JSDOCSTR("clear screen and home cursor, "
 		"optionally (in v3.13b+) setting current attribute first")
 	,310
-- 
GitLab