diff --git a/src/sbbs3/getkey.cpp b/src/sbbs3/getkey.cpp index 46e9238af76ab7159d6be81a7056428c8dc115be..663054bf5246546b3d29a179a7bcf24f7bcd60f7 100644 --- a/src/sbbs3/getkey.cpp +++ b/src/sbbs3/getkey.cpp @@ -418,8 +418,9 @@ int sbbs_t::getkeys(const char *keys, uint max, int mode) /****************************************************************************/ /* Prints PAUSE message and waits for a key stoke */ +/* Returns false if aborted by user */ /****************************************************************************/ -void sbbs_t::pause() +bool sbbs_t::pause(bool set_abort) { char ch; uint tempattrs=curatr; /* was lclatr(-1) */ @@ -427,7 +428,7 @@ void sbbs_t::pause() size_t len; if((sys_status&SS_ABORT) || pause_inside) - return; + return false; pause_inside = true; lncntr=0; if(online==ON_REMOTE) @@ -444,7 +445,8 @@ void sbbs_t::pause() clear_hotspots(); pause_hotspot = NULL; } - if(ch==no_key() || ch==quit_key()) + bool aborted = (ch==no_key() || ch==quit_key() || (sys_status & SS_ABORT)); + if(set_abort && aborted) sys_status|=SS_ABORT; else if(ch==LF) // down arrow == display one more line lncntr=rows-2; @@ -454,6 +456,7 @@ void sbbs_t::pause() nodesync(); attr(tempattrs); pause_inside = false; + return !aborted; } /****************************************************************************/ diff --git a/src/sbbs3/js_console.cpp b/src/sbbs3/js_console.cpp index b78c376f3e73503a5abaed2c703d9b73fe5b51d7..171ea2583f65609d5a2a791b80aeaefb7e096e00 100644 --- a/src/sbbs3/js_console.cpp +++ b/src/sbbs3/js_console.cpp @@ -1177,16 +1177,22 @@ js_crlf(JSContext *cx, uintN argc, jsval *arglist) static JSBool js_pause(JSContext *cx, uintN argc, jsval *arglist) { + jsval *argv=JS_ARGV(cx, arglist); sbbs_t* sbbs; + bool set_abort = true; jsrefcount rc; if((sbbs=(sbbs_t*)js_GetClassPrivate(cx, JS_THIS_OBJECT(cx, arglist), &js_console_class))==NULL) return(JS_FALSE); - JS_SET_RVAL(cx, arglist, JSVAL_VOID); + uintN argn = 0; + if(argc > argn && JSVAL_IS_BOOLEAN(argv[argn])) { + set_abort = JSVAL_TO_BOOLEAN(argv[argn]); + argn++; + } rc=JS_SUSPENDREQUEST(cx); - sbbs->pause(); + JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->pause(set_abort))); JS_RESUMEREQUEST(cx, rc); return(JS_TRUE); } @@ -2406,8 +2412,9 @@ static jsSyncMethodSpec js_console_functions[] = { ,JSDOCSTR("output <i>count</i> number of carriage-return/line-feed pairs (new-lines)") ,310 }, - {"pause", js_pause, 0, JSTYPE_VOID, JSDOCSTR("") - ,JSDOCSTR("display pause prompt and wait for key hit") + {"pause", js_pause, 0, JSTYPE_BOOLEAN, JSDOCSTR("[set_abort=true]") + ,JSDOCSTR("display pause prompt and wait for key hit, returns <i>false</i> if user responded with Quit/Abort key.<br>" + "Passing <tt>false</tt> for the <i>set_abort</i> argument will prevent the ''console.aborted'' flag from being set by this method.") ,310 }, {"beep", js_beep, 1, JSTYPE_VOID, JSDOCSTR("[count=<tt>1</tt>]") diff --git a/src/sbbs3/sbbs.h b/src/sbbs3/sbbs.h index d3a35819a9a847460e7cc98635ebd873bff98d43..9e46509ae832547a573e4bf79714f3df9e6b25a8 100644 --- a/src/sbbs3/sbbs.h +++ b/src/sbbs3/sbbs.h @@ -907,7 +907,7 @@ public: bool yesno(const char *str, int mode = 0); bool noyes(const char *str, int mode = 0); bool pause_inside = false; - void pause(void); + bool pause(bool set_abort = true); const char* mnestr = nullptr; void mnemonics(const char *str);