diff --git a/exec/SlyEdit.js b/exec/SlyEdit.js index 2d7600a32c8abdb5c8f282b852a1b6865e3a6028..b5e54e5a502ca98aadfee80b44a56d1db00e6acc 100644 --- a/exec/SlyEdit.js +++ b/exec/SlyEdit.js @@ -80,6 +80,19 @@ * offline readers etc. * 2019-08-09 Eric Oulashin Version 1.68 * Releasing this version + * 2019-08-14 Eric Oulashin Version 1.69 + * Updated to only use console.inkey() for user input + * and not use console.getkey() anymore. + * The change was made in the getUserKey() function + * in SlyEdit_Misc.js. + * Also, SlyEdit will now write the editor style + * (ICE or DCT) to result.ed at the end when a message + * is saved. Also, when editing a message, if the cursor + * is at the end of the last line and the user presses + * the DEL key, then treat it as a backspace. Some + * terminals send a delete for backspace, particularly + * with keyboards that have a delete key but no backspace + * key. */ /* Command-line arguments: @@ -176,8 +189,8 @@ if (console.screen_columns < 80) } // Constants -const EDITOR_VERSION = "1.68"; -const EDITOR_VER_DATE = "2019-08-09"; +const EDITOR_VERSION = "1.69"; +const EDITOR_VER_DATE = "2019-08-14"; // Program variables @@ -615,7 +628,7 @@ if ((exitCode == 0) && (gEditLines.length > 0)) { dropFile.writeln("0"); dropFile.writeln(gMsgSubj); - dropFile.writeln(EDITOR_PROGRAM_NAME + " " + EDITOR_VERSION + " (" + EDITOR_VER_DATE + ")"); + dropFile.writeln(EDITOR_PROGRAM_NAME + " " + EDITOR_VERSION + " (" + EDITOR_VER_DATE + ") (" + EDITOR_STYLE + " style)"); dropFile.close(); } @@ -1042,6 +1055,15 @@ function doEditLoop() while (continueOn) { userInput = getKeyWithESCChars(K_NOCRLF|K_NOSPIN, 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 + // terminals send a delete for backspace, particularly with + // keyboards that have a delete key but no backspace key. + var atEndOfLastLine = ((gEditLinesIndex == gEditLines.length - 1) && (gTextLineIndex == gEditLines[gEditLinesIndex].text.length)); + if (atEndOfLastLine && (userInput == KEY_DEL)) + userInput = BACKSPACE; + if (!bbs.online) { var logStr = EDITOR_PROGRAM_NAME + ": User is no longer online (" + user.alias + " on node " + bbs.node_num + ")"; @@ -1068,7 +1090,7 @@ function doEditLoop() // If gEditLines currently has 1 less line than we need, // then add a new line to gEditLines. if (gEditLines.length == gEditLinesIndex) - gEditLines.push(new TextLine()); + gEditLines.push(new TextLine()); // Take the appropriate action for the key pressed. switch (userInput) diff --git a/exec/SlyEdit_Misc.js b/exec/SlyEdit_Misc.js index 3db88151b08797b1aa2911b8bda65d9ea88699e3..c6be665c2ffe6674f3849628b96cc0e2ee5d5d48 100644 --- a/exec/SlyEdit_Misc.js +++ b/exec/SlyEdit_Misc.js @@ -3895,33 +3895,27 @@ function firstLetterIsUppercase(pString) // or console.inkey()). function getUserKey(pMode, pCfgObj) { - var defaultTimeoutMS = 300000; - var userKey = ""; + var userKey = ""; + var inputTimeoutMS = 300000; - if (typeof(pCfgObj) == "object") - { - // If the user is a sysop, don't use an input timeout. - if ((typeof(pCfgObj.userIsSysop) == "boolean") && pCfgObj.userIsSysop) - userKey = console.getkey(pMode); - else if (typeof(pCfgObj.userInputTimeout) == "number") - userKey = console.inkey(pMode, pCfgObj.inputTimeoutMS); - else - userKey = console.inkey(pMode, defaultTimeoutMS); - } - else if (typeof(pCfgObj) == "boolean") - { - // pCfgObj is a boolean that specifies whether or not the user is a sysop. - // If so, then use console.getkey(). If the user isn't a sysop, use a - // timeout of 5 minutes. - if (pCfgObj) - userKey = console.getkey(pMode); - else - userKey = console.inkey(pMode, defaultTimeoutMS); - } - else // pCfgObj is not a known type, so use the default input timeout. - userKey = console.inkey(pMode, defaultTimeoutMS); + // If the user is a sysop, then use a much higher timeout. + if (typeof(pCfgObj) == "object") + { + if ((typeof(pCfgObj.userIsSysop) == "boolean") && pCfgObj.userIsSysop) + inputTimeoutMS = 999999; + else if (typeof(pCfgObj.userInputTimeout) == "number") + inputTimeoutMS = pCfgObj.inputTimeoutMS; + } + else if (typeof(pCfgObj) == "boolean") + { + if (pCfgObj) + inputTimeoutMS = 999999; + } + + // Input a key from the user + userKey = console.inkey(pMode, inputTimeoutMS); - return userKey; + return userKey; } // Gets a string of user input such that each character is validated against a @@ -5017,7 +5011,7 @@ function displayDebugText(pDebugX, pDebugY, pText, pOriginalPos, pClearDebugLine { console.gotoxy(pDebugX, pDebugY); if (pClearDebugLineFirst) - console.clearline(); + console.clearline(); // Output the text console.print(pText); if (pPauseAfter)