diff --git a/exec/SlyEdit.js b/exec/SlyEdit.js index bb491a5aa6858b9a29fbfdb56f1817c7c6104a21..aafa65c5306ff1de926deb28674deec218bfcd89 100644 --- a/exec/SlyEdit.js +++ b/exec/SlyEdit.js @@ -1,5 +1,3 @@ -// $Id: SlyEdit.js,v 1.74 2020/04/05 21:03:43 nightfox Exp $ - /* This is a text editor for Synchronet designed to mimic the look & feel of * DCTEdit and IceEdit, since neither of those editors have been developed * for quite a while and still exist only as 16-bit DOS applications. @@ -150,8 +148,12 @@ * Removed high-ascii characters from the SlyEdit JS files; used * ascii() with their numeric ASCII values instead. This should avoid * issues with text editors converting characters incorrectly. + * 2022-06-21 Eric Oulashin Version 1.79 + * JS strict mode enabled. Small JS issues fixed. */ +"use strict"; + /* Command-line arguments: 1 (argv[0]): Filename to read/edit 2 (argv[1]): Editor mode ("DCT", "ICE", or "RANDOM") @@ -198,9 +200,6 @@ else load(gStartupPath + "SlyEdit_Misc.js"); } -// Determine whether the user settings file exists -const userSettingsFileExistedOnStartup = file_exists(gUserSettingsFilename); - // Load program settings from SlyEdit.cfg, and load the user configuratio nsettings var gConfigSettings = ReadSlyEditConfigFile(); var gUserSettings = ReadUserSettingsFile(gConfigSettings); @@ -220,13 +219,13 @@ const SPELL_CHECK_PAUSE_MS = 1000; // Exit if the Synchronet version is below the minimum. if (system.version_num < 31400) { - console.print("\1n"); + console.print("\x01n"); console.crlf(); - console.print("\1n\1h\1y\1i* Warning:\1n\1h\1w " + EDITOR_PROGRAM_NAME); - console.print(" " + "requires version \1g3.14\1w or"); + console.print("\x01n\x01h\x01y\x01i* Warning:\x01n\x01h\x01w " + EDITOR_PROGRAM_NAME); + console.print(" " + "requires version \x01g3.14\x01w or"); console.crlf(); - console.print("higher of Synchronet. This BBS is using version \1g"); - console.print(system.version + "\1w. Please notify the sysop."); + console.print("higher of Synchronet. This BBS is using version \x01g"); + console.print(system.version + "\x01w. Please notify the sysop."); console.crlf(); console.pause(); exit(1); // 1: Aborted @@ -235,19 +234,19 @@ if (system.version_num < 31400) // than 80 characters wide, then exit. if (!console.term_supports(USER_ANSI)) { - console.print("\1n\r\n\1h\1yERROR: \1w" + EDITOR_PROGRAM_NAME + - " requires an ANSI terminal.\1n\r\n\1p"); + console.print("\x01n\r\n\x01h\x01yERROR: \x01w" + EDITOR_PROGRAM_NAME + + " requires an ANSI terminal.\x01n\r\n\x01p"); exit(1); // 1: Aborted } if (console.screen_columns < 80) { - console.print("\1n\r\n\1h\1w" + EDITOR_PROGRAM_NAME + " requires a terminal width of at least 80 characters.\1n\r\n\1p"); + console.print("\x01n\r\n\x01h\x01w" + EDITOR_PROGRAM_NAME + " requires a terminal width of at least 80 characters.\x01n\r\n\x01p"); exit(1); // 1: Aborted } // Constants -const EDITOR_VERSION = "1.78"; -const EDITOR_VER_DATE = "2022-06-09"; +const EDITOR_VERSION = "1.79"; +const EDITOR_VER_DATE = "2022-06-21"; // Program variables @@ -274,10 +273,10 @@ if (console.screen_columns < 80) */ // Colors -var gQuoteWinTextColor = "\1n\1" + "7\1k"; // Normal text color for the quote window (DCT default) -var gQuoteLineHighlightColor = "\1n\1w"; // Highlighted text color for the quote window (DCT default) -var gTextAttrs = "\1n\1w"; // The text color for edit mode -var gQuoteLineColor = "\1n\1c"; // The text color for quote lines +var gQuoteWinTextColor = "\x01n\x01" + "7\x01k"; // Normal text color for the quote window (DCT default) +var gQuoteLineHighlightColor = "\x01n\x01w"; // Highlighted text color for the quote window (DCT default) +var gTextAttrs = "\x01n\x01w"; // The text color for edit mode +var gQuoteLineColor = "\x01n\x01c"; // The text color for quote lines var gUseTextAttribs = false; // Will be set to true if text colors start to be used // gQuotePrefix contains the text to prepend to quote lines. @@ -378,7 +377,7 @@ gCrossPostMsgSubs.numSubBoards = function () { } } return numMsgSubs; -} +}; @@ -393,7 +392,7 @@ var fpDisplayBottomHelpLine = null; var fpDisplayTime = null; var fpDisplayTimeRemaining = null; var fpCallESCMenu = null; -var fpRefreshSubjectonScreen = null; +var fpRefreshSubjectOnScreen = null; var fpGlobalScreenVarsSetup = null; // Subject screen position & length (for changing the subject). Note: These // will be set in the IceStuff or DCTStuff scripts, depending on which theme @@ -550,7 +549,7 @@ console.ctrlkey_passthru = "+ACGKLOPQRTUVWXYZ_"; // status settings are restored upon script exit, even if there is a runtime error. js.on_exit("console.ctrlkey_passthru = gOldPassthru; bbs.sys_status = gOldStatus;"); // Enable delete line in SyncTERM (Disabling ANSI Music in the process) -console.write("\033[=1M"); +console.write("\x1B[=1M"); // 1B (27): ESC console.clear(); var gMsgAreaInfo = null; // Will store the value returned by getCurMsgInfo(). @@ -570,7 +569,7 @@ if (dropFileName != undefined) if (dropFile.exists && dropFile.open("r")) { dropFileTime = dropFile.date; - info = dropFile.readAll(); + var info = dropFile.readAll(); dropFile.close(); gFromName = info[0]; @@ -657,7 +656,7 @@ var exitCode = doEditLoop(); // Clear the screen and display the end-of-program information (if the setting // is enabled). -console.clear("\1n"); +console.clear("\x01n"); if (gConfigSettings.displayEndInfoScreen) { displayProgramExitInfo(false); @@ -798,9 +797,9 @@ if ((exitCode == 0) && (gEditLines.length > 0)) } } - console.print("\1n"); + console.print("\x01n"); console.crlf(); - console.print("\1n" + gConfigSettings.genColors.msgWillBePostedHdr + "Your message will be posted into the following area(s):"); + console.print("\x01n" + gConfigSettings.genColors.msgWillBePostedHdr + "Your message will be posted into the following area(s):"); console.crlf(); // If the user is posting in the originally-chosen sub-board and other sub-boards, // then make a log in the BBS log that the user is posting a message (for @@ -819,14 +818,14 @@ if ((exitCode == 0) && (gEditLines.length > 0)) if (gCrossPostMsgSubs.propIsFuncName(grpIndex)) continue; - console.print("\1n" + gConfigSettings.genColors.msgPostedGrpHdr + msg_area.grp_list[grpIndex].description + ":"); + console.print("\x01n" + gConfigSettings.genColors.msgPostedGrpHdr + msg_area.grp_list[grpIndex].description + ":"); console.crlf(); for (var subCode in gCrossPostMsgSubs[grpIndex]) { if (subCode == gMsgAreaInfo.subBoardCode) { - printf("\1n " + gConfigSettings.genColors.msgPostedSubBoardName + "%-48s", msg_area.sub[subCode].description.substr(0, 48)); - console.print("\1n " + gConfigSettings.genColors.msgPostedOriginalAreaText + "(original message area)"); + printf("\x01n " + gConfigSettings.genColors.msgPostedSubBoardName + "%-48s", msg_area.sub[subCode].description.substr(0, 48)); + console.print("\x01n " + gConfigSettings.genColors.msgPostedOriginalAreaText + "(original message area)"); } // If subCode is not the user's current sub, then if the user is allowed // to post in that sub, then post the message there. @@ -840,7 +839,7 @@ if ((exitCode == 0) && (gEditLines.length > 0)) " " + msg_area.sub[subCode].description + " (" + gMsgSubj + ")"); // Write the cross-posting message area on the user's screen. - printf("\1n " + gConfigSettings.genColors.msgPostedSubBoardName + "%-73s", msg_area.sub[subCode].description.substr(0, 73)); + printf("\x01n " + gConfigSettings.genColors.msgPostedSubBoardName + "%-73s", msg_area.sub[subCode].description.substr(0, 73)); if (msg_area.sub[subCode].can_post) { // If the user's auto-sign setting is enabled, then auto-sign @@ -861,13 +860,13 @@ if ((exitCode == 0) && (gEditLines.length > 0)) { savedTheMessage = true; crossPosted = true; - console.print("\1n\1h\1b[\1n\1g" + CHECK_CHAR + "\1n\1h\1b]\1n"); + console.print("\x01n\x01h\x01b[\x01n\x01g" + CHECK_CHAR + "\x01n\x01h\x01b]\x01n"); } else { - console.print("\1n\1h\1b[\1rX\1b]\1n"); + console.print("\x01n\x01h\x01b[\x01rX\x01b]\x01n"); console.crlf(); - console.print(" \1n\1h\1r*\1n " + postMsgErrStr); + console.print(" \x01n\x01h\x01r*\x01n " + postMsgErrStr); console.crlf(); } } @@ -875,16 +874,16 @@ if ((exitCode == 0) && (gEditLines.length > 0)) { // The user isn't allowed to post in the sub. Output a message // saying so. - console.print("\1n\1h\1b[\1rX\1b]\1n"); + console.print("\x01n\x01h\x01b[\x01rX\x01b]\x01n"); console.crlf(); - console.print(" \1n\1h\1r*\1n You're not allowed to post in this area."); + console.print(" \x01n\x01h\x01r*\x01n You're not allowed to post in this area."); console.crlf(); } } console.crlf(); } } - console.print("\1n"); + console.print("\x01n"); console.crlf(); } @@ -903,13 +902,13 @@ if ((exitCode == 0) && (gEditLines.length > 0)) // will say the message was aborted, and that's normal. if (crossPosted) { - console.print("\1n\1c* Note: Your message has been cross-posted in areas other than your currently-"); + console.print("\x01n\x01c* Note: Your message has been cross-posted in areas other than your currently-"); console.crlf(); console.print("selected message area. Because your message was not saved for your currently-"); console.crlf(); console.print("selected message area, the BBS will say the message was aborted, even"); console.crlf(); - console.print("though it was posted in those other areas. This is normal.n"); + console.print("though it was posted in those other areas. This is normal.\x01n"); console.crlf(); console.crlf(); } @@ -943,7 +942,7 @@ function saveMessageToFile() savedTheMessage = true; } else - console.print("\1n\1r\1h* Unable to save the message!\1n\r\n"); + console.print("\x01n\x01r\x01h* Unable to save the message!\x01n\r\n"); } @@ -1102,7 +1101,7 @@ function doEditLoop() var curpos = { x: gEditLeft, y: gEditTop - } + }; console.gotoxy(curpos); // initialTimeLeft and updateTimeLeft will be used to keep track of the user's @@ -1117,7 +1116,7 @@ function doEditLoop() var continueOn = true; while (continueOn) { - userInput = getKeyWithESCChars(K_NOCRLF|K_NOSPIN|K_NUL, gConfigSettings) + userInput = getKeyWithESCChars(K_NOCRLF|K_NOSPIN|K_NUL, gConfigSettings); // If the cursor is at the end of the last line and the user // pressed the DEL key, then treat it as a backspace. Some @@ -1143,7 +1142,7 @@ function doEditLoop() returnCode = 1; // Aborted continueOn = false; console.crlf(); - console.print("\1n\1h\1r" + EDITOR_PROGRAM_NAME + ": Input timeout reached."); + console.print("\x01n\x01h\x01r" + EDITOR_PROGRAM_NAME + ": Input timeout reached."); continue; } @@ -1168,7 +1167,7 @@ function doEditLoop() else { // Make sure the edit color attribute is set. - //console.print("\1n" + gTextAttrs); + //console.print("\x01n" + gTextAttrs); console.print(chooseEditColor()); } break; @@ -1207,7 +1206,7 @@ function doEditLoop() returnCode = 1; // Aborted continueOn = false; console.crlf(); - console.print("\1n\1h\1r" + EDITOR_PROGRAM_NAME + ": Input timeout reached."); + console.print("\x01n\x01h\x01r" + EDITOR_PROGRAM_NAME + ": Input timeout reached."); continue; } } @@ -1233,7 +1232,7 @@ function doEditLoop() chgColorRetobj.returnCode = 1; // Aborted continueOn = false; console.crlf(); - console.print("\1n\1h\1r" + EDITOR_PROGRAM_NAME + ": Input timeout reached."); + console.print("\x01n\x01h\x01r" + EDITOR_PROGRAM_NAME + ": Input timeout reached."); continue; } }*/ @@ -1477,7 +1476,7 @@ function doEditLoop() returnCode = 1; // Aborted continueOn = false; console.crlf(); - console.print("\1n\1h\1r" + EDITOR_PROGRAM_NAME + ": Input timeout reached."); + console.print("\x01n\x01h\x01r" + EDITOR_PROGRAM_NAME + ": Input timeout reached."); continue; } } @@ -1509,7 +1508,7 @@ function doEditLoop() case KEY_INSERT: case TOGGLE_INSERT_KEY: toggleInsertMode(null); - //console.print("\1n" + gTextAttrs); + //console.print("\x01n" + gTextAttrs); console.print(chooseEditColor()); console.gotoxy(curpos); break; @@ -1691,7 +1690,7 @@ function doEditLoop() doUserSettings(curpos, true); break; case CHANGE_SUBJECT_KEY: - console.print("\1n"); + console.print("\x01n"); console.gotoxy(gSubjPos.x, gSubjPos.y); var subj = console.getstr(gSubjScreenLen, K_LINE|K_NOCRLF|K_NOSPIN|K_TRIM); if (subj.length > 0) @@ -2387,7 +2386,7 @@ function doEnterKey(pCurpos, pCurrentWordLength) else { // Make sure the edit color attribute is set back. - //console.print("\1n" + gTextAttrs); + //console.print("\x01n" + gTextAttrs); console.print(chooseEditColor()); // Blank out the data in the text line, set the data in @@ -2950,7 +2949,7 @@ function doQuoteSelection(pCurpos, pCurrentWordLength) else ++curpos.y; } - } + }; // Set the current & top item indexes back into the menu, if we know them already if (typeof(doQuoteSelection.selectedQuoteLineIdx) !== "undefined" && typeof(doQuoteSelection.topQuoteLineIdx) !== "undefined") { @@ -3171,7 +3170,7 @@ function displayEditLines(pStartScreenRow, pArrayIndex, pEndScreenRow, pClearRem var endScreenRow = (pEndScreenRow != null ? pEndScreenRow : gEditBottom); // Display the message lines - console.print("\1n" + gTextAttrs); + console.print("\x01n" + gTextAttrs); var screenLine = pStartScreenRow; var arrayIndex = pArrayIndex; while ((screenLine <= endScreenRow) && (arrayIndex < gEditLines.length)) @@ -3223,7 +3222,7 @@ function displayEditLines(pStartScreenRow, pArrayIndex, pEndScreenRow, pClearRem var clearRemainingScreenLines = (pClearRemainingScreenRows != null ? pClearRemainingScreenRows : true); if (clearRemainingScreenLines && (screenLine <= endScreenRow)) { - console.print("\1n" + gTextAttrs); + console.print("\x01n" + gTextAttrs); var screenLineBackup = screenLine; // So we can move the cursor back clearMsgAreaToBottom(incrementLineBeforeClearRemaining ? screenLine+1 : screenLine, pIgnoreEditAreaBuffer); // Move the cursor back to the end of the current text line. @@ -3315,7 +3314,7 @@ function displayMessageRectangle(pX, pY, pWidth, pHeight, pEditLinesIndex, pClea for (var rectangleLine = 0; rectangleLine < pHeight; ++rectangleLine) { // Output the correct color for the line - console.print("\1n" + (isQuoteLine(gEditLines, editLinesIndex) ? gQuoteLineColor : gTextAttrs)); + console.print("\x01n" + (isQuoteLine(gEditLines, editLinesIndex) ? gQuoteLineColor : gTextAttrs)); // Go to the position on the screen screenY = pY + rectangleLine; console.gotoxy(pX, screenY); @@ -3480,10 +3479,10 @@ function displayProgramInfoBox() var boxHeight = 12; var boxTopLeftX = Math.floor(console.screen_columns / 2) - Math.floor(boxWidth/2); var boxTopLeftY = gEditTop + Math.floor(gEditHeight / 2) - Math.floor(boxHeight/2); - var borderBGColor = "\1b\1h\1" + "4"; // High blue with blue background + var borderBGColor = "\x01b\x01h\x01" + "4"; // High blue with blue background // Draw the box border console.gotoxy(boxTopLeftX, boxTopLeftY); - console.print("\1n" + borderBGColor); + console.print("\x01n" + borderBGColor); console.print(UPPER_LEFT_SINGLE); var innerWidth = boxWidth - 2; for (var i = 0; i < innerWidth; ++i) @@ -3505,7 +3504,7 @@ function displayProgramInfoBox() console.gotoxy(boxTopLeftX+1, boxTopLeftY+1); var boxWidthFillFormatStr = "%" + innerWidth + "s"; printf(boxWidthFillFormatStr, ""); - console.print("\1w"); + console.print("\x01w"); var textLine = centeredText(innerWidth, EDITOR_PROGRAM_NAME + " " + EDITOR_VERSION + " (" + EDITOR_VER_DATE + ")"); console.gotoxy(boxTopLeftX+1, boxTopLeftY+2); console.print(textLine); @@ -3514,9 +3513,9 @@ function displayProgramInfoBox() console.gotoxy(boxTopLeftX+1, boxTopLeftY+4); printf(boxWidthFillFormatStr, ""); console.gotoxy(boxTopLeftX+1, boxTopLeftY+5); - console.print("\1y"); + console.print("\x01y"); console.print(centeredText(innerWidth, "BBS tools web page:")); - console.print("\1m"); + console.print("\x01m"); console.gotoxy(boxTopLeftX+1, boxTopLeftY+6); console.print(centeredText(innerWidth, "http://digdist.synchro.net/DDBBSStuff.html")); console.gotoxy(boxTopLeftX+1, boxTopLeftY+7); @@ -3524,12 +3523,12 @@ function displayProgramInfoBox() console.gotoxy(boxTopLeftX+1, boxTopLeftY+8); printf(boxWidthFillFormatStr, ""); console.gotoxy(boxTopLeftX+1, boxTopLeftY+9); - console.print("\1c"); + console.print("\x01c"); console.print(centeredText(innerWidth, "Thanks for using " + EDITOR_PROGRAM_NAME + "!")); console.gotoxy(boxTopLeftX+1, boxTopLeftY+10); printf(boxWidthFillFormatStr, ""); - console.print("\1n"); + console.print("\x01n"); // Wait for a keypress getKeyWithESCChars(K_NOCRLF|K_NOSPIN, gConfigSettings); // Erase the info box @@ -3685,10 +3684,10 @@ function importFile(pIsSysop, pCurpos) while (continueOn) { // Go to the last row on the screen and prompt the user for a filename - var promptText = "\1n\1cFile:\1h"; + var promptText = "\x01n\x01cFile:\x01h"; var promptTextLen = strip_ctrl(promptText).length; console.gotoxy(1, console.screen_rows); - console.cleartoeol("\1n"); + console.cleartoeol("\x01n"); console.print(promptText); var filename = console.getstr(console.screen_columns-promptTextLen-1, K_NOCRLF); continueOn = (filename != ""); @@ -3749,10 +3748,10 @@ function importFile(pIsSysop, pCurpos) continueOn = false; } else // Unable to open the file - writeWithPause(1, console.screen_rows, "\1y\1hUnable to open the file!", ERRORMSG_PAUSE_MS); + writeWithPause(1, console.screen_rows, "\x01y\x01hUnable to open the file!", ERRORMSG_PAUSE_MS); } else // Could not find the correct case for the file (it doesn't exist?) - writeWithPause(1, console.screen_rows, "\1y\1hUnable to locate the file!", ERRORMSG_PAUSE_MS); + writeWithPause(1, console.screen_rows, "\x01y\x01hUnable to locate the file!", ERRORMSG_PAUSE_MS); } } @@ -3818,10 +3817,10 @@ function exportToFile(pIsSysop) return; // Go to the last row on the screen and prompt the user for a filename - var promptText = "ncFile:h"; + var promptText = "\x01n\x01cFile:\x01h"; var promptTextLen = strip_ctrl(promptText).length; console.gotoxy(1, console.screen_rows); - console.cleartoeol("n"); + console.cleartoeol("\x01n"); console.print(promptText); var filename = console.getstr(console.screen_columns-promptTextLen-1, K_NOCRLF); if (filename != "") @@ -3839,13 +3838,13 @@ function exportToFile(pIsSysop) outFile.write(gEditLines[i].text); } outFile.close(); - writeWithPause(1, console.screen_rows, "mhMessage exported.", ERRORMSG_PAUSE_MS); + writeWithPause(1, console.screen_rows, "\x01m\x01hMessage exported.", ERRORMSG_PAUSE_MS); } else // Could not open the file for writing - writeWithPause(1, console.screen_rows, "yhUnable to open the file for writing!", ERRORMSG_PAUSE_MS); + writeWithPause(1, console.screen_rows, "\x01y\x01hUnable to open the file for writing!", ERRORMSG_PAUSE_MS); } else // No filename specified - writeWithPause(1, console.screen_rows, "\1m\1hMessage not exported.", ERRORMSG_PAUSE_MS); + writeWithPause(1, console.screen_rows, "\x01m\x01hMessage not exported.", ERRORMSG_PAUSE_MS); // Refresh the help line on the bottom of the screen fpDisplayBottomHelpLine(console.screen_rows, gUseQuotes); @@ -3877,10 +3876,10 @@ function findText(pCurpos) findText.searchStartIndex = 0; // Go to the last row on the screen and prompt the user for text to find - var promptText = "\1n\1cText:\1h"; + var promptText = "\x01n\x01cText:\x01h"; var promptTextLen = strip_ctrl(promptText).length; console.gotoxy(1, console.screen_rows); - console.cleartoeol("\1n"); + console.cleartoeol("\x01n"); console.print(promptText); var searchText = console.getstr(console.screen_columns-promptTextLen-1, K_NOCRLF); @@ -3949,7 +3948,7 @@ function findText(pCurpos) // different color. var highlightText = gEditLines[i].text.substr(textIndex, searchText.length); console.gotoxy(retObj.x, retObj.y); - console.print("\1n\1k\1" + "4" + highlightText); + console.print("\x01n\x01k\x01" + "4" + highlightText); mswait(TEXT_SEARCH_PAUSE_MS); console.gotoxy(retObj.x, retObj.y); //console.print(gTextAttrs + highlightText); @@ -3970,8 +3969,8 @@ function findText(pCurpos) if (!textFound) { console.gotoxy(1, console.screen_rows); - console.cleartoeol("\1n"); - console.print("\1y\1hThe text wasn't found!"); + console.cleartoeol("\x01n"); + console.print("\x01y\x01hThe text wasn't found!"); mswait(ERRORMSG_PAUSE_MS); findText.searchStartIndex = 0; @@ -4029,7 +4028,7 @@ function doSpellCheck(pCurpos, pConfirmSpellcheck) dictFilenames = gConfigSettings.dictionaryFilenames; if (dictFilenames.length == 0) { - writeWithPause(1, console.screen_rows, "\1y\1hThere are no dictionaries configured!\1n", ERRORMSG_PAUSE_MS); + writeWithPause(1, console.screen_rows, "\x01y\x01hThere are no dictionaries configured!\x01n", ERRORMSG_PAUSE_MS); // Refresh the help line on the bottom of the screen fpDisplayBottomHelpLine(console.screen_rows, gUseQuotes); console.gotoxy(pCurpos.x, pCurpos.y); @@ -4038,7 +4037,7 @@ function doSpellCheck(pCurpos, pConfirmSpellcheck) // Load the dictionary file(s) console.gotoxy(1, console.screen_rows); - console.cleartoeol("\1n"); + console.cleartoeol("\x01n"); if (dictFilenames.length > 1) console.print("Reading dictionaries..."); else @@ -4054,7 +4053,7 @@ function doSpellCheck(pCurpos, pConfirmSpellcheck) // return. if (dictionaries.length == 0) { - writeWithPause(1, console.screen_rows, "\1y\1hUnable to load the dictionary file(s)!\1n", ERRORMSG_PAUSE_MS); + writeWithPause(1, console.screen_rows, "\x01y\x01hUnable to load the dictionary file(s)!\x01n", ERRORMSG_PAUSE_MS); // Refresh the help line on the bottom of the screen fpDisplayBottomHelpLine(console.screen_rows, gUseQuotes); console.gotoxy(pCurpos.x, pCurpos.y); @@ -4256,7 +4255,7 @@ function spellCheckWordInLine(pDictionaries, pEditLineIdx, pWordArray, pWordIdx, var highlightText = gEditLines[pEditLineIdx].text.substr(wordIdxInLine, currentWord.length); //console.gotoxy(retObj.x, retObj.y); // Updated line position console.gotoxy(oldLineX, retObj.y); // Old line position - console.print("\1n\1k\1" + "4" + highlightText); + console.print("\x01n\x01k\x01" + "4" + highlightText); mswait(SPELL_CHECK_PAUSE_MS); //console.gotoxy(retObj.x, retObj.y); // Updated line position console.gotoxy(oldLineX, retObj.y); // Old line position @@ -4378,31 +4377,31 @@ function inputWordCorrection(pMisspelledWord, pCurpos, pEditLineIdx) var maxInputLen = txtBoxWidth - 2; // Draw the top border of the input box - var borderLine = "\1n\1g" + UPPER_LEFT_SINGLE + RIGHT_T_SINGLE; - borderLine += "\1b\1h" + pMisspelledWord.substr(0, txtBoxWidth-4); - borderLine += "\1n\1g" + LEFT_T_SINGLE; + var borderLine = "\x01n\x01g" + UPPER_LEFT_SINGLE + RIGHT_T_SINGLE; + borderLine += "\x01b\x01h" + pMisspelledWord.substr(0, txtBoxWidth-4); + borderLine += "\x01n\x01g" + LEFT_T_SINGLE; var remainingWidth = txtBoxWidth - strip_ctrl(borderLine).length - 1; for (var i = 0; i < remainingWidth; ++i) borderLine += HORIZONTAL_SINGLE; - borderLine += UPPER_RIGHT_SINGLE + "\1n"; + borderLine += UPPER_RIGHT_SINGLE + "\x01n"; console.gotoxy(txtBoxX, txtBoxY); console.print(borderLine); // Draw the bottom border of the input box - borderLine = "\1g" + LOWER_LEFT_SINGLE + RIGHT_T_SINGLE; - borderLine += "\1c\1hEnter\1y=\1bNo change\1n\1g" + LEFT_T_SINGLE + RIGHT_T_SINGLE + "\1H\1cCtrl-C\1n\1c/\1hESC\1y=\1bEnd\1n\1g" + LEFT_T_SINGLE; + borderLine = "\x01g" + LOWER_LEFT_SINGLE + RIGHT_T_SINGLE; + borderLine += "\x01c\x01hEnter\x01y=\x01bNo change\x01n\x01g" + LEFT_T_SINGLE + RIGHT_T_SINGLE + "\x01H\x01cCtrl-C\x01n\x01c/\x01hESC\x01y=\x01bEnd\x01n\x01g" + LEFT_T_SINGLE; var remainingWidth = txtBoxWidth - strip_ctrl(borderLine).length - 1; for (var i = 0; i < remainingWidth; ++i) borderLine += HORIZONTAL_SINGLE; - borderLine += LOWER_RIGHT_SINGLE + "\1n"; + borderLine += LOWER_RIGHT_SINGLE + "\x01n"; console.gotoxy(txtBoxX, txtBoxY+2); console.print(borderLine); // Draw the side borders - console.print("\1n\1g"); + console.print("\x01n\x01g"); console.gotoxy(txtBoxX, txtBoxY+1); console.print(VERTICAL_SINGLE); console.gotoxy(txtBoxX+txtBoxWidth-1, txtBoxY+1); console.print(VERTICAL_SINGLE); - console.print("\1n"); + console.print("\x01n"); // Go to the middle row for user input var inputX = txtBoxX + 1; @@ -4465,7 +4464,7 @@ function inInsertMode() // is a normal line or a quote line. function chooseEditColor() { - return ("\1n" + (isQuoteLine(gEditLines, gEditLinesIndex) ? gQuoteLineColor : gTextAttrs)); + return ("\x01n" + (isQuoteLine(gEditLines, gEditLinesIndex) ? gQuoteLineColor : gTextAttrs)); } // This function calculates the row on the screen to stop updating the @@ -4512,7 +4511,7 @@ function updateTime(pCurpos, pMoveCursorBack) // Display the current time on the screen fpDisplayTime(currentTime); // Make sure the edit color attribute is set. - console.print("\1n" + gTextAttrs); + console.print("\x01n" + gTextAttrs); // Move the cursor back to where it was if (pMoveCursorBack) console.gotoxy(curpos); @@ -4553,16 +4552,16 @@ function doColorSelection(pTxtAttrs, pCurpos, pCurrentWordLength) var curpos = { x: 1, y: colorSelTopLine - } + }; console.gotoxy(curpos); - console.print("\1n\1cForeground: \1w\1hK:\1n\1kBlack \1w\1hR:\1n\1rRed \1w\1hG:\1n\1gGreen \1w\1hY:\1n\1yYellow \1w\1hB:\1n\1bBlue \1w\1hM:\1n\1mMagenta \1w\1hC:\1n\1cCyan \1w\1hW:\1n\1wWhite"); - console.cleartoeol("\1n"); + console.print("\x01n\x01cForeground: \x01w\x01hK:\x01n\x01kBlack \x01w\x01hR:\x01n\x01rRed \x01w\x01hG:\x01n\x01gGreen \x01w\x01hY:\x01n\x01yYellow \x01w\x01hB:\x01n\x01bBlue \x01w\x01hM:\x01n\x01mMagenta \x01w\x01hC:\x01n\x01cCyan \x01w\x01hW:\x01n\x01wWhite"); + console.cleartoeol("\x01n"); console.crlf(); - console.print("\1n\1cBackground: \1w\1h0:\1n\1" + "0Black\1n \1w\1h1:\1n\1" + "1Red\1n \1w\1h2:\1n\1" + "2\1kGreen\1n \1w\1h3:\1" + "3Yellow\1n \1w\1h4:\1n\1" + "4Blue\1n \1w\1h5:\1n\1" + "5Magenta\1n \1w\1h6:\1n\1" + "6\1kCyan\1n \1w\1h7:\1n\1" + "7\1kWhite"); - console.cleartoeol("\1n"); + console.print("\x01n\x01cBackground: \x01w\x01h0:\x01n\x01" + "0Black\x01n \x01w\x01h1:\x01n\x01" + "1Red\x01n \x01w\x01h2:\x01n\x01" + "2\x01kGreen\x01n \x01w\x01h3:\x01" + "3Yellow\x01n \x01w\x01h4:\x01n\x01" + "4Blue\x01n \x01w\x01h5:\x01n\x01" + "5Magenta\x01n \x01w\x01h6:\x01n\x01" + "6\x01kCyan\x01n \x01w\x01h7:\x01n\x01" + "7\x01kWhite"); + console.cleartoeol("\x01n"); console.crlf(); - console.clearline("\1n"); - console.print("\1cSpecial: \1w\1hH:\1n\1hHigh Intensity \1wI:\1n\1iBlinking \1n\1w\1hN:\1nNormal \1h\1g" + CENTERED_SQUARE + " \1n\1cChoose colors/attributes\1h\1g: \1c"); + console.clearline("\x01n"); + console.print("\x01cSpecial: \x01w\x01hH:\x01n\x01hHigh Intensity \x01wI:\x01n\x01iBlinking \x01n\x01w\x01hN:\x01nNormal \x01h\x01g" + CENTERED_SQUARE + " \x01n\x01cChoose colors/attributes\x01h\x01g: \x01c"); // Get the attribute codes from the user. Ideally, we'd use console.getkeys(), // but that outputs a CR at the end, which is undesirable. So instead, we call // getUserInputWithSetOfInputStrs (defined in SlyEdit_Misc.js). @@ -4574,9 +4573,9 @@ function doColorSelection(pTxtAttrs, pCurpos, pCurrentWordLength) // If the user entered some attributes, then set them in retObj.txtAttrs. if (attrCodeKeys.length > 0) { - retObj.txtAttrs = (attrCodeKeys.charAt(0) == "N" ? "" : "\1n"); + retObj.txtAttrs = (attrCodeKeys.charAt(0) == "N" ? "" : "\x01n"); for (var i = 0; i < attrCodeKeys.length; ++i) - retObj.txtAttrs += "\1" + attrCodeKeys.charAt(i); + retObj.txtAttrs += "\x01" + attrCodeKeys.charAt(i); } // Display the parts of the screen text that we covered up with the @@ -4628,15 +4627,14 @@ function drawInitialCrossPostSelBoxTopBorder(pTopLeft, pWidth, pBorderColor, pTe // pMsgSubs: Boolean - Whether or not this is being used for the message sub-boards. // If true, then this will output "Toggle" for the Enter action. Otherwise // (for message groups), this will output "Select" for the Enter action. -function drawInitialCrossPostSelBoxBottomBorder(pBottomLeft, pWidth, pBorderColor, - pMsgSubs) +function drawInitialCrossPostSelBoxBottomBorder(pBottomLeft, pWidth, pBorderColor, pMsgSubs) { console.gotoxy(pBottomLeft); console.print(pBorderColor + LOWER_LEFT_SINGLE + HORIZONTAL_SINGLE + HORIZONTAL_SINGLE + HORIZONTAL_SINGLE + HORIZONTAL_SINGLE + RIGHT_T_SINGLE + - "\1n\1h\1c\1b, \1c\1b, \1cPgUp\1b, \1cPgDn\1b, \1cHome\1b, \1cEnd\1b, \1cEnter\1y=\1b" - + (pMsgSubs ? "Toggle" : "Select") + ", \1cCtrl-C\1n\1c/\1hQ\1y=\1bEnd, \1c?\1y=\1bHelp\1n" + "\x01n\x01h\x01c"+ UP_ARROW + "\x01b, \x01c"+ DOWN_ARROW + "\x01b, \x01cPgUp\x01b, \x01cPgDn\x01b, \x01cHome\x01b, \x01cEnd\x01b, " + + (pMsgSubs ? "\x01cSpace\x01y=\x01bToggle" : "\x01cEnter\x01y=\x01bSelect") + ", \x01cCtrl-C\x01n\x01c/\x01hQ\x01y=\x01bEnd, \x01c?\x01y=\x01bHelp\x01n" + pBorderColor + LEFT_T_SINGLE); - len = pWidth - 71; + var len = pWidth - 71; for (var i = 0; i < len; ++i) console.print(HORIZONTAL_SINGLE); console.print(LOWER_RIGHT_SINGLE); @@ -4655,17 +4653,17 @@ function displayCrossPostHelp(selBoxUpperLeft, selBoxLowerRight) if (typeof(displayCrossPostHelp.helpLines) == "undefined") { displayCrossPostHelp.helpLines = new Array(); - displayCrossPostHelp.helpLines.push("\1n\1cCross-posing allows you to post a message in more than one message"); + displayCrossPostHelp.helpLines.push("\x01n\x01cCross-posing allows you to post a message in more than one message"); displayCrossPostHelp.helpLines.push("area. To select areas for cross-posting, do the following:"); - displayCrossPostHelp.helpLines.push(" \1h1. \1n\1cChoose a message group from the list with the Enter key."); + displayCrossPostHelp.helpLines.push(" \x01h1. \x01n\x01cChoose a message group from the list with the Enter key."); displayCrossPostHelp.helpLines.push(" Alternately, you may type the number of the message group."); - displayCrossPostHelp.helpLines.push(" \1h2. \1n\1cIn the list of message sub-boards that appears, toggle individual"); + displayCrossPostHelp.helpLines.push(" \x01h2. \x01n\x01cIn the list of message sub-boards that appears, toggle individual"); displayCrossPostHelp.helpLines.push(" sub-boards with the Enter key. Alternately, you may type the"); displayCrossPostHelp.helpLines.push(" number of the message sub-board."); displayCrossPostHelp.helpLines.push("Message sub-boards that are toggled for cross-posting will include a"); - displayCrossPostHelp.helpLines.push("check mark (" + gConfigSettings.genColors.crossPostChk + CHECK_CHAR + "\1n\1c) in the sub-board list. Initially, your current message"); + displayCrossPostHelp.helpLines.push("check mark (" + gConfigSettings.genColors.crossPostChk + CHECK_CHAR + "\x01n\x01c) in the sub-board list. Initially, your current message"); displayCrossPostHelp.helpLines.push("sub-board is enabled by default. Also, your current message group is"); - displayCrossPostHelp.helpLines.push("marked with an asterisk (" + gConfigSettings.genColors.crossPostMsgGrpMark + "*\1n\1c)."); + displayCrossPostHelp.helpLines.push("marked with an asterisk (" + gConfigSettings.genColors.crossPostMsgGrpMark + "*\x01n\x01c)."); displayCrossPostHelp.helpLines.push("To navigate the list, you may use the up & down arrow keys, PageUp and"); displayCrossPostHelp.helpLines.push("PageDown to go to the previous & next page, Home to go to the first"); displayCrossPostHelp.helpLines.push("page, and End to go to the last page. To end: Ctrl-C, Q, or ESC."); @@ -4676,7 +4674,7 @@ function displayCrossPostHelp(selBoxUpperLeft, selBoxLowerRight) var selBoxInnerHeight = selBoxLowerRight.y - selBoxUpperLeft.y - 1; var lineLen = 0; var screenRow = selBoxUpperLeft.y+1; - console.print("\1n"); + console.print("\x01n"); for (var i = 0; (i < displayCrossPostHelp.helpLines.length) && (screenRow < selBoxLowerRight.y); ++i) { console.gotoxy(selBoxUpperLeft.x+1, screenRow++); @@ -4696,7 +4694,7 @@ function displayCrossPostHelp(selBoxUpperLeft, selBoxLowerRight) if (screenRow < selBoxLowerRight.y) { var printfStr = "%-" + selBoxInnerWidth + "s"; - console.print("\1n"); + console.print("\x01n"); for (; screenRow < selBoxLowerRight.y; ++screenRow) { console.gotoxy(selBoxUpperLeft.x+1, screenRow); @@ -4751,11 +4749,11 @@ function doCrossPosting(pOriginalCurpos) // Position the cursor after the "Cross-posting: " text in the border and // write the "Choose group" text console.gotoxy(pSelBoxUpperLeft.x+17, pSelBoxUpperLeft.y); - console.print("\1n" + gConfigSettings.genColors.listBoxBorderText + "Choose group"); + console.print("\x01n" + gConfigSettings.genColors.listBoxBorderText + "Choose group"); // Re-write the border characters to overwrite the message group name grpDesc = msg_area.grp_list[pGrpIndex].description.substr(0, pSelBoxInnerWidth-25); // Write the updated border character(s) - console.print("\1n" + gConfigSettings.genColors.listBoxBorder + LEFT_T_SINGLE); + console.print("\x01n" + gConfigSettings.genColors.listBoxBorder + LEFT_T_SINGLE); if (grpDesc.length > 3) { var numChars = grpDesc.length - 3; @@ -4866,12 +4864,12 @@ function promptUserForCrossPostSubBoardCodes(pSelBoxUpperLeft, pSelBoxLowerRight // Set up an object containing the colors to use for the items in the group/sub-board lists var menuListColors = { - areaMark: "\1g\1h", - areaNum: "\1n\1w\1h", - desc: "\1n\1c", - areaNumHighlight: "\1w\1h", - descHighlight: "\1c", - bkgHighlight: "\1" + "4" + areaMark: "\x01g\x01h", + areaNum: "\x01n\x01w\x01h", + desc: "\x01n\x01c", + areaNumHighlight: "\x01w\x01h", + descHighlight: "\x01c", + bkgHighlight: "\x01" + "4" }; // Calculate the selection box width & height, with borders @@ -4880,8 +4878,8 @@ function promptUserForCrossPostSubBoardCodes(pSelBoxUpperLeft, pSelBoxLowerRight // Don't let the box's height be more than 17 characters. if (selBoxHeight > 17) { - selBoxLowerRight.y = selBoxUpperLeft.y + 16; // For a height of 17 characters - selBoxHeight = selBoxLowerRight.y - selBoxUpperLeft.y + 1; + pSelBoxLowerRight.y = pSelBoxUpperLeft.y + 16; // For a height of 17 characters + selBoxHeight = pSelBoxLowerRight.y - pSelBoxUpperLeft.y + 1; } // Inner size of the box (for the text menu items) var selBoxInnerWidth = selBoxWidth - 2; @@ -4910,11 +4908,13 @@ function promptUserForCrossPostSubBoardCodes(pSelBoxUpperLeft, pSelBoxLowerRight consolePauseWithoutText(); } else if (msgGrpMenu.lastUserInput == "Q" || msgGrpMenu.lastUserInput == CTRL_C) - { continueOn = false; - } else if (typeof(grpIdx) == "number") { + // Change the bottom box text to say Space=Toggle (instead of Enter=Select) + drawInitialCrossPostSelBoxBottomBorder({ x: pSelBoxUpperLeft.x, y: pSelBoxLowerRight.y }, + selBoxWidth, gConfigSettings.genColors.listBoxBorder, + true); // Get an object of selected sub-board indexes that we can pass to // the sub-board menu. var selectedItemIndexes = {}; @@ -4952,6 +4952,10 @@ function promptUserForCrossPostSubBoardCodes(pSelBoxUpperLeft, pSelBoxLowerRight for (var idx in selectedSubBoards) gCrossPostMsgSubs.add(selectedSubBoards[idx]); } + // Change the bottom box text back to say Enter=Select (instead of Space=Toggle) + drawInitialCrossPostSelBoxBottomBorder({ x: pSelBoxUpperLeft.x, y: pSelBoxLowerRight.y }, + selBoxWidth, gConfigSettings.genColors.listBoxBorder, + false); } else continueOn = false; @@ -5189,12 +5193,11 @@ function writeCantPostErrMsg(pX, pY, pSubBoardNum, pSelBoxWidth, pSelBoxInnerWid { var cantPostErrMsg = "You're not allowed to post in area " + pSubBoardNum + "."; console.gotoxy(pX+1, pY); - printf("\1n\1h\1y%-" + pSelBoxInnerWidth + "s", cantPostErrMsg); + printf("\x01n\x01h\x01y%-" + pSelBoxInnerWidth + "s", cantPostErrMsg); console.gotoxy(pX+cantPostErrMsg.length+1, pY); mswait(pPauseMS); // Refresh the bottom border of the selection box - drawInitialCrossPostSelBoxBottomBorder({ x: pX, y: pY }, pSelBoxWidth, - gConfigSettings.genColors.listBoxBorder, true); + drawInitialCrossPostSelBoxBottomBorder({ x: pX, y: pY }, pSelBoxWidth, gConfigSettings.genColors.listBoxBorder, true); console.gotoxy(pCurpos); } @@ -5291,7 +5294,7 @@ function listTextReplacements() if (gNumTxtReplacements == 0) { var originalCurpos = console.getxy(); - writeMsgOntBtmHelpLineWithPause("\1n\1h\1yThere are no text replacements.", ERRORMSG_PAUSE_MS); + writeMsgOntBtmHelpLineWithPause("\x01n\x01h\x01yThere are no text replacements.", ERRORMSG_PAUSE_MS); console.print(chooseEditColor()); // Make sure the edit color is correct console.gotoxy(originalCurpos); return; @@ -5328,13 +5331,13 @@ function listTextReplacements() // Construct the top & bottom border strings if they don't exist already. if (typeof(listTextReplacements.topBorder) == "undefined") { - listTextReplacements.topBorder = "\1n" + gConfigSettings.genColors.listBoxBorder - + UPPER_LEFT_SINGLE + "\1n" + gConfigSettings.genColors.listBoxBorderText + "Text" - + "\1n" + gConfigSettings.genColors.listBoxBorder; + listTextReplacements.topBorder = "\x01n" + gConfigSettings.genColors.listBoxBorder + + UPPER_LEFT_SINGLE + "\x01n" + gConfigSettings.genColors.listBoxBorderText + "Text" + + "\x01n" + gConfigSettings.genColors.listBoxBorder; for (var i = 0; i < (txtWidth-3); ++i) listTextReplacements.topBorder += HORIZONTAL_SINGLE; - listTextReplacements.topBorder += "\1n" + gConfigSettings.genColors.listBoxBorderText - + "Replacement" + "\1n" + gConfigSettings.genColors.listBoxBorder; + listTextReplacements.topBorder += "\x01n" + gConfigSettings.genColors.listBoxBorderText + + "Replacement" + "\x01n" + gConfigSettings.genColors.listBoxBorder; for (var i = 0; i < (txtWidth-11); ++i) listTextReplacements.topBorder += HORIZONTAL_SINGLE; listTextReplacements.topBorder += UPPER_RIGHT_SINGLE; @@ -5343,26 +5346,26 @@ function listTextReplacements() if (typeof(listTextReplacements.bottomBorder) == "undefined") { var numReplacementsStr = "Total: " + listTextReplacements.txtReplacementArr.length; - listTextReplacements.bottomBorder = "\1n" + gConfigSettings.genColors.listBoxBorder - + LOWER_LEFT_SINGLE + "\1n" + gConfigSettings.genColors.listBoxBorderText - + UP_ARROW + ", " + DOWN_ARROW + ", ESC/Ctrl-T/C=Close" + "\1n" + listTextReplacements.bottomBorder = "\x01n" + gConfigSettings.genColors.listBoxBorder + + LOWER_LEFT_SINGLE + "\x01n" + gConfigSettings.genColors.listBoxBorderText + + UP_ARROW + ", " + DOWN_ARROW + ", ESC/Ctrl-T/C=Close" + "\x01n" + gConfigSettings.genColors.listBoxBorder; var maxNumChars = boxInfo.width - numReplacementsStr.length - 28; for (var i = 0; i < maxNumChars; ++i) listTextReplacements.bottomBorder += HORIZONTAL_SINGLE; - listTextReplacements.bottomBorder += RIGHT_T_SINGLE + "\1n" - + gConfigSettings.genColors.listBoxBorderText + numReplacementsStr + "\1n" + listTextReplacements.bottomBorder += RIGHT_T_SINGLE + "\x01n" + + gConfigSettings.genColors.listBoxBorderText + numReplacementsStr + "\x01n" + gConfigSettings.genColors.listBoxBorder + LEFT_T_SINGLE; listTextReplacements.bottomBorder += LOWER_RIGHT_SINGLE; } // printf format strings for the list if (typeof(listTextReplacements.listFormatStr) == "undefined") { - listTextReplacements.listFormatStr = "\1n" + gConfigSettings.genColors.listBoxItemText + listTextReplacements.listFormatStr = "\x01n" + gConfigSettings.genColors.listBoxItemText + "%-" + txtWidth + "s %-" + txtWidth + "s"; } if (typeof(listTextReplacements.listFormatStrNormalAttr) == "undefined") - listTextReplacements.listFormatStrNormalAttr = "\1n%-" + txtWidth + "s %-" + txtWidth + "s"; + listTextReplacements.listFormatStrNormalAttr = "\x01n%-" + txtWidth + "s %-" + txtWidth + "s"; // Limit the box height to up to 12 lines. boxInfo.height = gNumTxtReplacements + 2; @@ -5378,7 +5381,7 @@ function listTextReplacements() console.gotoxy(boxInfo.topLeftX, boxInfo.topLeftY+boxInfo.height-1); console.print(listTextReplacements.bottomBorder); // Draw the side borders - console.print("\1n" + gConfigSettings.genColors.listBoxBorder); + console.print("\x01n" + gConfigSettings.genColors.listBoxBorder); for (var i = 0; i < boxInfo.height-2; ++i) { console.gotoxy(boxInfo.topLeftX, boxInfo.topLeftY+i+1); @@ -5433,9 +5436,9 @@ function listTextReplacements() // Update the page number in the top border of the box. console.gotoxy(pageNumTxtStartX, boxInfo.topLeftY); - console.print("\1n" + gConfigSettings.genColors.listBoxBorder + RIGHT_T_SINGLE); - printf("\1n" + gConfigSettings.genColors.listBoxBorderText + "Page %4d of %4d", pageNum+1, numPages); - console.print("\1n" + gConfigSettings.genColors.listBoxBorder + LEFT_T_SINGLE); + console.print("\x01n" + gConfigSettings.genColors.listBoxBorder + RIGHT_T_SINGLE); + printf("\x01n" + gConfigSettings.genColors.listBoxBorderText + "Page %4d of %4d", pageNum+1, numPages); + console.print("\x01n" + gConfigSettings.genColors.listBoxBorder + LEFT_T_SINGLE); // Just for sane appearance: Move the cursor to the first character of // the first row and make it the color for the text replacements. @@ -5444,7 +5447,7 @@ function listTextReplacements() } // Get a key from the user (upper-case) and take action based upon it. - userInput = getUserKey(K_UPPER|K_NOCRLF|K_NOSPIN, gConfigSettings); + var userInput = getUserKey(K_UPPER|K_NOCRLF|K_NOSPIN, gConfigSettings); switch (userInput) { case KEY_UP: @@ -5526,13 +5529,13 @@ function doUserSettings(pCurpos, pReturnCursorToOriginalPos) gConfigSettings, false, true); optionBox.addInputLoopExitKey(CTRL_U); // Update the bottom help text to be more specific to the user settings box - var bottomBorderText = "\1n\1h\1c\1b, \1c\1b, \1cEnter\1y=\1bSelect\1n\1c/\1h\1btoggle, " - + "\1cESC\1n\1c/\1hQ\1n\1c/\1hCtrl-U\1y=\1bClose"; + var bottomBorderText = "\x01n\x01h\x01c"+ UP_ARROW + "\x01b, \x01c"+ DOWN_ARROW + "\x01b, \x01cEnter\x01y=\x01bSelect\x01n\x01c/\x01h\x01btoggle, " + + "\x01cESC\x01n\x01c/\x01hQ\x01n\x01c/\x01hCtrl-U\x01y=\x01bClose"; // This one contains the page navigation keys.. Don't really need to show those, // since the settings box only has one page right now: - /*var bottomBorderText = "\1n\1h\1c\1b, \1c\1b, \1cN\1y)\1bext, \1cP\1y)\1brev, " - + "\1cF\1y)\1birst, \1cL\1y)\1bast, \1cEnter\1y=\1bSelect, " - + "\1cESC\1n\1c/\1hQ\1n\1c/\1hCtrl-U\1y=\1bClose";*/ + /*var bottomBorderText = "\x01n\x01h\x01c"+ UP_ARROW + "\x01b, \x01c"+ DOWN_ARROW + "\x01b, \x01cN\x01y)\x01bext, \x01cP\x01y)\x01brev, " + + "\x01cF\x01y)\x01birst, \x01cL\x01y)\x01bast, \x01cEnter\x01y=\x01bSelect, " + + "\x01cESC\x01n\x01c/\x01hQ\x01n\x01c/\x01hCtrl-U\x01y=\x01bClose";*/ optionBox.setBottomBorderText(bottomBorderText, true, false); @@ -5645,7 +5648,7 @@ function doUserSettings(pCurpos, pReturnCursorToOriginalPos) optionBox.refreshOnScreen(optionBox.chosenTextItemIndex); } else - writeWithPause(1, console.screen_rows, "\1y\1hThere are no dictionaries!\1n", ERRORMSG_PAUSE_MS); + writeWithPause(1, console.screen_rows, "\x01y\x01hThere are no dictionaries!\x01n", ERRORMSG_PAUSE_MS); break; default: break; @@ -5672,7 +5675,7 @@ function doUserSettings(pCurpos, pReturnCursorToOriginalPos) if (settingsChanged) { if (!WriteUserSettingsFile(gUserSettings)) - writeMsgOntBtmHelpLineWithPause("\1n\1y\1hFailed to save settings!\1n", ERRORMSG_PAUSE_MS); + writeMsgOntBtmHelpLineWithPause("\x01n\x01y\x01hFailed to save settings!\x01n", ERRORMSG_PAUSE_MS); } // We're done, so erase the option box. @@ -5730,9 +5733,9 @@ function doUserDictionaryLanguageSelection(pBoxTopLeftX, pBoxTopLeftY, pBoxWidth right: VERTICAL_SINGLE }); dictMenu.scrollbarEnabled = true; - dictMenu.colors.borderColor = "\1g"; - dictMenu.topBorderText = "\1b\1hSelect dictionary languages (\1cEnter\1g: \1bChoose, \1cSpacebar\1g: \1bMulti-select\1b)\1n"; - dictMenu.bottomBorderText = "\1c\1hESC\1y/\1cQ\1g: \1bQuit\1n"; + dictMenu.colors.borderColor = "\x01g"; + dictMenu.topBorderText = "\x01b\x01hSelect dictionary languages (\x01cEnter\x01g: \x01bChoose, \x01cSpacebar\x01g: \x01bMulti-select\x01b)\x01n"; + dictMenu.bottomBorderText = "\x01c\x01hESC\x01y/\x01cQ\x01g: \x01bQuit\x01n"; var userChoice = dictMenu.GetVal(true, selectedItemIndexes); if (userChoice != null) { @@ -5773,9 +5776,9 @@ function doTaglineSelection() // Set up the menu var taglineMenu = new DDLightbarMenu(gEditLeft, boxTopRow, gEditWidth, boxHeight); - taglineMenu.colors.borderColor = "\1g"; - taglineMenu.colors.itemColor = "\1n\1c"; - taglineMenu.colors.selectedItemColor = "\1n\1w\1h\1" + "4"; + taglineMenu.colors.borderColor = "\x01g"; + taglineMenu.colors.itemColor = "\x01n\x01c"; + taglineMenu.colors.selectedItemColor = "\x01n\x01w\x01h\x01" + "4"; taglineMenu.borderEnabled = true; taglineMenu.SetBorderChars({ upperLeft: UPPER_LEFT_SINGLE, @@ -5787,10 +5790,10 @@ function doTaglineSelection() left: VERTICAL_SINGLE, right: VERTICAL_SINGLE }); - taglineMenu.topBorderText = "\1n\1g" + RIGHT_T_SINGLE + "\1b\1hTaglines\1n\1g" + LEFT_T_SINGLE; - taglineMenu.bottomBorderText = "\1n\1h\1c\1b, \1c\1b, \1cPgUp\1b/\1cPgDn\1b, " - + "\1cF\1y)\1birst, \1cL\1y)\1bast, \1cHOME\1b, \1cEND\1b, \1cEnter\1y=\1bSelect, " - + "\1cR\1y)\1bandom, \1cESC\1n\1c/\1h\1cQ\1y=\1bEnd"; + taglineMenu.topBorderText = "\x01n\x01g" + RIGHT_T_SINGLE + "\x01b\x01hTaglines\x01n\x01g" + LEFT_T_SINGLE; + taglineMenu.bottomBorderText = "\x01n\x01h\x01c"+ UP_ARROW + "\x01b, \x01c"+ DOWN_ARROW + "\x01b, \x01cPgUp\x01b/\x01cPgDn\x01b, " + + "\x01cF\x01y)\x01birst, \x01cL\x01y)\x01bast, \x01cHOME\x01b, \x01cEND\x01b, \x01cEnter\x01y=\x01bSelect, " + + "\x01cR\x01y)\x01bandom, \x01cESC\x01n\x01c/\x01h\x01cQ\x01y=\x01bEnd"; taglineMenu.additionalQuitKeys = "RrQqFfLl"; taglineMenu.wrapNavigation = true; taglineMenu.ampersandHotkeysInItems = false; @@ -6022,7 +6025,7 @@ function letUserUploadMessageFile(pCurpos) var uploadedMessage = false; if (promptYesNo("Upload a mesage", true, "Upload message", true, true)) { - console.print("\1n"); + console.print("\x01n"); console.gotoxy(1, console.screen_rows); console.crlf(); var msgFilename = system.node_dir + "uploadedMsg.txt"; @@ -6064,13 +6067,13 @@ function letUserUploadMessageFile(pCurpos) } else { - console.print("\1y\1hFailed to read the message file!\1n\r\n\1p"); + console.print("\x01y\x01hFailed to read the message file!\x01n\r\n\x01p"); fpRedrawScreen(gEditLeft, gEditRight, gEditTop, gEditBottom, gTextAttrs, gInsertMode, gUseQuotes, 0, displayEditLines); } } else { - console.print("\1y\1hUpload failed!\1n\r\n\1p"); + console.print("\x01y\x01hUpload failed!\x01n\r\n\x01p"); fpRedrawScreen(gEditLeft, gEditRight, gEditTop, gEditBottom, gTextAttrs, gInsertMode, gUseQuotes, 0, displayEditLines); } } diff --git a/exec/SlyEdit_DCTStuff.js b/exec/SlyEdit_DCTStuff.js index dcc4e9142494a0e9e733d9f3abfff7c74757cf57..19f2660981fd898a127c7fd24b10f92a6dd89cf0 100644 --- a/exec/SlyEdit_DCTStuff.js +++ b/exec/SlyEdit_DCTStuff.js @@ -1,5 +1,3 @@ -// $Id: SlyEdit_DCTStuff.js,v 1.21 2019/06/06 03:50:47 nightfox Exp $ - /* This file contains DCTEdit-specific functions for SlyEdit. * * Author: Eric Oulashin (AKA Nightfox) @@ -16,6 +14,8 @@ * 2021-12-11 Eric Oulashin Updated the quote window bottom border text */ +"use strict"; + if (typeof(require) === "function") { require("sbbsdefs.js", "K_NOCRLF"); @@ -113,7 +113,7 @@ function redrawScreen_DCTStyle(pEditLeft, pEditRight, pEditTop, pEditBottom, pEd // Calculate the width of the from name field: 28 characters, based // on an 80-column screen width. var fieldWidth = (console.screen_columns * (28/80)).toFixed(0); - screenText = gFromName.substr(0, fieldWidth); + var screenText = gFromName.substr(0, fieldWidth); console.print(randomTwoColorString(VERTICAL_SINGLE, gConfigSettings.DCTColors.TopBorderColor1, gConfigSettings.DCTColors.TopBorderColor2) + " " + gConfigSettings.DCTColors.TopLabelColor + "From " + @@ -235,13 +235,13 @@ function redrawScreen_DCTStyle(pEditLeft, pEditRight, pEditTop, pEditBottom, pEd function refreshSubjectOnScreen_DCTStyle(pX, pY, pLength, pText) { - console.print("\1n" + gConfigSettings.DCTColors.TopSubjColor); + console.print("\x01n" + gConfigSettings.DCTColors.TopSubjColor); console.gotoxy(pX, pY); //printf("%-" + pLength + "s", pText.substr(0, pLength)); // Ensure the text is no longer than the field width var subj = pText.substr(0, pLength); console.print(subj); - console.print("\1n" + gConfigSettings.DCTColors.TopSubjFillColor); + console.print("\x01n" + gConfigSettings.DCTColors.TopSubjFillColor); var fieldWidth = pLength - subj.length; for (var i = 0; i < fieldWidth; ++i) console.print(DOT_CHAR); @@ -344,30 +344,30 @@ function DisplayBottomHelpLine_DCTStyle(pLineNum, pUsingQuotes) + "[" + gConfigSettings.DCTColors.BottomHelpKeys + "CTRL" + gConfigSettings.DCTColors.BottomHelpFill + DOT_CHAR + gConfigSettings.DCTColors.BottomHelpKeys + "Z" - + gConfigSettings.DCTColors.BottomHelpBrackets + "]\1n " - + gConfigSettings.DCTColors.BottomHelpKeyDesc + "Save\1n " + + gConfigSettings.DCTColors.BottomHelpBrackets + "]\x01n " + + gConfigSettings.DCTColors.BottomHelpKeyDesc + "Save\x01n " + gConfigSettings.DCTColors.BottomHelpBrackets + "[" + gConfigSettings.DCTColors.BottomHelpKeys + "CTRL" + gConfigSettings.DCTColors.BottomHelpFill + DOT_CHAR + gConfigSettings.DCTColors.BottomHelpKeys + "A" - + gConfigSettings.DCTColors.BottomHelpBrackets + "]\1n " + + gConfigSettings.DCTColors.BottomHelpBrackets + "]\x01n " + gConfigSettings.DCTColors.BottomHelpKeyDesc + "Abort"; // If we can allow message quoting, then add a text to show Ctrl-Q for // quoting. if (pUsingQuotes) { - DisplayBottomHelpLine_DCTStyle.helpText += "\1n " + DisplayBottomHelpLine_DCTStyle.helpText += "\x01n " + gConfigSettings.DCTColors.BottomHelpBrackets + "[" + gConfigSettings.DCTColors.BottomHelpKeys + "CTRL" + gConfigSettings.DCTColors.BottomHelpFill + DOT_CHAR + gConfigSettings.DCTColors.BottomHelpKeys + "Q" - + gConfigSettings.DCTColors.BottomHelpBrackets + "]\1n " + + gConfigSettings.DCTColors.BottomHelpBrackets + "]\x01n " + gConfigSettings.DCTColors.BottomHelpKeyDesc + "Quote"; } - DisplayBottomHelpLine_DCTStyle.helpText += "\1n " + DisplayBottomHelpLine_DCTStyle.helpText += "\x01n " + gConfigSettings.DCTColors.BottomHelpBrackets + "[" + gConfigSettings.DCTColors.BottomHelpKeys + "ESC" - + gConfigSettings.DCTColors.BottomHelpBrackets + "]\1n " + + gConfigSettings.DCTColors.BottomHelpBrackets + "]\x01n " + gConfigSettings.DCTColors.BottomHelpKeyDesc + "Menu"; // Center the text by padding it in the front with spaces. This is done instead // of using console.center() because console.center() will output a newline, @@ -383,7 +383,7 @@ function DisplayBottomHelpLine_DCTStyle(pLineNum, pUsingQuotes) lineNum = pLineNum; console.gotoxy(1, lineNum); console.print(DisplayBottomHelpLine_DCTStyle.helpText); - console.print("\1n"); + console.print("\x01n"); console.cleartoeol(); } @@ -455,7 +455,7 @@ function DrawQuoteWindowBottomBorder_DCTStyle(pEditLeft, pEditRight) + HORIZONTAL_SINGLE + HORIZONTAL_SINGLE + gConfigSettings.DCTColors.QuoteWinBorderTextColor + "[" + UP_ARROW + "/" + DOWN_ARROW + "/PgUp/PgDn/Home/End] Scroll" + gConfigSettings.DCTColors.QuoteWinBorderColor + HORIZONTAL_SINGLE - + HORIZONTAL_SINGLE + gConfigSettings.DCTColors.QuoteWinBorderTextColor + + HORIZONTAL_SINGLE + gConfigSettings.DCTColors.QuoteWinBorderTextColor; /* + "[" + UP_ARROW + "/" + DOWN_ARROW + "/PgUp/PgDn] Scroll" + gConfigSettings.DCTColors.QuoteWinBorderColor + HORIZONTAL_SINGLE @@ -642,9 +642,9 @@ function displayTime_DCTStyle(pTimeStr) console.gotoxy(curposX, 3); if (pTimeStr == null) - console.print("n" + gConfigSettings.DCTColors.TopTimeColor + getCurrentTimeStr()); + console.print("\x01n" + gConfigSettings.DCTColors.TopTimeColor + getCurrentTimeStr()); else - console.print("n" + gConfigSettings.DCTColors.TopTimeColor + pTimeStr); + console.print("\x01n" + gConfigSettings.DCTColors.TopTimeColor + pTimeStr); } // Displays the number of minutes remaining on the screen. @@ -703,7 +703,7 @@ function doDCTESCMenu(pEditLeft, pEditRight, pEditTop, pDisplayMessageRectangle, gConfigSettings.DCTColors.SelectedMenuLabelBorders + THIN_RECTANGLE_LEFT); } else - console.print("\1n " + gConfigSettings.DCTColors.UnselectedMenuLabelText + "File\1n "); + console.print("\x01n " + gConfigSettings.DCTColors.UnselectedMenuLabelText + "File\x01n "); // Edit console.gotoxy(pItemPositions.editX, pItemPositions.mainMenuY); if (pHighlightedItemNum == 1) @@ -713,7 +713,7 @@ function doDCTESCMenu(pEditLeft, pEditRight, pEditTop, pDisplayMessageRectangle, gConfigSettings.DCTColors.SelectedMenuLabelBorders + THIN_RECTANGLE_LEFT); } else - console.print("\1n " + gConfigSettings.DCTColors.UnselectedMenuLabelText + "Edit\1n "); + console.print("\x01n " + gConfigSettings.DCTColors.UnselectedMenuLabelText + "Edit\x01n "); // SysOp if (pIsSysop) { @@ -725,7 +725,7 @@ function doDCTESCMenu(pEditLeft, pEditRight, pEditTop, pDisplayMessageRectangle, gConfigSettings.DCTColors.SelectedMenuLabelBorders + THIN_RECTANGLE_LEFT); } else - console.print("\1n " + gConfigSettings.DCTColors.UnselectedMenuLabelText + "SysOp\1n "); + console.print("\x01n " + gConfigSettings.DCTColors.UnselectedMenuLabelText + "SysOp\x01n "); } // Help console.gotoxy(pItemPositions.helpX, pItemPositions.mainMenuY); @@ -736,7 +736,7 @@ function doDCTESCMenu(pEditLeft, pEditRight, pEditTop, pDisplayMessageRectangle, gConfigSettings.DCTColors.SelectedMenuLabelBorders + THIN_RECTANGLE_LEFT); } else - console.print("\1n " + gConfigSettings.DCTColors.UnselectedMenuLabelText + "Help\1n "); + console.print("\x01n " + gConfigSettings.DCTColors.UnselectedMenuLabelText + "Help\x01n "); // Display the menu (and capture the return object so that we can // also return it here). @@ -756,14 +756,18 @@ function doDCTESCMenu(pEditLeft, pEditRight, pEditTop, pDisplayMessageRectangle, // Only create this object once. if (typeof(doDCTESCMenu.mainMenuItemPositions) == "undefined") { - doDCTESCMenu.mainMenuItemPositions = new Object(); - // Vertical position on the screen for the main menu items - doDCTESCMenu.mainMenuItemPositions.mainMenuY = pEditTop - 1; - // Horizontal position of the "File" text - doDCTESCMenu.mainMenuItemPositions.fileX = gEditLeft + 5; - // Horizontal position of the "Edit" text + doDCTESCMenu.mainMenuItemPositions = { + // Vertical position on the screen for the main menu items + mainMenuY: pEditTop - 1, + // Horizontal position of the "File" text + fileX: gEditLeft + 5, + // Horizontal position of the "Edit" text + editX: 0, + // Horizontal position of the "SysOp" text + sysopX: 0, + helpX: 0 + }; doDCTESCMenu.mainMenuItemPositions.editX = doDCTESCMenu.mainMenuItemPositions.fileX + 11; - // Horizontal position of the "SysOp" text doDCTESCMenu.mainMenuItemPositions.sysopX = doDCTESCMenu.mainMenuItemPositions.editX + 11; // Horizontal position of of the "Help" text if (pIsSysop) @@ -781,7 +785,7 @@ function doDCTESCMenu(pEditLeft, pEditRight, pEditTop, pDisplayMessageRectangle, // Set up the menu objects. Only create these objects once. if (typeof(doDCTESCMenu.allMenus) == "undefined") { - doDCTESCMenu.allMenus = new Array(); + doDCTESCMenu.allMenus = []; // File menu doDCTESCMenu.allMenus[fileMenuNum] = new DCTMenu(doDCTESCMenu.mainMenuItemPositions.fileX, doDCTESCMenu.mainMenuItemPositions.mainMenuY+1); doDCTESCMenu.allMenus[fileMenuNum].addItem("&Save Ctrl-Z", DCTMENU_FILE_SAVE); @@ -1080,14 +1084,15 @@ function DCTMenuItem() // pTopLeftY: The upper-left screen row function DCTMenu(pTopLeftX, pTopLeftY) { - this.colors = new Object(); - // Unselected item colors - this.colors.unselected = "n7k"; - // Selected item colors - this.colors.selected = "nw"; - // Other colors - this.colors.hotkey = "hw"; - this.colors.border = "n7k"; + this.colors = { + // Unselected item colors + unselected: "\x01n\x01" + "7\x01k", + // Selected item colors + selected: "\x01n\x01w", + // Other colors + hotkey: "\x01h\x01w", + border: "\x01n\x01" + "+\x01k" + }; this.topLeftX = 1; // Upper-left screen column if ((pTopLeftX != null) && (pTopLeftX > 0) && (pTopLeftX <= console.screen_columns)) @@ -1100,16 +1105,16 @@ function DCTMenu(pTopLeftX, pTopLeftY) this.selectedItemIndex = 0; // this.menuItems will contain DCTMenuItem objects. - this.menuItems = new Array(); + this.menuItems = []; // hotkeyRetvals is an array, indexed by hotkey, that contains // the return values for each hotkey. - this.hotkeyRetvals = new Array(); + this.hotkeyRetvals = []; // exitLoopKeys will contain keys that will exit the input loop // when pressed by the user, so that calling code can catch them. // It's indexed by the key, and the value is the return code that // should be returned for that key. - this.exitLoopKeys = new Array(); + this.exitLoopKeys = []; // Border style: "single" or "double" this.borderStyle = "single"; @@ -1119,7 +1124,7 @@ function DCTMenu(pTopLeftX, pTopLeftY) this.clearSpaceAroundMenu = false; // clearSpaceColor controls which color to use when drawing the // clear space around the menu. - this.clearSpaceColor = "n"; + this.clearSpaceColor = "\x01n"; // clearSpaceTopText specifies text to display above the top of the // menu when clearing space around it. this.clearSpaceTopText = ""; @@ -1272,237 +1277,240 @@ function DCTMenu_DisplayItem(pItemIndex, pPrintBorders) // userInput: The last user input function DCTMenu_DoInputLoop() { - var returnObj = new Object(); - returnObj.returnVal = -1; - returnObj.userInput = ""; - - // If clearSpaceAroundMenu is true, then draw a blank row - // above the menu. - if (this.clearSpaceAroundMenu && (this.topLeftY > 1)) - { - // If there is room, output a space to the left, diagonal - // from the top-left corner of the menu. - if (this.topLeftX > 1) - { - console.gotoxy(this.topLeftX-1, this.topLeftY-1); - console.print(this.clearSpaceColor + " "); - } - else - console.gotoxy(this.topLeftX, this.topLeftY-1); - - // Output this.clearSpaceTopText - console.print(this.clearSpaceTopText); - // Output the rest of the blank space - var textLen = strip_ctrl(this.clearSpaceTopText).length; - if (textLen < this.width) - { - var numSpaces = this.width - textLen; - if (this.topLeftX + this.width < console.screen_columns) - ++numSpaces; - for (var i = 0; i < numSpaces; ++i) - console.print(this.clearSpaceColor + " "); - } - } + var returnObj = { + returnVal: -1, + userInput: "" + }; + + // If clearSpaceAroundMenu is true, then draw a blank row + // above the menu. + if (this.clearSpaceAroundMenu && (this.topLeftY > 1)) + { + // If there is room, output a space to the left, diagonal + // from the top-left corner of the menu. + if (this.topLeftX > 1) + { + console.gotoxy(this.topLeftX-1, this.topLeftY-1); + console.print(this.clearSpaceColor + " "); + } + else + console.gotoxy(this.topLeftX, this.topLeftY-1); - // Before drawing the top border, if clearSpaceAroundMenu is - // true, put space before the border. - if (this.clearSpaceAroundMenu && (this.topLeftY > 1)) - { - console.gotoxy(this.topLeftX-1, this.topLeftY); - console.print(this.clearSpaceColor + " "); - } - else - console.gotoxy(this.topLeftX, this.topLeftY); - // Draw the top border - var innerWidth = this.width - 2; - if (this.borderStyle == "single") - { - console.print(this.colors.border + UPPER_LEFT_SINGLE); - for (var i = 0; i < innerWidth; ++i) - console.print(HORIZONTAL_SINGLE); - console.print(this.colors.border + UPPER_RIGHT_SINGLE); - } - else if (this.borderStyle == "double") - { - console.print(this.colors.border + UPPER_LEFT_DOUBLE); - for (var i = 0; i < innerWidth; ++i) - console.print(HORIZONTAL_DOUBLE); - console.print(this.colors.border + UPPER_RIGHT_DOUBLE); - } - // If clearSpaceAroundMenu is true, then put a space after the border. - if (this.clearSpaceAroundMenu && (this.topLeftX + this.width < console.screen_columns)) - console.print(this.clearSpaceColor + " "); + // Output this.clearSpaceTopText + console.print(this.clearSpaceTopText); + // Output the rest of the blank space + var textLen = strip_ctrl(this.clearSpaceTopText).length; + if (textLen < this.width) + { + var numSpaces = this.width - textLen; + if (this.topLeftX + this.width < console.screen_columns) + ++numSpaces; + for (var i = 0; i < numSpaces; ++i) + console.print(this.clearSpaceColor + " "); + } + } - // Print the menu items (and side spaces outside the menu if - // clearSpaceAroundMenu is true). - var itemColor = ""; - for (var i = 0; i < this.menuItems.length; ++i) - { - if (this.clearSpaceAroundMenu && (this.topLeftX > 1)) - { - console.gotoxy(this.topLeftX-1, this.topLeftY + i + 1); - console.print(this.clearSpaceColor + " "); - } + // Before drawing the top border, if clearSpaceAroundMenu is + // true, put space before the border. + if (this.clearSpaceAroundMenu && (this.topLeftY > 1)) + { + console.gotoxy(this.topLeftX-1, this.topLeftY); + console.print(this.clearSpaceColor + " "); + } + else + console.gotoxy(this.topLeftX, this.topLeftY); + // Draw the top border + var innerWidth = this.width - 2; + if (this.borderStyle == "single") + { + console.print(this.colors.border + UPPER_LEFT_SINGLE); + for (var i = 0; i < innerWidth; ++i) + console.print(HORIZONTAL_SINGLE); + console.print(this.colors.border + UPPER_RIGHT_SINGLE); + } + else if (this.borderStyle == "double") + { + console.print(this.colors.border + UPPER_LEFT_DOUBLE); + for (var i = 0; i < innerWidth; ++i) + console.print(HORIZONTAL_DOUBLE); + console.print(this.colors.border + UPPER_RIGHT_DOUBLE); + } + // If clearSpaceAroundMenu is true, then put a space after the border. + if (this.clearSpaceAroundMenu && (this.topLeftX + this.width < console.screen_columns)) + console.print(this.clearSpaceColor + " "); + + // Print the menu items (and side spaces outside the menu if + // clearSpaceAroundMenu is true). + var itemColor = ""; + for (var i = 0; i < this.menuItems.length; ++i) + { + if (this.clearSpaceAroundMenu && (this.topLeftX > 1)) + { + console.gotoxy(this.topLeftX-1, this.topLeftY + i + 1); + console.print(this.clearSpaceColor + " "); + } - this.displayItem(i, true); + this.displayItem(i, true); - if (this.clearSpaceAroundMenu && (this.topLeftX + this.width < console.screen_columns)) - { - console.gotoxy(this.topLeftX + this.width, this.topLeftY + i + 1); - console.print(this.clearSpaceColor + " "); - } - } + if (this.clearSpaceAroundMenu && (this.topLeftX + this.width < console.screen_columns)) + { + console.gotoxy(this.topLeftX + this.width, this.topLeftY + i + 1); + console.print(this.clearSpaceColor + " "); + } + } - // Before drawing the bottom border, if clearSpaceAroundMenu is - // true, put space before the border. - if (this.clearSpaceAroundMenu && (this.topLeftY > 1)) - { - console.gotoxy(this.topLeftX - 1, this.topLeftY + this.height - 1); - console.print(this.clearSpaceColor + " "); - } - else - console.gotoxy(this.topLeftX, this.topLeftY + this.height - 1); - // Draw the bottom border - if (this.borderStyle == "single") - { - console.print(this.colors.border + LOWER_LEFT_SINGLE); - for (var i = 0; i < innerWidth; ++i) - console.print(HORIZONTAL_SINGLE); - console.print(LOWER_RIGHT_SINGLE); - } - else if (this.borderStyle == "double") - { - console.print(this.colors.border + LOWER_LEFT_DOUBLE); - for (var i = 0; i < innerWidth; ++i) - console.print(HORIZONTAL_DOUBLE); - console.print(LOWER_RIGHT_DOUBLE); - } - // If clearSpaceAroundMenu is true, then put a space after the border. - if (this.clearSpaceAroundMenu && (this.topLeftX + this.width < console.screen_columns)) - console.print(this.clearSpaceColor + " "); + // Before drawing the bottom border, if clearSpaceAroundMenu is + // true, put space before the border. + if (this.clearSpaceAroundMenu && (this.topLeftY > 1)) + { + console.gotoxy(this.topLeftX - 1, this.topLeftY + this.height - 1); + console.print(this.clearSpaceColor + " "); + } + else + console.gotoxy(this.topLeftX, this.topLeftY + this.height - 1); + // Draw the bottom border + if (this.borderStyle == "single") + { + console.print(this.colors.border + LOWER_LEFT_SINGLE); + for (var i = 0; i < innerWidth; ++i) + console.print(HORIZONTAL_SINGLE); + console.print(LOWER_RIGHT_SINGLE); + } + else if (this.borderStyle == "double") + { + console.print(this.colors.border + LOWER_LEFT_DOUBLE); + for (var i = 0; i < innerWidth; ++i) + console.print(HORIZONTAL_DOUBLE); + console.print(LOWER_RIGHT_DOUBLE); + } + // If clearSpaceAroundMenu is true, then put a space after the border. + if (this.clearSpaceAroundMenu && (this.topLeftX + this.width < console.screen_columns)) + console.print(this.clearSpaceColor + " "); - // If clearSpaceAroundMenu is true, then draw a blank row - // below the menu. - if (this.clearSpaceAroundMenu && (this.topLeftY + this.height < console.screen_rows)) - { - var numSpaces = this.width + 2; - if (this.topLeftX > 1) - console.gotoxy(this.topLeftX-1, this.topLeftY + this.height); - else - { - console.gotoxy(this.topLeftX, this.topLeftY + this.height); - --numSpaces; - } + // If clearSpaceAroundMenu is true, then draw a blank row + // below the menu. + if (this.clearSpaceAroundMenu && (this.topLeftY + this.height < console.screen_rows)) + { + var numSpaces = this.width + 2; + if (this.topLeftX > 1) + console.gotoxy(this.topLeftX-1, this.topLeftY + this.height); + else + { + console.gotoxy(this.topLeftX, this.topLeftY + this.height); + --numSpaces; + } - if (this.topLeftX + this.width >= console.screen_columns) - --numSpaces; + if (this.topLeftX + this.width >= console.screen_columns) + --numSpaces; - for (var i = 0; i < numSpaces; ++i) - console.print(this.clearSpaceColor + " "); - } + for (var i = 0; i < numSpaces; ++i) + console.print(this.clearSpaceColor + " "); + } - // Place the cursor on the line of the selected item - console.gotoxy(this.topLeftX + 1, this.topLeftY + this.selectedItemIndex + 1); + // Place the cursor on the line of the selected item + console.gotoxy(this.topLeftX + 1, this.topLeftY + this.selectedItemIndex + 1); - // Keep track of the current cursor position - var curpos = new Object(); - curpos.x = this.topLeftX + 1; - curpos.y = this.topLeftY + this.selectedItemIndex + 1; + // Keep track of the current cursor position + var curpos = { + x: this.topLeftX + 1, + y: this.topLeftY + this.selectedItemIndex + 1 + }; - // Input loop - const topItemLineNumber = this.topLeftY + 1; - const bottomItemLineNumber = this.topLeftY + this.height - 1; - var continueOn = true; - while (continueOn) - { - // Get a key, (time out after the selected time), and take appropriate action. + // Input loop + const topItemLineNumber = this.topLeftY + 1; + const bottomItemLineNumber = this.topLeftY + this.height - 1; + var continueOn = true; + while (continueOn) + { + // Get a key, (time out after the selected time), and take appropriate action. returnObj.userInput = getUserKey(K_UPPER|K_NOECHO|K_NOCRLF|K_NOSPIN, gConfigSettings); // If the user input is blank, then the input timed out, and we should quit. if (returnObj.userInput == "") { - continueOn = false; - break; + continueOn = false; + break; } - // Take appropriate action, depending on the user's keypress. - switch (returnObj.userInput) - { - case KEY_ENTER: - // Set returnObj.returnVal to the currently-selected item's returnVal, - // and exit the input loop. - returnObj.returnVal = this.menuItems[this.selectedItemIndex].returnVal; - continueOn = false; - break; - case KEY_UP: - // Go up one item - if (this.menuItems.length > 1) - { - // If we're below the top menu item, then go up one item. Otherwise, - // go to the last menu item. - var oldIndex = this.selectedItemIndex; - if ((curpos.y > topItemLineNumber) && (this.selectedItemIndex > 0)) - { - --curpos.y; - --this.selectedItemIndex; - } - else - { - curpos.y = bottomItemLineNumber - 1; - this.selectedItemIndex = this.menuItems.length - 1; - } - // Refresh the items on the screen so that the item colors - // are updated. - this.displayItem(oldIndex, false); - this.displayItem(this.selectedItemIndex, false); - } - break; - case KEY_DOWN: - // Go down one item - if (this.menuItems.length > 1) - { - // If we're above the bottom menu item, then go down one item. Otherwise, - // go to the first menu item. - var oldIndex = this.selectedItemIndex; - if ((curpos.y < bottomItemLineNumber) && (this.selectedItemIndex < this.menuItems.length - 1)) - { - ++curpos.y; - ++this.selectedItemIndex; - } - else - { - curpos.y = this.topLeftY + 1; - this.selectedItemIndex = 0; - } - // Refresh the items on the screen so that the item colors - // are updated. - this.displayItem(oldIndex, false); - this.displayItem(this.selectedItemIndex, false); - } - break; - case KEY_ESC: - continueOn = false; - break; - default: - // If the user's input is one of the hotkeys, then stop the - // input loop and return with the return code for the hotkey. - if (typeof(this.hotkeyRetvals[returnObj.userInput]) != "undefined") - { - returnObj.returnVal = this.hotkeyRetvals[returnObj.userInput]; - continueOn = false; - } - // If the user's input is one of the loop-exit keys, then stop - // the input loop. - else if (typeof(this.exitLoopKeys[returnObj.userInput]) != "undefined") - { - returnObj.returnVal = this.exitLoopKeys[returnObj.userInput]; - continueOn = false; - } - break; - } - } + // Take appropriate action, depending on the user's keypress. + switch (returnObj.userInput) + { + case KEY_ENTER: + // Set returnObj.returnVal to the currently-selected item's returnVal, + // and exit the input loop. + returnObj.returnVal = this.menuItems[this.selectedItemIndex].returnVal; + continueOn = false; + break; + case KEY_UP: + // Go up one item + if (this.menuItems.length > 1) + { + // If we're below the top menu item, then go up one item. Otherwise, + // go to the last menu item. + var oldIndex = this.selectedItemIndex; + if ((curpos.y > topItemLineNumber) && (this.selectedItemIndex > 0)) + { + --curpos.y; + --this.selectedItemIndex; + } + else + { + curpos.y = bottomItemLineNumber - 1; + this.selectedItemIndex = this.menuItems.length - 1; + } + // Refresh the items on the screen so that the item colors + // are updated. + this.displayItem(oldIndex, false); + this.displayItem(this.selectedItemIndex, false); + } + break; + case KEY_DOWN: + // Go down one item + if (this.menuItems.length > 1) + { + // If we're above the bottom menu item, then go down one item. Otherwise, + // go to the first menu item. + var oldIndex = this.selectedItemIndex; + if ((curpos.y < bottomItemLineNumber) && (this.selectedItemIndex < this.menuItems.length - 1)) + { + ++curpos.y; + ++this.selectedItemIndex; + } + else + { + curpos.y = this.topLeftY + 1; + this.selectedItemIndex = 0; + } + // Refresh the items on the screen so that the item colors + // are updated. + this.displayItem(oldIndex, false); + this.displayItem(this.selectedItemIndex, false); + } + break; + case KEY_ESC: + continueOn = false; + break; + default: + // If the user's input is one of the hotkeys, then stop the + // input loop and return with the return code for the hotkey. + if (typeof(this.hotkeyRetvals[returnObj.userInput]) != "undefined") + { + returnObj.returnVal = this.hotkeyRetvals[returnObj.userInput]; + continueOn = false; + } + // If the user's input is one of the loop-exit keys, then stop + // the input loop. + else if (typeof(this.exitLoopKeys[returnObj.userInput]) != "undefined") + { + returnObj.returnVal = this.exitLoopKeys[returnObj.userInput]; + continueOn = false; + } + break; + } + } - return returnObj; + return returnObj; } + // Returns the number of items in the menu. function DCTMenu_NumItems() { @@ -1514,9 +1522,9 @@ function DCTMenu_RemoveAllItems() this.width = 0; this.height = 0; this.selectedItemIndex = 0; - this.menuItems = new Array(); - this.hotkeyRetvals = new Array(); - this.exitLoopKeys = new Array(); + this.menuItems = []; + this.hotkeyRetvals = []; + this.exitLoopKeys = []; } // Returns the the script's execution directory. diff --git a/exec/SlyEdit_IceStuff.js b/exec/SlyEdit_IceStuff.js index 01af28ac7afabb7691add1f0f4a2888874fb8b89..98dd23362da1197a06b4e253e9d9b8111bf0dd5a 100644 --- a/exec/SlyEdit_IceStuff.js +++ b/exec/SlyEdit_IceStuff.js @@ -1,5 +1,3 @@ -// $Id: SlyEdit_IceStuff.js,v 1.29 2019/06/06 03:50:47 nightfox Exp $ - /* This contains IceEdit-specific functions for SlyEdit. * * Author: Eric Oulashin (AKA Nightfox) @@ -16,6 +14,8 @@ * 2021-12-11 Eric Oulashin Updated the quote window bottom border text */ +"use strict"; + if (typeof(require) === "function") { require("sbbsdefs.js", "K_NOCRLF"); @@ -103,7 +103,7 @@ function redrawScreen_IceStyle(pEditLeft, pEditRight, pEditTop, pEditBottom, pEd // on an 80-column screen width. var fieldWidth = (console.screen_columns * (29/80)).toFixed(0); var screenText = gToName.substr(0, fieldWidth); - console.print("\1n" + randomTwoColorString(VERTICAL_SINGLE, + console.print("\x01n" + randomTwoColorString(VERTICAL_SINGLE, gConfigSettings.iceColors.BorderColor1, gConfigSettings.iceColors.BorderColor2) + gConfigSettings.iceColors.TopInfoBkgColor + " " + @@ -144,7 +144,7 @@ function redrawScreen_IceStyle(pEditLeft, pEditRight, pEditTop, pEditBottom, pEd // Subject fieldWidth = (console.screen_columns * (54/80)).toFixed(0); screenText = gMsgSubj.substr(0, fieldWidth); - console.print("\1n" + randomTwoColorString(VERTICAL_SINGLE, + console.print("\x01n" + randomTwoColorString(VERTICAL_SINGLE, gConfigSettings.iceColors.BorderColor1, gConfigSettings.iceColors.BorderColor2) + gConfigSettings.iceColors.TopInfoBkgColor + " " + @@ -175,7 +175,7 @@ function redrawScreen_IceStyle(pEditLeft, pEditRight, pEditTop, pEditBottom, pEd console.print(" "); // Insert/overwrite mode - console.print(" " + gConfigSettings.iceColors.EditMode + pInsertMode + " n" + + console.print(" " + gConfigSettings.iceColors.EditMode + pInsertMode + " \x01n" + randomTwoColorString(VERTICAL_SINGLE, gConfigSettings.iceColors.BorderColor1, gConfigSettings.iceColors.BorderColor2)); @@ -184,17 +184,17 @@ function redrawScreen_IceStyle(pEditLeft, pEditRight, pEditTop, pEditBottom, pEd // Generate this border line only once, for efficiency. if (typeof(redrawScreen_IceStyle.msgAreaBorder) == "undefined") { - redrawScreen_IceStyle.msgAreaBorder = "n" + redrawScreen_IceStyle.msgAreaBorder = "\x01n" + randomTwoColorString(LEFT_T_SINGLE + HORIZONTAL_SINGLE, gConfigSettings.iceColors.BorderColor1, gConfigSettings.iceColors.BorderColor2) // User #, padded with high-black dim block characters, 5 characters for a screen // that's 80 characters wide. - + "h" + THIN_RECTANGLE_LEFT + "#k"; + + "\x01h" + THIN_RECTANGLE_LEFT + "#\x01k"; fieldWidth = (console.screen_columns * (5/80)).toFixed(0) - user.number.toString().length; for (var i = 0; i < fieldWidth; ++i) redrawScreen_IceStyle.msgAreaBorder += BLOCK1; - redrawScreen_IceStyle.msgAreaBorder += "c" + user.number + redrawScreen_IceStyle.msgAreaBorder += "\x01c" + user.number + gConfigSettings.iceColors.BorderColor1 + THIN_RECTANGLE_RIGHT; @@ -215,8 +215,8 @@ function redrawScreen_IceStyle(pEditLeft, pEditRight, pEditTop, pEditBottom, pEd gConfigSettings.iceColors.BorderColor2); // Write the message area name - redrawScreen_IceStyle.msgAreaBorder += "h" + gConfigSettings.iceColors.BorderColor1 - + THIN_RECTANGLE_LEFT + " " + iceText(msgAreaName, "w") + " h" + redrawScreen_IceStyle.msgAreaBorder += "\x01h" + gConfigSettings.iceColors.BorderColor1 + + THIN_RECTANGLE_LEFT + " " + iceText(msgAreaName, "\x01w") + " \x01h" + gConfigSettings.iceColors.BorderColor1 + THIN_RECTANGLE_RIGHT; // Calculate the field width for the node number field. @@ -235,12 +235,12 @@ function redrawScreen_IceStyle(pEditLeft, pEditRight, pEditTop, pEditBottom, pEd gConfigSettings.iceColors.BorderColor2); // Output the node # field - redrawScreen_IceStyle.msgAreaBorder += "h" + gConfigSettings.iceColors.BorderColor1 - + THIN_RECTANGLE_LEFT + iceText("Node", "w") + "nb:hk"; + redrawScreen_IceStyle.msgAreaBorder += "\x01h" + gConfigSettings.iceColors.BorderColor1 + + THIN_RECTANGLE_LEFT + iceText("Node", "\x01w") + "\x01n\x01b:\x01h\x01k"; fieldWidth -= bbs.node_num.toString().length; for (var i = 0; i < fieldWidth; ++i) redrawScreen_IceStyle.msgAreaBorder += BLOCK1; - redrawScreen_IceStyle.msgAreaBorder += "c" + bbs.node_num + redrawScreen_IceStyle.msgAreaBorder += "\x01c" + bbs.node_num + gConfigSettings.iceColors.BorderColor1 + THIN_RECTANGLE_RIGHT; // Write the last 2 characters of top border @@ -267,7 +267,7 @@ function redrawScreen_IceStyle(pEditLeft, pEditRight, pEditTop, pEditBottom, pEd function refreshSubjectOnScreen_IceStyle(pX, pY, pLength, pText) { - console.print("\1n" + gConfigSettings.iceColors.TopInfoBkgColor + gConfigSettings.iceColors.TopSubjectColor); + console.print("\x01n" + gConfigSettings.iceColors.TopInfoBkgColor + gConfigSettings.iceColors.TopSubjectColor); console.gotoxy(pX, pY); printf("%-" + pLength + "s", pText.substr(0, pLength)); } @@ -293,15 +293,15 @@ function DisplayTextAreaBottomBorder_IceStyle(pLineNum, pUseQuotes, pEditLeft, p if (typeof(DisplayTextAreaBottomBorder_IceStyle.border) == "undefined") { // Build the string of CTRL key combinations that will be displayed - var ctrlKeyHelp = "n" + gConfigSettings.iceColors.KeyInfoLabelColor - + "CTRL nhb(nwAhb)n" + var ctrlKeyHelp = "\x01n" + gConfigSettings.iceColors.KeyInfoLabelColor + + "CTRL \x01n\x01h\x01b(\x01n\x01wA\x01h\x01b)\x01n" + gConfigSettings.iceColors.KeyInfoLabelColor + "Abort"; if (pUseQuotes) { - ctrlKeyHelp += " nhb(nwQhb)n" + ctrlKeyHelp += " \x01n\x01h\x01b(\x01n\x01wQ\x01h\x01b)\x01n" + gConfigSettings.iceColors.KeyInfoLabelColor + "Quote"; } - ctrlKeyHelp += " nhb(nwZhb)n" + ctrlKeyHelp += " \x01n\x01h\x01b(\x01n\x01wZ\x01h\x01b)\x01n" + gConfigSettings.iceColors.KeyInfoLabelColor + "Save"; // Start the border text with the first 2 border characters @@ -311,9 +311,9 @@ function DisplayTextAreaBottomBorder_IceStyle(pLineNum, pUseQuotes, pEditLeft, p randomTwoColorString(LOWER_LEFT_SINGLE + HORIZONTAL_SINGLE, gConfigSettings.iceColors.BorderColor1, gConfigSettings.iceColors.BorderColor2) - + "h" + gConfigSettings.iceColors.BorderColor1 + THIN_RECTANGLE_LEFT - + iceText("Registered To: " + system.operator.substr(0, 20), "w") - + "h" + gConfigSettings.iceColors.BorderColor1 + THIN_RECTANGLE_RIGHT; + + "\x01h" + gConfigSettings.iceColors.BorderColor1 + THIN_RECTANGLE_LEFT + + iceText("Registered To: " + system.operator.substr(0, 20), "\x01w") + + "\x01h" + gConfigSettings.iceColors.BorderColor1 + THIN_RECTANGLE_RIGHT; // Append border characters up until the point we'll have to write the CTRL key // help text. var screenText = ""; @@ -326,7 +326,7 @@ function DisplayTextAreaBottomBorder_IceStyle(pLineNum, pUseQuotes, pEditLeft, p gConfigSettings.iceColors.BorderColor2); // CTRL key help and the remaining 2 characters in the border. - DisplayTextAreaBottomBorder_IceStyle.border += "h" + gConfigSettings.iceColors.BorderColor1 + DisplayTextAreaBottomBorder_IceStyle.border += "\x01h" + gConfigSettings.iceColors.BorderColor1 + THIN_RECTANGLE_LEFT + ctrlKeyHelp + gConfigSettings.iceColors.BorderColor1 + THIN_RECTANGLE_RIGHT + randomTwoColorString(HORIZONTAL_SINGLE + LOWER_RIGHT_SINGLE, @@ -357,11 +357,11 @@ function DisplayBottomHelpLine_IceStyle(pLineNum, pUsingQuotes) if (typeof(DisplayBottomHelpLine_IceStyle.helpText) == "undefined") { // This line contains the copyright mesage & ESC key help - var screenText = iceText(EDITOR_PROGRAM_NAME + " v", "\1w") + "\1c\1h" + var screenText = iceText(EDITOR_PROGRAM_NAME + " v", "\x01w") + "\x01c\x01h" + EDITOR_VERSION.toString() + " " - + iceText("Copyright", "\1w") + " \1c\1h" + COPYRIGHT_YEAR + " " - + iceText("Eric Oulashin", "\1w") + " \1n\1b" + DOT_CHAR + " " - + iceText("Press ESCape For Help", "\1w"); + + iceText("Copyright", "\x01w") + " \x01c\x01h" + COPYRIGHT_YEAR + " " + + iceText("Eric Oulashin", "\x01w") + " \x01n\x01b" + DOT_CHAR + " " + + iceText("Press ESCape For Help", "\x01w"); // Calculate the starting position to center the help text, and front-pad // DisplayBottomHelpLine_IceStyle.helpText with that many spaces. var xPos = (console.screen_columns / 2).toFixed(0) @@ -380,7 +380,7 @@ function DisplayBottomHelpLine_IceStyle(pLineNum, pUsingQuotes) // Display the help text on the screen console.gotoxy(1, lineNum); console.print(DisplayBottomHelpLine_IceStyle.helpText); - console.print("\1n"); + console.print("\x01n"); console.cleartoeol(); } @@ -499,7 +499,7 @@ function promptYesNo_IceStyle(pQuestion, pDefaultYes) // Print the question, and highlight "yes" or "no", depending on // the value of pDefaultYes. - console.print(iceText(pQuestion + "? ", "w")); + console.print(iceText(pQuestion + "? ", "\x01w")); displayIceYesNoText(pDefaultYes); // yesNoX contains the horizontal position for the "Yes" & "No" text. @@ -553,16 +553,16 @@ function displayTime_IceStyle(pTimeStr) { console.gotoxy(console.screen_columns-7, 2); if (pTimeStr == null) - console.print("n" + gConfigSettings.iceColors.TopInfoBkgColor + gConfigSettings.iceColors.TopTimeColor + getCurrentTimeStr()); + console.print("\x01n" + gConfigSettings.iceColors.TopInfoBkgColor + gConfigSettings.iceColors.TopTimeColor + getCurrentTimeStr()); else - console.print("n" + gConfigSettings.iceColors.TopInfoBkgColor + gConfigSettings.iceColors.TopTimeColor + pTimeStr); + console.print("\x01n" + gConfigSettings.iceColors.TopInfoBkgColor + gConfigSettings.iceColors.TopTimeColor + pTimeStr); } // Displays the number of minutes remaining on the screen. function displayTimeRemaining_IceStyle() { var fieldWidth = (console.screen_columns * (4/80)).toFixed(0); - var formatStr = "n" + gConfigSettings.iceColors.TopInfoBkgColor + var formatStr = "\x01n" + gConfigSettings.iceColors.TopInfoBkgColor + gConfigSettings.iceColors.TopTimeLeftColor + "%-" + fieldWidth + "s"; var startX = console.screen_columns - fieldWidth - 5; @@ -589,20 +589,20 @@ function iceText(pString, pColor, pBkgColor) return ""; // Set the color. Default to blue. - var color = "b"; + var color = "\x01b"; if ((typeof(pColor) != "undefined") && (pColor != null)) color = pColor; // Set the background color. Default to normal black. - var bkgColor = "nk"; + var bkgColor = "\x01n\x01k"; if ((typeof(pBkgColor) != "undefined") && (pBkgColor != null)) bkgColor = pBkgColor; // Create a copy of the string without any control characters, // and then add our coloring to it. pString = strip_ctrl(pString); - var returnString = "n" + bkgColor + color; - var lastColor = "n" + color; + var returnString = "\x01n" + bkgColor + color; + var lastColor = "\x01n" + color; var character = ""; for (var i = 0; i < pString.length; ++i) { @@ -613,9 +613,9 @@ function iceText(pString, pColor, pBkgColor) { // If the last color was not the normal color, then append // the normal color to returnString. - if (lastColor != "n" + color) - returnString += "n" + bkgColor + color; - lastColor = "n" + color; + if (lastColor != "\x01n" + color) + returnString += "\x01n" + bkgColor + color; + lastColor = "\x01n" + color; } // Lower-case letter: Make it bright with the passed-in color. else if (character.match(/[a-z]/) != null) @@ -623,27 +623,27 @@ function iceText(pString, pColor, pBkgColor) // If this is the first character or if the last color was // not the bright color, then append the bright color to // returnString. - if ((i == 0) || (lastColor != ("h" + color))) - returnString += "h" + color; - lastColor = "h" + color; + if ((i == 0) || (lastColor != ("\x01h" + color))) + returnString += "\x01h" + color; + lastColor = "\x01h" + color; } // Number: Make it bright cyan else if (character.match(/[0-9]/) != null) { // If the last color was not bright cyan, then append // bright cyan to returnString. - if (lastColor != "hc") - returnString += "hc"; - lastColor = "hc"; + if (lastColor != "\x01h\x01c") + returnString += "\x01h\x01c"; + lastColor = "\x01h\x01c"; } // All else: Make it bright blue else { // If the last color was not bright cyan, then append // bright cyan to returnString. - if (lastColor != "hb") - returnString += "hb"; - lastColor = "hb"; + if (lastColor != "\x01h\x01b") + returnString += "\x01h\x01b"; + lastColor = "\x01h\x01b"; } // Append the character from pString. @@ -678,8 +678,8 @@ function doIceESCMenu(pY, pCanCrossPost) var promptText = "Select An Option: "; console.gotoxy(1, pY); - console.print(iceText(promptText, "\1w")); - console.cleartoeol("\1n"); + console.print(iceText(promptText, "\x01w")); + console.cleartoeol("\x01n"); // Input loop var lastMenuItem = (pCanCrossPost ? ICE_ESC_MENU_CROSS_POST : ICE_ESC_MENU_SPELL_CHECK); var userChoice = ICE_ESC_MENU_SAVE; @@ -693,73 +693,73 @@ function doIceESCMenu(pY, pCanCrossPost) switch (userChoice) { case ICE_ESC_MENU_SAVE: - console.print(iceStyledPromptText("Save", true) + "\1n "); - console.print(iceStyledPromptText("Abort", false) + "\1n "); - console.print(iceStyledPromptText("Edit", false) + "\1n "); - console.print(iceStyledPromptText("Settings", false) + "\1n "); - console.print(iceStyledPromptText("Help", false) + "\1n "); + console.print(iceStyledPromptText("Save", true) + "\x01n "); + console.print(iceStyledPromptText("Abort", false) + "\x01n "); + console.print(iceStyledPromptText("Edit", false) + "\x01n "); + console.print(iceStyledPromptText("Settings", false) + "\x01n "); + console.print(iceStyledPromptText("Help", false) + "\x01n "); console.print(iceStyledPromptText("sPlchk", false)); if (pCanCrossPost) - console.print("\1n " + iceStyledPromptText("Cross-post", false)); + console.print("\x01n " + iceStyledPromptText("Cross-post", false)); break; case ICE_ESC_MENU_ABORT: - console.print(iceStyledPromptText("Save", false) + "\1n "); - console.print(iceStyledPromptText("Abort", true) + "\1n "); - console.print(iceStyledPromptText("Edit", false) + "\1n "); - console.print(iceStyledPromptText("Settings", false) + "\1n "); - console.print(iceStyledPromptText("Help", false) + "\1n "); + console.print(iceStyledPromptText("Save", false) + "\x01n "); + console.print(iceStyledPromptText("Abort", true) + "\x01n "); + console.print(iceStyledPromptText("Edit", false) + "\x01n "); + console.print(iceStyledPromptText("Settings", false) + "\x01n "); + console.print(iceStyledPromptText("Help", false) + "\x01n "); console.print(iceStyledPromptText("sPlchk", false)); if (pCanCrossPost) - console.print("\1n " + iceStyledPromptText("Cross-post", false)); + console.print("\x01n " + iceStyledPromptText("Cross-post", false)); break; case ICE_ESC_MENU_EDIT: - console.print(iceStyledPromptText("Save", false) + "\1n "); - console.print(iceStyledPromptText("Abort", false) + "\1n "); - console.print(iceStyledPromptText("Edit", true) + "\1n "); - console.print(iceStyledPromptText("Settings", false) + "\1n "); - console.print(iceStyledPromptText("Help", false) + "\1n "); + console.print(iceStyledPromptText("Save", false) + "\x01n "); + console.print(iceStyledPromptText("Abort", false) + "\x01n "); + console.print(iceStyledPromptText("Edit", true) + "\x01n "); + console.print(iceStyledPromptText("Settings", false) + "\x01n "); + console.print(iceStyledPromptText("Help", false) + "\x01n "); console.print(iceStyledPromptText("sPlchk", false)); if (pCanCrossPost) - console.print("\1n " + iceStyledPromptText("Cross-post", false)); + console.print("\x01n " + iceStyledPromptText("Cross-post", false)); break; case ICE_ESC_MENU_SETTINGS: - console.print(iceStyledPromptText("Save", false) + "\1n "); - console.print(iceStyledPromptText("Abort", false) + "\1n "); - console.print(iceStyledPromptText("Edit", false) + "\1n "); - console.print(iceStyledPromptText("Settings", true) + "\1n "); - console.print(iceStyledPromptText("Help", false) + "\1n "); + console.print(iceStyledPromptText("Save", false) + "\x01n "); + console.print(iceStyledPromptText("Abort", false) + "\x01n "); + console.print(iceStyledPromptText("Edit", false) + "\x01n "); + console.print(iceStyledPromptText("Settings", true) + "\x01n "); + console.print(iceStyledPromptText("Help", false) + "\x01n "); console.print(iceStyledPromptText("sPlchk", false)); if (pCanCrossPost) - console.print("\1n " + iceStyledPromptText("Cross-post", false)); + console.print("\x01n " + iceStyledPromptText("Cross-post", false)); break; case ICE_ESC_MENU_HELP: - console.print(iceStyledPromptText("Save", false) + "\1n "); - console.print(iceStyledPromptText("Abort", false) + "\1n "); - console.print(iceStyledPromptText("Edit", false) + "\1n "); - console.print(iceStyledPromptText("Settings", false) + "\1n "); - console.print(iceStyledPromptText("Help", true) + "\1n "); + console.print(iceStyledPromptText("Save", false) + "\x01n "); + console.print(iceStyledPromptText("Abort", false) + "\x01n "); + console.print(iceStyledPromptText("Edit", false) + "\x01n "); + console.print(iceStyledPromptText("Settings", false) + "\x01n "); + console.print(iceStyledPromptText("Help", true) + "\x01n "); console.print(iceStyledPromptText("sPlchk", false)); if (pCanCrossPost) - console.print("\1n " + iceStyledPromptText("Cross-post", false)); + console.print("\x01n " + iceStyledPromptText("Cross-post", false)); break; case ICE_ESC_MENU_SPELL_CHECK: - console.print(iceStyledPromptText("Save", false) + "\1n "); - console.print(iceStyledPromptText("Abort", false) + "\1n "); - console.print(iceStyledPromptText("Edit", false) + "\1n "); - console.print(iceStyledPromptText("Settings", false) + "\1n "); - console.print(iceStyledPromptText("Help", false) + "\1n "); + console.print(iceStyledPromptText("Save", false) + "\x01n "); + console.print(iceStyledPromptText("Abort", false) + "\x01n "); + console.print(iceStyledPromptText("Edit", false) + "\x01n "); + console.print(iceStyledPromptText("Settings", false) + "\x01n "); + console.print(iceStyledPromptText("Help", false) + "\x01n "); console.print(iceStyledPromptText("sPlchk", true)); if (pCanCrossPost) - console.print("\1n " + iceStyledPromptText("Cross-post", false)); + console.print("\x01n " + iceStyledPromptText("Cross-post", false)); break; break; case ICE_ESC_MENU_CROSS_POST: - console.print(iceStyledPromptText("Save", false) + "\1n "); - console.print(iceStyledPromptText("Abort", false) + "\1n "); - console.print(iceStyledPromptText("Edit", false) + "\1n "); - console.print(iceStyledPromptText("Settings", false) + "\1n "); - console.print(iceStyledPromptText("Help", false) + "\1n "); - console.print(iceStyledPromptText("sPlchk", false) + "\1n "); + console.print(iceStyledPromptText("Save", false) + "\x01n "); + console.print(iceStyledPromptText("Abort", false) + "\x01n "); + console.print(iceStyledPromptText("Edit", false) + "\x01n "); + console.print(iceStyledPromptText("Settings", false) + "\x01n "); + console.print(iceStyledPromptText("Help", false) + "\x01n "); + console.print(iceStyledPromptText("sPlchk", false) + "\x01n "); console.print(iceStyledPromptText("Cross-post", true)); break; } @@ -817,7 +817,7 @@ function doIceESCMenu(pY, pCanCrossPost) } // Make sure special text attributes are cleared. - console.print("\1n"); + console.print("\x01n"); // Now that the user has made a choice, set userAction switch (userChoice) @@ -866,18 +866,18 @@ function iceStyledPromptText(pText, pHighlight) + gConfigSettings.iceColors.SelectedOptionBorderColor + THIN_RECTANGLE_RIGHT; else styledText = gConfigSettings.iceColors.UnselectedOptionBorderColor + THIN_RECTANGLE_LEFT - + iceText(pText, "w") + gConfigSettings.iceColors.UnselectedOptionBorderColor + + iceText(pText, "\x01w") + gConfigSettings.iceColors.UnselectedOptionBorderColor + THIN_RECTANGLE_RIGHT; } else { if (pHighlight) styledText = gConfigSettings.iceColors.SelectedOptionBorderColor + THIN_RECTANGLE_LEFT - + "n4hy" + pText.substr(0, 1) + "c" + pText.substr(1) + "n" + + "\x01n\x01" + "4\x01h\x01y" + pText.substr(0, 1) + "\x01c" + pText.substr(1) + "\x01n" + gConfigSettings.iceColors.SelectedOptionBorderColor + THIN_RECTANGLE_RIGHT; else styledText = gConfigSettings.iceColors.UnselectedOptionBorderColor + THIN_RECTANGLE_LEFT - + iceText(pText, "c") + gConfigSettings.iceColors.UnselectedOptionBorderColor + + iceText(pText, "\x01c") + gConfigSettings.iceColors.UnselectedOptionBorderColor + THIN_RECTANGLE_RIGHT; } return styledText; @@ -899,16 +899,16 @@ function displayIceYesNoText(pYesSelected) THIN_RECTANGLE_RIGHT + gConfigSettings.iceColors.UnselectedOptionBorderColor + " " + THIN_RECTANGLE_LEFT + gConfigSettings.iceColors.UnselectedOptionTextColor + "NO" + gConfigSettings.iceColors.UnselectedOptionBorderColor + - THIN_RECTANGLE_RIGHT + "n"); + THIN_RECTANGLE_RIGHT + "\x01n"); } else { console.print(gConfigSettings.iceColors.SelectedOptionBorderColor + THIN_RECTANGLE_LEFT + - "n4hyYcesn" + gConfigSettings.iceColors.SelectedOptionBorderColor + + "\x01n\x01" + "4\x01h\x01yY\x01ces\x01n" + gConfigSettings.iceColors.SelectedOptionBorderColor + THIN_RECTANGLE_RIGHT + gConfigSettings.iceColors.UnselectedOptionBorderColor + - " " + THIN_RECTANGLE_LEFT + "nhcNnco" + + " " + THIN_RECTANGLE_LEFT + "\x01n\x01h\x01cN\x01n\x01co" + gConfigSettings.iceColors.UnselectedOptionBorderColor + THIN_RECTANGLE_RIGHT + - "n"); + "\x01n"); } } else @@ -921,16 +921,16 @@ function displayIceYesNoText(pYesSelected) " " + gConfigSettings.iceColors.SelectedOptionBorderColor + THIN_RECTANGLE_LEFT + gConfigSettings.iceColors.SelectedOptionTextColor + "NO" + gConfigSettings.iceColors.SelectedOptionBorderColor + THIN_RECTANGLE_RIGHT + - "n"); + "\x01n"); } else { console.print(gConfigSettings.iceColors.UnselectedOptionBorderColor + THIN_RECTANGLE_LEFT + - "nhcYnces" + gConfigSettings.iceColors.UnselectedOptionBorderColor + + "\x01n\x01h\x01cY\x01n\x01ces" + gConfigSettings.iceColors.UnselectedOptionBorderColor + THIN_RECTANGLE_RIGHT + " " + gConfigSettings.iceColors.SelectedOptionBorderColor + - THIN_RECTANGLE_LEFT + "n4hyNcon" + + THIN_RECTANGLE_LEFT + "\x01n\x01" + "4\x01h\x01yN\x01co\x01n" + gConfigSettings.iceColors.SelectedOptionBorderColor + THIN_RECTANGLE_RIGHT + - "n"); + "\x01n"); } } } diff --git a/exec/SlyEdit_Misc.js b/exec/SlyEdit_Misc.js index 5c1e2e0b2a18933adbdf14e6e3c677e16b1a125d..a7e0288c07a32ec9b91edc3c29d1a787e441ada7 100644 --- a/exec/SlyEdit_Misc.js +++ b/exec/SlyEdit_Misc.js @@ -1,5 +1,3 @@ -// $Id: SlyEdit_Misc.js,v 1.51 2019/06/06 03:50:47 nightfox Exp $ - /* This file declares some general helper functions and variables * that are used by SlyEdit. * @@ -47,6 +45,8 @@ * sub-board information with an empty sub-board code (in the rare * case when no sub-boards are configured). */ + +"use strict"; if (typeof(require) === "function") require("text.js", "Pause"); @@ -62,48 +62,48 @@ var BKG_ATTR = 2; // Background color attribute var SPECIAL_ATTR = 3; // Special attribute // Box-drawing/border characters: Single-line -var UPPER_LEFT_SINGLE = ascii(169); -var HORIZONTAL_SINGLE = ascii(196); -var UPPER_RIGHT_SINGLE = ascii(191); // or 170? -var VERTICAL_SINGLE = ascii(179); -var LOWER_LEFT_SINGLE = ascii(192); -var LOWER_RIGHT_SINGLE = ascii(217); -var T_SINGLE = ascii(194); -var LEFT_T_SINGLE = ascii(195); -var RIGHT_T_SINGLE = ascii(180); -var BOTTOM_T_SINGLE = ascii(193); -var CROSS_SINGLE = ascii(197); +var UPPER_LEFT_SINGLE = "\xDA"; //ASCII 218 +var HORIZONTAL_SINGLE = "\xC4"; //ASCII 196 +var UPPER_RIGHT_SINGLE = "\xBF"; //ASCII 191 // or 170? +var VERTICAL_SINGLE = "\xB3"; //ASCII 179 +var LOWER_LEFT_SINGLE = "\xC0"; //ASCII 192 +var LOWER_RIGHT_SINGLE = "\xD9"; //ASCII 217 +var T_SINGLE = "\xC2"; //ASCII 194 +var LEFT_T_SINGLE = "\xC3"; //ASCII 195 +var RIGHT_T_SINGLE = "\xB4"; //ASCII 180 +var BOTTOM_T_SINGLE = "\xC1"; //ASCII 193 +var CROSS_SINGLE = "\xC5"; //ASCII 197 // Box-drawing/border characters: Double-line -var UPPER_LEFT_DOUBLE = ascii(201); -var HORIZONTAL_DOUBLE = ascii(205); -var UPPER_RIGHT_DOUBLE = ascii(187); -var VERTICAL_DOUBLE = ascii(186); -var LOWER_LEFT_DOUBLE = ascii(200); -var LOWER_RIGHT_DOUBLE = ascii(188); -var T_DOUBLE = ascii(203); -var LEFT_T_DOUBLE = ascii(204); -var RIGHT_T_DOUBLE = ascii(185); -var BOTTOM_T_DOUBLE = ascii(202); -var CROSS_DOUBLE = ascii(206); +var UPPER_LEFT_DOUBLE = "\xC9"; //ASCII 201 +var HORIZONTAL_DOUBLE = "\xCD"; //ASCII 205 +var UPPER_RIGHT_DOUBLE = "\xBB"; //ASCII 187 +var VERTICAL_DOUBLE = "\xBA"; //ASCII 186 +var LOWER_LEFT_DOUBLE = "\xCB"; //ASCII 200 +var LOWER_RIGHT_DOUBLE = "\xBC"; //ASCII 188 +var T_DOUBLE = "\xCB"; //ASCII 203 +var LEFT_T_DOUBLE = "\xCC"; //ASCII 204 +var RIGHT_T_DOUBLE = "\xB9"; //ASCII 185 +var BOTTOM_T_DOUBLE = "\xCA"; //ASCII 202 +var CROSS_DOUBLE = "\xCE"; //ASCII 206 // Box-drawing/border characters: Vertical single-line with horizontal double-line -var UPPER_LEFT_VSINGLE_HDOUBLE = ascii(213); -var UPPER_RIGHT_VSINGLE_HDOUBLE = ascii(184); -var LOWER_LEFT_VSINGLE_HDOUBLE = ascii(212); -var LOWER_RIGHT_VSINGLE_HDOUBLE = ascii(190); +var UPPER_LEFT_VSINGLE_HDOUBLE = "\xD5"; //ASCII 213 +var UPPER_RIGHT_VSINGLE_HDOUBLE = "\xB8"; //ASCII 184 +var LOWER_LEFT_VSINGLE_HDOUBLE = "\xD4"; //ASCII 212 +var LOWER_RIGHT_VSINGLE_HDOUBLE = "\xBE"; //ASCII 190 // Other special characters -var DOT_CHAR = ascii(249); -var CHECK_CHAR = ascii(251); -var THIN_RECTANGLE_LEFT = ascii(221); -var THIN_RECTANGLE_RIGHT = ascii(222); -var CENTERED_SQUARE = ascii(254); -var BLOCK1 = ascii(176); // Dimmest block -var BLOCK2 = ascii(177); -var BLOCK3 = ascii(178); -var BLOCK4 = ascii(219); // Brightest block +var DOT_CHAR = "\xF9"; //ASCII 249 +var CHECK_CHAR = "\xFB"; //ASCII 251 +var THIN_RECTANGLE_LEFT = "\xDD"; //ASCII 221 +var THIN_RECTANGLE_RIGHT = "\xDE"; //ASCII 222 +var CENTERED_SQUARE = "\xFE"; //ASCII 254 +var BLOCK1 = "\xB0"; //ASCII 176 // Dimmest block +var BLOCK2 = "\xB1"; //ASCII 177 +var BLOCK3 = "\xB2"; //ASCII 178 +var BLOCK4 = "\xDB"; //ASCII 219 // Brightest block // Navigational keys -var UP_ARROW = ascii(24); -var DOWN_ARROW = ascii(25); +var UP_ARROW = "\x18"; //ASCII 24 +var DOWN_ARROW = "\x19"; //ASCII 25 // CTRL keys var CTRL_A = "\x01"; var CTRL_B = "\x02"; @@ -145,11 +145,11 @@ var CTRL_X = "\x18"; var CTRL_Y = "\x19"; var CTRL_Z = "\x1a"; var KEY_ESC = "\x1b"; -var KEY_F1 = "\1F1"; -var KEY_F2 = "\1F2"; -var KEY_F3 = "\1F3"; -var KEY_F4 = "\1F4"; -var KEY_F5 = "\1F5"; +var KEY_F1 = "\x01F1"; +var KEY_F2 = "\x01F2"; +var KEY_F3 = "\x01F3"; +var KEY_F4 = "\x01F4"; +var KEY_F5 = "\x01F5"; // PageUp & PageDown keys - Synchronet 3.17 as of about December 18, 2017 // use CTRL-P and CTRL-N for PageUp and PageDown, respectively. sbbsdefs.js // defines them as KEY_PAGEUP and KEY_PAGEDN; I've used slightly different names @@ -183,7 +183,7 @@ var ESC_MENU_USER_SETTINGS = 12; var ESC_MENU_SPELL_CHECK = 13; -var COPYRIGHT_YEAR = 2021; +var COPYRIGHT_YEAR = 2022; // Store the full path & filename of the Digital Distortion Message // Lister, since it will be used more than once. @@ -479,10 +479,10 @@ function ChoiceScrollbox(pLeftX, pTopY, pWidth, pHeight, pTopBorderText, pSlyEdC numSpaces = nonSpcIdx - firstSpcIdx; if (numSpaces > 0) { - pTopBorderText = firstStrPart + "\1n" + pSlyEdCfgObj.genColors.listBoxBorder; + pTopBorderText = firstStrPart + "\x01n" + pSlyEdCfgObj.genColors.listBoxBorder; for (var i = 0; i < numSpaces; ++i) pTopBorderText += HORIZONTAL_SINGLE; - pTopBorderText += "\1n" + pSlyEdCfgObj.genColors.listBoxBorderText + lastStrPart; + pTopBorderText += "\x01n" + pSlyEdCfgObj.genColors.listBoxBorderText + lastStrPart; } // Look for the next space and non-space character after that. @@ -527,11 +527,11 @@ function ChoiceScrollbox(pLeftX, pTopY, pWidth, pHeight, pTopBorderText, pSlyEdC var maxTopBorderTextLen = innerBorderWidth - (pAddTCharsAroundTopText ? 21 : 19); if (strip_ctrl(pTopBorderText).length > maxTopBorderTextLen) pTopBorderText = pTopBorderText.substr(0, maxTopBorderTextLen); - this.topBorder = "\1n" + pSlyEdCfgObj.genColors.listBoxBorder + UPPER_LEFT_SINGLE; + this.topBorder = "\x01n" + pSlyEdCfgObj.genColors.listBoxBorder + UPPER_LEFT_SINGLE; if (addTopTCharsAroundText) this.topBorder += RIGHT_T_SINGLE; - this.topBorder += "\1n" + pSlyEdCfgObj.genColors.listBoxBorderText - + pTopBorderText + "\1n" + pSlyEdCfgObj.genColors.listBoxBorder; + this.topBorder += "\x01n" + pSlyEdCfgObj.genColors.listBoxBorderText + + pTopBorderText + "\x01n" + pSlyEdCfgObj.genColors.listBoxBorder; if (addTopTCharsAroundText) this.topBorder += LEFT_T_SINGLE; const topBorderTextLen = strip_ctrl(pTopBorderText).length; @@ -540,16 +540,16 @@ function ChoiceScrollbox(pLeftX, pTopY, pWidth, pHeight, pTopBorderText, pSlyEdC numHorizBorderChars -= 2; for (var i = 0; i <= numHorizBorderChars; ++i) this.topBorder += HORIZONTAL_SINGLE; - this.topBorder += RIGHT_T_SINGLE + "\1n" + pSlyEdCfgObj.genColors.listBoxBorderText - + "Page 1 of 1" + "\1n" + pSlyEdCfgObj.genColors.listBoxBorder + LEFT_T_SINGLE + this.topBorder += RIGHT_T_SINGLE + "\x01n" + pSlyEdCfgObj.genColors.listBoxBorderText + + "Page 1 of 1" + "\x01n" + pSlyEdCfgObj.genColors.listBoxBorder + LEFT_T_SINGLE + UPPER_RIGHT_SINGLE; // Bottom border string - this.btmBorderNavText = "\1n\1h\1c\1b, \1c\1b, \1cN\1y)\1bext, \1cP\1y)\1brev, " - + "\1cF\1y)\1birst, \1cL\1y)\1bast, \1cHOME\1b, \1cEND\1b, \1cEnter\1y=\1bSelect, " - + "\1cESC\1n\1c/\1h\1cQ\1y=\1bEnd"; - this.bottomBorder = "\1n" + pSlyEdCfgObj.genColors.listBoxBorder + LOWER_LEFT_SINGLE - + RIGHT_T_SINGLE + this.btmBorderNavText + "\1n" + pSlyEdCfgObj.genColors.listBoxBorder + this.btmBorderNavText = "\x01n\x01h\x01c" + UP_ARROW + "\x01b, \x01c" + DOWN_ARROW + "\x01b, \x01cN\x01y)\x01bext, \x01cP\x01y)\x01brev, " + + "\x01cF\x01y)\x01birst, \x01cL\x01y)\x01bast, \x01cHOME\x01b, \x01cEND\x01b, \x01cEnter\x01y=\x01bSelect, " + + "\x01cESC\x01n\x01c/\x01h\x01cQ\x01y=\x01bEnd"; + this.bottomBorder = "\x01n" + pSlyEdCfgObj.genColors.listBoxBorder + LOWER_LEFT_SINGLE + + RIGHT_T_SINGLE + this.btmBorderNavText + "\x01n" + pSlyEdCfgObj.genColors.listBoxBorder + LEFT_T_SINGLE; var numCharsRemaining = this.dimensions.width - strip_ctrl(this.btmBorderNavText).length - 6; for (var i = 0; i < numCharsRemaining; ++i) @@ -557,9 +557,9 @@ function ChoiceScrollbox(pLeftX, pTopY, pWidth, pHeight, pTopBorderText, pSlyEdC this.bottomBorder += LOWER_RIGHT_SINGLE; // Item format strings - this.listIemFormatStr = "\1n" + pSlyEdCfgObj.genColors.listBoxItemText + "%-" + this.listIemFormatStr = "\x01n" + pSlyEdCfgObj.genColors.listBoxItemText + "%-" + +(this.dimensions.width-2) + "s"; - this.listIemHighlightFormatStr = "\1n" + pSlyEdCfgObj.genColors.listBoxItemHighlight + "%-" + this.listIemHighlightFormatStr = "\x01n" + pSlyEdCfgObj.genColors.listBoxItemHighlight + "%-" + +(this.dimensions.width-2) + "s"; // Key functionality override function pointers @@ -785,12 +785,12 @@ function ChoiceScrollbox_SetBottomBorderText(pText, pAddTChars, pAutoStripIfTooL } // Re-build the bottom border string based on the new text - this.bottomBorder = "n" + this.SlyEdCfgObj.genColors.listBoxBorder + LOWER_LEFT_SINGLE; + this.bottomBorder = "\x01n" + this.SlyEdCfgObj.genColors.listBoxBorder + LOWER_LEFT_SINGLE; if (pAddTChars) this.bottomBorder += RIGHT_T_SINGLE; - if (pText.indexOf("n") != 0) - this.bottomBorder += "n"; - this.bottomBorder += pText + "n" + this.SlyEdCfgObj.genColors.listBoxBorder; + if (pText.indexOf("\x01n") != 0) + this.bottomBorder += "\x01n"; + this.bottomBorder += pText + "\x01n" + this.SlyEdCfgObj.genColors.listBoxBorder; if (pAddTChars) this.bottomBorder += LEFT_T_SINGLE; var numCharsRemaining = this.dimensions.width - strip_ctrl(this.bottomBorder).length - 3; @@ -848,7 +848,7 @@ function ChoiceScrollbox_DrawInnerMenu(pSelectedIndex) // Update the page number in the top border of the box. console.gotoxy(this.pageNumTxtStartX, this.dimensions.topLeftY); - printf("\1n" + this.SlyEdCfgObj.genColors.listBoxBorderText + "Page %4d of %4d", this.pageNum+1, this.numPages); + printf("\x01n" + this.SlyEdCfgObj.genColors.listBoxBorderText + "Page %4d of %4d", this.pageNum+1, this.numPages); return selectedItemRow; } function ChoiceScrollbox_RefreshOnScreen(pSelectedIndex) @@ -1147,7 +1147,7 @@ function ChoiceScrollbox_DoInputLoop(pDrawBorder) } } - console.print("\1n"); // To prevent outputting highlight colors, etc.. + console.print("\x01n"); // To prevent outputting highlight colors, etc.. return retObj; } @@ -1170,11 +1170,11 @@ function randomDimBrightString(pString, pColor) return ""; // Set the color. Default to green. - var color = "g"; + var color = "\x01g"; if ((pColor != null) && (typeof(pColor) != "undefined")) color = pColor; - return(randomTwoColorString(pString, "n" + color, "nh" + color)); + return(randomTwoColorString(pString, "\x01n" + color, "\x01n\x01h" + color)); } // This function takes a string and returns a copy of the string @@ -1193,10 +1193,10 @@ function randomTwoColorString(pString, pColor1, pColor2) return ""; // Set the colors. Default to green. - var color1 = "ng"; + var color1 = "\x01n\x01g"; if ((pColor1 != null) && (typeof(pColor1) != "undefined")) color1 = pColor1; - var color2 = "ngh"; + var color2 = "\x01n\x01g\x01h"; if ((pColor2 != null) && (typeof(pColor2) != "undefined")) color2 = pColor2; @@ -1296,20 +1296,20 @@ function displayHelpHeader() { displayHelpHeader.headerLines = new Array(); - var headerText = EDITOR_PROGRAM_NAME + " Help w(y" + var headerText = EDITOR_PROGRAM_NAME + " Help \x01w(\x01y" + (EDITOR_STYLE == "DCT" ? "DCT" : "Ice") - + " modew)"; + + " mode\x01w)"; var headerTextLen = strip_ctrl(headerText).length; // Top border - var headerTextStr = "nhc" + UPPER_LEFT_SINGLE; + var headerTextStr = "\x01n\x01h\x01c" + UPPER_LEFT_SINGLE; for (var i = 0; i < headerTextLen + 2; ++i) headerTextStr += HORIZONTAL_SINGLE; headerTextStr += UPPER_RIGHT_SINGLE; displayHelpHeader.headerLines.push(headerTextStr); // Middle line: Header text string - headerTextStr = VERTICAL_SINGLE + "4y " + headerText + " nhc" + headerTextStr = VERTICAL_SINGLE + "\x01" + "4\x01y " + headerText + " \x01n\x01h\x01c" + VERTICAL_SINGLE; displayHelpHeader.headerLines.push(headerTextStr); @@ -1341,7 +1341,7 @@ function displayCommandList(pDisplayHeader, pClear, pPause, pCanCrossPost, pIsSy pTxtReplacments, pUserSettings, pSpellCheck) { if (pClear) - console.clear("\1n"); + console.clear("\x01n"); if (pDisplayHeader) { displayHelpHeader(); @@ -1359,7 +1359,7 @@ function displayCommandList(pDisplayHeader, pClear, pPause, pCanCrossPost, pIsSy // if not specified, this function won't display a CR. function displayCmdKeyFormatted(pKey, pDesc, pCR) { - printf("\1c\1h%-13s\1g: \1n\1c%s", pKey, pDesc); + printf("\x01c\x01h%-13s\x01g: \x01n\x01c%s", pKey, pDesc); if (pCR) console.crlf(); } @@ -1372,15 +1372,15 @@ function displayCommandList(pDisplayHeader, pClear, pPause, pCanCrossPost, pIsSy sepChar1 = " "; if ((pKey2.length == 0) && (pDesc2.length == 0)) sepChar2 = " "; - printf("\1c\1h%-13s\1g" + sepChar1 + " \1n\1c%-28s \1k\1h" + VERTICAL_SINGLE + - " \1c\1h%-8s\1g" + sepChar2 + " \1n\1c%s", pKey, pDesc, pKey2, pDesc2); + printf("\x01c\x01h%-13s\x01g" + sepChar1 + " \x01n\x01c%-28s \x01k\x01h" + VERTICAL_SINGLE + + " \x01c\x01h%-8s\x01g" + sepChar2 + " \x01n\x01c%s", pKey, pDesc, pKey2, pDesc2); if (pCR) console.crlf(); } // Help keys and slash commands - printf("\1n\1g%-44s %-33s\r\n", "Help keys", "Slash commands (on blank line)"); - printf("\1k\1h%-44s %-33s\r\n", charStr(HORIZONTAL_SINGLE, 9), charStr(HORIZONTAL_SINGLE, 30)); + printf("\x01n\x01g%-44s %-33s\r\n", "Help keys", "Slash commands (on blank line)"); + printf("\x01k\x01h%-44s %-33s\r\n", charStr(HORIZONTAL_SINGLE, 9), charStr(HORIZONTAL_SINGLE, 30)); displayCmdKeyFormattedDouble("Ctrl-G", "General help", "/A", "Abort", true); displayCmdKeyFormattedDouble("Ctrl-L", "Command key list (this list)", "/S", "Save", true); displayCmdKeyFormattedDouble("", "", "/Q", "Quote message", true); @@ -1391,10 +1391,10 @@ function displayCommandList(pDisplayHeader, pClear, pPause, pCanCrossPost, pIsSy if (pCanCrossPost) displayCmdKeyFormattedDouble("", "", "/C", "Cross-post selection", true); displayCmdKeyFormattedDouble("", "", "/UPLOAD", "Upload a message", true); - printf(" \1c\1h%-7s\1g \1n\1c%s", "", "", "/?", "Show help"); + printf(" \x01c\x01h%-7s\x01g \x01n\x01c%s", "", "", "/?", "Show help"); console.crlf(); // Command/edit keys - console.print("\1n\1gCommand/edit keys\r\n\1k\1h" + charStr(HORIZONTAL_SINGLE, 17) + "\r\n"); + console.print("\x01n\x01gCommand/edit keys\r\n\x01k\x01h" + charStr(HORIZONTAL_SINGLE, 17) + "\r\n"); displayCmdKeyFormattedDouble("Ctrl-A", "Abort message", "PageUp", "Page up", true); displayCmdKeyFormattedDouble("Ctrl-Z", "Save message", "PageDown", "Page down", true); displayCmdKeyFormattedDouble("Ctrl-Q", "Quote message", "Ctrl-W", "Word/text search", true); @@ -1442,11 +1442,11 @@ function charStr(pChar, pNumTimes) function displayGeneralHelp(pDisplayHeader, pClear, pPause) { if (pClear) - console.clear("\1n"); + console.clear("\x01n"); if (pDisplayHeader) displayHelpHeader(); - console.print("\1n\1cSlyEdit is a full-screen message editor that mimics the look & feel of\r\n"); + console.print("\x01n\x01cSlyEdit is a full-screen message editor that mimics the look & feel of\r\n"); console.print("IceEdit or DCT Edit, two popular editors. The editor is currently in " + (EDITOR_STYLE == "DCT" ? "DCT" : "Ice") + "\r\nmode.\r\n"); console.print("At the top of the screen, information about the message being written (or\r\n"); @@ -1466,14 +1466,14 @@ function displayGeneralHelp(pDisplayHeader, pClear, pPause) function displayProgramInfo(pClear, pPause) { if (pClear) - console.clear("\1n"); + console.clear("\x01n"); // Print the program information - console.center("\1n\1h\1c" + EDITOR_PROGRAM_NAME + "\1n \1cVersion \1g" + - EDITOR_VERSION + " \1w\1h(\1b" + EDITOR_VER_DATE + "\1w)"); - console.center("\1n\1cby Eric Oulashin"); + console.center("\x01n\x01h\x01c" + EDITOR_PROGRAM_NAME + "\x01n \x01cVersion \x01g" + + EDITOR_VERSION + " \x01w\x01h(\x01b" + EDITOR_VER_DATE + "\x01w)"); + console.center("\x01n\x01cby Eric Oulashin"); console.crlf(); - console.print("\1n\1cSlyEdit is a full-screen message editor for Synchronet that mimics the look &\r\n"); + console.print("\x01n\x01cSlyEdit is a full-screen message editor for Synchronet that mimics the look &\r\n"); console.print("feel of IceEdit or DCT Edit."); console.crlf(); if (pPause) @@ -1487,14 +1487,14 @@ function displayProgramInfo(pClear, pPause) function displayProgramExitInfo(pClearScreen) { if (pClearScreen) - console.clear("\1n"); + console.clear("\x01n"); - console.print("\1n\1cYou have been using \1hSlyEdit \1n\1cversion \1g" + EDITOR_VERSION + " \1n\1m(" + EDITOR_VER_DATE + ")"); + console.print("\x01n\x01cYou have been using \x01hSlyEdit \x01n\x01cversion \x01g" + EDITOR_VERSION + " \x01n\x01m(" + EDITOR_VER_DATE + ")"); console.crlf(); - console.print("\1n\1cby Eric Oulashin of \1c\1hD\1n\1cigital \1hD\1n\1cistortion \1hB\1n\1cBS"); + console.print("\x01n\x01cby Eric Oulashin of \x01c\x01hD\x01n\x01cigital \x01hD\x01n\x01cistortion \x01hB\x01n\x01cBS"); console.crlf(); console.crlf(); - console.print("\1n\1cAcknowledgements for look & feel go to the following people:"); + console.print("\x01n\x01cAcknowledgements for look & feel go to the following people:"); console.crlf(); console.print("Dan Traczynski: Creator of DCT Edit"); console.crlf(); @@ -1513,7 +1513,7 @@ function displayProgramExitInfo(pClearScreen) // If not specified, defaults to normal attribute. function writeWithPause(pX, pY, pText, pPauseMS, pClearLineAttrib) { - var clearLineAttrib = "\1n"; + var clearLineAttrib = "\x01n"; if ((pClearLineAttrib != null) && (typeof(pClearLineAttrib) == "string")) clearLineAttrib = pClearLineAttrib; console.gotoxy(pX, pY); @@ -1609,27 +1609,27 @@ function ReadSlyEditConfigFile() // General SlyEdit color settings genColors: { // Cross-posting UI element colors - listBoxBorder: "\1n\1g", - listBoxBorderText: "\1n\1b\1h", - crossPostMsgAreaNum: "\1n\1h\1w", - crossPostMsgAreaNumHighlight: "\1n\1" + "4\1h\1w", - crossPostMsgAreaDesc: "\1n\1c", - crossPostMsgAreaDescHighlight: "\1n\1" + "4\1c", - crossPostChk: "\1n\1h\1y", - crossPostChkHighlight: "\1n\1" + "4\1h\1y", - crossPostMsgGrpMark: "\1n\1h\1g", - crossPostMsgGrpMarkHighlight: "\1n\1" + "4\1h\1g", + listBoxBorder: "\x01n\x01g", + listBoxBorderText: "\x01n\x01b\x01h", + crossPostMsgAreaNum: "\x01n\x01h\x01w", + crossPostMsgAreaNumHighlight: "\x01n\x01" + "4\x01h\x01w", + crossPostMsgAreaDesc: "\x01n\x01c", + crossPostMsgAreaDescHighlight: "\x01n\x01" + "4\x01c", + crossPostChk: "\x01n\x01h\x01y", + crossPostChkHighlight: "\x01n\x01" + "4\x01h\x01y", + crossPostMsgGrpMark: "\x01n\x01h\x01g", + crossPostMsgGrpMarkHighlight: "\x01n\x01" + "4\x01h\x01g", // Colors for certain output strings - msgWillBePostedHdr: "\1n\1c", - msgPostedGrpHdr: "\1n\1h\1b", - msgPostedSubBoardName: "\1n\1g", - msgPostedOriginalAreaText: "\1n\1c", - msgHasBeenSavedText: "\1n\1h\1c", - msgAbortedText: "\1n\1m\1h", - emptyMsgNotSentText: "\1n\1m\1h", - genMsgErrorText: "\1n\1m\1h", - listBoxItemText: "\1n\1c", - listBoxItemHighlight: "\1n\1" + "4\1w\1h" + msgWillBePostedHdr: "\x01n\x01c", + msgPostedGrpHdr: "\x01n\x01h\x01b", + msgPostedSubBoardName: "\x01n\x01g", + msgPostedOriginalAreaText: "\x01n\x01c", + msgHasBeenSavedText: "\x01n\x01h\x01c", + msgAbortedText: "\x01n\x01m\x01h", + emptyMsgNotSentText: "\x01n\x01m\x01h", + genMsgErrorText: "\x01n\x01m\x01h", + listBoxItemText: "\x01n\x01c", + listBoxItemHighlight: "\x01n\x01" + "4\x01w\x01h" }, // Default Ice-style colors @@ -1638,31 +1638,31 @@ function ReadSlyEditConfigFile() // Ice color theme file ThemeFilename: genFullPathCfgFilename("SlyIceColors_BlueIce.cfg", gStartupPath), // Text edit color - TextEditColor: "\1n\1w", + TextEditColor: "\x01n\x01w", // Quote line color - QuoteLineColor: "\1n\1c", + QuoteLineColor: "\x01n\x01c", // Ice colors for the quote window - QuoteWinText: "\1n\1h\1w", // White - QuoteLineHighlightColor: "\1" + "4\1h\1c", // High cyan on blue background - QuoteWinBorderTextColor: "\1n\1c\1h", // Bright cyan - BorderColor1: "\1n\1b", // Blue - BorderColor2: "\1n\1b\1h", // Bright blue + QuoteWinText: "\x01n\x01h\x01w", // White + QuoteLineHighlightColor: "\x01" + "4\x01h\x01c", // High cyan on blue background + QuoteWinBorderTextColor: "\x01n\x01c\x01h", // Bright cyan + BorderColor1: "\x01n\x01b", // Blue + BorderColor2: "\x01n\x01b\x01h", // Bright blue // Ice colors for multi-choice prompts - SelectedOptionBorderColor: "\1n\1b\1h\1" + "4", - SelectedOptionTextColor: "\1n\1c\1h\1" + "4", - UnselectedOptionBorderColor: "\1n\1b", - UnselectedOptionTextColor: "\1n\1w", + SelectedOptionBorderColor: "\x01n\x01b\x01h\x01" + "4", + SelectedOptionTextColor: "\x01n\x01c\x01h\x01" + "4", + UnselectedOptionBorderColor: "\x01n\x01b", + UnselectedOptionTextColor: "\x01n\x01w", // Ice colors for the top info area - TopInfoBkgColor: "\1" + "4", - TopLabelColor: "\1c\1h", - TopLabelColonColor: "\1b\1h", - TopToColor: "\1w\1h", - TopFromColor: "\1w\1h", - TopSubjectColor: "\1w\1h", - TopTimeColor: "\1g\1h", - TopTimeLeftColor: "\1g\1h", - EditMode: "\1c\1h", - KeyInfoLabelColor: "\1c\1h" + TopInfoBkgColor: "\x01" + "4", + TopLabelColor: "\x01c\x01h", + TopLabelColonColor: "\x01b\x01h", + TopToColor: "\x01w\x01h", + TopFromColor: "\x01w\x01h", + TopSubjectColor: "\x01w\x01h", + TopTimeColor: "\x01g\x01h", + TopTimeLeftColor: "\x01g\x01h", + EditMode: "\x01c\x01h", + KeyInfoLabelColor: "\x01c\x01h" }, // Default DCT-style colors @@ -1670,63 +1670,58 @@ function ReadSlyEditConfigFile() // DCT color theme file ThemeFilename: genFullPathCfgFilename("SlyDCTColors_Default.cfg", gStartupPath), // Text edit color - TextEditColor: "\1n\1w", + TextEditColor: "\x01n\x01w", // Quote line color - QuoteLineColor: "\1n\1c", + QuoteLineColor: "\x01n\x01c", // DCT colors for the border stuff - TopBorderColor1: "\1n\1r", - TopBorderColor2: "\1n\1r\1h", - EditAreaBorderColor1: "\1n\1g", - EditAreaBorderColor2: "\1n\1g\1h", - EditModeBrackets: "\1n\1k\1h", - EditMode: "\1n\1w", + TopBorderColor1: "\x01n\x01r", + TopBorderColor2: "\x01n\x01r\x01h", + EditAreaBorderColor1: "\x01n\x01g", + EditAreaBorderColor2: "\x01n\x01g\x01h", + EditModeBrackets: "\x01n\x01k\x01h", + EditMode: "\x01n\x01w", // DCT colors for the top informational area - TopLabelColor: "\1n\1b\1h", - TopLabelColonColor: "\1n\1b", - TopFromColor: "\1n\1c\1h", - TopFromFillColor: "\1n\1c", - TopToColor: "\1n\1c\1h", - TopToFillColor: "\1n\1c", - TopSubjColor: "\1n\1w\1h", - TopSubjFillColor: "\1n\1w", - TopAreaColor: "\1n\1g\1h", - TopAreaFillColor: "\1n\1g", - TopTimeColor: "\1n\1y\1h", - TopTimeFillColor: "\1n\1r", - TopTimeLeftColor: "\1n\1y\1h", - TopTimeLeftFillColor: "\1n\1r", - TopInfoBracketColor: "\1n\1m", - // DCT colors for the quote window - QuoteWinText: "\1n\1" + "7\1k", - QuoteLineHighlightColor: "\1n\1w", - QuoteWinBorderTextColor: "\1n\1" + "7\1r", - QuoteWinBorderColor: "\1n\1k\1" + "7", + TopLabelColor: "\x01n\x01b\x01h", + TopLabelColonColor: "\x01n\x01b", + TopFromColor: "\x01n\x01c\x01h", + TopFromFillColor: "\x01n\x01c", + TopToColor: "\x01n\x01c\x01h", + TopToFillColor: "\x01n\x01c", + TopSubjColor: "\x01n\x01w\x01h", + TopSubjFillColor: "\x01n\x01w", + TopAreaColor: "\x01n\x01g\x01h", + TopAreaFillColor: "\x01n\x01g", + TopTimeColor: "\x01n\x01y\x01h", + TopTimeFillColor: "\x01n\x01r", + TopTimeLeftColor: "\x01n\x01y\x01h", + TopTimeLeftFillColor: "\x01n\x01r", + TopInfoBracketColor: "\x01n\x01m", // DCT colors for the quote window - QuoteWinText: "\1n\1" + "7\1b", - QuoteLineHighlightColor: "\1n\1w", - QuoteWinBorderTextColor: "\1n\1" + "7\1r", - QuoteWinBorderColor: "\1n\1k\1" + "7", + QuoteWinText: "\x01n\x01" + "7\x01b", // or k + QuoteLineHighlightColor: "\x01n\x01w", + QuoteWinBorderTextColor: "\x01n\x01" + "7\x01r", + QuoteWinBorderColor: "\x01n\x01k\x01" + "7", // DCT colors for the bottom row help text - BottomHelpBrackets: "\1n\1k\1h", - BottomHelpKeys: "\1n\1r\1h", - BottomHelpFill: "\1n\1r", - BottomHelpKeyDesc: "\1n\1c", + BottomHelpBrackets: "\x01n\x01k\x01h", + BottomHelpKeys: "\x01n\x01r\x01h", + BottomHelpFill: "\x01n\x01r", + BottomHelpKeyDesc: "\x01n\x01c", // DCT colors for text boxes - TextBoxBorder: "\1n\1k\1" + "7", - TextBoxBorderText: "\1n\1r\1" + "7", - TextBoxInnerText: "\1n\1b\1" + "7", - YesNoBoxBrackets: "\1n\1k\1" + "7", - YesNoBoxYesNoText: "\1n\1w\1h\1" + "7", + TextBoxBorder: "\x01n\x01k\x01" + "7", + TextBoxBorderText: "\x01n\x01r\x01" + "7", + TextBoxInnerText: "\x01n\x01b\x01" + "7", + YesNoBoxBrackets: "\x01n\x01k\x01" + "7", + YesNoBoxYesNoText: "\x01n\x01w\x01h\x01" + "7", // DCT colors for the menus - SelectedMenuLabelBorders: "\1n\1w", - SelectedMenuLabelText: "\1n\1k\1" + "7", - UnselectedMenuLabelText: "\1n\1w\1h", - MenuBorders: "\1n\1k\1" + "7", - MenuSelectedItems: "\1n\1w", - MenuUnselectedItems: "\1n\1k\1" + "7", - MenuHotkeys: "\1n\1w\1h\1" + "7" + SelectedMenuLabelBorders: "\x01n\x01w", + SelectedMenuLabelText: "\x01n\x01k\x01" + "7", + UnselectedMenuLabelText: "\x01n\x01w\x01h", + MenuBorders: "\x01n\x01k\x01" + "7", + MenuSelectedItems: "\x01n\x01w", + MenuUnselectedItems: "\x01n\x01k\x01" + "7", + MenuHotkeys: "\x01n\x01w\x01h\x01" + "7" } - } + }; // Open the SlyEdit configuration file var slyEdCfgFileName = genFullPathCfgFilename("SlyEdit.cfg", gStartupPath); @@ -2351,54 +2346,55 @@ function toggleAttr(pAttrType, pAttrs, pNewAttr) // If pAttrs starts with the normal attribute, then // remove it (we'll put it back on later). var normalAtStart = false; - if (pAttrs.search(/^N/) == 0) + if (pAttrs.search(/^\x01N/) == 0) { normalAtStart = true; pAttrs = pAttrs.substr(2); } // Prepend the attribute control character to the new attribute - var newAttr = "" + pNewAttr; + var newAttr = "\x01" + pNewAttr; - // Set a regex for searching & replacing - var regex = ""; + // Set a regexStr for searching & replacing + var regexStr = ""; switch (pAttrType) { case FORE_ATTR: // Foreground attribute - regex = /K|R|G|Y|B|M|C|W/g; + regexStr = "\x01K|\x01R|\x01G|\x01Y|\x01B|\x01M|\x01C|\x01W"; break; case BKG_ATTR: // Background attribute - regex = /0|1|2|3|4|5|6|7/g; + regexStr = "x01" + "0|\x01" + "1|\x01" + "2|\x01" + "3|\x01" + "4|\x01" + "5|\x01" + "6|\x01" + "7"; break; case SPECIAL_ATTR: // Special attribute - //regex = /H|I|N/g; + //regexStr = /\x01H|\x01I|\x01N/g; index = pAttrs.search(newAttr); if (index > -1) - pAttrs = pAttrs.replace(newAttr, ""); + pAttrs = pAttrs.replace(newAttr, ""); else - pAttrs += newAttr; + pAttrs += newAttr; break; default: break; } - // If regex is not blank, then search & replace on it in + // If regexStr is not blank, then search & replace on it in // pAttrs. - if (regex != "") + if (regexStr != "") { + var regex = new RegExp(regexStr, 'g'); pAttrs = removeAttrIfExists(pAttrs, newAttr); - // If the regex is found, then replace it. Otherwise, + // If the regexStr is found, then replace it. Otherwise, // add pNewAttr to the attribute string. if (pAttrs.search(regex) > -1) - pAttrs = pAttrs.replace(regex, "" + pNewAttr); + pAttrs = pAttrs.replace(regex, "\x01" + pNewAttr); else - pAttrs += "" + pNewAttr; + pAttrs += "\x01" + pNewAttr; } // If pAttrs started with the normal attribute, then // put it back on. if (normalAtStart) - pAttrs = "N" + pAttrs; + pAttrs = "\x01N" + pAttrs; return pAttrs; } @@ -2459,13 +2455,13 @@ function wrapTextLines(pLineArr, pStartLineIndex, pEndIndex, pLineWidth, pIdxesR if (trimIndex == -1) trimIndex = pLineArr[i].length - trimLen; // Trim the text, and remove leading spaces from it too. - trimmedText = pLineArr[i].substr(trimIndex).replace(/^ +/, ""); + var trimmedText = pLineArr[i].substr(trimIndex).replace(/^ +/, ""); pLineArr[i] = pLineArr[i].substr(0, trimIndex); if (i < pLineArr.length - 1) { // Append a space to the end of the trimmed text if it doesn't have one. if ((trimmedText.length > 0) && (trimmedText.charAt(trimmedText.length-1) != " ")) - trimmedText += " " + trimmedText += " "; // Prepend the trimmed text to the next line. If the next line's index // is within the paragraph we're wrapping, then go ahead and prepend the // text to the next line. Otherwise, add a new line to the array and @@ -4416,8 +4412,8 @@ function consolePauseWithESCChars(pCfgObj) // "@EXEC:" (to execute a script), default to a "press a key" message. var pausePromptText = bbs.text(Pause); // 563: The "Press a key" text in text.dat if (pausePromptText.toUpperCase().indexOf("@EXEC:") > -1) - pausePromptText = "\1n\1c[ Press a key ] "; - console.print("\1n" + pausePromptText); + pausePromptText = "\x01n\x01c[ Press a key ] "; + console.print("\x01n" + pausePromptText); getKeyWithESCChars(K_NOSPIN|K_NOCRLF|K_NOECHO, pCfgObj); } @@ -4434,8 +4430,8 @@ function consolePauseWithoutText() // characters such as PageUp, PageDown, and ESC. If PageUp // or PageDown are pressed, this function will return the // string defined by KEY_PAGE_UP or EY_PAGE_DOWN, -// respectively. Also, F1-F5 will be returned as "\1F1" -// through "\1F5", respectively. +// respectively. Also, F1-F5 will be returned as "\x01F1" +// through "\x01F5", respectively. // Thanks goes to Psi-Jack for the original impementation // of this function. // diff --git a/exec/load/dd_lightbar_menu.js b/exec/load/dd_lightbar_menu.js index de4ccbbfaeef2fcba6b3c5938668e63b3756d9ea..aedf28f3f6c91e971b258469566907233e7f86ca 100644 --- a/exec/load/dd_lightbar_menu.js +++ b/exec/load/dd_lightbar_menu.js @@ -45,7 +45,7 @@ selectedItemColor: The color to use for selected items (current default is blue below. itemTextCharHighlightColor: The color of a highlighted non-space character in an item text (specified by having a & in the item text). - It's important not to specify a "\1n" in here in case + It's important not to specify a "\x01n" in here in case the item text should have a background color. borderColor: The color for the borders (if borders are enabled) You can also call SetColors() and pass in a JS object with any or all of the @@ -129,9 +129,9 @@ When numbered mode is enabled, you can specify the color used to display the item numbers. For a non-selected item, set .colors.itemNumColor. For selected items, set .colors.highlightedItemNumColor. This is separate from the item color setting (.colors.itemColor). For example: -lbMenu.colors.itemNumColor = "\1c"; // Use cyan for the item numbers for non-selected items. +lbMenu.colors.itemNumColor = "\x01c"; // Use cyan for the item numbers for non-selected items. // For the selected item, use high cyan with a blue background for the item number -lbMenu.colors.highlightedItemNumColor = "\1" + "4\1c\1h"; +lbMenu.colors.highlightedItemNumColor = "\x01" + "4\x01c\x01h"; This menu also supports multiple options selected (by default, that is not enabled). To enable that, set the multiSelect property to true. When enabled, the GetVal() @@ -155,13 +155,13 @@ lbMenu.SetItemHotkey(1, "s"); // Show the menu and get the chosen item from the user var val = lbMenu.GetVal(); // Output the chosen menu item -console.print("\1n\r\n"); +console.print("\x01n\r\n"); console.print("Value:" + val + ":, type: " + typeof(val) + "\r\n"); console.pause(); // Changing the normal item color to green & selected item color to bright green: -lbMenu.colors.itemColor = "\1n\1g"; -lbMenu.colors.selectedItemColor = "\1n\1h\1g"; +lbMenu.colors.itemColor = "\x01n\x01g"; +lbMenu.colors.selectedItemColor = "\x01n\x01h\x01g"; // Disabling the navigation wrap behavior: lbMenu.wrapNavigation = false; @@ -263,7 +263,7 @@ lbMenu.ValidateSelectItem = function(pItemRetval) { return true; else { - console.print("* Can't choose " + pItemRetval + " because blah blah blah!\r\n\1p"); + console.print("* Can't choose " + pItemRetval + " because blah blah blah!\r\n\x01p"); return false; } } @@ -327,6 +327,8 @@ The parameters: pSelectedItemIndexes: Optional - An object containing indexes of selected items */ +"use strict"; + if (typeof(require) === "function") { require("sbbsdefs.js", "K_UPPER"); @@ -411,16 +413,16 @@ function DDLightbarMenu(pX, pY, pWidth, pHeight) this.borderEnabled = false; this.drawnAlready = false; this.colors = { - itemColor: "\1n\1w\1" + "4", // Can be either a string or an array specifying colors within the item - selectedItemColor: "\1n\1b\1" + "7", // Can be either a string or an array specifying colors within the item - altItemColor: "\1n\1w\1" + "4", // Alternate item color. Can be either a string or an array specifying colors within the item - altSelectedItemColor: "\1n\1b\1" + "7", // Alternate selected item color. Can be either a string or an array specifying colors within the item - itemTextCharHighlightColor: "\1y\1h", - borderColor: "\1n\1b", - scrollbarScrollBlockColor: "\1h\1w", - scrollbarBGColor: "\1h\1k", - itemNumColor: "\1n", - highlightedItemNumColor: "\1n" + itemColor: "\x01n\x01w\x01" + "4", // Can be either a string or an array specifying colors within the item + selectedItemColor: "\x01n\x01b\x01" + "7", // Can be either a string or an array specifying colors within the item + altItemColor: "\x01n\x01w\x01" + "4", // Alternate item color. Can be either a string or an array specifying colors within the item + altSelectedItemColor: "\x01n\x01b\x01" + "7", // Alternate selected item color. Can be either a string or an array specifying colors within the item + itemTextCharHighlightColor: "\x01y\x01h", + borderColor: "\x01n\x01b", + scrollbarScrollBlockColor: "\x01h\x01w", + scrollbarBGColor: "\x01h\x01k", + itemNumColor: "\x01n", + highlightedItemNumColor: "\x01n" }; // Characters to use to draw the border this.borderChars = { @@ -469,8 +471,8 @@ function DDLightbarMenu(pX, pY, pWidth, pHeight) // codes in strings. // For one that looks at the whole word having only Synchronet attribute // codes, it would have ^ and $ around it, as in - // /^\1[krgybmcw01234567hinpq,;\.dtl<>\[\]asz]$/i - this.syncAttrRegex = /\1[krgybmcw01234567hinpq,;\.dtl<>\[\]asz]/i; + // /^\x01[krgybmcw01234567hinpq,;\.dtl<>\[\]asz]$/i + this.syncAttrRegex = /\x01[krgybmcw01234567hinpq,;\.dtl<>\[\]asz]/i; // Whether or not to exit the input loop when an item is selected/submitted // (i.e. with ENTER; not for toggling with multi-select) @@ -794,7 +796,7 @@ function DDLightbarMenu_Draw(pSelectedItemIndexes, pDrawBorders, pDrawScrollbar) if (writeTheItem) { console.gotoxy(curPos.x, curPos.y++); - console.print("\1n"); + console.print("\x01n"); if (this.numberedMode) printf(numberFormatStr, ""); var itemText = addAttrsToString(format(itemFormatStr, ""), this.colors.itemColor); @@ -815,7 +817,7 @@ function DDLightbarMenu_DrawBorder() return; // Draw the border around the menu options - console.print("\1n" + this.colors.borderColor); + console.print("\x01n" + this.colors.borderColor); // Upper border console.gotoxy(this.pos.x, this.pos.y); if (this.borderChars.hasOwnProperty("upperLeft") && (typeof(this.borderChars.upperLeft) == "string")) @@ -828,7 +830,7 @@ function DDLightbarMenu_DrawBorder() // Display the top border text (if any) in the top border. Ensure the text // length is no longer than the maximum possible length (lineLen). var borderText = shortenStrWithAttrCodes(this.topBorderText, lineLen); - console.print("\1n" + borderText + "\1n" + this.colors.borderColor); + console.print("\x01n" + borderText + "\x01n" + this.colors.borderColor); var remainingLineLen = lineLen - console.strlen(borderText); for (var i = 0; i < remainingLineLen; ++i) console.print(this.borderChars.top); @@ -854,7 +856,7 @@ function DDLightbarMenu_DrawBorder() // Display the bottom border text (if any) in the bottom border. Ensure the text // length is no longer than the maximum possible length (lineLen). var borderText = shortenStrWithAttrCodes(this.bottomBorderText, lineLen); - console.print("\1n" + borderText + "\1n" + this.colors.borderColor); + console.print("\x01n" + borderText + "\x01n" + this.colors.borderColor); var remainingLineLen = lineLen - console.strlen(borderText); for (var i = 0; i < remainingLineLen; ++i) console.print(this.borderChars.bottom); @@ -903,6 +905,17 @@ function DDLightbarMenu_DrawBorder() function DDLightbarMenu_WriteItem(pIdx, pItemLen, pHighlight, pSelected, pScreenX, pScreenY) { var itemText = this.GetItemText(pIdx, pItemLen, pHighlight, pSelected); + // Temporary + if (user.is_sysop) + { + var outFile = new File("/home/erico/temp/debug.txt"); + if (outFile.open("a")) + { + outFile.writeln(itemText); + outFile.close(); + } + } + // End Temporary // If this.nextDrawOnlyItemSubstr is an object with start & end properties, // then create a string that is shortened from itemText from those start & end // indexes, and add color to it. @@ -912,10 +925,10 @@ function DDLightbarMenu_WriteItem(pIdx, pItemLen, pHighlight, pSelected, pScreen var len = this.nextDrawOnlyItemSubstr.end - this.nextDrawOnlyItemSubstr.start; var shortenedText = substrWithAttrCodes(itemText, this.nextDrawOnlyItemSubstr.start, len); console.gotoxy(pScreenX+this.nextDrawOnlyItemSubstr.start, pScreenY); - console.print(shortenedText + "\1n"); + console.print(shortenedText + "\x01n"); } else - console.print(itemText + "\1n"); + console.print(itemText + "\x01n"); } // Writes a menu item at its location on the menu. This should only be called @@ -979,7 +992,7 @@ function DDLightbarMenu_DrawPartial(pStartX, pStartY, pWidth, pHeight, pSelected // Top line if (lineNum == this.pos.y) { - console.print("\1n" + this.colors.borderColor); + console.print("\x01n" + this.colors.borderColor); for (var posX = pStartX; posX <= lastX; ++posX) { console.gotoxy(posX, lineNum); @@ -994,7 +1007,7 @@ function DDLightbarMenu_DrawPartial(pStartX, pStartY, pWidth, pHeight, pSelected // Bottom line else if (lineNum == this.pos.y + this.size.height - 1) { - console.print("\1n" + this.colors.borderColor); + console.print("\x01n" + this.colors.borderColor); for (var posX = pStartX; posX <= lastX; ++posX) { console.gotoxy(posX, lineNum); @@ -1017,7 +1030,7 @@ function DDLightbarMenu_DrawPartial(pStartX, pStartY, pWidth, pHeight, pSelected { if (!printedBorderColor) { - console.print("\1n" + this.colors.borderColor); + console.print("\x01n" + this.colors.borderColor); printedBorderColor = true; } console.print(this.borderChars.left); @@ -1026,7 +1039,7 @@ function DDLightbarMenu_DrawPartial(pStartX, pStartY, pWidth, pHeight, pSelected { if (!printedBorderColor) { - console.print("\1n" + this.colors.borderColor); + console.print("\x01n" + this.colors.borderColor); printedBorderColor = true; } console.print(this.borderChars.right); @@ -1077,7 +1090,7 @@ function DDLightbarMenu_DrawPartial(pStartX, pStartY, pWidth, pHeight, pSelected // Write the menu items if (writeMenuItems) { - var blankItemTextFormatStr = "\1n%" + itemLen + "s"; + var blankItemTextFormatStr = "\x01n%" + itemLen + "s"; for (var lineNum = pStartY + this.pos.y - 1; lineNum <= lastLineNum; ++lineNum) { var startX = pStartX; @@ -1103,7 +1116,7 @@ function DDLightbarMenu_DrawPartial(pStartX, pStartY, pWidth, pHeight, pSelected if (shortenedText.length == 0) shortenedText = format(blankItemTextFormatStr, ""); console.gotoxy(startX, lineNum); - console.print(shortenedText + "\1n"); + console.print(shortenedText + "\x01n"); } } } @@ -1235,7 +1248,7 @@ function DDLightbarMenu_GetItemText(pIdx, pItemLen, pHighlight, pSelected) if (nextChar != " ") { itemText = itemText.substr(0, ampersandIndex) + this.colors.itemTextCharHighlightColor - + nextChar + "\1n" + itemColor + itemText.substr(ampersandIndex+2); + + nextChar + "\x01n" + itemColor + itemText.substr(ampersandIndex+2); } } } @@ -1271,12 +1284,12 @@ function DDLightbarMenu_GetItemText(pIdx, pItemLen, pHighlight, pSelected) // If in numbered mode, prepend the item number to the front of the item text. if (this.numberedMode) { - var numColor = "\1n" + this.colors.itemNumColor; + var numColor = "\x01n" + this.colors.itemNumColor; if (typeof(pHighlight) === "boolean") numColor = (pHighlight ? this.colors.highlightedItemNumColor : this.colors.itemNumColor); else numColor = (pIdx == this.selectedItemIdx ? this.colors.highlightedItemNumColor : this.colors.itemNumColor); - itemText = format("\1n" + numColor + "%" + this.itemNumLen + "d \1n", pIdx+1) + itemText; + itemText = format("\x01n" + numColor + "%" + this.itemNumLen + "d \x01n", pIdx+1) + itemText; } } return itemText; @@ -1286,7 +1299,7 @@ function DDLightbarMenu_GetItemText(pIdx, pItemLen, pHighlight, pSelected) function DDLightbarMenu_Erase() { var formatStr = "%" + this.size.width + "s"; // For use with printf() - console.print("\1n"); + console.print("\x01n"); var curPos = { x: this.pos.x, y: this.pos.y }; for (var i = 0; i < this.size.height; ++i) { @@ -1879,16 +1892,16 @@ function DDLightbarMenu_GetVal(pDraw, pSelectedItemIndexes) if (Array.isArray(itemColor)) { var bkgColor = getBackgroundAttrAtIdx(itemColor, this.size.width-1); - itemColor = "\1n\1h\1g" + bkgColor; + itemColor = "\x01n\x01h\x01g" + bkgColor; } - console.print(itemColor + " " + this.multiSelectItemChar + "\1n"); + console.print(itemColor + " " + this.multiSelectItemChar + "\x01n"); } else { // Display the last 2 characters of the regular item text var itemText = this.GetItemText(this.selectedItemIdx, null, true, false); var textToPrint = substrWithAttrCodes(itemText, console.strlen(itemText)-2, 2); - console.print(textToPrint + "\1n"); + console.print(textToPrint + "\x01n"); } } } @@ -1907,13 +1920,13 @@ function DDLightbarMenu_GetVal(pDraw, pSelectedItemIndexes) var promptX = this.pos.x; var promptY = this.pos.y+this.size.height; console.gotoxy(promptX, promptY); - printf("\1n%" + this.size.width + "s", ""); // Blank out what might be on the screen already + printf("\x01n%" + this.size.width + "s", ""); // Blank out what might be on the screen already console.gotoxy(promptX, promptY); - console.print("\1cItem #: \1h"); + console.print("\x01cItem #: \x01h"); var userEnteredItemNum = console.getnum(numItems); // Blank out the input prompt console.gotoxy(promptX, promptY); - printf("\1n%" + this.size.width + "s", ""); + printf("\x01n%" + this.size.width + "s", ""); // If the user entered a number, then get that item's return value // and stop the input loop. if (userEnteredItemNum > 0) @@ -2009,7 +2022,7 @@ function DDLightbarMenu_GetVal(pDraw, pSelectedItemIndexes) // Set the screen color back to normal so that text written to the screen // after this looks good. - console.print("\1n"); + console.print("\x01n"); // If in multi-select mode, populate userChoices with the choices // that the user selected. @@ -2122,7 +2135,7 @@ function DDLightbarMenu_SetBorderChars(pBorderChars) // non-space character in an item text // (specified by having a & in the item // text). -// It's important not to specify a "\1n" +// It's important not to specify a "\x01n" // in here in case the item text should // have a background color. // borderColor: The color to use for the border @@ -2263,7 +2276,7 @@ function DDLightbarMenu_DisplayInitialScrollbar(pSolidBlockStartRow, pNumSolidBl { if (!wroteBrightBlockColor) { - console.print("\1n" + this.colors.scrollbarScrollBlockColor); + console.print("\x01n" + this.colors.scrollbarScrollBlockColor); wroteBrightBlockColor = true; wroteDimBlockColor = false; } @@ -2274,7 +2287,7 @@ function DDLightbarMenu_DisplayInitialScrollbar(pSolidBlockStartRow, pNumSolidBl { if (!wroteDimBlockColor) { - console.print("\1n" + this.colors.scrollbarBGColor); + console.print("\x01n" + this.colors.scrollbarBGColor); wroteDimBlockColor = true; } console.print(this.scrollbarInfo.BGChar); @@ -2318,14 +2331,14 @@ function DDLightbarMenu_UpdateScrollbar(pNewStartRow, pOldStartRow, pNumSolidBlo { // No overlap // Write dim blocks over the old solid block section - console.print("\1n" + this.colors.scrollbarBGColor); + console.print("\x01n" + this.colors.scrollbarBGColor); for (var screenY = pOldStartRow; screenY <= oldLastRow; ++screenY) { console.gotoxy(scrollbarCol, screenY); console.print(this.scrollbarInfo.BGChar); } // Write solid blocks in the new locations - console.print("\1n" + this.colors.scrollbarScrollBlockColor); + console.print("\x01n" + this.colors.scrollbarScrollBlockColor); for (var screenY = pNewStartRow; screenY <= newLastRow; ++screenY) { console.gotoxy(scrollbarCol, screenY); @@ -2336,14 +2349,14 @@ function DDLightbarMenu_UpdateScrollbar(pNewStartRow, pOldStartRow, pNumSolidBlo { // There is some overlap // Write dim blocks on top - console.print("\1n" + this.colors.scrollbarBGColor); + console.print("\x01n" + this.colors.scrollbarBGColor); for (var screenY = pOldStartRow; screenY < pNewStartRow; ++screenY) { console.gotoxy(scrollbarCol, screenY); console.print(this.scrollbarInfo.BGChar); } // Write bright blocks on the bottom - console.print("\1n" + this.colors.scrollbarScrollBlockColor); + console.print("\x01n" + this.colors.scrollbarScrollBlockColor); for (var screenY = oldLastRow+1; screenY <= newLastRow; ++screenY) { console.gotoxy(scrollbarCol, screenY); @@ -2358,14 +2371,14 @@ function DDLightbarMenu_UpdateScrollbar(pNewStartRow, pOldStartRow, pNumSolidBlo { // No overlap // Write dim blocks over the old solid block section - console.print("\1n" + this.colors.scrollbarBGColor); + console.print("\x01n" + this.colors.scrollbarBGColor); for (var screenY = pOldStartRow; screenY <= oldLastRow; ++screenY) { console.gotoxy(scrollbarCol, screenY); console.print(this.scrollbarInfo.BGChar); } // Write solid blocks in the new locations - console.print("\1n" + this.colors.scrollbarScrollBlockColor); + console.print("\x01n" + this.colors.scrollbarScrollBlockColor); for (var screenY = pNewStartRow; screenY <= newLastRow; ++screenY) { console.gotoxy(scrollbarCol, screenY); @@ -2376,7 +2389,7 @@ function DDLightbarMenu_UpdateScrollbar(pNewStartRow, pOldStartRow, pNumSolidBlo { // There is some overlap // Write bright blocks on top - console.print("\1n" + this.colors.scrollbarScrollBlockColor); + console.print("\x01n" + this.colors.scrollbarScrollBlockColor); var endRow = pOldStartRow; for (var screenY = pNewStartRow; screenY < endRow; ++screenY) { @@ -2384,7 +2397,7 @@ function DDLightbarMenu_UpdateScrollbar(pNewStartRow, pOldStartRow, pNumSolidBlo console.print(this.scrollbarInfo.blockChar); } // Write dim blocks on the bottom - console.print("\1n" + this.colors.scrollbarBGColor); + console.print("\x01n" + this.colors.scrollbarBGColor); endRow = pOldStartRow + numSolidBlocks; for (var screenY = pNewStartRow+numSolidBlocks; screenY < endRow; ++screenY) { @@ -2798,17 +2811,17 @@ function addAttrsToString(pStr, pAttrs) // the last's end, then append the gap in the string with the // normal attribute if ((i > 0) && (pAttrs[i].start > pAttrs[i-1].end)) - str += "\1n" + pStr.substring(pAttrs[i-1].end, pAttrs[i].start); + str += "\x01n" + pStr.substring(pAttrs[i-1].end, pAttrs[i].start); // If the properties for the current attrib object are all valid, append // the current part of the string with the given attributes if ((pAttrs[i].start >= lastEnd) && (pAttrs[i].start >= 0) && (pAttrs[i].start < pStr.length) && (pAttrs[i].end > pAttrs[i].start) && (pAttrs[i].end <= pStr.length)) - str += "\1n" + pAttrs[i].attrs + pStr.substring(pAttrs[i].start, pAttrs[i].end); + str += "\x01n" + pAttrs[i].attrs + pStr.substring(pAttrs[i].start, pAttrs[i].end); // For the last attribute object, allow the end index to be <= 0 or // more than the length of the string to apply the attributes to the // rest of the string. //else if ((i == pAttrs.length-1) && (pAttrs[i].start >= lastEnd) && (pAttrs[i].start >= 0) && (pAttrs[i].start < pStr.length) && (pAttrs[i].end <= 0)) else if ((i == pAttrs.length-1) && (pAttrs[i].start >= lastEnd) && (pAttrs[i].start >= 0) && (pAttrs[i].start < pStr.length) && ((pAttrs[i].end <= 0) || (pAttrs[i].end > pStr.length))) - str += "\1n" + pAttrs[i].attrs + pStr.substring(pAttrs[i].start); + str += "\x01n" + pAttrs[i].attrs + pStr.substring(pAttrs[i].start); lastEnd = pAttrs[i].end; } @@ -2816,13 +2829,13 @@ function addAttrsToString(pStr, pAttrs) // with the normal attribute. var theStrLen = console.strlen(str); if (theStrLen < pStr.length) - str += "\1n" + pStr.substring(theStrLen); + str += "\x01n" + pStr.substring(theStrLen); } else str = pStr; } else if (typeof(pAttrs) == "string") - str = "\1n" + pAttrs + pStr; + str = "\x01n" + pAttrs + pStr; else str = pStr; return str; @@ -2844,7 +2857,7 @@ function getBackgroundAttrAtIdx(pAttrs, pIdx) // Magenta: 5 // Cyan: 6 // White/grey: 7 - var syncBkgAttrRegex = /\1[01234567]/; + var syncBkgAttrRegex = /\x01[01234567]/; var bkgAttr = ""; if (Array.isArray(pAttrs)) { @@ -2935,7 +2948,7 @@ function substrWithAttrCodes(pStr, pStartIdx, pLen) var len = pLen; var printableCharCount = 0; var syncAttrCount = 0; - var syncAttrRegexWholeWord = /^\1[krgybmcw01234567hinpq,;\.dtl<>\[\]asz]$/i; + var syncAttrRegexWholeWord = /^\x01[krgybmcw01234567hinpq,;\.dtl<>\[\]asz]$/i; var i = startIdx; while ((printableCharCount < pLen) && (i < pStr.length)) { @@ -2954,7 +2967,7 @@ function substrWithAttrCodes(pStr, pStartIdx, pLen) var shortenedStr = pStr.substr(startIdx, len); // Include any attribute codes that might appear before the start index // in the string - var attrIdx = pStr.lastIndexOf("\1", startIdx); + var attrIdx = pStr.lastIndexOf("\x01", startIdx); if (attrIdx >= 0) { var attrStartIdx = -1; @@ -3015,8 +3028,8 @@ function printedToRealIdxInStr(pStr, pIdx) // characters such as PageUp, PageDown, and ESC. If PageUp // or PageDown are pressed, this function will return the // string defined by KEY_PAGE_UP or EY_PAGE_DOWN, -// respectively. Also, F1-F5 will be returned as "\1F1" -// through "\1F5", respectively. +// respectively. Also, F1-F5 will be returned as "\x01F1" +// through "\x01F5", respectively. // Thanks goes to Psi-Jack for the original impementation // of this function. // @@ -3081,3 +3094,55 @@ function getKeyWithESCChars(pGetKeyMode, pInputTimeoutMS) return userInput; } + + + +function logStackTrace(levels) { + var callstack = []; + var isCallstackPopulated = false; + try { + i.dont.exist += 0; //doesn't exist- that's the point + } catch (e) { + if (e.stack) { //Firefox / chrome + var lines = e.stack.split('\n'); + for (var i = 0, len = lines.length; i < len; i++) { + callstack.push(lines[i]); + } + //Remove call to logStackTrace() + callstack.shift(); + isCallstackPopulated = true; + } + else if (window.opera && e.message) { //Opera + var lines = e.message.split('\n'); + for (var i = 0, len = lines.length; i < len; i++) { + if (lines[i].match(/^\s*[A-Za-z0-9\-_\$]+\(/)) { + var entry = lines[i]; + //Append next line also since it has the file info + if (lines[i + 1]) { + entry += " at " + lines[i + 1]; + i++; + } + callstack.push(entry); + } + } + //Remove call to logStackTrace() + callstack.shift(); + isCallstackPopulated = true; + } + } + if (!isCallstackPopulated) { //IE and Safari + var currentFunction = arguments.callee.caller; + while (currentFunction) { + var fn = currentFunction.toString(); + var fname = fn.substring(fn.indexOf("function") + 8, fn.indexOf("(")) || "anonymous"; + callstack.push(fname); + currentFunction = currentFunction.caller; + } + } + if (levels) { + console.print(callstack.slice(0, levels).join("\r\n")); + } + else { + console.print(callstack.join("\r\n")); + } +} \ No newline at end of file diff --git a/xtrn/ddfilelister/ddfilelister.js b/xtrn/ddfilelister/ddfilelister.js index 600f61fd3b76de6354bade0bf3f800fec6cd1033..3cebf23d7d285731fdd1da9d7d020fee12cc3035 100644 --- a/xtrn/ddfilelister/ddfilelister.js +++ b/xtrn/ddfilelister/ddfilelister.js @@ -49,6 +49,8 @@ * line. */ +"use strict"; + if (typeof(require) === "function") { require("sbbsdefs.js", "K_UPPER"); @@ -88,10 +90,10 @@ if (system.version_num < 31900) { if (user.is_sysop) { - var message = "\1n\1h\1y\1i* Warning:\1n\1h\1w Digital Distortion File Lister " - + "requires version \1g3.19\1w or\r\n" - + "higher of Synchronet. This BBS is using version \1g" + system.version - + "\1w.\1n"; + var message = "\x01n\x01h\x01y\x01i* Warning:\x01n\x01h\x01w Digital Distortion File Lister " + + "requires version \x01g3.19\x01w or\r\n" + + "higher of Synchronet. This BBS is using version \x01g" + system.version + + "\x01w.\x01n"; console.crlf(); console.print(message); console.crlf(); @@ -139,35 +141,35 @@ gListIdxes.descriptionStart = gListIdxes.fileSizeEnd; gListIdxes.descriptionEnd = console.screen_columns - 1; // Leave 1 character remaining on the screen // Colors var gColors = { - filename: "\1n\1b\1h", - fileSize: "\1n\1m\1h", - desc: "\1n\1w", - bkgHighlight: "\1n\1" + "4", - filenameHighlight: "\1c\1h", - fileSizeHighlight: "\1c\1h", - descHighlight: "\1c\1h", - fileTimestamp: "\1g\1h", - fileInfoWindowBorder: "\1r", - fileInfoWindowTitle: "\1g", - errorBoxBorder: "\1g\1h", - errorMessage: "\1y\1h", - successMessage: "\1c", - - batchDLInfoWindowBorder: "\1r", - batchDLInfoWindowTitle: "\1g", - confirmFileActionWindowBorder: "\1r", - confirmFileActionWindowWindowTitle: "\1g", - - fileAreaMenuBorder: "\1b", - fileNormalBkg: "\1" + "4", - fileAreaNum: "\1w", - fileAreaDesc: "\1w", - fileAreaNumItems: "\1w", - - fileAreaMenuHighlightBkg: "\1" + "7", - fileAreaNumHighlight: "\1b", - fileAreaDescHighlight: "\1b", - fileAreaNumItemsHighlight: "\1b" + filename: "\x01n\x01b\x01h", + fileSize: "\x01n\x01m\x01h", + desc: "\x01n\x01w", + bkgHighlight: "\x01n\x01" + "4", + filenameHighlight: "\x01c\x01h", + fileSizeHighlight: "\x01c\x01h", + descHighlight: "\x01c\x01h", + fileTimestamp: "\x01g\x01h", + fileInfoWindowBorder: "\x01r", + fileInfoWindowTitle: "\x01g", + errorBoxBorder: "\x01g\x01h", + errorMessage: "\x01y\x01h", + successMessage: "\x01c", + + batchDLInfoWindowBorder: "\x01r", + batchDLInfoWindowTitle: "\x01g", + confirmFileActionWindowBorder: "\x01r", + confirmFileActionWindowWindowTitle: "\x01g", + + fileAreaMenuBorder: "\x01b", + fileNormalBkg: "\x01" + "4", + fileAreaNum: "\x01w", + fileAreaDesc: "\x01w", + fileAreaNumItems: "\x01w", + + fileAreaMenuHighlightBkg: "\x01" + "7", + fileAreaNumHighlight: "\x01b", + fileAreaDescHighlight: "\x01b", + fileAreaNumItemsHighlight: "\x01b" }; @@ -235,12 +237,12 @@ if (listPopRetObj.exitNow) if (gFileList.length == 0) { console.crlf(); - console.print("\1n\1c"); + console.print("\x01n\x01c"); if (gScriptMode == MODE_LIST_CURDIR) console.print("There are no files in the current directory."); else console.print("No files were found."); - console.print("\1n"); + console.print("\x01n"); console.crlf(); console.pause(); exit(0); @@ -248,7 +250,7 @@ if (gFileList.length == 0) // Clear the screen and display the header lines -console.clear("\1n"); +console.clear("\x01n"); displayFileLibAndDirHeader(); // Construct and display the menu/command bar at the bottom of the screen var fileMenuBar = new DDFileMenuBar({ x: 1, y: console.screen_rows }); @@ -311,12 +313,12 @@ while (continueDoingFileList) { if (actionRetObj.reDrawHeaderTextOnly) { - console.print("\1n"); + console.print("\x01n"); displayFileLibAndDirHeader(true); // Will move the cursor where it needs to be } else if (actionRetObj.reDrawListerHeader) { - console.print("\1n"); + console.print("\x01n"); console.gotoxy(1, 1); displayFileLibAndDirHeader(); } @@ -403,7 +405,7 @@ while (continueDoingFileList) gFileListMenu.WriteItemAtItsLocation(idxNum, isSelected, false); } else - console.print("\1n\r\nNot drawing idx " + idxNum + "\r\n\1p"); + console.print("\x01n\r\nNot drawing idx " + idxNum + "\r\n\x01p"); } } } @@ -537,15 +539,15 @@ function showFileInfo(pFileList, pFileListMenu) // Make sure the displayed filename isn't too crazy long var frameInnerWidth = frameWidth - 2; // Without borders var adjustedFilename = shortenFilename(fileMetadata.name, frameInnerWidth, false); - var fileInfoStr = "\1n\1wFilename"; + var fileInfoStr = "\x01n\x01wFilename"; if (adjustedFilename.length < fileMetadata.name.length) fileInfoStr += " (shortened)"; fileInfoStr += ":\r\n"; - fileInfoStr += gColors.filename + adjustedFilename + "\1n\1w\r\n"; + fileInfoStr += gColors.filename + adjustedFilename + "\x01n\x01w\r\n"; // Note: File size can also be retrieved by calling a FileBase's get_size(fileMetadata.name) // TODO: Shouldn't need the max length here - fileInfoStr += "Size: " + gColors.fileSize + getFileSizeStr(fileMetadata.size, 99999) + "\1n\1w\r\n"; - fileInfoStr += "Timestamp: " + gColors.fileTimestamp + strftime("%Y-%m-%d %H:%M:%S", fileMetadata.time) + "\1n\1w\r\n" + fileInfoStr += "Size: " + gColors.fileSize + getFileSizeStr(fileMetadata.size, 99999) + "\x01n\x01w\r\n"; + fileInfoStr += "Timestamp: " + gColors.fileTimestamp + strftime("%Y-%m-%d %H:%M:%S", fileMetadata.time) + "\x01n\x01w\r\n" fileInfoStr += "\r\n"; // File library/directory information @@ -553,8 +555,8 @@ function showFileInfo(pFileList, pFileListMenu) var dirIdx = file_area.dir[dirCode].index; var libDesc = file_area.lib_list[libIdx].description; var dirDesc = file_area.dir[dirCode].description; - fileInfoStr += "\1c\1hLib\1g: \1n\1c" + libDesc.substr(0, frameInnerWidth-5) + "\1n\1w\r\n"; - fileInfoStr += "\1c\1hDir\1g: \1n\1c" + dirDesc.substr(0, frameInnerWidth-5) + "\1n\1w\r\n"; + fileInfoStr += "\x01c\x01hLib\x01g: \x01n\x01c" + libDesc.substr(0, frameInnerWidth-5) + "\x01n\x01w\r\n"; + fileInfoStr += "\x01c\x01hDir\x01g: \x01n\x01c" + dirDesc.substr(0, frameInnerWidth-5) + "\x01n\x01w\r\n"; fileInfoStr += "\r\n"; // fileMetadata should have extdDesc, but check just in case @@ -596,16 +598,16 @@ function showFileInfo(pFileList, pFileListMenu) if (typeof(fileMetadata[prop]) === "string" && fileMetadata[prop].length == 0) continue; var propName = prop.charAt(0).toUpperCase() + prop.substr(1); - fileInfoStr += "\r\n\1n\1c\1h" + propName + "\1g:\1n\1c "; + fileInfoStr += "\r\n\x01n\x01c\x01h" + propName + "\x01g:\x01n\x01c "; if (prop == "added") fileInfoStr += strftime("%Y-%m-%d %H:%M:%S", fileMetadata.added); else fileInfoStr += fileMetadata[prop].toString().substr(0, frameInnerWidth); - fileInfoStr += "\1n\1w"; + fileInfoStr += "\x01n\x01w"; } } } - fileInfoStr += "\1n\1w"; + fileInfoStr += "\x01n\x01w"; // Construct & draw a frame with the file information & do the input loop // for the frame until the user closes the frame. @@ -669,10 +671,10 @@ function viewFile(pFileList, pFileListMenu) // View the file console.gotoxy(1, console.screen_rows); - console.print("\1n"); + console.print("\x01n"); console.crlf(); var successfullyViewed = bbs.view_file(fullyPathedFilename); - console.print("\1n"); + console.print("\x01n"); if (gPauseAfterViewingFile || !successfullyViewed) console.pause(); @@ -780,7 +782,7 @@ function addSelectedFilesToBatchDLQueue(pFileList, pFileListMenu) var rightFormatStr = "%" + +(frameUpperLeftX+frameWidth-1) + "s"; var lastFrameRow = frameUpperLeftY + frameHeight - 1; var lastRow = console.screen_rows - 1; - console.print("\1n"); + console.print("\x01n"); for (var screenRow = gNumHeaderLinesDisplayed+1; screenRow <= lastRow; ++screenRow) { console.gotoxy(1, screenRow); @@ -797,13 +799,13 @@ function addSelectedFilesToBatchDLQueue(pFileList, pFileListMenu) // Build a frame with batch DL queue stats and prompt the user if they want to // download their batch DL queue var frameTitle = "Download your batch queue (Y/N)?"; - // \1cFiles: \1h1 \1n\1c(\1h100 \1n\1cMax) Credits: 0 Bytes: \1h2,228,254 \1n\1c Time: 00:09:40 + // \x01cFiles: \x01h1 \x01n\x01c(\x01h100 \x01n\x01cMax) Credits: 0 Bytes: \x01h2,228,254 \x01n\x01c Time: 00:09:40 // Note: The maximum number of allowed files in the batch download queue doesn't seem to // be available to JavaScript. var totalQueueSize = batchDLQueueStats.totalSize + pFileList[pFileListMenu.selectedItemIdx].size; var totalQueueCost = batchDLQueueStats.totalCost + pFileList[pFileListMenu.selectedItemIdx].cost; - var queueStats = "\1n\1cFiles: \1h" + batchDLQueueStats.numFilesInQueue + " \1n\1cCredits: \1h" - + totalQueueCost + "\1n\1c Bytes: \1h" + numWithCommas(totalQueueSize) + "\1n\1w\r\n"; + var queueStats = "\x01n\x01cFiles: \x01h" + batchDLQueueStats.numFilesInQueue + " \x01n\x01cCredits: \x01h" + + totalQueueCost + "\x01n\x01c Bytes: \x01h" + numWithCommas(totalQueueSize) + "\x01n\x01w\r\n"; for (var i = 0; i < batchDLQueueStats.filenames.length; ++i) { queueStats += shortenFilename(batchDLQueueStats.filenames[i].filename, frameInnerWidth, false) + "\r\n"; @@ -825,7 +827,7 @@ function addSelectedFilesToBatchDLQueue(pFileList, pFileListMenu) { retObj.reDrawListerHeader = true; retObj.reDrawCmdBar = true; - console.print("\1n"); + console.print("\x01n"); console.gotoxy(1, console.screen_rows); console.crlf(); bbs.batch_download(); @@ -842,7 +844,7 @@ function addSelectedFilesToBatchDLQueue(pFileList, pFileListMenu) // Build a frame object to show the names of the files that failed to be added to the // user's batch DL queue var frameTitle = "Failed to add these files to batch DL queue"; - var fileListStr = "\1n\1w"; + var fileListStr = "\x01n\x01w"; for (var i = 0; i < filenamesFailed.length; ++i) fileListStr += shortenFilename(filenamesFailed[i], frameInnerWidth, false) + "\r\n"; var lastUserInput = displayBorderedFrameAndDoInputLoop(frameUpperLeftX, frameUpperLeftY, frameWidth, @@ -889,7 +891,7 @@ function getUserDLQueueStats() // See if a section exists for the filename //File.iniGetAllObjects([name_property] [,prefix=none] [,lowercase=false] [,blanks=false]) var allIniObjs = batchDLFile.iniGetAllObjects(); - console.print("\1n\r\n"); + console.print("\x01n\r\n"); for (var i = 0; i < allIniObjs.length; ++i) { if (typeof(allIniObjs[i]) === "object") @@ -927,10 +929,10 @@ function displayHelpScreen() { var retObj = getDefaultActionRetObj(); - console.clear("\1n"); + console.clear("\x01n"); // Display program information - displayTextWithLineBelow("Digital Distortion File Lister", true, "\1n\1c\1h", "\1k\1h") - console.center("\1n\1cVersion \1g" + LISTER_VERSION + " \1w\1h(\1b" + LISTER_DATE + "\1w)"); + displayTextWithLineBelow("Digital Distortion File Lister", true, "\x01n\x01c\x01h", "\x01k\x01h") + console.center("\x01n\x01cVersion \x01g" + LISTER_VERSION + " \x01w\x01h(\x01b" + LISTER_DATE + "\x01w)"); console.crlf(); // If listing files in a directory, display information about the current file directory. @@ -938,18 +940,18 @@ function displayHelpScreen() { var libIdx = file_area.dir[bbs.curdir_code].lib_index; var dirIdx = file_area.dir[bbs.curdir_code].index; - console.print("\1n\1cCurrent file library: \1g" + file_area.lib_list[libIdx].description); + console.print("\x01n\x01cCurrent file library: \x01g" + file_area.lib_list[libIdx].description); console.crlf(); - console.print("\1cCurrent file directory: \1g" + file_area.dir[bbs.curdir_code].description); + console.print("\x01cCurrent file directory: \x01g" + file_area.dir[bbs.curdir_code].description); console.crlf(); - console.print("\1cThere are \1g" + file_area.dir[bbs.curdir_code].files + " \1cfiles in this directory."); + console.print("\x01cThere are \x01g" + file_area.dir[bbs.curdir_code].files + " \x01cfiles in this directory."); } else if (gScriptMode == MODE_SEARCH_FILENAME) - console.print("\1n\1cCurrently performing a filename search"); + console.print("\x01n\x01cCurrently performing a filename search"); else if (gScriptMode == MODE_SEARCH_DESCRIPTION) - console.print("\1n\1cCurrently performing a description search"); + console.print("\x01n\x01cCurrently performing a description search"); else if (gScriptMode == MODE_NEW_FILE_SEARCH) - console.print("\1n\1cCurrently performing a new file search"); + console.print("\x01n\x01cCurrently performing a new file search"); console.crlf(); console.crlf(); @@ -971,7 +973,7 @@ function displayHelpScreen() console.print(helpStr); // Display the commands available var commandStrWidth = 8; - var printfStr = "\1n\1c\1h%-" + commandStrWidth + "s\1g: \1n\1c%s\r\n"; + var printfStr = "\x01n\x01c\x01h%-" + commandStrWidth + "s\x01g: \x01n\x01c%s\r\n"; printf(printfStr, "I", "Display extended file information"); printf(printfStr, "V", "View the file"); printf(printfStr, "B", "Flag the file(s) for batch download"); @@ -982,7 +984,7 @@ function displayHelpScreen() } printf(printfStr, "?", "Show this help screen"); printf(printfStr, "Q", "Quit back to the BBS"); - console.print("\1n"); + console.print("\x01n"); console.crlf(); //console.pause(); @@ -1036,7 +1038,7 @@ function chooseFilebaseAndMoveFileToOtherFilebase(pFileList, pFileListMenu) height: fileLibMenu.size.height + 1 // + 1 because of the label above the menu }; console.gotoxy(fileLibMenu.pos.x, fileLibMenu.pos.y-1); - printf("\1n\1c\1h|\1n\1c%-" + +(fileLibMenu.size.width-1) + "s\1n", "Choose a destination area"); + printf("\x01n\x01c\x01h|\x01n\x01c%-" + +(fileLibMenu.size.width-1) + "s\x01n", "Choose a destination area"); // Prompt the user which directory to move the file to var chosenDirCode = null; var continueOn = true; @@ -1450,7 +1452,7 @@ function DDFileMenuBar_constructPromptText() var numSolidBlocks = console.screen_columns - numInnerChars - 11; var numSolidBlocksPerSide = Math.floor(numSolidBlocks / 2); // Build the prompt text: Start with the left blocks - this.promptText = "\1n\1w" + BLOCK1 + BLOCK2 + BLOCK3 + BLOCK4; + this.promptText = "\x01n\x01w" + BLOCK1 + BLOCK2 + BLOCK3 + BLOCK4; for (var i = 0; i < numSolidBlocksPerSide; ++i) this.promptText += BLOCK4; this.promptText += THIN_RECTANGLE_LEFT; @@ -1471,10 +1473,10 @@ function DDFileMenuBar_constructPromptText() this.promptText += this.getDDFileMenuBarItemText(this.cmdArray[i].itemText, selected, withTrailingBlock); } // Add the right-side blocks - this.promptText += "\1w" + THIN_RECTANGLE_RIGHT; + this.promptText += "\x01w" + THIN_RECTANGLE_RIGHT; for (var i = 0; i < numSolidBlocksPerSide; ++i) this.promptText += BLOCK4; - this.promptText += BLOCK3 + BLOCK2 + BLOCK1 + "\1n"; + this.promptText += BLOCK3 + BLOCK2 + BLOCK1 + "\x01n"; } // For the DDFileMenuBar class: Gets the text for a prompt item based on its index function DDFileMenuBar_getItemTextFromIdx(pIdx) @@ -1505,11 +1507,11 @@ function DDFileMenuBar_refreshWithNewAction(pCmdIdx) // Re-draw the last item text with regular colors var itemText = this.getItemTextFromIdx(this.currentCommandIdx); console.gotoxy(this.cmdArray[this.currentCommandIdx].pos, this.pos.y); - console.print("\1n" + this.getDDFileMenuBarItemText(itemText, false, false)); + console.print("\x01n" + this.getDDFileMenuBarItemText(itemText, false, false)); // Draw the new item text with selected colors itemText = this.getItemTextFromIdx(pCmdIdx); console.gotoxy(this.cmdArray[pCmdIdx].pos, this.pos.y); - console.print("\1n" + this.getDDFileMenuBarItemText(itemText, true, false)); + console.print("\x01n" + this.getDDFileMenuBarItemText(itemText, true, false)); console.gotoxy(this.pos.x+strip_ctrl(this.promptText).length-1, this.pos.y); this.lastCommandIdx = this.currentCommandIdx; @@ -1539,14 +1541,14 @@ function DDFileMenuBar_getDDFileMenuBarItemText(pText, pSelected, pWithTrailingB var firstChar = pText.length > 0 ? pText.charAt(0) : ""; var restOfText = pText.length > 1 ? pText.substr(1, pText.length - 1) : ""; // Build the item text and return it - var itemText = "\1n"; + var itemText = "\x01n"; if (selected) - itemText += "\1" + "1\1r\1h" + firstChar + "\1n\1" + "1\1k" + restOfText; + itemText += "\x01" + "1\x01r\x01h" + firstChar + "\x01n\x01" + "1\x01k" + restOfText; else - itemText += "\1" + "6\1c\1h" + firstChar + "\1n\1" + "6\1k" + restOfText; - itemText += "\1n"; + itemText += "\x01" + "6\x01c\x01h" + firstChar + "\x01n\x01" + "6\x01k" + restOfText; + itemText += "\x01n"; if (withTrailingBlock) - itemText += "\1w" + THIN_RECTANGLE_RIGHT + THIN_RECTANGLE_LEFT + "\1n"; + itemText += "\x01w" + THIN_RECTANGLE_RIGHT + THIN_RECTANGLE_LEFT + "\x01n"; return itemText; } // For the DDFileMenuBar class: Increments to the next menu item and refreshes the @@ -1828,11 +1830,11 @@ function displayBorderedFrameAndDoInputLoop(pFrameX, pFrameY, pFrameWidth, pFram return; // Display the border for the frame - var keyHelpStr = "\1n\1c\1hQ\1b/\1cEnter\1b/\1cESC\1y: \1gClose\1b"; - var scrollLoopNavHelp = "\1c\1hUp\1b/\1cDn\1b/\1cHome\1b/\1cEnd\1b/\1cPgup\1b/\1cPgDn\1y: \1gNav"; + var keyHelpStr = "\x01n\x01c\x01hQ\x01b/\x01cEnter\x01b/\x01cESC\x01y: \x01gClose\x01b"; + var scrollLoopNavHelp = "\x01c\x01hUp\x01b/\x01cDn\x01b/\x01cHome\x01b/\x01cEnd\x01b/\x01cPgup\x01b/\x01cPgDn\x01y: \x01gNav"; if (console.screen_columns >= 80) keyHelpStr += ", " + scrollLoopNavHelp; - var borderColor = (typeof(pBorderColor) === "string" ? pBorderColor : "\1r"); + var borderColor = (typeof(pBorderColor) === "string" ? pBorderColor : "\x01r"); drawBorder(pFrameX, pFrameY, pFrameWidth, pFrameHeight, borderColor, "double", pFrameTitle, pTitleColor, keyHelpStr); // Construct the frame window for the file info @@ -1849,7 +1851,7 @@ function displayBorderedFrameAndDoInputLoop(pFrameX, pFrameY, pFrameWidth, pFram var scrollbarObj = new ScrollBar(frameObj, {bg: BG_BLACK, fg: LIGHTGRAY, orientation: "vertical", autohide: false}); // Put the file info string in the frame window, then start the // user input loop for the frame - frameObj.putmsg(pFrameContents, "\1n"); + frameObj.putmsg(pFrameContents, "\x01n"); var lastUserInput = doFrameInputLoop(frameObj, scrollbarObj, pFrameContents, pAdditionalQuitKeys); //infoFrame.bottom(); @@ -1974,32 +1976,32 @@ function displayFileLibAndDirHeader(pTextOnly) var hdrTextWidth = console.screen_columns - 21; var descWidth = hdrTextWidth - 11; - var libText = format("\1cLib \1w\1h#\1b%4d\1c: \1n\1c%-" + descWidth + "s\1n", +(libIdx+1), libDesc.substr(0, descWidth)); - var dirText = format("\1cDir \1w\1h#\1b%4d\1c: \1n\1c%-" + descWidth + "s\1n", +(dirIdx+1), dirDesc.substr(0, descWidth)); + var libText = format("\x01cLib \x01w\x01h#\x01b%4d\x01c: \x01n\x01c%-" + descWidth + "s\x01n", +(libIdx+1), libDesc.substr(0, descWidth)); + var dirText = format("\x01cDir \x01w\x01h#\x01b%4d\x01c: \x01n\x01c%-" + descWidth + "s\x01n", +(dirIdx+1), dirDesc.substr(0, descWidth)); // Library line if (textOnly) { console.gotoxy(6, 1); - console.print("\1n" + libText); + console.print("\x01n" + libText); console.gotoxy(6, 2); - console.print("\1n" + dirText); + console.print("\x01n" + dirText); } else { - console.print("\1n\1w" + BLOCK1 + BLOCK2 + BLOCK3 + BLOCK4 + THIN_RECTANGLE_LEFT); + console.print("\x01n\x01w" + BLOCK1 + BLOCK2 + BLOCK3 + BLOCK4 + THIN_RECTANGLE_LEFT); console.print(libText); - console.print("\1w" + THIN_RECTANGLE_RIGHT + "\1k\1h" + BLOCK4 + "\1n\1w" + THIN_RECTANGLE_LEFT + - "\1g\1hDD File\1n\1w"); + console.print("\x01w" + THIN_RECTANGLE_RIGHT + "\x01k\x01h" + BLOCK4 + "\x01n\x01w" + THIN_RECTANGLE_LEFT + + "\x01g\x01hDD File\x01n\x01w"); console.print(THIN_RECTANGLE_RIGHT + BLOCK4 + BLOCK3 + BLOCK2 + BLOCK1); console.crlf(); // Directory line - console.print("\1n\1w" + BLOCK1 + BLOCK2 + BLOCK3 + BLOCK4 + THIN_RECTANGLE_LEFT); + console.print("\x01n\x01w" + BLOCK1 + BLOCK2 + BLOCK3 + BLOCK4 + THIN_RECTANGLE_LEFT); console.print(dirText); - console.print("\1w" + THIN_RECTANGLE_RIGHT + "\1k\1h" + BLOCK4 + "\1n\1w" + THIN_RECTANGLE_LEFT + - "\1g\1hLister \1n\1w"); + console.print("\x01w" + THIN_RECTANGLE_RIGHT + "\x01k\x01h" + BLOCK4 + "\x01n\x01w" + THIN_RECTANGLE_LEFT + + "\x01g\x01hLister \x01n\x01w"); console.print(THIN_RECTANGLE_RIGHT + BLOCK4 + BLOCK3 + BLOCK2 + BLOCK1); - console.print("\1n"); + console.print("\x01n"); // List header console.crlf(); @@ -2023,8 +2025,8 @@ function displayListHdrLine(pMoveToLocationFirst) var filenameLen = gListIdxes.filenameEnd - gListIdxes.filenameStart; var fileSizeLen = gListIdxes.fileSizeEnd - gListIdxes.fileSizeStart -1; var descLen = gListIdxes.descriptionEnd - gListIdxes.descriptionStart + 1; - var formatStr = "\1n\1w\1h%-" + filenameLen + "s %" + fileSizeLen + "s %-" - + +(descLen-7) + "s\1n\1w%5s\1n"; + var formatStr = "\x01n\x01w\x01h%-" + filenameLen + "s %" + fileSizeLen + "s %-" + + +(descLen-7) + "s\x01n\x01w%5s\x01n"; var listHdrEndText = THIN_RECTANGLE_RIGHT + BLOCK4 + BLOCK3 + BLOCK2 + BLOCK1; printf(formatStr, "Filename", "Size", "Description", listHdrEndText); } @@ -2155,7 +2157,7 @@ function createFileLibMenu() if (file_area.lib_list.length == 0) { console.crlf(); - console.print("\1n\1y\1hThere are no file libraries available\1n"); + console.print("\x01n\x01y\x01hThere are no file libraries available\x01n"); console.crlf(); console.pause(); return; @@ -2203,15 +2205,15 @@ function createFileLibMenu() var numDirsStart = descEnd; //var numDirsEnd = numDirsStart + fileLibMenu.numDirsLen; fileLibMenu.SetColors({ - itemColor: [{start: libNumStart, end: libNumEnd, attrs: "\1n" + gColors.fileNormalBkg + gColors.fileAreaNum}, - {start: descStart, end:descEnd, attrs: "\1n" + gColors.fileNormalBkg + gColors.fileAreaDesc}, - {start: numDirsStart, end: -1, attrs: "\1n" + gColors.fileNormalBkg + gColors.fileAreaNumItems}], - selectedItemColor: [{start: libNumStart, end: libNumEnd, attrs: "\1n" + gColors.fileAreaMenuHighlightBkg + gColors.fileAreaNumHighlight}, - {start: descStart, end:descEnd, attrs: "\1n" + gColors.fileAreaMenuHighlightBkg + gColors.fileAreaDescHighlight}, - {start: numDirsStart, end: -1, attrs: "\1n" + gColors.fileAreaMenuHighlightBkg + gColors.fileAreaNumItemsHighlight}] + itemColor: [{start: libNumStart, end: libNumEnd, attrs: "\x01n" + gColors.fileNormalBkg + gColors.fileAreaNum}, + {start: descStart, end:descEnd, attrs: "\x01n" + gColors.fileNormalBkg + gColors.fileAreaDesc}, + {start: numDirsStart, end: -1, attrs: "\x01n" + gColors.fileNormalBkg + gColors.fileAreaNumItems}], + selectedItemColor: [{start: libNumStart, end: libNumEnd, attrs: "\x01n" + gColors.fileAreaMenuHighlightBkg + gColors.fileAreaNumHighlight}, + {start: descStart, end:descEnd, attrs: "\x01n" + gColors.fileAreaMenuHighlightBkg + gColors.fileAreaDescHighlight}, + {start: numDirsStart, end: -1, attrs: "\x01n" + gColors.fileAreaMenuHighlightBkg + gColors.fileAreaNumItemsHighlight}] }); - fileLibMenu.topBorderText = "\1y\1hFile Libraries"; + fileLibMenu.topBorderText = "\x01y\x01hFile Libraries"; // Define the menu function for getting an item fileLibMenu.GetItem = function(pIdx) { var menuItemObj = this.MakeItemWithRetval(pIdx); @@ -2300,15 +2302,15 @@ function createFileDirMenu(pLibIdx) var numDirsStart = descEnd; //var numDirsEnd = numDirsStart + fileDirMenu.numDirsLen; fileDirMenu.SetColors({ - itemColor: [{start: dirNumStart, end: dirNumEnd, attrs: "\1n" + gColors.fileNormalBkg + gColors.fileAreaNum}, - {start: descStart, end:descEnd, attrs: "\1n" + gColors.fileNormalBkg + gColors.fileAreaDesc}, - {start: numDirsStart, end: -1, attrs: "\1n" + gColors.fileNormalBkg + gColors.fileAreaNumItems}], - selectedItemColor: [{start: dirNumStart, end: dirNumEnd, attrs: "\1n" + gColors.fileAreaMenuHighlightBkg + gColors.fileAreaNumHighlight}, - {start: descStart, end:descEnd, attrs: "\1n" + gColors.fileAreaMenuHighlightBkg + gColors.fileAreaDescHighlight}, - {start: numDirsStart, end: -1, attrs: "\1n" + gColors.fileAreaMenuHighlightBkg + gColors.fileAreaNumItemsHighlight}] + itemColor: [{start: dirNumStart, end: dirNumEnd, attrs: "\x01n" + gColors.fileNormalBkg + gColors.fileAreaNum}, + {start: descStart, end:descEnd, attrs: "\x01n" + gColors.fileNormalBkg + gColors.fileAreaDesc}, + {start: numDirsStart, end: -1, attrs: "\x01n" + gColors.fileNormalBkg + gColors.fileAreaNumItems}], + selectedItemColor: [{start: dirNumStart, end: dirNumEnd, attrs: "\x01n" + gColors.fileAreaMenuHighlightBkg + gColors.fileAreaNumHighlight}, + {start: descStart, end:descEnd, attrs: "\x01n" + gColors.fileAreaMenuHighlightBkg + gColors.fileAreaDescHighlight}, + {start: numDirsStart, end: -1, attrs: "\x01n" + gColors.fileAreaMenuHighlightBkg + gColors.fileAreaNumItemsHighlight}] }); - fileDirMenu.topBorderText = "\1y\1h" + ("File directories of " + file_area.lib_list[pLibIdx].description).substr(0, fileDirMenu.size.width-2); + fileDirMenu.topBorderText = "\x01y\x01h" + ("File directories of " + file_area.lib_list[pLibIdx].description).substr(0, fileDirMenu.size.width-2); // Define the menu function for ggetting an item fileDirMenu.GetItem = function(pIdx) { // Return the internal code for the directory for the item @@ -2442,8 +2444,8 @@ function getFileSizeStr(pFileSize, pMaxLen) function displayTextWithLineBelow(pText, pCenter, pTextColor, pLineColor) { var centerText = (typeof(pCenter) == "boolean" ? pCenter : false); - var textColor = (typeof(pTextColor) == "string" ? pTextColor : "\1n\1w"); - var lineColor = (typeof(pLineColor) == "string" ? pLineColor : "\1n\1k\1h"); + var textColor = (typeof(pTextColor) == "string" ? pTextColor : "\x01n\x01w"); + var lineColor = (typeof(pLineColor) == "string" ? pLineColor : "\x01n\x01k\x01h"); // Output the text and a solid line on the next line. if (centerText) @@ -2544,9 +2546,9 @@ function displayMsgs(pMsgArray, pIsError, pWaitAndErase) var titleColor = pIsError ? gColors.errorMessage : gColors.successMessage; drawBorder(gErrorMsgBoxULX, gErrorMsgBoxULY, gErrorMsgBoxWidth, gErrorMsgBoxHeight, gColors.errorBoxBorder, "single", title, titleColor, ""); - var msgColor = "\1n" + (pIsError ? gColors.errorMessage : gColors.successMessage); + var msgColor = "\x01n" + (pIsError ? gColors.errorMessage : gColors.successMessage); var innerWidth = gErrorMsgBoxWidth - 2; - var msgFormatStr = msgColor + "%-" + innerWidth + "s\1n"; + var msgFormatStr = msgColor + "%-" + innerWidth + "s\x01n"; for (var i = 0; i < pMsgArray.length; ++i) { console.gotoxy(gErrorMsgBoxULX+1, gErrorMsgBoxULY+1); @@ -2619,7 +2621,7 @@ function drawBorder(pX, pY, pWidth, pHeight, pColor, pLineStyle, pTitle, pTitleC // Top border console.gotoxy(pX, pY); - console.print("\1n" + pColor); + console.print("\x01n" + pColor); console.print(borderChars.UL); var innerWidth = pWidth - 2; // Include the title text in the top border, if there is any specified @@ -2634,9 +2636,9 @@ function drawBorder(pX, pY, pWidth, pHeight, pColor, pLineStyle, pTitle, pTitleC // Note: substrWithAttrCodes() is defined in dd_lightbar_menu.js var titleText = pTitle; if (typeof(pTitleColor) === "string") - titleText = "\1n" + pTitleColor + titleTextWithoutAttrs; - console.print(borderChars.preText + "\1n" + substrWithAttrCodes(titleText, 0, titleLen) + - "\1n" + pColor + borderChars.postText); + titleText = "\x01n" + pTitleColor + titleTextWithoutAttrs; + console.print(borderChars.preText + "\x01n" + substrWithAttrCodes(titleText, 0, titleLen) + + "\x01n" + pColor + borderChars.postText); if (innerWidth > 0) console.print(pColor); } @@ -2666,8 +2668,8 @@ function drawBorder(pX, pY, pWidth, pHeight, pColor, pLineStyle, pTitle, pTitleC innerWidth -= textLen; innerWidth -= 2; // ?? Correctional // Note: substrWithAttrCodes() is defined in dd_lightbar_menu.js - console.print(borderChars.preText + "\1n" + substrWithAttrCodes(pBottomBorderText, 0, textLen) + - "\1n" + pColor + borderChars.postText); + console.print(borderChars.preText + "\x01n" + substrWithAttrCodes(pBottomBorderText, 0, textLen) + + "\x01n" + pColor + borderChars.postText); if (innerWidth > 0) console.print(pColor); } @@ -2699,10 +2701,10 @@ function drawSeparatorLine(pX, pY, pWidth) width = maxWidth; console.gotoxy(pX, pY); - console.print("\1n\1g\1h"); + console.print("\x01n\x01g\x01h"); for (var i = 0; i < width; ++i) console.print(HORIZONTAL_SINGLE); - console.print("\1n"); + console.print("\x01n"); } // Confirms with the user to perform an action with a file or set of files @@ -2733,7 +2735,7 @@ function confirmFileActionWithUser(pFilenames, pActionName, pDefaultYes) var filename = (typeof(pFilenames) === "string" ? pFilenames : pFilenames[0]); drawSeparatorLine(1, console.screen_rows-2, console.screen_columns-1); console.gotoxy(1, console.screen_rows-1); - console.cleartoeol("\1n"); + console.cleartoeol("\x01n"); console.gotoxy(1, console.screen_rows-1); var shortFilename = shortenFilename(filename, Math.floor(console.screen_columns/2), false); if (pDefaultYes) @@ -2755,7 +2757,7 @@ function confirmFileActionWithUser(pFilenames, pActionName, pDefaultYes) var frameTitle = pActionName + " files? (Y/N)"; var additionalQuitKeys = "yYnN"; var frameInnerWidth = frameWidth - 2; // Without borders; for filename lengths - var fileListStr = "\1n\1w"; + var fileListStr = "\x01n\x01w"; for (var i = 0; i < pFilenames.length; ++i) fileListStr += shortenFilename(pFilenames[i], frameInnerWidth, false) + "\r\n"; var lastUserInput = displayBorderedFrameAndDoInputLoop(frameUpperLeftX, frameUpperLeftY, frameWidth, @@ -2889,11 +2891,11 @@ function readConfigFile() { // Was unable to read the configuration file. Output a warning to the user // that defaults will be used and to notify the sysop. - console.print("\1n"); + console.print("\x01n"); console.crlf(); - console.print("\1w\1hUnable to open the configuration file: \1y" + cfgFilename); + console.print("\x01w\x01hUnable to open the configuration file: \x01y" + cfgFilename); console.crlf(); - console.print("\1wDefault settings will be used. Please notify the sysop."); + console.print("\x01wDefault settings will be used. Please notify the sysop."); mswait(2000); } @@ -2943,9 +2945,9 @@ function readConfigFile() if (gColors.hasOwnProperty(setting)) { // Trim leading & trailing spaces from the value when - // setting a color. Also, replace any instances of "\1" + // setting a color. Also, replace any instances of "\x01" or "\1" // with the Synchronet attribute control character. - gColors[setting] = trimSpaces(value, true, false, true).replace(/\\1/g, "\1"); + gColors[setting] = trimSpaces(value, true, false, true).replace(/\\[xX]01/g, "\x01").replace(/\\1/g, "\x01"); } } } @@ -2957,11 +2959,11 @@ function readConfigFile() // Was unable to read the theme file. Output a warning to the user // that defaults will be used and to notify the sysop. this.cfgFileSuccessfullyRead = false; - console.print("\1n"); + console.print("\x01n"); console.crlf(); - console.print("\1w\1hUnable to open the theme file: \1y" + themeFilename); + console.print("\x01w\x01hUnable to open the theme file: \x01y" + themeFilename); console.crlf(); - console.print("\1wDefault colors will be used. Please notify the sysop."); + console.print("\x01wDefault colors will be used. Please notify the sysop."); mswait(2000); } } @@ -3135,8 +3137,8 @@ function populateFileList(pSearchMode) filebase.close(); var libIdx = file_area.dir[bbs.curdir_code].lib_index; console.crlf(); - console.print("\1n\1cThere are no files in \1h" + file_area.lib_list[libIdx].description + "\1n\1c - \1h" + - file_area.dir[bbs.curdir_code].description + "\1n"); + console.print("\x01n\x01cThere are no files in \x01h" + file_area.lib_list[libIdx].description + "\x01n\x01c - \x01h" + + file_area.dir[bbs.curdir_code].description + "\x01n"); console.crlf(); console.pause(); retObj.exitNow = true; @@ -3162,7 +3164,7 @@ function populateFileList(pSearchMode) else { console.crlf(); - console.print("\1n\1h\1yUnable to open \1w" + file_area.dir[bbs.curdir_code].description + "\1n"); + console.print("\x01n\x01h\x01yUnable to open \x01w" + file_area.dir[bbs.curdir_code].description + "\x01n"); console.crlf(); console.pause(); retObj.exitNow = true; @@ -3175,7 +3177,7 @@ function populateFileList(pSearchMode) var lastDirCode = ""; // Prompt the user for directory, library, or all - console.print("\1n"); + console.print("\x01n"); console.crlf(); console.mnemonics(bbs.text(DirLibOrAll)); var validInputOptions = "DLA"; @@ -3202,11 +3204,11 @@ function populateFileList(pSearchMode) var lastDirCode = ""; // Prompt the user for directory, library, or all - console.print("\1n"); + console.print("\x01n"); console.crlf(); - //console.print("\r\n\1c\1hFind Text in File Descriptions (no wildcards)\1n\r\n"); + //console.print("\r\n\x01c\x01hFind Text in File Descriptions (no wildcards)\x01n\r\n"); console.mnemonics(bbs.text(DirLibOrAll)); - console.print("\1n"); + console.print("\x01n"); var validInputOptions = "DLA"; var userInputDLA = console.getkeys(validInputOptions, -1, K_UPPER); var searchDescription = ""; @@ -3260,16 +3262,16 @@ function populateFileList(pSearchMode) */ // Prompt the user for directory, library, or all - console.print("\1n"); + console.print("\x01n"); console.crlf(); console.mnemonics(bbs.text(DirLibOrAll)); var validInputOptions = "DLA"; var userInputDLA = console.getkeys(validInputOptions, -1, K_UPPER); - console.print("\1n"); + console.print("\x01n"); console.crlf(); if (userInputDLA == "D" || userInputDLA == "L" || userInputDLA == "A") { - console.print("\1n\1cSearching for files uploaded after \1h" + system.timestr(bbs.new_file_time) + "\1n"); + console.print("\x01n\x01cSearching for files uploaded after \x01h" + system.timestr(bbs.new_file_time) + "\x01n"); console.crlf(); } var searchRetObj = searchDirGroupOrAll(userInputDLA, function(pDirCode) { @@ -3295,13 +3297,13 @@ function populateFileList(pSearchMode) if (dirErrors.length > 0) { - console.print("\1n\1y\1h"); + console.print("\x01n\x01y\x01h"); for (var i = 0; i < dirErrors.length; ++i) { console.print(dirErrors[i]); console.crlf(); } - console.print("\1n"); + console.print("\x01n"); console.pause(); retObj.exitNow = true; retObj.exitCode = 1; @@ -3657,7 +3659,7 @@ function displayFileExtDescOnMainScreen(pFileIdx, pStartScreenRow, pEndScreenRow if (typeof(pEndScreenRow) === "number" && pEndScreenRow > firstScreenRow && pStartScreenRow <= lastScreenRow) lastScreenRow = pEndScreenRow; var fileDescArray = fileDesc.split("\r\n"); - console.print("\1n"); + console.print("\x01n"); // screenRowNum is to keep track of the row on the screen where the // description line would be placed, in case the start row is after that var screenRowNum = firstScreenRow; @@ -3688,13 +3690,13 @@ function displayFileExtDescOnMainScreen(pFileIdx, pStartScreenRow, pEndScreenRow // If there is room, shoe the file date on the next line if (screenRowForPrinting <= lastScreenRow && fileMetadata.hasOwnProperty("time")) { - console.print("\1n"); + console.print("\x01n"); console.gotoxy(startX, screenRowForPrinting++); var dateStr = "Date: " + strftime("%Y-%m-%d", fileMetadata.time); printf("%-" + maxDescLen + "s", dateStr.substr(0, maxDescLen)); } // Clear the rest of the lines to the bottom of the list area - console.print("\1n"); + console.print("\x01n"); while (screenRowForPrinting <= lastScreenRow) { console.gotoxy(startX, screenRowForPrinting++); diff --git a/xtrn/slyvote/readme.txt b/xtrn/slyvote/readme.txt index 696920a865979eadf6228962ef8ea50fa7fff503..213a06e96e60d3ed1b107e628a8aaf2528291eea 100644 --- a/xtrn/slyvote/readme.txt +++ b/xtrn/slyvote/readme.txt @@ -1,6 +1,6 @@ SlyVote - Version 1.11 - Release date: 2021-04-02 + Version 1.12 + Release date: 2022-06-21 by @@ -224,4 +224,4 @@ the sbbs/ctrl directory): 780 (VotedAlready) 781 (R_Voting) 787 (PollVoteNotice) -791 (BallotHdr) \ No newline at end of file +791 (BallotHdr) diff --git a/xtrn/slyvote/slyvote.js b/xtrn/slyvote/slyvote.js index 38500be11a3028aee281d2df2333c09923a28d1e..0fe4c9a3110e64fbebb15d2d9b7e89aeedd24dc8 100644 --- a/xtrn/slyvote/slyvote.js +++ b/xtrn/slyvote/slyvote.js @@ -1,5 +1,3 @@ -// $Id: slyvote.js,v 1.16 2020/05/23 03:37:09 nightfox Exp $ - /* This is a voting door for Synchronet. It requires Synchronet 3.17 or higher, since * it makes use of the new voting features added to the message bases in Synchronet * 3.17. Also, this requires an ANSI client. @@ -178,11 +176,18 @@ * was showing all available message groups but * some could be empty due to having no sub-boards * that allow polls. + * 2022-06-21 Eric Oulashin Version 1.12 + * Made an update to get vote stats to be displayed again. + * Also, no longer has hard-coded CP437 characters, and + * now uses "use strict" for better runtime checks of proper + * code. */ // TODO: Have a messsage group selection so that it doesn't have to display all // sub-boards, which can potentially take a long time +"use strict"; + const requireFnExists = (typeof(require) === "function"); if (requireFnExists) @@ -194,9 +199,9 @@ else // Exit if the Synchronet version is below the minimum. if (system.version_num < 31700) { - var message = "\1n\1h\1y\1i* Warning:\1n\1h\1w SlyVote requires version " - + "\1g3.17\1w or\r\nhigher of Synchronet. This BBS is using " - + "version \1g" + system.version + "\1w. Please notify the sysop."; + var message = "\x01n\x01h\x01y\x01i* Warning:\x01n\x01h\x01w SlyVote requires version " + + "\x01g3.17\x01w or\r\nhigher of Synchronet. This BBS is using " + + "version \x01g" + system.version + "\x01w. Please notify the sysop."; console.crlf(); console.print(message); console.crlf(); @@ -208,7 +213,7 @@ if (system.version_num < 31700) if (!console.term_supports(USER_ANSI)) { console.crlf(); - console.print("\1n\1hSlyVote requires an ANSI client."); + console.print("\x01n\x01hSlyVote requires an ANSI client."); console.crlf(); console.pause(); exit(); @@ -222,9 +227,9 @@ if ((user.security.restrictions & UFLAG_V) == UFLAG_V) console.crlf(); console.crlf(); // Use the line from text.dat that says the user is not allowed to vote - console.print("\1n" + RemoveCRLFCodes(bbs.text(R_Voting)) + "\1n"); + console.print("\x01n" + RemoveCRLFCodes(processBBSTextDatText(bbs.text(R_Voting))) + "\x01n"); console.crlf(); - console.print("\1cYou can still view poll results.\1n"); + console.print("\x01cYou can still view poll results.\x01n"); console.crlf(); console.pause(); } @@ -247,8 +252,8 @@ else var gAvatar = load({}, "avatar_lib.js"); // Version information -var SLYVOTE_VERSION = "1.11"; -var SLYVOTE_DATE = "2021-04-02"; +var SLYVOTE_VERSION = "1.12"; +var SLYVOTE_DATE = "2022-06-21"; // Determine the script's startup directory. // This code is a trick that was created by Deuce, suggested by Rob Swindell @@ -297,6 +302,11 @@ var BLOCK1 = "\xB0"; // Dimmest block var BLOCK2 = "\xB1"; var BLOCK3 = "\xB2"; var BLOCK4 = "\xDB"; // Brightest block +var MID_BLOCK = "\xDC"; +var TALL_UPPER_MID_BLOCK = "\xFE"; +var UPPER_CENTER_BLOCK = "\xDF"; +var LOWER_CENTER_BLOCK = "\xDC"; +var TINY_DOT = "\xFA"; // Strings for the various message attributes (used by makeAllAttrStr(), // makeMainMsgAttrStr(), makeAuxMsgAttrStr(), and makeNetMsgAttrStr()) @@ -312,7 +322,7 @@ var gMainMsgAttrStrs = { MSG_VALIDATED: "Valid", MSG_REPLIED: "Repl", MSG_NOREPLY: "NoRepl" -} +}; var gAuxMsgAttrStrs = { MSG_FILEREQUEST: "Freq", MSG_FILEATTACH: "Attach", @@ -321,7 +331,7 @@ var gAuxMsgAttrStrs = { MSG_RECEIPTREQ: "RctReq", MSG_CONFIRMREQ: "ConfReq", MSG_NODISP: "NoDisp" -} +}; var gNetMsgAttrStrs = { MSG_LOCAL: "FromLocal", MSG_INTRANSIT: "Transit", @@ -338,7 +348,7 @@ var gNetMsgAttrStrs = { MSG_TYPELOCAL: "ForLocal", MSG_TYPEECHO: "ForEcho", MSG_TYPENET: "ForNetmail" -} +}; // An amount of milliseconds to wait after displaying an error message, etc. var ERROR_PAUSE_WAIT_MS = 1500; @@ -374,7 +384,7 @@ var gReaderKeys = { vote: "V", close: "C", quit: "Q" -} +}; if (gUserIsSysop) gReaderKeys.validateMsg = "A"; @@ -383,9 +393,9 @@ if (gSlyVoteCfg.cfgReadError.length > 0) { log(LOG_ERR, "SlyVote: Error reading slyvote.cfg"); bbs.log_str("SlyVote: Error reading slyvote.cfg"); - console.print("\1n"); + console.print("\x01n"); console.crlf(); - console.print("\1h\1y* Error reading slyvote.cfg\1n"); + console.print("\x01h\x01y* Error reading slyvote.cfg\x01n"); console.crlf(); console.pause(); exit(); @@ -405,9 +415,9 @@ if (Object.keys(gSlyVoteCfg.msgGroups).length > 0) } if (!subBoardsConfigured) { - console.print("\1n"); + console.print("\x01n"); console.crlf(); - console.print("\1cThere are no sub-boards configured.\1n"); + console.print("\x01cThere are no sub-boards configured.\x01n"); console.crlf(); console.pause(); exit(); @@ -456,10 +466,10 @@ else } // Output a "loading..." text, in case it takes a while to count the polls in // the current sub-board -console.print("\1n"); +console.print("\x01n"); console.crlf(); var subBoardName = msg_area.sub[gSubBoardCode].grp_name + ": " + msg_area.sub[gSubBoardCode].description; -console.print("\1gLoading SlyVote (counting polls in \1c" + subBoardName + "\1g)...\1n"); +console.print("\x01gLoading SlyVote (counting polls in \x01c" + subBoardName + "\x01g)...\x01n"); console.line_counter = 0; var gSubBoardPollCountObj = CountPollsInSubBoard(gSubBoardCode); @@ -499,7 +509,7 @@ while (gContinueSlyVote) // Before exiting, update the user settings file if (!WriteUserSettingsFile(gUserSettings, gUserSettingsFilename)) { - console.print("\1n\1y\1hFailed to update your user settings file!\1n"); + console.print("\x01n\x01y\x01hFailed to update your user settings file!\x01n"); mswait(ERROR_PAUSE_WAIT_MS); } @@ -524,7 +534,7 @@ if (!WriteUserSettingsFile(gUserSettings, gUserSettingsFilename)) function ChooseVotingSubBoard(pMsgGrps) { // Clear the screen & display the SlyVote stylized text - console.clear("\1n"); + console.clear("\x01n"); DisplaySlyVoteText(); // Draw columns to frame the voting menu @@ -535,6 +545,7 @@ function ChooseVotingSubBoard(pMsgGrps) if (typeof(ChooseVotingSubBoard.grpMenu) != "object") ChooseVotingSubBoard.grpMenu = CreateMsgGrpMenu(listTopRow, drawColRetObj, pMsgGrps); + var chosenSubBoard = null; // If there is only one message group, then just let the user choose sub-boards // within that message group. Otherwise, display the group menu and let the user // choose a message group and then a sub-board. @@ -548,7 +559,7 @@ function ChooseVotingSubBoard(pMsgGrps) { // Display the "choose a group" text console.gotoxy(drawColRetObj.columnX1+10, listTopRow-1); - console.print("\1n\1b\1hChoose a group (\1cESC\1g/\1cQ\1g=\1n\1cExit\1h\1b)\1n"); + console.print("\x01n\x01b\x01hChoose a group (\x01cESC\x01g/\x01cQ\x01g=\x01n\x01cExit\x01h\x01b)\x01n"); chosenGrpIdx = ChooseVotingSubBoard.grpMenu.GetVal(); // Note: If the user quits out of the menu without making a selection, // chosenGrpIdx will be null. @@ -556,7 +567,6 @@ function ChooseVotingSubBoard(pMsgGrps) // Sub-board selection within a message group if (typeof(ChooseVotingSubBoard.subBoardMenus) != "object") ChooseVotingSubBoard.subBoardMenus = {}; - var chosenSubBoard = null; if ((chosenGrpIdx != null) && (chosenGrpIdx > -1)) { // If the sub-board menu for the chosen group name doesn't exist, then create it @@ -565,19 +575,19 @@ function ChooseVotingSubBoard(pMsgGrps) // In case it takes a while to load the sub-board information, display // some text saying we're loading the sub-boards console.gotoxy(drawColRetObj.columnX1+2, listTopRow); - console.print("\1n\1cLoading sub-boards\1i...\1n"); // In case loading sub-boards takes a while + console.print("\x01n\x01cLoading sub-boards\x01i...\x01n"); // In case loading sub-boards takes a while ChooseVotingSubBoard.subBoardMenus[chosenGrpIdx] = CreateSubBoardMenu(chosenGrpIdx, listTopRow, drawColRetObj, pMsgGrps); } // Display the message group - var msgGrpText = "\1n\1b\1hGroup: \1w" + msg_area.grp_list[chosenGrpIdx].name + "\1n"; + var msgGrpText = "\x01n\x01b\x01hGroup: \x01w" + msg_area.grp_list[chosenGrpIdx].name + "\x01n"; var txtDisplayLen = strip_ctrl(msgGrpText).length; var textX = (console.screen_columns/2) - (txtDisplayLen/2); console.gotoxy(textX, listTopRow-2); console.print(msgGrpText); // Display the "choose a sub-board" text console.gotoxy(drawColRetObj.columnX1+2, listTopRow-1); - var chooseASubBoardText = "\1n\1b\1hChoose a sub-board (\1cESC\1g/\1cQ\1g=\1n\1cExit\1h\1b) \1y\1h" + CHECK_CHAR + "\1n\1c=\1b\1hHas polls\1n"; + var chooseASubBoardText = "\x01n\x01b\x01hChoose a sub-board (\x01cESC\x01g/\x01cQ\x01g=\x01n\x01cExit\x01h\x01b) \x01y\x01h" + CHECK_CHAR + "\x01n\x01c=\x01b\x01hHas polls\x01n"; console.print(chooseASubBoardText); // Let the user choose a sub-board chosenSubBoard = ChooseVotingSubBoard.subBoardMenus[chosenGrpIdx].GetVal(); @@ -590,11 +600,11 @@ function ChooseVotingSubBoard(pMsgGrps) // Erase the message group text textX = (console.screen_columns/2) - (txtDisplayLen/2); console.gotoxy(textX, listTopRow-2); - console.print(format("\1n%-" + txtDisplayLen + "s", "")); + console.print(format("\x01n%-" + txtDisplayLen + "s", "")); txtDisplayLen = strip_ctrl(chooseASubBoardText).length; // Erase the "choose a sub-board" text console.gotoxy(drawColRetObj.columnX1+2, listTopRow-1); - console.print(format("\1n%-" + txtDisplayLen + "s", "")); + console.print(format("\x01n%-" + txtDisplayLen + "s", "")); } } else @@ -603,7 +613,7 @@ function ChooseVotingSubBoard(pMsgGrps) // Return an object with useful values return { - subBoardChoice: chosenSubBoard, + subBoardChoice: (chosenSubBoard == null ? "" : chosenSubBoard), menuPos: ChooseVotingSubBoard.grpMenu.pos, menuSize: ChooseVotingSubBoard.grpMenu.size }; @@ -619,7 +629,7 @@ function ChooseVotingSubBoard(pMsgGrps) // Return value: A DDLightbarMenu object for the message group menu function CreateMsgGrpMenu(pListTopRow, pDrawColRetObj, pMsgGrps) { - grpMenu = new DDLightbarMenu(pDrawColRetObj.columnX1+pDrawColRetObj.colWidth-1, pListTopRow, pDrawColRetObj.textLen, pDrawColRetObj.colHeight); + var grpMenu = new DDLightbarMenu(pDrawColRetObj.columnX1+pDrawColRetObj.colWidth-1, pListTopRow, pDrawColRetObj.textLen, pDrawColRetObj.colHeight); grpMenu.ampersandHotkeysInItems = false; grpMenu.scrollbarEnabled = true; grpMenu.AddAdditionalQuitKeys("qQ"); @@ -656,7 +666,7 @@ function CreateSubBoardMenu(pGrpIdx, pListTopRow, pDrawColRetObj, pMsgGrps) var selectedItemIndex = 0; // Populate the sub-board menu for the group with its list of sub-boards var areaNameLen = pDrawColRetObj.textLen - 3; - subBoardMenu = new DDLightbarMenu(pDrawColRetObj.columnX1+pDrawColRetObj.colWidth-1, pListTopRow, pDrawColRetObj.textLen, pDrawColRetObj.colHeight); + var subBoardMenu = new DDLightbarMenu(pDrawColRetObj.columnX1+pDrawColRetObj.colWidth-1, pListTopRow, pDrawColRetObj.textLen, pDrawColRetObj.colHeight); subBoardMenu.areaNameLen = areaNameLen; subBoardMenu.ampersandHotkeysInItems = false; subBoardMenu.scrollbarEnabled = true; @@ -682,7 +692,7 @@ function CreateSubBoardMenu(pGrpIdx, pListTopRow, pDrawColRetObj, pMsgGrps) this.subBoardPollCounts[subCode] = pollCount; } var menuItemObj = this.MakeItemWithRetval(-1); - var hasPollsChar = (pollCount ? "\1y\1h" + CHECK_CHAR + "\1n" : " "); + var hasPollsChar = (pollCount ? "\x01y\x01h" + CHECK_CHAR + "\x01n" : " "); menuItemObj.text = format("%-" + this.areaNameLen + "s %s", msg_area.sub[subCode].name.substr(0, this.areaNameLen), hasPollsChar); menuItemObj.retval = subCode; return menuItemObj; @@ -690,13 +700,13 @@ function CreateSubBoardMenu(pGrpIdx, pListTopRow, pDrawColRetObj, pMsgGrps) } else { - var areaNameLen = pDrawColRetObj.textLen - 2; + areaNameLen = pDrawColRetObj.textLen - 2; if (pMsgGrps[pGrpIdx].length > subBoardMenu.GetNumItemsPerPage()) --areaNameLen; for (var i = 0; i < pMsgGrps[pGrpIdx].length; ++i) { var subCode = pMsgGrps[pGrpIdx][i]; - var hasPollsChar = (subBoardHasPolls(subCode) ? "\1y\1h" + CHECK_CHAR + "\1n" : " "); + var hasPollsChar = (subBoardHasPolls(subCode) ? "\x01y\x01h" + CHECK_CHAR + "\x01n" : " "); var itemText = format("%-" + areaNameLen + "s %s", msg_area.sub[subCode].name.substr(0, areaNameLen), hasPollsChar); subBoardMenu.Add(itemText, subCode); if (subCode == gSubBoardCode) @@ -743,7 +753,7 @@ function DoMainMenu() var quitToBBSOpt = 6; // Display the SlyVote screen and menu of choices - console.clear("\1n"); + console.clear("\x01n"); var mainScrRetObj = DisplaySlyVoteMainVoteScreen(false); if (gMainMenu == null) { @@ -764,8 +774,8 @@ function DoMainMenu() } else gMainMenu.Add("&Quit To BBS", quitToBBSOpt, "6"); - gMainMenu.colors.itemColor = "\1n\1w"; - gMainMenu.colors.selectedItemColor = "\1n\1" + "4\1w\1h"; + gMainMenu.colors.itemColor = "\x01n\x01w"; + gMainMenu.colors.selectedItemColor = "\x01n\x01" + "4\x01w\x01h"; } // Get the user's choice and take appropriate action var userChoice = gMainMenu.GetVal(true); @@ -774,14 +784,14 @@ function DoMainMenu() if (msg_area.sub[gSubBoardCode].can_post) nextProgramState = VOTING_ON_A_POLL; else - DisplayErrorWithPause("\1y\1h" + RemoveCRLFCodes(bbs.text(CantPostOnSub)), gMessageRow, false); + DisplayErrorWithPause("\x01y\x01h" + RemoveCRLFCodes(processBBSTextDatText(bbs.text(CantPostOnSub))), gMessageRow, false); } else if (userChoice == answerAllPollsOpt) { if (msg_area.sub[gSubBoardCode].can_post) nextProgramState = VOTE_ON_ALL_POLLS; else - DisplayErrorWithPause("\1y\1h" + RemoveCRLFCodes(bbs.text(CantPostOnSub)), gMessageRow, false); + DisplayErrorWithPause("\x01y\x01h" + RemoveCRLFCodes(processBBSTextDatText(bbs.text(CantPostOnSub))), gMessageRow, false); } else if (userChoice == createPollOpt) { @@ -794,7 +804,7 @@ function DoMainMenu() var curSubCodeBackup = bbs.cursub_code; bbs.cursub_code = gSubBoardCode; // Let the user post a poll - console.print("\1n"); + console.print("\x01n"); console.gotoxy(1, console.screen_rows); bbs.exec("?postpoll.js"); // Restore the user's sub-board @@ -804,7 +814,7 @@ function DoMainMenu() gSubBoardPollCountObj = CountPollsInSubBoard(gSubBoardCode); } else - DisplayErrorWithPause("\1y\1h" + RemoveCRLFCodes(bbs.text(CantPostOnSub)), gMessageRow, false); + DisplayErrorWithPause("\x01y\x01h" + RemoveCRLFCodes(processBBSTextDatText(bbs.text(CantPostOnSub))), gMessageRow, false); } else if (userChoice == viewResultsOpt) { @@ -812,10 +822,10 @@ function DoMainMenu() nextProgramState = VIEWING_VOTE_RESULTS; else { - var errorMsg = format(RemoveCRLFCodes(bbs.text(CantReadSub)), msg_area.sub[gSubBoardCode].grp_name, msg_area.sub[gSubBoardCode].name); - if (errorMsg.substr(0, 2) == "\1n") + var errorMsg = format(RemoveCRLFCodes(processBBSTextDatText(bbs.text(CantReadSub))), msg_area.sub[gSubBoardCode].grp_name, msg_area.sub[gSubBoardCode].name); + if (errorMsg.substr(0, 2) == "\x01n") errorMsg = errorMsg.substr(2); - DisplayErrorWithPause("\1y\1h" + errorMsg, gMessageRow, false); + DisplayErrorWithPause("\x01y\x01h" + errorMsg, gMessageRow, false); } } else if (userChoice == viewStatsOpt) @@ -851,7 +861,7 @@ function ChooseVotePoll(pLetUserChoose) var nextProgramState = VOTING_ON_A_POLL; // Clear the screen between the top & bottom borders var formatStr = "%" + console.screen_columns + "s"; - console.print("\1n"); + console.print("\x01n"); for (var posY = gMessageRow; posY < gBottomBorderRow; ++posY) { console.gotoxy(1, posY); @@ -863,7 +873,7 @@ function ChooseVotePoll(pLetUserChoose) if (votePollInfo.errorMsg.length > 0) { console.gotoxy(1, gMessageRow); - console.print("\1n\1y\1h" + votePollInfo.errorMsg + "\1n"); + console.print("\x01n\x01y\x01h" + votePollInfo.errorMsg + "\x01n"); console.crlf(); console.pause(); return MAIN_MENU; @@ -871,12 +881,12 @@ function ChooseVotePoll(pLetUserChoose) else if (votePollInfo.msgHdrs.length == 0) { console.gotoxy(1, gMessageRow); - console.print("\1n\1g"); + console.print("\x01n\x01g"); if (votePollInfo.pollsExist) console.print("You have already voted on all polls in this sub-board, or all polls are closed"); else console.print("There are no polls to vote on in this sub-board"); - console.print("\1n"); + console.print("\x01n"); console.crlf(); console.pause(); return MAIN_MENU; @@ -885,16 +895,16 @@ function ChooseVotePoll(pLetUserChoose) if ((user.security.restrictions & UFLAG_V) == UFLAG_V) { console.gotoxy(1, gMessageRow); - console.print("\1n" + RemoveCRLFCodes(bbs.text(R_Voting)) + "\1n"); + console.print("\x01n" + RemoveCRLFCodes(processBBSTextDatText(bbs.text(R_Voting))) + "\x01n"); console.crlf(); console.pause(); return MAIN_MENU; } // Draw the columns to frame the voting polls - console.print("\1n"); + console.print("\x01n"); var pleaseSelectTextRow = 6; - listTopRow = pleaseSelectTextRow + 2; + var listTopRow = pleaseSelectTextRow + 2; var drawColRetObj = DrawVoteColumns(listTopRow); //var startCol = drawColRetObj.columnX1+2; @@ -922,10 +932,10 @@ function ChooseVotePoll(pLetUserChoose) var drawPollsMenu = true; while (nextProgramState == VOTING_ON_A_POLL) { - var pleaseSectPollText = "\1n\1c\1hP\1n\1clease select a poll to vote on (\1hESC\1n\1g=\1cReturn)\1n"; + var pleaseSectPollText = "\x01n\x01c\x01hP\x01n\x01clease select a poll to vote on (\x01hESC\x01n\x01g=\x01cReturn)\x01n"; console.gotoxy(18, pleaseSelectTextRow); console.print(pleaseSectPollText); - console.print("\1n"); + console.print("\x01n"); var chosenMsgNum = pollsMenu.GetVal(drawPollsMenu); if (chosenMsgNum != null) { @@ -948,11 +958,11 @@ function ChooseVotePoll(pLetUserChoose) for (var i = 0; i < votePollInfo.msgHdrs.length; ++i) { // Display the poll number - //var pollNumText = format("\1n\1c%3d of %-3d", +(i+1), votePollInfo.msgHdrs.length); - var pollNumText = format("\1n\1c%3d/%-3d", +(i+1), votePollInfo.msgHdrs.length); + //var pollNumText = format("\x01n\x01c%3d of %-3d", +(i+1), votePollInfo.msgHdrs.length); + var pollNumText = format("\x01n\x01c%3d/%-3d", +(i+1), votePollInfo.msgHdrs.length); console.gotoxy(1, console.screen_rows-4); console.print(pollNumText); - pollNumTextLen = strip_ctrl(pollNumText).length; + pollNumTextLen = console.strlen(pollNumText); //strip_ctrl(pollNumText).length; // Let the user vote on the poll var voteRetObj = DisplayPollOptionsAndVote(gSubBoardCode, votePollInfo.msgHdrs[i].number, startCol, listTopRow, drawColRetObj.textLen, menuHeight); if (voteRetObj.userExited) @@ -961,13 +971,13 @@ function ChooseVotePoll(pLetUserChoose) { DisplayErrorWithPause(voteRetObj.errorMsg, gMessageRow, voteRetObj.mnemonicsRequiredForErrorMsg); console.gotoxy(1, console.screen_rows-4); - printf("\1n%" + strip_ctrl(pollNumText).length + "s", ""); + printf("\x01n%" + pollNumTextLen + "s", ""); break; } } // Erase the poll number text console.gotoxy(1, console.screen_rows-4); - printf("\1n%" + strip_ctrl(pollNumText).length + "s", ""); + printf("\x01n%" + pollNumTextLen + "s", ""); } return nextProgramState; @@ -1009,7 +1019,7 @@ function DisplayPollOptionsAndVote(pSubBoardCode, pMsgNum, pStartCol, pStartRow, //var ESCQuitY = console.screen_rows-17; var ESCQuitY = console.screen_rows-10; console.gotoxy(ESCQuitX, ESCQuitY); - console.print("\1n\1c\1hESC\1g=\1n\1cQuit\1n"); + console.print("\x01n\x01c\x01hESC\x01g=\x01n\x01cQuit\x01n"); // Get the poll options and let the user choose one var msgHdr = msgbase.get_msg_header(false, pMsgNum, true); @@ -1021,21 +1031,21 @@ function DisplayPollOptionsAndVote(pSubBoardCode, pMsgNum, pStartCol, pStartRow, var pollSubjectStartCol = (console.screen_columns / 2) - (pollSubject.length / 2); var subjectRow = pStartRow-5; console.gotoxy(pollSubjectStartCol, subjectRow); - console.print("\1n\1g\1h" + pollSubject + "\1n"); + console.print("\x01n\x01g\x01h" + pollSubject + "\x01n"); // Write the maximum number of choices possible var numChoicesRow = subjectRow+1; var numChoicesPossibleText = ""; if (msgHdr.votes > 1) - numChoicesPossibleText = format("\1n\1gYou can submit up to \1h%d\1n\1g choices. Spacebar=Choose, Enter=Submit", msgHdr.votes); + numChoicesPossibleText = format("\x01n\x01gYou can submit up to \x01h%d\x01n\x01g choices. Spacebar=Choose, Enter=Submit", msgHdr.votes); else - numChoicesPossibleText = format("\1n\1gYou can submit up to \1h%d\1n\1g choice. Enter=Submit", msgHdr.votes); - numChoicesPossibleText += ", ESC=Quit\1n"; + numChoicesPossibleText = format("\x01n\x01gYou can submit up to \x01h%d\x01n\x01g choice. Enter=Submit", msgHdr.votes); + numChoicesPossibleText += ", ESC=Quit\x01n"; var numChoicesPossibleTextLen = strip_ctrl(numChoicesPossibleText).length; var numChoicesCol = (console.screen_columns / 2) - (numChoicesPossibleTextLen / 2); console.gotoxy(numChoicesCol, numChoicesRow); console.print(numChoicesPossibleText); // Output up to the first 3 poll comment lines - //console.print("\1n"); + //console.print("\x01n"); var i = 0; var commentStartRow = pStartRow - 3; for (var row = commentStartRow; (row < commentStartRow+3) && (i < pollTextAndOpts.commentLines.length); ++row) @@ -1058,8 +1068,8 @@ function DisplayPollOptionsAndVote(pSubBoardCode, pMsgNum, pStartCol, pStartRow, optionsMenu.multiSelect = false; for (i = 0; i < pollTextAndOpts.options.length; ++i) optionsMenu.Add(pollTextAndOpts.options[i], i+1); - optionsMenu.colors.itemColor = "\1c"; - optionsMenu.colors.selectedItemColor = "\1b\1" + "7"; + optionsMenu.colors.itemColor = "\x01c"; + optionsMenu.colors.selectedItemColor = "\x01b\x01" + "7"; // Get the user's choice(s) on the poll var userChoice = optionsMenu.GetVal(true); // Erase the poll subject text so it doesn't look weird when the @@ -1084,17 +1094,17 @@ function DisplayPollOptionsAndVote(pSubBoardCode, pMsgNum, pStartCol, pStartRow, // If there was an error, then show it. Otherwise, show a success message. //var firstLineEraseLength = pollSubject.length; console.gotoxy(1, subjectRow); - printf("\1n%" + pollSubject.length + "s", ""); + printf("\x01n%" + pollSubject.length + "s", ""); console.gotoxy(1, subjectRow); if (voteRetObj.errorMsg.length > 0) { var voteErrMsg = voteRetObj.errorMsg.substr(0, console.screen_columns - 2); firstLineEraseLength = voteErrMsg.length; - console.print("\1y\1h* " + voteErrMsg); + console.print("\x01y\x01h* " + voteErrMsg); } else { - console.print("\1gYour vote was successfully saved."); + console.print("\x01gYour vote was successfully saved."); firstLineEraseLength = 33; IncrementNumPollsVotedForUser(); } @@ -1104,7 +1114,7 @@ function DisplayPollOptionsAndVote(pSubBoardCode, pMsgNum, pStartCol, pStartRow, retObj.userExited = true; // Before returning, erase the comment lines from the screen - console.print("\1n"); + console.print("\x01n"); console.gotoxy(1, subjectRow); printf("%" + firstLineEraseLength + "s", ""); console.gotoxy(numChoicesCol, numChoicesRow); @@ -1122,12 +1132,12 @@ function DisplayPollOptionsAndVote(pSubBoardCode, pMsgNum, pStartCol, pStartRow, // Erase the ESC=Quit text console.gotoxy(ESCQuitX, ESCQuitY); - printf("\1n%8s", ""); + printf("\x01n%8s", ""); } else { // The user has already voted - retObj.errorMsg = bbs.text(VotedAlready); + retObj.errorMsg = processBBSTextDatText(bbs.text(VotedAlready)); retObj.errorMsg = RemoveCRLFCodes(retObj.errorMsg); retObj.mnemonicsRequiredForErrorMsg = true; } @@ -1588,8 +1598,8 @@ function GetMsgBody(pMsgbase, pMsgHdr, pSubBoardCode, pUser) voteOptDescLen = 27; // Format strings for outputting the voting option lines - var unvotedOptionFormatStr = "\1n\1" + "0\1c\1h%2d\1n\1" + "0\1c: \1w\1h%-" + voteOptDescLen + "s [%-4d %6.2f%]\1n\1" + "0"; - var votedOptionFormatStr = "\1n\1" + "0\1c\1h%2d\1n\1" + 0 + "\1c: \1" + "5\1w\1h%-" + voteOptDescLen + "s [%-4d %6.2f%]\1n\1" + "0"; + var unvotedOptionFormatStr = "\x01n\x01" + "0\x01c\x01h%2d\x01n\x01" + "0\x01c: \x01w\x01h%-" + voteOptDescLen + "s [%-4d %6.2f%]\x01n\x01" + "0"; + var votedOptionFormatStr = "\x01n\x01" + "0\x01c\x01h%2d\x01n\x01" + 0 + "\x01c: \x01" + "5\x01w\x01h%-" + voteOptDescLen + "s [%-4d %6.2f%]\x01n\x01" + "0"; // Add up the total number of votes so that we can // calculate vote percentages. var totalNumVotes = 0; @@ -1638,14 +1648,14 @@ function GetMsgBody(pMsgbase, pMsgHdr, pSubBoardCode, pUser) // if voting is allowed in this sub-board and the current logged-in // user has not voted on this message, then append some text saying how to vote. if ((pMsgHdr.auxattr & POLL_CLOSED) == POLL_CLOSED) // If the poll is closed - msgBody += "\1n\1y\1hThis poll is closed for voting.\1n\r\n"; + msgBody += "\x01n\x01y\x01hThis poll is closed for voting.\x01n\r\n"; else { var votingAllowed = ((pSubBoardCode != "mail") && (((msg_area.sub[pSubBoardCode].settings & SUB_NOVOTING) == 0)) && ((user.security.restrictions & UFLAG_V) == 0)); // Would be UFLAG_V if the user isn't allowed to vote if (votingAllowed && !HasUserVotedOnMsg(pMsgHdr.number, pSubBoardCode, pMsgbase, pUser)) - msgBody += "\1n\1" + "0\r\n\1gTo vote in this poll, press \1w\1h" + gReaderKeys.vote + "\1n\1" + "0\1g now.\r\n"; + msgBody += "\x01n\x01" + "0\r\n\x01gTo vote in this poll, press \x01w\x01h" + gReaderKeys.vote + "\x01n\x01" + "0\x01g now.\r\n"; } // If the current logged-in user created this poll, then show the @@ -1659,8 +1669,10 @@ function GetMsgBody(pMsgbase, pMsgHdr, pSubBoardCode, pUser) { // Get the line from text.dat for writing who voted & when. It // is a format string and should look something like this: - //"\r\n\1n\1" + "0\1hOn %s, in \1c%s \1n\1" + "0\1c%s\r\n\1h\1m%s voted in your poll: \1n\1" + "0\1h%s\r\n" 787 PollVoteNotice - var userVotedInYourPollText = "\1n\1w\1h" + bbs.text(PollVoteNotice); + //"\r\n\x01n\x01" + "0\x01hOn %s, in \x01c%s \x01n\x01" + "0\x01c%s\r\n\x01h\x01m%s voted in your poll: \x01n\x01" + "0\x01h%s\r\n" 787 PollVoteNotice + // For some reason, the bright white text in the PollVoteNotice text here will actually + // appear as bright black unless we replace \x01n\x01h with \x01n\x01w\x01h + var userVotedInYourPollText = processBBSTextDatText(bbs.text(PollVoteNotice)); // Pass true to get_all_msg_headers() to tell it to return vote messages // (the parameter was introduced in Synchronet 3.17+) @@ -1687,7 +1699,7 @@ function GetMsgBody(pMsgbase, pMsgHdr, pSubBoardCode, pUser) msgBody = pMsgbase.get_msg_body(false, pMsgHdr.number); // Remove any Synchronet pause codes that might exist in the message - msgBody = msgBody.replace("\1p", "").replace("\1P", ""); + msgBody = msgBody.replace(/\\[xX]01[pP]/g, ""); // If the user is a sysop, this is a moderated message area, and the message // hasn't been validated, then prepend the message with a message to let the @@ -1696,11 +1708,11 @@ function GetMsgBody(pMsgbase, pMsgHdr, pSubBoardCode, pUser) { if (gUserIsSysop && msg_area.sub[pSubBoardCode].is_moderated && ((pMsgHdr.attr & MSG_VALIDATED) == 0)) { - var validateNotice = "\1n\1h\1yThis is an unvalidated message in a moderated area. Press " - + gReaderKeys.validateMsg + " to validate it.\r\n\1g"; + var validateNotice = "\x01n\x01h\x01yThis is an unvalidated message in a moderated area. Press " + + gReaderKeys.validateMsg + " to validate it.\r\n\x01g"; for (var i = 0; i < 79; ++i) - validateNotice += "�"; // Horizontal single line - validateNotice += "\1n\r\n"; + validateNotice += HORIZONTAL_SINGLE; + validateNotice += "\x01n\r\n"; msgBody = validateNotice + msgBody; } } @@ -1739,13 +1751,6 @@ function GetPollTextAndOpts(pMsgHdr) if (pMsgHdr.hasOwnProperty("field_list")) { - // Go through field_list and append the voting options and stats to - // msgBody - var pollComment = ""; - var optionNum = 1; - var numVotes = 0; - var votePercentage = 0; - var tallyIdx = 0; for (var fieldI = 0; fieldI < pMsgHdr.field_list.length; ++fieldI) { if (pMsgHdr.field_list[fieldI].type == SMB_COMMENT) @@ -1784,13 +1789,14 @@ function GetPollTextAndOpts(pMsgHdr) // If something went wrong, this will be null. function VoteOnPoll(pSubBoardCode, pMsgbase, pMsgHdr, pUser, pUserVoteNumber, pRemoveNLsFromVoteText) { - var retObj = new Object(); - retObj.BBSHasVoteFunction = (typeof(pMsgbase.vote_msg) === "function"); - retObj.savedVote = false; - retObj.userQuit = false; - retObj.errorMsg = ""; - retObj.mnemonicsRequiredForErrorMsg = false; - retObj.updatedHdr = null; + var retObj = { + BBSHasVoteFunction: (typeof(pMsgbase.vote_msg) === "function"), + savedVote: false, + userQuit: false, + errorMsg: "", + mnemonicsRequiredForErrorMsg: false, + updatedHdr: null + }; // Don't allow voting for personal email if (pSubBoardCode == "mail") @@ -1802,7 +1808,7 @@ function VoteOnPoll(pSubBoardCode, pMsgbase, pMsgHdr, pUser, pUserVoteNumber, pR if ((user.security.restrictions & UFLAG_V) == UFLAG_V) { // Use the line from text.dat that says the user is not allowed to vote - retObj.errorMsg = "\1n" + RemoveCRLFCodes(bbs.text(R_Voting)); + retObj.errorMsg = "\x01n" + RemoveCRLFCodes(processBBSTextDatText(bbs.text(R_Voting))); return retObj; } @@ -1811,12 +1817,12 @@ function VoteOnPoll(pSubBoardCode, pMsgbase, pMsgHdr, pUser, pUserVoteNumber, pR if (!retObj.BBSHasVoteFunction) return retObj; - var removeNLsFromVoteText = (typeof(pRemoveNLsFromVoteText) === "boolean" ? pRemoveNLsFromVoteText : false) + var removeNLsFromVoteText = (typeof(pRemoveNLsFromVoteText) === "boolean" ? pRemoveNLsFromVoteText : false); // See if voting is allowed in the current sub-board if ((msg_area.sub[pSubBoardCode].settings & SUB_NOVOTING) == SUB_NOVOTING) { - retObj.errorMsg = bbs.text(VotingNotAllowed); + retObj.errorMsg = processBBSTextDatText(bbs.text(VotingNotAllowed)); if (removeNLsFromVoteText) retObj.errorMsg = RemoveCRLFCodes(retObj.errorMsg); retObj.mnemonicsRequiredForErrorMsg = true; @@ -1865,7 +1871,7 @@ function VoteOnPoll(pSubBoardCode, pMsgbase, pMsgHdr, pUser, pUserVoteNumber, pR } else if (userVotedMaxVotes) { - retObj.errorMsg = bbs.text(VotedAlready); + retObj.errorMsg = processBBSTextDatText(bbs.text(VotedAlready)); if (removeNLsFromVoteText) retObj.errorMsg = RemoveCRLFCodes(retObj.errorMsg); retObj.mnemonicsRequiredForErrorMsg = true; @@ -1876,7 +1882,7 @@ function VoteOnPoll(pSubBoardCode, pMsgbase, pMsgHdr, pUser, pUserVoteNumber, pR // If the user has voted on this message already, then set an error message and return. if (HasUserVotedOnMsg(pMsgHdr.number, pSubBoardCode, pMsgbase, pUser)) { - retObj.errorMsg = bbs.text(VotedAlready); + retObj.errorMsg = processBBSTextDatText(bbs.text(VotedAlready)); if (removeNLsFromVoteText) retObj.errorMsg = RemoveCRLFCodes(retObj.errorMsg); retObj.mnemonicsRequiredForErrorMsg = true; @@ -1893,10 +1899,11 @@ function VoteOnPoll(pSubBoardCode, pMsgbase, pMsgHdr, pUser, pUserVoteNumber, pR // Do some initial setup of the header for the vote message to be // saved to the messagebase - var voteMsgHdr = new Object(); - voteMsgHdr.thread_back = pMsgHdr.number; - voteMsgHdr.reply_id = pMsgHdr.id; - voteMsgHdr.from = (pMsgbase.cfg.settings & SUB_NAME) == SUB_NAME ? user.name : user.alias; + var voteMsgHdr = { + thread_back: pMsgHdr.number, + reply_id: pMsgHdr.id, + from: (pMsgbase.cfg.settings & SUB_NAME) == SUB_NAME ? user.name : user.alias + }; if (pMsgHdr.from.hasOwnProperty("from_net_type")) { voteMsgHdr.from_net_type = pMsgHdr.from_net_type; @@ -1913,10 +1920,10 @@ function VoteOnPoll(pSubBoardCode, pMsgbase, pMsgHdr, pUser, pUserVoteNumber, pR var userInputNum = 0; if (typeof(pUserVoteNumber) != "number") { - console.clear("\1n"); - var selectHdr = bbs.text(BallotHdr); - printf("\1n" + selectHdr + "\1n", pMsgHdr.subject); - var optionFormatStr = "\1n\1c\1h%2d\1n\1c: \1h%s\1n"; + console.clear("\x01n"); + var selectHdr = processBBSTextDatText(bbs.text(BallotHdr)); + printf("\x01n" + selectHdr + "\x01n", pMsgHdr.subject); + var optionFormatStr = "\x01n\x01c\x01h%2d\x01n\x01c: \x01h%s\x01n"; var optionNum = 1; for (var fieldI = 0; fieldI < pMsgHdr.field_list.length; ++fieldI) { @@ -1931,9 +1938,9 @@ function VoteOnPoll(pSubBoardCode, pMsgbase, pMsgHdr, pUser, pUserVoteNumber, pR if (pMsgHdr.votes > 1) { // Support multiple answers from the user - console.print("\1n\1gYour vote numbers, separated by commas, up to \1h" + pMsgHdr.votes + "\1n\1g (Blank/Q=Quit):"); + console.print("\x01n\x01gYour vote numbers, separated by commas, up to \x01h" + pMsgHdr.votes + "\x01n\x01g (Blank/Q=Quit):"); console.crlf(); - console.print("\1c\1h"); + console.print("\x01c\x01h"); var userInput = consoleGetStrWithValidKeys("0123456789,Q", null, false); if ((userInput.length > 0) && (userInput.toUpperCase() != "Q")) { @@ -1979,14 +1986,14 @@ function VoteOnPoll(pSubBoardCode, pMsgbase, pMsgHdr, pUser, pUserVoteNumber, pR { // Get the selection prompt text from text.dat and replace the %u or %d with // the number 1 (default option) - var selectPromptText = bbs.text(SelectItemWhich); + var selectPromptText = processBBSTextDatText(bbs.text(SelectItemWhich)); selectPromptText = selectPromptText.replace(/%[uU]/, 1).replace(/%[dD]/, 1); console.mnemonics(selectPromptText); var maxNum = optionNum - 1; userInputNum = console.getnum(maxNum); if (userInputNum == -1) // The user chose Q to quit retObj.userQuit = true; - console.print("\1n"); + console.print("\x01n"); } } else @@ -2025,9 +2032,9 @@ function DisplaySlyVoteMainVoteScreen(pClearScr) { var clearScr = (typeof(pClearScr) == "boolean" ? pClearScr : true); if (clearScr) - console.clear("\1n"); + console.clear("\x01n"); else - console.print("\1n"); + console.print("\x01n"); // Borders and stylized SlyVote text DisplayTopScreenBorder(); @@ -2037,13 +2044,13 @@ function DisplaySlyVoteMainVoteScreen(pClearScr) DisplayBottomScreenBorder(); // Write the current sub-board var subBoardText = msg_area.sub[gSubBoardCode].grp_name + " - " + msg_area.sub[gSubBoardCode].name; - subBoardText = "\1n\1b\1hCurrent sub-board: \1w" + subBoardText.substr(0, console.scren_columns); + subBoardText = "\x01n\x01b\x01hCurrent sub-board: \x01w" + subBoardText.substr(0, console.scren_columns); var subBoardTextX = (console.screen_columns/2) - (strip_ctrl(subBoardText).length/2); console.gotoxy(subBoardTextX, 9); console.print(subBoardText); // Write the number of polls in the sub-board var numOpenPolls = gSubBoardPollCountObj.numPolls-gSubBoardPollCountObj.numClosedPolls; - var numPollsText = format("\1n\1b\1hThere are \1w%d \1bopen polls in this sub-board (\1w%d\1b total)", + var numPollsText = format("\x01n\x01b\x01hThere are \x01w%d \x01bopen polls in this sub-board (\x01w%d\x01b total)", numOpenPolls, gSubBoardPollCountObj.numPolls); var numPollsTextX = (console.screen_columns/2) - (strip_ctrl(numPollsText).length/2); @@ -2058,21 +2065,21 @@ function DisplaySlyVoteMainVoteScreen(pClearScr) } else numPollsVotedOn = gSubBoardPollCountObj.numPollsUserVotedOn; - numPollsText = format("\1n\1b\1hYou have voted on \1w%s \1bpolls in this sub-board (\1w%d\1b remaining)", + numPollsText = format("\x01n\x01b\x01hYou have voted on \x01w%s \x01bpolls in this sub-board (\x01w%d\x01b remaining)", numPollsVotedOn, gSubBoardPollCountObj.numPollsRemainingForUser); var numPollsTextX = (console.screen_columns/2) - (strip_ctrl(numPollsText).length/2); console.gotoxy(numPollsTextX, 11); console.print(numPollsText); // Write the SlyVote version centered - console.print("\1n"); + console.print("\x01n"); var fieldWidth = 28; console.gotoxy(41, 14); - console.print(CenterText("\1n\1hSlyVote v\1c" + SLYVOTE_VERSION.replace(".", "\1b.\1c") + "\1n", fieldWidth)); + console.print(CenterText("\x01n\x01hSlyVote v\x01c" + SLYVOTE_VERSION.replace(".", "\x01b.\x01c") + "\x01n", fieldWidth)); // Write the "Registered to" text centered console.gotoxy(41, 17); - console.print(CenterText("\1n\1h" + system.operator + "\1n", fieldWidth)); + console.print(CenterText("\x01n\x01h" + system.operator + "\x01n", fieldWidth)); console.gotoxy(41, 18); - console.print(CenterText("\1n\1h" + system.name + "\1n", fieldWidth)); + console.print(CenterText("\x01n\x01h" + system.name + "\x01n", fieldWidth)); // Write the menu of options var curPos = { x: 7, y: 13 }; var retObj = { optMenuX: curPos.x+4, optMenuY: curPos.y }; // For the option menu to be used later @@ -2082,7 +2089,7 @@ function DisplaySlyVoteMainVoteScreen(pClearScr) for (var optNum = 1; optNum <= numMenuOptions; ++optNum) { console.gotoxy(curPos.x, curPos.y++); - console.print("\1" + "7\1h\1w�\1n\1k\1" + "7" + optNum + "\1n\1" + "7\1k\1h�\1n"); + console.print("\x01" + "7\x01h\x01w" + THIN_RECTANGLE_LEFT + "\x01n\x01k\x01" + "7" + optNum + "\x01n\x01" + "7\x01k\x01h" + THIN_RECTANGLE_RIGHT + "\x01n"); } return retObj; @@ -2090,50 +2097,88 @@ function DisplaySlyVoteMainVoteScreen(pClearScr) function DisplayTopScreenBorder() { - console.print("0"); - console.crlf(); - console.print("nh nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�"); - console.crlf(); + if (typeof(DisplayTopScreenBorder.borderText) !== "string") + { + DisplayTopScreenBorder.borderText = strRepeat("\x01n\x01b" + MID_BLOCK + "\x01h" + TALL_UPPER_MID_BLOCK + "\x01c" + UPPER_CENTER_BLOCK + "\x01b" + TALL_UPPER_MID_BLOCK, 19); + DisplayTopScreenBorder.borderText += "\x01n\x01b" + MID_BLOCK; + } + + console.print("\x01n"); + //console.crlf(); + console.print(DisplayTopScreenBorder.borderText); + console.print("\x01n"); + //console.crlf(); } function DisplaySlyVoteText() { - console.print("��"); - console.crlf(); - console.print("�hc������� nc��� hb� nc��� ��� h��� ��� nc������� ������� ������� h�"); - console.crlf(); - console.print("�� ����� nc� ��������� h� � � � nc� ��� � ��� ��� � �����"); - console.crlf(); - console.print(" h������� � nc� ����� �� �� h������� nc� ��� � � � � �����"); - console.crlf(); - console.print("�hb� c������� nc������� h� nc��� h����� nb�c������� ��� h� nc������� hb�"); - console.crlf(); - console.print("�nb�"); - console.crlf(); + if (typeof(DisplaySlyVoteText.slyVoteTextLines) === "undefined") + { + var LOWER_CENTER_BLOCK_2 = strRepeat(LOWER_CENTER_BLOCK, 2); + var LOWER_CENTER_BLOCK_3 = strRepeat(LOWER_CENTER_BLOCK, 3); + var LOWER_CENTER_BLOCK_4 = strRepeat(LOWER_CENTER_BLOCK, 4); + var LOWER_CENTER_BLOCK_5 = strRepeat(LOWER_CENTER_BLOCK, 5); + var LOWER_CENTER_BLOCK_7 = strRepeat(LOWER_CENTER_BLOCK, 7); + var spaces11 = " "; + DisplaySlyVoteText.slyVoteTextLines = [ + "\x01" + spaces11 + TINY_DOT, + spaces11 + "\x01n\x01h\x01c" + LOWER_CENTER_BLOCK_7 + " \x01n\x01c" + LOWER_CENTER_BLOCK_3 + " \x01h\x01b" + TINY_DOT + " \x01n\x01c" + LOWER_CENTER_BLOCK_3 + " " + LOWER_CENTER_BLOCK_3 + " \x01h" + LOWER_CENTER_BLOCK_3 + " " + LOWER_CENTER_BLOCK_3 + " \x01n\x01c" + LOWER_CENTER_BLOCK_7 + " " + LOWER_CENTER_BLOCK_7 + " " + LOWER_CENTER_BLOCK_7 + " \x01h" + TINY_DOT, + spaces11 + "\x01n\x01h\x01c" + BLOCK4 + " " + LOWER_CENTER_BLOCK_4 + BLOCK4 + " \x01n\x01c" + BLOCK4 + " " + BLOCK4 + "\x01 " + BLOCK4 + LOWER_CENTER_BLOCK + UPPER_CENTER_BLOCK + BLOCK4 + UPPER_CENTER_BLOCK + LOWER_CENTER_BLOCK + BLOCK4 + " \x01h" + BLOCK4 + " " + BLOCK4 + " " + BLOCK4 + " " + BLOCK4 + " \x01n\x01c" + BLOCK4 + " " + LOWER_CENTER_BLOCK_3 + " " + BLOCK4 + " " + BLOCK4 + LOWER_CENTER_BLOCK_2 + " " + LOWER_CENTER_BLOCK_2 + BLOCK4 + " " + BLOCK4 + " " + LOWER_CENTER_BLOCK_4 + BLOCK4 + "", + " \x01h" + TINY_DOT + " " + BLOCK4 + strRepeat(LOWER_CENTER_BLOCK, 4) + " " + BLOCK4 + " \x01n\x01c" + BLOCK4 + " " + BLOCK4 + LOWER_CENTER_BLOCK_4 + " " + UPPER_CENTER_BLOCK + BLOCK4 + " " + BLOCK4 + UPPER_CENTER_BLOCK + " \x01h" + BLOCK4 + LOWER_CENTER_BLOCK + UPPER_CENTER_BLOCK + BLOCK4 + UPPER_CENTER_BLOCK + LOWER_CENTER_BLOCK + BLOCK4 + " \x01n\x01c" + BLOCK4 + " " + BLOCK4 + LOWER_CENTER_BLOCK + BLOCK4 + " " + BLOCK4 + " " + BLOCK4 + " " + BLOCK4 + " " + BLOCK4 + " " + LOWER_CENTER_BLOCK_3 + BLOCK4 + LOWER_CENTER_BLOCK, + "\x01n \x01h\x01b" + TINY_DOT + " \x01c" + BLOCK4 + LOWER_CENTER_BLOCK_5 + BLOCK4 + " \x01n\x01c" + BLOCK4 + LOWER_CENTER_BLOCK_5 + BLOCK4 + " \x01h" + TINY_DOT + " \x01n\x01c" + BLOCK4 + LOWER_CENTER_BLOCK + BLOCK4 + " \x01h" + UPPER_CENTER_BLOCK + BLOCK4 + LOWER_CENTER_BLOCK + BLOCK4 + UPPER_CENTER_BLOCK + " \x01n\x01b" + TINY_DOT + "\x01c" + BLOCK4 + LOWER_CENTER_BLOCK_5 + BLOCK4 + " " + BLOCK4 + LOWER_CENTER_BLOCK + BLOCK4 + " \x01h" + TINY_DOT + " \x01n\x01c" + BLOCK4 + LOWER_CENTER_BLOCK_5 + BLOCK4 + " \x01h\x01b" + TINY_DOT, + "\x01n \x01b" + TINY_DOT + ]; + } + + console.print("\x01n"); + for (var i = 0; i < DisplaySlyVoteText.slyVoteTextLines.length; ++i) + { + console.print(DisplaySlyVoteText.slyVoteTextLines[i]); + console.crlf(); + } + console.print("\x01n"); } function DisplayVerAndRegBorders() { + if (typeof(DisplayVerAndRegBorders.borderLines) === "undefined") + { + var HORIZONTAL_SINGLE_2 = strRepeat(HORIZONTAL_SINGLE, 2); + var HORIZONTAL_SINGLE_3 = strRepeat(HORIZONTAL_SINGLE, 3); + DisplayVerAndRegBorders.borderLines = [ + "\x01b\x01h" + UPPER_LEFT_SINGLE + HORIZONTAL_SINGLE + "\x01k" + strRepeat(HORIZONTAL_SINGLE, 2) + "\x01b" + HORIZONTAL_SINGLE + "\x01n\x01b" + HORIZONTAL_SINGLE_2 + "\x01h\x01k" + HORIZONTAL_SINGLE_3 + "\x01b" + HORIZONTAL_SINGLE + "\x01n\x01b" + HORIZONTAL_SINGLE + "\x01h" + HORIZONTAL_SINGLE_2 + "\x01n\x01b" + HORIZONTAL_SINGLE + "\x01h" + HORIZONTAL_SINGLE + "\x01k" + HORIZONTAL_SINGLE + "\x01b" + HORIZONTAL_SINGLE_2 + "\x01n\x01b" + HORIZONTAL_SINGLE + "\x01h\x01k" + HORIZONTAL_SINGLE + "\x01n\x01b" + HORIZONTAL_SINGLE + "\x01h" + HORIZONTAL_SINGLE + "\x01k" + HORIZONTAL_SINGLE_2 + "\x01b" + HORIZONTAL_SINGLE + "\x01n\x01b" + HORIZONTAL_SINGLE + "\x01h\x01k" + HORIZONTAL_SINGLE + "\x01n\x01b" + HORIZONTAL_SINGLE + "\x01h" + UPPER_RIGHT_SINGLE, + "\x01n\x01b" + VERTICAL_SINGLE + "\x01n \x01k\x01h" + VERTICAL_SINGLE, + "\x01b" + LOWER_LEFT_SINGLE + HORIZONTAL_SINGLE_2 + "\x01k" + HORIZONTAL_SINGLE_2 + "\x01n\x01b" + HORIZONTAL_SINGLE_3 + "\x01h\x01k" + HORIZONTAL_SINGLE + "\x01b" + HORIZONTAL_SINGLE + "\x01k" + HORIZONTAL_SINGLE + "\x01b" + HORIZONTAL_SINGLE + "\x01n\x01b" + HORIZONTAL_SINGLE + "\x01h" + HORIZONTAL_SINGLE_2 + "\x01k" + HORIZONTAL_SINGLE + "\x01n\x01b" + HORIZONTAL_SINGLE + "\x01h\x01k" + HORIZONTAL_SINGLE + "\x01n\x01b" + HORIZONTAL_SINGLE + "\x01h" + HORIZONTAL_SINGLE + "\x01k" + HORIZONTAL_SINGLE + "\x01b" + HORIZONTAL_SINGLE + "\x01k" + HORIZONTAL_SINGLE_2 + "\x01b" + HORIZONTAL_SINGLE + "\x01k" + HORIZONTAL_SINGLE + "\x01b" + HORIZONTAL_SINGLE + "\x01n\x01b" + HORIZONTAL_SINGLE + "\x01h" + HORIZONTAL_SINGLE + "\x01n\x01b" + LOWER_RIGHT_SINGLE, + UPPER_LEFT_SINGLE + "\x01h\x01k" + HORIZONTAL_SINGLE + "\x01n\x01b" + HORIZONTAL_SINGLE_3 + "\x01h\x01k" + HORIZONTAL_SINGLE + "\x01b" + RIGHT_T_SINGLE + " \x01n\x01bR\x01he\x01n\x01bgistere\x01h\x01kd To: \x01b" + LEFT_T_SINGLE + "\x01k" + HORIZONTAL_SINGLE + "\x01n\x01b" + HORIZONTAL_SINGLE + "\x01h" + HORIZONTAL_SINGLE + "\x01k" + HORIZONTAL_SINGLE + HORIZONTAL_SINGLE + UPPER_RIGHT_SINGLE, + "\x01n\x01b" + VERTICAL_SINGLE + "\x01n \x01b\x01h" + VERTICAL_SINGLE, + "\x01n\x01k\x01h" + VERTICAL_SINGLE + "\x01n \x01b" + VERTICAL_SINGLE, + "\x01h" + LOWER_LEFT_SINGLE + "\x01k" + HORIZONTAL_SINGLE + "\x01n\x01b" + HORIZONTAL_SINGLE + "\x01h\x01k" + HORIZONTAL_SINGLE + "\x01n\x01b" + HORIZONTAL_SINGLE + "\x01h" + HORIZONTAL_SINGLE_3 + "\x01k" + HORIZONTAL_SINGLE_2 + "\x01b" + HORIZONTAL_SINGLE + "\x01n\x01b" + HORIZONTAL_SINGLE + "\x01h" + HORIZONTAL_SINGLE_3 + "\x01k" + HORIZONTAL_SINGLE + "\x01n\x01b" + HORIZONTAL_SINGLE + "\x01h" + HORIZONTAL_SINGLE + "\x01n\x01b" + HORIZONTAL_SINGLE + "\x01h" + HORIZONTAL_SINGLE_2 + "\x01n\x01b" + HORIZONTAL_SINGLE + "\x01h" + HORIZONTAL_SINGLE + "\x01n\x01b" + HORIZONTAL_SINGLE + "\x01h" + HORIZONTAL_SINGLE + "\x01n\x01b" + HORIZONTAL_SINGLE + "\x01h" + HORIZONTAL_SINGLE + "\x01n\x01b" + HORIZONTAL_SINGLE + "\x01h\x01k" + HORIZONTAL_SINGLE + "\x01b" + LOWER_RIGHT_SINGLE + ]; + } + var curPos = { x: 40, y: 13 }; console.gotoxy(curPos.x, curPos.y++); - console.print("h��k��b�nb��hk���b�nb�h��nb�h�k�b��nb�hk�nb�h�k��b�nb�hk�nb�h�"); - console.gotoxy(curPos.x, curPos.y++); - console.print("nb��hw c b c �k�"); - console.gotoxy(curPos.x, curPos.y++); - console.print("b���k��nb���hk�b�k�b�nb�h��k�nb�hk�nb�h�k�b�k��b�k�b�nb�h�nb�"); - console.gotoxy(curPos.x, curPos.y++); - console.print("�hk�nb���hk�b� nbRhenbgisterehkd To: b�k�nb�h�k�Ŀ"); - console.gotoxy(curPos.x, curPos.y++); - console.print("nb��h�"); - console.gotoxy(curPos.x, curPos.y++); - console.print("k��nb�"); - console.gotoxy(curPos.x, curPos.y++); - console.print("h�k�nb�hk�nb�h���k��b�nb�h���k�nb�h�nb�h��nb�h�nb�h�nb�h�nb�hk�b�"); + console.print("\x01n"); + for (var i = 0; i < DisplayVerAndRegBorders.borderLines.length; ++i) + { + console.print(DisplayVerAndRegBorders.borderLines[i]); + console.gotoxy(curPos.x, curPos.y++); + } + console.print("\x01n"); } function DisplayBottomScreenBorder() { - console.print(" nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�h�c�b�nb�n"); + if (typeof(DisplayBottomScreenBorder.borderText) !== "string") + { + DisplayBottomScreenBorder.borderText = " " + strRepeat("\x01n\x01b" + UPPER_CENTER_BLOCK + "\x01h" + TALL_UPPER_MID_BLOCK + "\x01c" + LOWER_CENTER_BLOCK + "\x01b" + TALL_UPPER_MID_BLOCK, 19); + DisplayBottomScreenBorder.borderText += "\x01n\x01b" + UPPER_CENTER_BLOCK; + } + console.print("\x01n"); + //console.crlf(); + console.print(DisplayBottomScreenBorder.borderText); + console.print("\x01n"); + //console.crlf(); } // Centers some text within a specified field length. @@ -2198,75 +2243,30 @@ function GetPollHdrs(pSubBoardCode, pCheckIfUserVoted, pOnlyOpenPolls) var msgbase = new MsgBase(pSubBoardCode); if (msgbase.open()) { - if (typeof(msgbase.get_index) === "function") + var msgHdrs = msgbase.get_all_msg_headers(true); + for (var prop in msgHdrs) { - var msgIndexes = msgbase.get_index(); - if (msgIndexes != null) - { - for (var i = 0; i < msgIndexes.length; ++i) - { - // Skip deleted and unreadable messages - if ((msgIndexes[i].attr & MSG_DELETE) == MSG_DELETE) - continue; + // Skip deleted and unreadable messages + if ((msgHdrs[prop].attr & MSG_DELETE) == MSG_DELETE) + continue; + if (!IsReadableMsgHdr(msgHdrs[prop], pSubBoardCode)) + continue; - if ((msgIndexes[i].attr & MSG_POLL) == MSG_POLL) - { - var msgHdr = msgbase.get_msg_header(false, msgIndexes[i].number, true); - if (msgHdr != null) - { - // Note: IsReadableMsgHdr() checks the 'to' name for unvalidated messages - // for the sysop if the sub-board requires validation, but when using get_index(), - // the 'to' field seems to be numbers or undefined, so we use the full - // header for this check. - if (!IsReadableMsgHdr(msgHdr, pSubBoardCode)) - continue; - - var includeThisPoll = true; - if (pOnlyOpenPolls) - includeThisPoll = ((msgHdr.auxattr & POLL_CLOSED) == 0); - if (includeThisPoll) - { - retObj.pollsExist = true; - if (pCheckIfUserVoted) - { - if (!HasUserVotedOnMsg(msgHdr.number, pSubBoardCode, msgbase, user)) - retObj.msgHdrs.push(msgHdr); - } - else - retObj.msgHdrs.push(msgHdr); - } - } - } - } - } - } - else - { - var msgHdrs = msgbase.get_all_msg_headers(true); - for (var prop in msgHdrs) + if ((msgHdrs[prop].type & MSG_TYPE_POLL) == MSG_TYPE_POLL) { - // Skip deleted and unreadable messages - if ((msgHdrs[prop].attr & MSG_DELETE) == MSG_DELETE) - continue; - if (!IsReadableMsgHdr(msgHdrs[prop], pSubBoardCode)) - continue; - - if ((msgHdrs[prop].type & MSG_TYPE_POLL) == MSG_TYPE_POLL) + var includeThisPoll = true; + if (pOnlyOpenPolls) + includeThisPoll = ((msgHdrs[prop].auxattr & POLL_CLOSED) == 0); + if (includeThisPoll) { - var includeThisPoll = true; - if (pOnlyOpenPolls) - includeThisPoll = ((msgHdrs[prop].auxattr & POLL_CLOSED) == 0); - if (includeThisPoll) + retObj.pollsExist = true; + if (pCheckIfUserVoted) { - retObj.pollsExist = true; - if (pCheckIfUserVoted) - { - if (!HasUserVotedOnMsg(msgHdrs[prop].number, pSubBoardCode, msgbase, user)) - retObj.msgHdrs.push(msgHdrs[prop]); - } - else + if (!HasUserVotedOnMsg(msgHdrs[prop].number, pSubBoardCode, msgbase, user)) retObj.msgHdrs.push(msgHdrs[prop]); } + else + retObj.msgHdrs.push(msgHdrs[prop]); } } } @@ -2279,6 +2279,10 @@ function GetPollHdrs(pSubBoardCode, pCheckIfUserVoted, pOnlyOpenPolls) return retObj; } +// Lets the user view the voting results for a sub-board. +// +// Parameters: +// pSubBoardCode: The internal code of the sub-board to view voting results for function ViewVoteResults(pSubBoardCode) { var nextProgramState = MAIN_MENU; @@ -2319,22 +2323,21 @@ function ViewVoteResults(pSubBoardCode) ++pollMsgIdx; } } - delete msgHdrs; // Free some memory // If there are no polls, then just return if (pollMsgHdrs.length == 0) { msgbase.close(); - DisplayErrorWithPause("\1n\1y\1hThere are no polls to view.\1n", gMessageRow, false); + DisplayErrorWithPause("\x01n\x01y\x01hThere are no polls to view.\x01n", gMessageRow, false); return nextProgramState; } // Create the key help line to be displayed at the bottom of the screen - var keyText = "\1rLeft\1b, \1rRight\1b, \1rUp\1b, \1rDn\1b, \1rPgUp\1b/\1rDn\1b, \1rF\1m)\1birst, \1rL\1m)\1bast, \1r#\1b, "; + var keyText = "\x01rLeft\x01b, \x01rRight\x01b, \x01rUp\x01b, \x01rDn\x01b, \x01rPgUp\x01b/\x01rDn\x01b, \x01rF\x01m)\x01birst, \x01rL\x01m)\x01bast, \x01r#\x01b, "; if (PollDeleteAllowed(msgbase, pSubBoardCode)) - keyText += "\1rDEL\1b, "; - keyText += "\1rC\1m)\1blose, \1rQ\1m)\1buit, \1r?"; - var keyHelpLine = "\1" + "7" + CenterText(keyText, console.screen_columns-1); + keyText += "\x01rDEL\x01b, "; + keyText += "\x01rC\x01m)\x01blose, \x01rQ\x01m)\x01buit, \x01r?"; + var keyHelpLine = "\x01" + "7" + CenterText(keyText, console.screen_columns-1); // Get the unmodified default header lines to be displayed var displayMsgHdrUnmodified = GetDefaultMsgDisplayHdr(); @@ -2345,7 +2348,7 @@ function ViewVoteResults(pSubBoardCode) console.screen_columns, frameHeight); // Prepare the screen and display the key help line on the last row of the screen - console.clear("\1n"); + console.clear("\x01n"); console.gotoxy(1, console.screen_rows); console.print(keyHelpLine); @@ -2365,11 +2368,11 @@ function ViewVoteResults(pSubBoardCode) if (drawKeyHelpLine) { console.gotoxy(1, console.screen_rows); - console.print("\1n" + keyHelpLine); + console.print("\x01n" + keyHelpLine); } // Get the message header lines to be displayed - var dateTimeStr = pollMsgHdrs[currentMsgIdx]["date"].replace(/ [-+][0-9]+$/, ""); + var dateTimeStr = pollMsgHdrs[currentMsgIdx].date.replace(/ [-+][0-9]+$/, ""); var displayMsgHdr = GetDisplayMsgHdrForMsg(pollMsgHdrs[currentMsgIdx], displayMsgHdrUnmodified, pSubBoardCode, pollMsgHdrs.length, currentMsgIdx+1, dateTimeStr, false, false); // Display the message header on the screen if (drawMsg) @@ -2387,7 +2390,7 @@ function ViewVoteResults(pSubBoardCode) gAvatar.draw(pollMsgHdrs[currentMsgIdx].from_ext, pollMsgHdrs[currentMsgIdx].from, pollMsgHdrs[currentMsgIdx].from_net_addr, /* above: */true, /* right-justified: */true); console.attributes = 0; // Clear the background attribute as the next line might scroll, filling with BG attribute } - console.print("\1n"); + console.print("\x01n"); } var msgBodyText = GetMsgBody(msgbase, pollMsgHdrs[currentMsgIdx], pSubBoardCode, user); if (msgBodyText == null) @@ -2396,7 +2399,7 @@ function ViewVoteResults(pSubBoardCode) // Load the poll text into the Frame object and draw the frame frameAndScrollbar.frame.clear(); frameAndScrollbar.frame.attr&=~HIGH; - frameAndScrollbar.frame.putmsg(msgBodyText, "\1n"); + frameAndScrollbar.frame.putmsg(msgBodyText, "\x01n"); frameAndScrollbar.frame.scrollTo(0, 0); if (drawMsg) { @@ -2407,7 +2410,7 @@ function ViewVoteResults(pSubBoardCode) } // Let the user scroll the message, and take appropriate action based // on the user input - var scrollRetObj = ScrollFrame(frameAndScrollbar.frame, frameAndScrollbar.scrollbar, 0, "\1n", false, 1, console.screen_rows); + var scrollRetObj = ScrollFrame(frameAndScrollbar.frame, frameAndScrollbar.scrollbar, 0, "\x01n", false, 1, console.screen_rows); drawMsg = true; drawKeyHelpLine = false; if (scrollRetObj.lastKeypress == KEY_LEFT) @@ -2456,14 +2459,13 @@ function ViewVoteResults(pSubBoardCode) { var msgHdrs = msgbase.get_all_msg_headers(true); pollMsgHdrs[currentMsgIdx] = msgHdrs[pollMsgHdrs[currentMsgIdx].number]; - delete msgHdrs; IncrementNumPollsVotedForUser(); } // If there is an error message, then display it at the bottom row. if (voteRetObj.errorMsg.length > 0) { console.gotoxy(1, console.screen_rows-1); - printf("\1n%" + +(console.screen_columns-1) + "s", ""); + printf("\x01n%" + +(console.screen_columns-1) + "s", ""); console.gotoxy(1, console.screen_rows-1); if (voteRetObj.mnemonicsRequiredForErrorMsg) { @@ -2472,10 +2474,10 @@ function ViewVoteResults(pSubBoardCode) } else { - console.print("\1n\1y\1h" + voteRetObj.errorMsg.substr(0, console.screen_columns-1)); + console.print("\x01n\x01y\x01h" + voteRetObj.errorMsg.substr(0, console.screen_columns-1)); mswait(ERROR_PAUSE_WAIT_MS); console.gotoxy(1, console.screen_rows-1); - printf("\1n%" + strip_ctrl(voteRetObj.errorMsg).length + "s", ""); + printf("\x01n%" + strip_ctrl(voteRetObj.errorMsg).length + "s", ""); } drawMsg = true; drawKeyHelpLine = false; @@ -2504,7 +2506,7 @@ function ViewVoteResults(pSubBoardCode) { // Prompt to confirm whether the user wants to close the poll console.gotoxy(1, console.screen_rows-1); - printf("\1n%" + +(console.screen_columns-1) + "s", ""); + printf("\x01n%" + +(console.screen_columns-1) + "s", ""); console.gotoxy(1, console.screen_rows-1); if (!console.noyes("Close poll")) { @@ -2513,26 +2515,26 @@ function ViewVoteResults(pSubBoardCode) { pollMsgHdrs[currentMsgIdx].auxattr |= POLL_CLOSED; ++gSubBoardPollCountObj.numClosedPolls; - pollCloseMsg = "\1n\1cThis poll was successfully closed."; + pollCloseMsg = "\x01n\x01cThis poll was successfully closed."; } else - pollCloseMsg = "\1n\1r\1h* Failed to close this poll!"; + pollCloseMsg = "\x01n\x01r\x01h* Failed to close this poll!"; } } else - pollCloseMsg = "\1n\1y\1hCan't close this poll because it's not yours"; + pollCloseMsg = "\x01n\x01y\x01hCan't close this poll because it's not yours"; } else - pollCloseMsg = "\1n\1y\1hThis poll is already closed"; + pollCloseMsg = "\x01n\x01y\x01hThis poll is already closed"; } else - pollCloseMsg = "\1n\1y\1hThis message is not a poll"; + pollCloseMsg = "\x01n\x01y\x01hThis message is not a poll"; // Write the poll close success/failure/status message if (pollCloseMsg.length > 0) { console.gotoxy(1, console.screen_rows-1); - printf("\1n%" + +(console.screen_columns-1) + "s", ""); + printf("\x01n%" + +(console.screen_columns-1) + "s", ""); console.gotoxy(1, console.screen_rows-1); console.print(pollCloseMsg + "\n"); mswait(ERROR_PAUSE_WAIT_MS); @@ -2553,11 +2555,11 @@ function ViewVoteResults(pSubBoardCode) // Move the cursor to the last row of the screen and prompt the // user for the message number. console.gotoxy(1, console.screen_rows); - printf("\1n%" + +(console.screen_columns-1) + "s", ""); // Clear the last row + printf("\x01n%" + +(console.screen_columns-1) + "s", ""); // Clear the last row console.gotoxy(1, console.screen_rows); // Prompt for the message number, and go to that message if it's // different from the current message - var msgNumInput = PromptForMsgNum(pollMsgHdrs.length, {x: 1, y: console.screen_rows}, "\1n\1cPoll #\1g\1h: \1c", false, ERROR_PAUSE_WAIT_MS, false); + var msgNumInput = PromptForMsgNum(pollMsgHdrs.length, {x: 1, y: console.screen_rows}, "\x01n\x01cPoll #\x01g\x01h: \x01c", false); if (msgNumInput-1 != currentMsgIdx) currentMsgIdx = msgNumInput-1; else @@ -2570,9 +2572,9 @@ function ViewVoteResults(pSubBoardCode) { // Go to the last line and confirm whether to delete the message console.gotoxy(1, console.screen_rows); - printf("\1n%" + +(console.screen_columns-1) + "s", ""); + printf("\x01n%" + +(console.screen_columns-1) + "s", ""); console.gotoxy(1, console.screen_rows); - var deleteMsg = !console.noyes("\1n\1cDelete this poll\1n"); + var deleteMsg = !console.noyes("\x01n\x01cDelete this poll\x01n"); if (deleteMsg) { var delMsgRetObj = DeleteMessage(msgbase, pollMsgHdrs[currentMsgIdx].number, pSubBoardCode); @@ -2585,12 +2587,12 @@ function ViewVoteResults(pSubBoardCode) if (errorMsg.length > 0) { console.gotoxy(1, console.screen_rows); - printf("\1n%" + +(console.screen_columns-1) + "s", ""); + printf("\x01n%" + +(console.screen_columns-1) + "s", ""); console.gotoxy(1, console.screen_rows); - console.print("\1n\1y\1h* " + errorMsg); + console.print("\x01n\x01y\x01h* " + errorMsg); mswait(ERROR_PAUSE_WAIT_MS); console.gotoxy(1, console.screen_rows); - printf("\1n%" + strip_ctrl(errorMsg).length + "s", ""); + printf("\x01n%" + strip_ctrl(errorMsg).length + "s", ""); } // If the message was deleted, remove it from the array and @@ -2611,9 +2613,9 @@ function ViewVoteResults(pSubBoardCode) { continueOn = false; console.gotoxy(1, console.screen_rows); - console.print("\1n"); + console.print("\x01n"); console.crlf(); - console.print("\1nThere are no more polls.\1n"); + console.print("\x01nThere are no more polls.\x01n"); console.crlf(); console.pause(); } @@ -2640,21 +2642,21 @@ function ViewVoteResults(pSubBoardCode) { var validated = ValidateMsg(msgbase, pSubBoardCode, pollMsgHdrs[currentMsgIdx].number); console.gotoxy(1, console.screen_rows-2); - console.print("\1n\1h\1g"); + console.print("\x01n\x01h\x01g"); for (var i = 0; i < console.screen_columns-1; ++i) - console.print("�"); // Horizontal single line + console.print("?"); // Horizontal single line console.gotoxy(1, console.screen_rows-1); - printf("\1n%" + +(console.screen_columns-1) + "s", ""); + printf("\x01n%" + +(console.screen_columns-1) + "s", ""); console.gotoxy(1, console.screen_rows-1); if (validated) { - console.print("\1cMessage was validated successfully.\1n"); + console.print("\x01cMessage was validated successfully.\x01n"); drawMsg = true; pollMsgHdrs[currentMsgIdx].attr |= MSG_VALIDATED; } else { - console.print("\1y\1hMessage validation failed!\1n"); + console.print("\x01y\x01hMessage validation failed!\x01n"); drawMsg = false; } mswait(ERROR_PAUSE_WAIT_MS); @@ -2686,8 +2688,8 @@ function GetDefaultMsgDisplayHdr() // Sub-board name: 34% of console width var msgGrpNameLen = Math.floor(console.screen_columns * 0.2); var subBoardNameLen = Math.floor(console.screen_columns * 0.34); - var hdrLine1 = "\1n\1h\1c" + UPPER_LEFT_SINGLE + HORIZONTAL_SINGLE + "\1n\1c" - + HORIZONTAL_SINGLE + " \1h@GRP-L"; + var hdrLine1 = "\x01n\x01h\x01c" + UPPER_LEFT_SINGLE + HORIZONTAL_SINGLE + "\x01n\x01c" + + HORIZONTAL_SINGLE + " \x01h@GRP-L"; var numChars = msgGrpNameLen - 7; for (var i = 0; i < numChars; ++i) hdrLine1 += "#"; @@ -2695,52 +2697,52 @@ function GetDefaultMsgDisplayHdr() numChars = subBoardNameLen - 7; for (var i = 0; i < numChars; ++i) hdrLine1 += "#"; - hdrLine1 += "@\1k"; + hdrLine1 += "@\x01k"; numChars = console.screen_columns - console.strlen(hdrLine1) - 4; for (var i = 0; i < numChars; ++i) hdrLine1 += HORIZONTAL_SINGLE; - hdrLine1 += "\1n\1c" + HORIZONTAL_SINGLE + HORIZONTAL_SINGLE + "\1h" + hdrLine1 += "\x01n\x01c" + HORIZONTAL_SINGLE + HORIZONTAL_SINGLE + "\x01h" + HORIZONTAL_SINGLE + UPPER_RIGHT_SINGLE; hdrDisplayLines.push(hdrLine1); - var hdrLine2 = "\1n\1c" + VERTICAL_SINGLE + "\1h\1k" + BLOCK1 + BLOCK2 - + BLOCK3 + "\1gM\1n\1gsg#\1h\1c: \1b@MSG_NUM_AND_TOTAL-L"; + var hdrLine2 = "\x01n\x01c" + VERTICAL_SINGLE + "\x01h\x01k" + BLOCK1 + BLOCK2 + + BLOCK3 + "\x01gM\x01n\x01gsg#\x01h\x01c: \x01b@MSG_NUM_AND_TOTAL-L"; numChars = console.screen_columns - 32; for (var i = 0; i < numChars; ++i) hdrLine2 += "#"; - hdrLine2 += "@\1n\1c" + VERTICAL_SINGLE; + hdrLine2 += "@\x01n\x01c" + VERTICAL_SINGLE; hdrDisplayLines.push(hdrLine2); - var hdrLine3 = "\1n\1h\1k" + VERTICAL_SINGLE + BLOCK1 + BLOCK2 + BLOCK3 - + "\1gF\1n\1grom\1h\1c: \1b@MSG_FROM_AND_FROM_NET-L"; + var hdrLine3 = "\x01n\x01h\x01k" + VERTICAL_SINGLE + BLOCK1 + BLOCK2 + BLOCK3 + + "\x01gF\x01n\x01grom\x01h\x01c: \x01b@MSG_FROM_AND_FROM_NET-L"; numChars = console.screen_columns - 36; for (var i = 0; i < numChars; ++i) hdrLine3 += "#"; - hdrLine3 += "@\1k" + VERTICAL_SINGLE; + hdrLine3 += "@\x01k" + VERTICAL_SINGLE; hdrDisplayLines.push(hdrLine3); - var hdrLine4 = "\1n\1h\1k" + VERTICAL_SINGLE + BLOCK1 + BLOCK2 + BLOCK3 - + "\1gS\1n\1gubj\1h\1c: \1b@MSG_SUBJECT-L"; + var hdrLine4 = "\x01n\x01h\x01k" + VERTICAL_SINGLE + BLOCK1 + BLOCK2 + BLOCK3 + + "\x01gS\x01n\x01gubj\x01h\x01c: \x01b@MSG_SUBJECT-L"; numChars = console.screen_columns - 26; for (var i = 0; i < numChars; ++i) hdrLine4 += "#"; - hdrLine4 += "@\1k" + VERTICAL_SINGLE; + hdrLine4 += "@\x01k" + VERTICAL_SINGLE; hdrDisplayLines.push(hdrLine4); - var hdrLine5 = "\1n\1c" + VERTICAL_SINGLE + "\1h\1k" + BLOCK1 + BLOCK2 + BLOCK3 - + "\1gD\1n\1gate\1h\1c: \1b@MSG_DATE-L"; + var hdrLine5 = "\x01n\x01c" + VERTICAL_SINGLE + "\x01h\x01k" + BLOCK1 + BLOCK2 + BLOCK3 + + "\x01gD\x01n\x01gate\x01h\x01c: \x01b@MSG_DATE-L"; //numChars = console.screen_columns - 23; numChars = console.screen_columns - 67; for (var i = 0; i < numChars; ++i) hdrLine5 += "#"; - //hdrLine5 += "@\1n\1c" + VERTICAL_SINGLE; - hdrLine5 += "@ @MSG_TIMEZONE@\1n"; + //hdrLine5 += "@\x01n\x01c" + VERTICAL_SINGLE; + hdrLine5 += "@ @MSG_TIMEZONE@\x01n"; for (var i = 0; i < 40; ++i) hdrLine5 += " "; - hdrLine5 += "\1n\1c" + VERTICAL_SINGLE; + hdrLine5 += "\x01n\x01c" + VERTICAL_SINGLE; hdrDisplayLines.push(hdrLine5); - var hdrLine6 = "\1n\1h\1c" + BOTTOM_T_SINGLE + HORIZONTAL_SINGLE + "\1n\1c" - + HORIZONTAL_SINGLE + HORIZONTAL_SINGLE + "\1h\1k"; + var hdrLine6 = "\x01n\x01h\x01c" + BOTTOM_T_SINGLE + HORIZONTAL_SINGLE + "\x01n\x01c" + + HORIZONTAL_SINGLE + HORIZONTAL_SINGLE + "\x01h\x01k"; numChars = console.screen_columns - 8; for (var i = 0; i < numChars; ++i) hdrLine6 += HORIZONTAL_SINGLE; - hdrLine6 += "\1n\1c" + HORIZONTAL_SINGLE + HORIZONTAL_SINGLE + "\1h" + hdrLine6 += "\x01n\x01c" + HORIZONTAL_SINGLE + HORIZONTAL_SINGLE + "\x01h" + HORIZONTAL_SINGLE + BOTTOM_T_SINGLE; hdrDisplayLines.push(hdrLine6); @@ -2794,19 +2796,19 @@ function ReplaceMsgAtCodeFormatStr(pMsgHdr, pSubBoardCode, pNumMsgs, pDisplayMsg var replacementTxt = ""; if (pAtCodeStr.indexOf("@MSG_FROM_AND_FROM_NET") > -1) { - var fromWithNet = pMsgHdr["from"] + (typeof(pMsgHdr["from_net_addr"]) == "string" ? " (" + pMsgHdr["from_net_addr"] + ")" : ""); + var fromWithNet = pMsgHdr.from + (typeof(pMsgHdr.from_net_addr) == "string" ? " (" + pMsgHdr.from_net_addr + ")" : ""); replacementTxt = fromWithNet.substr(0, pSpecifiedLen); } else if (pAtCodeStr.indexOf("@MSG_FROM") > -1) - replacementTxt = pMsgHdr["from"].substr(0, pSpecifiedLen); + replacementTxt = pMsgHdr.from.substr(0, pSpecifiedLen); else if (pAtCodeStr.indexOf("@MSG_FROM_EXT") > -1) - replacementTxt = (typeof pMsgHdr["from_ext"] === "undefined" ? "" : pMsgHdr["from_ext"].substr(0, pSpecifiedLen)); + replacementTxt = (typeof pMsgHdr.from_ext === "undefined" ? "" : pMsgHdr.from_ext.substr(0, pSpecifiedLen)); else if ((pAtCodeStr.indexOf("@MSG_TO") > -1) || (pAtCodeStr.indexOf("@MSG_TO_NAME") > -1)) - replacementTxt = pMsgHdr["to"].substr(0, pSpecifiedLen); + replacementTxt = pMsgHdr.to.substr(0, pSpecifiedLen); else if (pAtCodeStr.indexOf("@MSG_TO_EXT") > -1) - replacementTxt = (typeof pMsgHdr["to_ext"] === "undefined" ? "" : pMsgHdr["to_ext"].substr(0, pSpecifiedLen)); + replacementTxt = (typeof pMsgHdr.to_ext === "undefined" ? "" : pMsgHdr.to_ext.substr(0, pSpecifiedLen)); else if (pAtCodeStr.indexOf("@MSG_SUBJECT") > -1) - replacementTxt = pMsgHdr["subject"].substr(0, pSpecifiedLen); + replacementTxt = pMsgHdr.subject.substr(0, pSpecifiedLen); else if (pAtCodeStr.indexOf("@MSG_DATE") > -1) replacementTxt = pDateTimeStr.substr(0, pSpecifiedLen); else if (pAtCodeStr.indexOf("@MSG_ATTR") > -1) @@ -2819,24 +2821,24 @@ function ReplaceMsgAtCodeFormatStr(pMsgHdr, pSubBoardCode, pNumMsgs, pDisplayMsg replacementTxt = pMsgAllAttrStr.substr(0, pSpecifiedLen); else if (pAtCodeStr.indexOf("@MSG_NUM_AND_TOTAL") > -1) { - var messageNum = (typeof(pDisplayMsgNum) == "number" ? pDisplayMsgNum : pMsgHdr["offset"]+1); + var messageNum = (typeof(pDisplayMsgNum) == "number" ? pDisplayMsgNum : pMsgHdr.offset+1); replacementTxt = (messageNum.toString() + "/" + pNumMsgs).substr(0, pSpecifiedLen); // "number" is also absolute number } else if (pAtCodeStr.indexOf("@MSG_NUM") > -1) { - var messageNum = (typeof(pDisplayMsgNum) == "number" ? pDisplayMsgNum : pMsgHdr["offset"]+1); + var messageNum = (typeof(pDisplayMsgNum) == "number" ? pDisplayMsgNum : pMsgHdr.offset+1); replacementTxt = messageNum.toString().substr(0, pSpecifiedLen); // "number" is also absolute number } else if (pAtCodeStr.indexOf("@MSG_ID") > -1) - replacementTxt = (typeof pMsgHdr["id"] === "undefined" ? "" : pMsgHdr["id"].substr(0, pSpecifiedLen)); + replacementTxt = (typeof pMsgHdr.id === "undefined" ? "" : pMsgHdr.id.substr(0, pSpecifiedLen)); else if (pAtCodeStr.indexOf("@MSG_REPLY_ID") > -1) - replacementTxt = (typeof pMsgHdr["reply_id"] === "undefined" ? "" : pMsgHdr["reply_id"].substr(0, pSpecifiedLen)); + replacementTxt = (typeof pMsgHdr.reply_id === "undefined" ? "" : pMsgHdr.reply_id.substr(0, pSpecifiedLen)); else if (pAtCodeStr.indexOf("@MSG_TIMEZONE") > -1) { if (pUseBBSLocalTimeZone) replacementTxt = system.zonestr(system.timezone).substr(0, pSpecifiedLen); else - replacementTxt = system.zonestr(pMsgHdr["when_written_zone"]).substr(0, pSpecifiedLen); + replacementTxt = system.zonestr(pMsgHdr.when_written_zone).substr(0, pSpecifiedLen); } else if (pAtCodeStr.indexOf("@GRP") > -1) { @@ -3056,7 +3058,7 @@ function ParseMsgAtCodes(pTextLine, pMsgHdr, pSubBoardCode, pNumMsgs, pDisplayMs fileDirLong = file_area.lib_list[bbs.curlib].dir_list[bbs.curdir].description; } } - var messageNum = (typeof(pDisplayMsgNum) == "number" ? pDisplayMsgNum : pMsgHdr["offset"]+1); + var messageNum = (typeof(pDisplayMsgNum) == "number" ? pDisplayMsgNum : pMsgHdr.offset+1); var msgUpvotes = 0; var msgDownvotes = 0; var msgVoteScore = 0; @@ -3066,13 +3068,13 @@ function ParseMsgAtCodes(pTextLine, pMsgHdr, pSubBoardCode, pNumMsgs, pDisplayMs msgDownvotes = pMsgHdr.total_votes - pMsgHdr.upvotes; msgVoteScore = pMsgHdr.upvotes - msgDownvotes; } - var newTxtLine = textLine.replace(/@MSG_SUBJECT@/gi, pMsgHdr["subject"]) - .replace(/@MSG_FROM@/gi, pMsgHdr["from"]) - .replace(/@MSG_FROM_AND_FROM_NET@/gi, pMsgHdr["from"] + (typeof(pMsgHdr["from_net_addr"]) == "string" ? " (" + pMsgHdr["from_net_addr"] + ")" : "")) - .replace(/@MSG_FROM_EXT@/gi, (typeof(pMsgHdr["from_ext"]) == "string" ? pMsgHdr["from_ext"] : "")) - .replace(/@MSG_TO@/gi, pMsgHdr["to"]) - .replace(/@MSG_TO_NAME@/gi, pMsgHdr["to"]) - .replace(/@MSG_TO_EXT@/gi, (typeof(pMsgHdr["to_ext"]) == "string" ? pMsgHdr["to_ext"] : "")) + var newTxtLine = textLine.replace(/@MSG_SUBJECT@/gi, pMsgHdr.subject) + .replace(/@MSG_FROM@/gi, pMsgHdr.from) + .replace(/@MSG_FROM_AND_FROM_NET@/gi, pMsgHdr.from + (typeof(pMsgHdr.from_net_addr) == "string" ? " (" + pMsgHdr.from_net_addr + ")" : "")) + .replace(/@MSG_FROM_EXT@/gi, (typeof(pMsgHdr.from_ext) == "string" ? pMsgHdr.from_ext : "")) + .replace(/@MSG_TO@/gi, pMsgHdr.to) + .replace(/@MSG_TO_NAME@/gi, pMsgHdr.to) + .replace(/@MSG_TO_EXT@/gi, (typeof(pMsgHdr.to_ext) == "string" ? pMsgHdr.to_ext : "")) .replace(/@MSG_DATE@/gi, pDateTimeStr) .replace(/@MSG_ATTR@/gi, mainMsgAttrStr) .replace(/@MSG_AUXATTR@/gi, auxMsgAttrStr) @@ -3080,11 +3082,11 @@ function ParseMsgAtCodes(pTextLine, pMsgHdr, pSubBoardCode, pNumMsgs, pDisplayMs .replace(/@MSG_ALLATTR@/gi, allMsgAttrStr) .replace(/@MSG_NUM_AND_TOTAL@/gi, messageNum.toString() + "/" + pNumMsgs) .replace(/@MSG_NUM@/gi, messageNum.toString()) - .replace(/@MSG_ID@/gi, (typeof(pMsgHdr["id"]) == "string" ? pMsgHdr["id"] : "")) - .replace(/@MSG_REPLY_ID@/gi, (typeof(pMsgHdr["reply_id"]) == "string" ? pMsgHdr["reply_id"] : "")) - .replace(/@MSG_FROM_NET@/gi, (typeof(pMsgHdr["from_net_addr"]) == "string" ? pMsgHdr["from_net_addr"] : "")) - .replace(/@MSG_TO_NET@/gi, (typeof(pMsgHdr["to_net_addr"]) == "string" ? pMsgHdr["to_net_addr"] : "")) - .replace(/@MSG_TIMEZONE@/gi, (useBBSLocalTimeZone ? system.zonestr(system.timezone) : system.zonestr(pMsgHdr["when_written_zone"]))) + .replace(/@MSG_ID@/gi, (typeof(pMsgHdr.id) == "string" ? pMsgHdr.id : "")) + .replace(/@MSG_REPLY_ID@/gi, (typeof(pMsgHdr.reply_id) == "string" ? pMsgHdr.reply_id : "")) + .replace(/@MSG_FROM_NET@/gi, (typeof(pMsgHdr.from_net_addr) == "string" ? pMsgHdr.from_net_addr : "")) + .replace(/@MSG_TO_NET@/gi, (typeof(pMsgHdr.to_net_addr) == "string" ? pMsgHdr.to_net_addr : "")) + .replace(/@MSG_TIMEZONE@/gi, (useBBSLocalTimeZone ? system.zonestr(system.timezone) : system.zonestr(pMsgHdr.when_written_zone))) .replace(/@GRP@/gi, groupName) .replace(/@GRPL@/gi, groupDesc) .replace(/@SUB@/gi, subName) @@ -3250,9 +3252,9 @@ function MsgWrittenTimeToLocalBBSTime(pMsgHdr) // Inputs a keypress from the user and handles some ESC-based // characters such as PageUp, PageDown, and ESC. If PageUp // or PageDown are pressed, this function will return the -// string "\1PgUp" (KEY_PAGE_UP) or "\1Pgdn" (KEY_PAGE_DOWN), -// respectively. Also, F1-F5 will be returned as "\1F1" -// through "\1F5", respectively. +// string "\x01PgUp" (KEY_PAGE_UP) or "\x01Pgdn" (KEY_PAGE_DOWN), +// respectively. Also, F1-F5 will be returned as "\x01F1" +// through "\x01F5", respectively. // Thanks goes to Psi-Jack for the original impementation // of this function. // @@ -3272,32 +3274,33 @@ function GetKeyWithESCChars(pGetKeyMode) switch (console.inkey(K_NOECHO|K_NOSPIN, 2)) { case '[': switch (console.inkey(K_NOECHO|K_NOSPIN, 2)) { - case 'V': - userInput = KEY_PAGE_UP; - break; - case 'U': - userInput = KEY_PAGE_DOWN; - break; + case 'V': + userInput = KEY_PAGE_UP; + break; + case 'U': + userInput = KEY_PAGE_DOWN; + break; } break; case 'O': switch (console.inkey(K_NOECHO|K_NOSPIN, 2)) { - case 'P': - userInput = "\1F1"; - break; - case 'Q': - userInput = "\1F2"; - break; - case 'R': - userInput = "\1F3"; - break; - case 'S': - userInput = "\1F4"; - break; - case 't': - userInput = "\1F5"; - break; + case 'P': + userInput = "\x01F1"; + break; + case 'Q': + userInput = "\x01F2"; + break; + case 'R': + userInput = "\x01F3"; + break; + case 'S': + userInput = "\x01F4"; + break; + case 't': + userInput = "\x01F5"; + break; } + break; default: break; } @@ -3334,9 +3337,10 @@ function ScrollFrame(pFrame, pScrollbar, pTopLineIdx, pTxtAttrib, pWriteTxtLines if (topLineIdxForLastPage < 0) topLineIdxForLastPage = 0; - var retObj = new Object(); - retObj.lastKeypress = ""; - retObj.topLineIdx = pTopLineIdx; + var retObj = { + lastKeypress: "", + topLineIdx: pTopLineIdx + }; if (pTopLineIdx > 0) pFrame.scrollTo(0, pTopLineIdx); @@ -3451,15 +3455,10 @@ function ScrollFrame(pFrame, pScrollbar, pTopLineIdx, pTxtAttrib, pWriteTxtLines // pPromptText: The text to use to prompt the user // pClearToEOLAfterPrompt: Whether or not to clear to the end of the line after // writing the prompt text (boolean) -// pErrorPauseTimeMS: The time (in milliseconds) to pause after displaying the -// error that the message number is invalid -// pRepeat: Boolean - Whether or not to ask repeatedly until the user enters a -// valid message number. Optional; defaults to false. // // Return value: The message number entered by the user. If the user didn't // enter a message number, this will be 0. -function PromptForMsgNum(pMaxNum, pCurPos, pPromptText, pClearToEOLAfterPrompt, - pErrorPauseTimeMS, pRepeat) +function PromptForMsgNum(pMaxNum, pCurPos, pPromptText, pClearToEOLAfterPrompt) { var curPosValid = ((pCurPos != null) && (typeof(pCurPos) == "object") && pCurPos.hasOwnProperty("x") && (typeof(pCurPos.x) == "number") && @@ -3488,16 +3487,16 @@ function PromptForMsgNum(pMaxNum, pCurPos, pPromptText, pClearToEOLAfterPrompt, var clearLen = console.screen_columns - curPos.x + 1; if (curPos.y == console.screen_rows) --clearLen; - printf("\1n%" + clearLen + "s", ""); + printf("\x01n%" + clearLen + "s", ""); } else { if (lastErrorLen > promptTextLen) { - console.print("\1n"); + console.print("\x01n"); console.gotoxy(pCurPos.x+promptTextLen, pCurPos.y); var clearLen = lastErrorLen - promptTextLen; - printf("\1n%" + clearLen + "s", ""); + printf("\x01n%" + clearLen + "s", ""); } } console.gotoxy(pCurPos.x+promptTextLen, pCurPos.y); @@ -3720,13 +3719,12 @@ function DrawVoteColumns(pTopRow, pBottomRow, pColumnX1, pColumnX2) // Draw the columns var bottomRow = (typeof(pBottomRow) == "number" ? pBottomRow : gBottomBorderRow-1); retObj.colHeight = bottomRow - pTopRow + 1; - //for (var posY = pTopRow; posY < gBottomBorderRow; ++posY) for (var posY = pTopRow; posY <= bottomRow; ++posY) { console.gotoxy(retObj.columnX1, posY); - console.print("\1" + "7\1h\1w�\1n\1k\1" + "7\1n\1" + "7\1k\1h�\1n"); + console.print("\x01" + "7\x01h\x01w" + THIN_RECTANGLE_LEFT + "\x01n\x01k\x01" + "7\x01n\x01" + "7\x01k\x01h" + THIN_RECTANGLE_RIGHT + "\x01n"); console.gotoxy(retObj.columnX2, posY); - console.print("\1" + "7\1h\1w�\1n\1k\1" + "7\1n\1" + "7\1k\1h�\1n"); + console.print("\x01" + "7\x01h\x01w" + THIN_RECTANGLE_LEFT + "\x01n\x01k\x01" + "7\x01n\x01" + "7\x01k\x01h" + THIN_RECTANGLE_RIGHT + "\x01n"); } return retObj; @@ -3759,28 +3757,28 @@ function DisplayViewingResultsHelpScr(pMsgbase, pSubBoardCode) console.crlf(); console.crlf(); var subBoardGrpAndName = msg_area.sub[pSubBoardCode].grp_name + " - " + msg_area.sub[pSubBoardCode].name; - console.print("\1cCurrently viewing results in area \1g" + subBoardGrpAndName); + console.print("\x01cCurrently viewing results in area \x01g" + subBoardGrpAndName); console.crlf(); console.crlf(); console.print("Keys"); console.crlf(); - console.print("\1k\1h����"); + console.print("\x01k\x01h" + strRepeat(HORIZONTAL_SINGLE, 4)); console.crlf(); - var keyHelpLines = ["\1h\1cDown\1g/\1cup arrow \1g: \1n\1cScroll the text down\1g/\1cup", - "\1h\1cLeft\1g/\1cright arrow \1g: \1n\1cGo to the previous\1g/\1cnext poll", - "\1h\1cPageUp\1g/\1cPageDown \1g: \1n\1cScroll the text up\1g/\1cdown a page", - "\1h\1cHOME \1g: \1n\1cGo to the top of the text", - "\1h\1cEND \1g: \1n\1cGo to the bottom of the text", - "\1h\1cF \1g: \1n\1cGo to the first poll", - "\1h\1cL \1g: \1n\1cGo to the last poll"]; + var keyHelpLines = ["\x01h\x01cDown\x01g/\x01cup arrow \x01g: \x01n\x01cScroll the text down\x01g/\x01cup", + "\x01h\x01cLeft\x01g/\x01cright arrow \x01g: \x01n\x01cGo to the previous\x01g/\x01cnext poll", + "\x01h\x01cPageUp\x01g/\x01cPageDown \x01g: \x01n\x01cScroll the text up\x01g/\x01cdown a page", + "\x01h\x01cHOME \x01g: \x01n\x01cGo to the top of the text", + "\x01h\x01cEND \x01g: \x01n\x01cGo to the bottom of the text", + "\x01h\x01cF \x01g: \x01n\x01cGo to the first poll", + "\x01h\x01cL \x01g: \x01n\x01cGo to the last poll"]; if (gUserIsSysop) - keyHelpLines.push("\1h\1cDEL \1g: \1n\1cDelete the current poll"); + keyHelpLines.push("\x01h\x01cDEL \x01g: \x01n\x01cDelete the current poll"); else if (PollDeleteAllowed(pMsgbase, pSubBoardCode)) - keyHelpLines.push("\1h\1cDEL \1g: \1n\1cDelete the current poll (if it's yours)"); - keyHelpLines.push("\1h\1cQ \1g: \1n\1cQuit out of viewing poll results"); + keyHelpLines.push("\x01h\x01cDEL \x01g: \x01n\x01cDelete the current poll (if it's yours)"); + keyHelpLines.push("\x01h\x01cQ \x01g: \x01n\x01cQuit out of viewing poll results"); for (var idx = 0; idx < keyHelpLines.length; ++idx) { - console.print("\1n" + keyHelpLines[idx]); + console.print("\x01n" + keyHelpLines[idx]); console.crlf(); } console.pause(); @@ -3792,10 +3790,10 @@ function DisplayProgramNameAndVerForHelpScreens() var progName = "SlyVote"; var posX = (console.screen_columns/2) - (progName.length/2); console.gotoxy(posX, 1); - console.print("\1c\1h" + progName); + console.print("\x01c\x01h" + progName); console.gotoxy(posX, 2); - console.print("\1k�������"); - var versionText = "\1n\1cVersion \1g" + SLYVOTE_VERSION + "\1w\1h (\1b" + SLYVOTE_DATE + "\1w)\1n"; + console.print("\x01k" + strRepeat(HORIZONTAL_SINGLE, 7)); + var versionText = "\x01n\x01cVersion \x01g" + SLYVOTE_VERSION + "\x01w\x01h (\x01b" + SLYVOTE_DATE + "\x01w)\x01n"; posX = (console.screen_columns/2) - (strip_ctrl(versionText).length/2); console.gotoxy(posX, 3); console.print(versionText); @@ -3853,16 +3851,16 @@ function DisplayErrorWithPause(pErrorMsg, pMessageRow, pMnemonicsRequired) console.mnemonics(errorMessage); mswait(ERROR_PAUSE_WAIT_MS); console.gotoxy(1, pMessageRow); - //printf("\1n%" + console.screen_columns + "s", ""); - printf("\1n%" + errorMessage.length + "s", ""); + //printf("\x01n%" + console.screen_columns + "s", ""); + printf("\x01n%" + errorMessage.length + "s", ""); } else { - var errorMessage = "\1n" + pErrorMsg.substr(0, console.screen_columns); - console.print("\1n\1y\1h" + errorMessage); + var errorMessage = "\x01n" + pErrorMsg.substr(0, console.screen_columns); + console.print("\x01n\x01y\x01h" + errorMessage); mswait(ERROR_PAUSE_WAIT_MS); console.gotoxy(1, pMessageRow); - printf("\1n%" + errorMessage.length + "s", ""); + printf("\x01n%" + errorMessage.length + "s", ""); } } @@ -3876,14 +3874,14 @@ function ViewStats(pSubBoardCode) if (pollRetObj.errorMsg.length > 0) { console.gotoxy(1, gMessageRow); - console.print("\1n\1h\1y" + pollRetObj.errorMsg + "\1n"); + console.print("\x01n\x01h\x01y" + pollRetObj.errorMsg + "\x01n"); mswait(ERROR_PAUSE_WAIT_MS); return; } if (pollRetObj.msgHdrs.length == 0) { console.gotoxy(1, gMessageRow); - console.print("\1n\1r\1yThere are no polls in this area.\1n"); + console.print("\x01n\x01r\x01yThere are no polls in this area.\x01n"); mswait(ERROR_PAUSE_WAIT_MS); return; } @@ -3900,17 +3898,17 @@ function ViewStats(pSubBoardCode) // Create a text message with the poll stats to display in a scrollable // frame - var statsText = "\1n\1h\1bPoll area: \1c" + msg_area.sub[gSubBoardCode].grp_name + " - " + msg_area.sub[gSubBoardCode].name + "\1n\r\n"; - statsText += "\1w\1hPolls ranked by number of votes (highest to lowest):\1n\r\n\r\n"; - var labelColor = "\1w\1h"; + var statsText = "\x01n\x01h\x01bSub-board: \x01c" + msg_area.sub[gSubBoardCode].grp_name + " - " + msg_area.sub[gSubBoardCode].name + "\x01n\r\n"; + statsText += "\x01w\x01hPolls ranked by number of votes (highest to lowest):\x01n\r\n\r\n"; + var labelColor = "\x01w\x01h"; for (var i = 0; i < pollRetObj.msgHdrs.length; ++i) { - statsText += "\1n" + labelColor + "Poll " + +(i+1) + "/" + pollRetObj.msgHdrs.length + ": \1n\1g" + pollRetObj.msgHdrs[i].subject + "\r\n"; - statsText += "\1n" + labelColor + "By: \1n\1r\1h" + pollRetObj.msgHdrs[i].from + "\r\n"; - statsText += "\1n" + labelColor + "Date: \1n\1b\1h" + pollRetObj.msgHdrs[i].date + "\r\n"; - statsText += "\1n" + labelColor + "Number of votes: \1n\1m\1h" + pollRetObj.msgHdrs[i].total_votes + "\r\n"; + statsText += "\x01n" + labelColor + "Poll " + +(i+1) + "/" + pollRetObj.msgHdrs.length + ": \x01n\x01g" + pollRetObj.msgHdrs[i].subject + "\r\n"; + statsText += "\x01n" + labelColor + "By: \x01n\x01r\x01h" + pollRetObj.msgHdrs[i].from + "\r\n"; + statsText += "\x01n" + labelColor + "Date: \x01n\x01b\x01h" + pollRetObj.msgHdrs[i].date + "\r\n"; + statsText += "\x01n" + labelColor + "Number of votes: \x01n\x01m\x01h" + pollRetObj.msgHdrs[i].total_votes + "\r\n"; if ((pollRetObj.msgHdrs[i].auxattr & POLL_CLOSED) == POLL_CLOSED) - statsText += "\1n\1y\1hThis poll is closed for voting.\r\n"; + statsText += "\x01n\x01y\x01hThis poll is closed for voting.\r\n"; // Find the option(s) with the highest number(s) of votes var tallyIdx = 0; var answersAndNumVotes = []; @@ -3939,12 +3937,12 @@ function ViewStats(pSubBoardCode) else if (pA.numVotes > pB.numVotes) return -1; }); - statsText += "\1n" + labelColor + "Option(s) with highest number of votes:\1n\r\n"; + statsText += "\x01n" + labelColor + "Option(s) with highest number of votes:\x01n\r\n"; for (var answerI = 0; answerI < answersAndNumVotes.length; ++answerI) { if (answersAndNumVotes[answerI].numVotes == 0) continue; - statsText += "\1n\1b\1h" + answersAndNumVotes[answerI].answerText + "\1w: \1m" + answersAndNumVotes[answerI].numVotes + "\1n\r\n"; + statsText += "\x01n\x01b\x01h" + answersAndNumVotes[answerI].answerText + "\x01w: \x01m" + answersAndNumVotes[answerI].numVotes + "\x01n\r\n"; if (answerI > 0) { if (answersAndNumVotes[answerI].numVotes != answersAndNumVotes[answerI-1].numVotes) @@ -3957,15 +3955,15 @@ function ViewStats(pSubBoardCode) // Create a scrollable frame to display the stats in var frameAndScrollbar = createFrameWithScrollbar(1, 1, console.screen_columns, console.screen_rows - 1); // Put the stats text in the frame - frameAndScrollbar.frame.putmsg(statsText, "\1n"); + frameAndScrollbar.frame.putmsg(statsText, "\x01n"); frameAndScrollbar.frame.scrollTo(0, 0); // Create the key help line to be displayed at the bottom of the screen - var keyText = "\1rUp\1b, \1rDn\1b, \1rPgUp\1b/\1rDn\1b, \1rHome\1b, \1rEnd\1b, \1rQ\1m)\1buit"; - var keyHelpLine = "\1" + "7" + CenterText(keyText, console.screen_columns-1); + var keyText = "\x01rUp\x01b, \x01rDn\x01b, \x01rPgUp\x01b/\x01rDn\x01b, \x01rHome\x01b, \x01rEnd\x01b, \x01rESC\x01b/\x01rQ\x01m)\x01buit"; + var keyHelpLine = "\x01" + "7" + CenterText(keyText, console.screen_columns-1); // Prepare the screen and display the key help line on the last row of the screen - console.clear("\1n"); + console.clear("\x01n"); console.gotoxy(1, console.screen_rows); console.print(keyHelpLine); @@ -3984,8 +3982,8 @@ function ViewStats(pSubBoardCode) // Let the user scroll the message, and take appropriate action based // on the user input - var scrollRetObj = ScrollFrame(frameAndScrollbar.frame, frameAndScrollbar.scrollbar, 0, "\1n", false, 1, console.screen_rows); - if (scrollRetObj.lastKeypress == gReaderKeys.quit) + var scrollRetObj = ScrollFrame(frameAndScrollbar.frame, frameAndScrollbar.scrollbar, 0, "\x01n", false, 1, console.screen_rows); + if (scrollRetObj.lastKeypress == gReaderKeys.quit || scrollRetObj.lastKeypress == KEY_ESC) continueOn = false; } } @@ -4123,7 +4121,7 @@ function subBoardHasPolls(pSubBoardCode) { for (var i = msgbase.total_msgs-1; !pollsExistInSubBoard && (i >= 0); --i) { - var msgIndex = msgbase.get_msg_index(true, i) + var msgIndex = msgbase.get_msg_index(true, i); if ((msgIndex == null) || ((msgIndex.attr & MSG_DELETE) == MSG_DELETE)) continue; if ((msgIndex.attr & MSG_POLL) == MSG_POLL) @@ -4317,4 +4315,35 @@ function createFrameWithScrollbar(pX, pY, pWidth, pHeight) retObj.frame.scrollbars = true; retObj.scrollbar = new ScrollBar(retObj.frame, {bg: BG_BLACK, fg: LIGHTGRAY, orientation: "vertical", autohide: false}); return retObj; -} \ No newline at end of file +} + +// Returns a string repeated a number of times +// +// Parameters: +// pStr: The string to be repeated (string) +// pNumTimes: The number of times to repeat the string (number) +// +// Return value: The string, repeated the number of times given +function strRepeat(pStr, pNumTimes) +{ + if (typeof(pStr) !== "string" || typeof(pNumTimes) !== "number") + return ""; + if (pStr.length == 0 || pNumTimes < 1) + return ""; + + var repeatedStr = ""; + for (var i = 0; i < pNumTimes; ++i) + repeatedStr += pStr; + return repeatedStr; +} + +// When using text strings from text.dat, for some reason, strings that use attribute +// normal followed by high, which should be white, appear as high black. This function +// fixes that. +function processBBSTextDatText(pText) +{ + if (typeof(pText) !== "string") + return ""; + + return pText.replace(/\x01n\x01h/g, "\x01n\x01w\x01h"); +}