Skip to content
Snippets Groups Projects
Commit c44a665f authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Merge branch 'ddmsgreader_console_aborted_and_newscan_subboard_status' into 'master'

DDMsgReader: Makes use of console.aborted for proper screen updates after the user quits @ help screen pause. Shows sub-board status during a new message scan.

See merge request !266
parents 023352d4 1920f43a
No related branches found
No related tags found
2 merge requests!463MRC mods by Codefenix (2024-10-20),!266DDMsgReader: Makes use of console.aborted for proper screen updates after the user quits @ help screen pause. Shows sub-board status during a new message scan.
...@@ -103,6 +103,11 @@ ...@@ -103,6 +103,11 @@
* Now allows editing the subject when forwarding a message * Now allows editing the subject when forwarding a message
* 2023-03-09 Eric Oulashin Version 1.67 * 2023-03-09 Eric Oulashin Version 1.67
* Fixes for time zone alignment & list key help for wide terminals * Fixes for time zone alignment & list key help for wide terminals
* 2023-03-15 Eric Oulashin Version 1.68
* Makes use of console.aborted when displaying help screens
* so that screen updates work better after pausing output.
* Also, when running a new message scan (not new-to-you), the current
* sub-board being scanned is now outputted.
*/ */
   
"use strict"; "use strict";
...@@ -208,8 +213,8 @@ var ansiterm = require("ansiterm_lib.js", 'expand_ctrl_a'); ...@@ -208,8 +213,8 @@ var ansiterm = require("ansiterm_lib.js", 'expand_ctrl_a');
   
   
// Reader version information // Reader version information
var READER_VERSION = "1.67"; var READER_VERSION = "1.68";
var READER_DATE = "2023-03-09"; var READER_DATE = "2023-03-15";
   
// Keyboard key codes for displaying on the screen // Keyboard key codes for displaying on the screen
var UP_ARROW = ascii(24); var UP_ARROW = ascii(24);
...@@ -1186,7 +1191,8 @@ function DigDistMsgReader(pSubBoardCode, pScriptArgs) ...@@ -1186,7 +1191,8 @@ function DigDistMsgReader(pSubBoardCode, pScriptArgs)
   
// this.tabReplacementText will be the text that tabs will be replaced // this.tabReplacementText will be the text that tabs will be replaced
// with in enhanced reader mode // with in enhanced reader mode
this.tabReplacementText = format("%" + this.numTabSpaces + "s", ""); //this.tabReplacementText = format("%" + this.numTabSpaces + "s", "");
this.tabReplacementText = format("%*s", this.numTabSpaces, "");
   
// Calculate the message list widths and format strings based on the current // Calculate the message list widths and format strings based on the current
// sub-board code and color settings. Start with a message # field length // sub-board code and color settings. Start with a message # field length
...@@ -1279,7 +1285,7 @@ function DigDistMsgReader(pSubBoardCode, pScriptArgs) ...@@ -1279,7 +1285,7 @@ function DigDistMsgReader(pSubBoardCode, pScriptArgs)
//hdrLine6 += "@\x01n\x01c" + VERTICAL_SINGLE; //hdrLine6 += "@\x01n\x01c" + VERTICAL_SINGLE;
hdrLine6 += "@ @MSG_TIMEZONE@\x01n"; hdrLine6 += "@ @MSG_TIMEZONE@\x01n";
numChars = console.screen_columns - 42; numChars = console.screen_columns - 42;
hdrLine6 += format("%" + numChars + "s", ""); hdrLine6 += format("%*s", numChars, ""); // More correct than format("%" + numChars + "s", "");
hdrLine6 += "\x01n\x01c" + VERTICAL_SINGLE; hdrLine6 += "\x01n\x01c" + VERTICAL_SINGLE;
this.enhMsgHeaderLines.push(hdrLine6); this.enhMsgHeaderLines.push(hdrLine6);
this.enhMsgHeaderLinesToReadingUser.push(hdrLine6); this.enhMsgHeaderLinesToReadingUser.push(hdrLine6);
...@@ -2222,14 +2228,7 @@ function DigDistMsgReader_PopulateHdrsIfSearch_DispErrorIfNoMsgs(pCloseMsgbaseAn ...@@ -2222,14 +2228,7 @@ function DigDistMsgReader_PopulateHdrsIfSearch_DispErrorIfNoMsgs(pCloseMsgbaseAn
formattedText = format(this.text.loadingPersonalMailText, subBoardGrpAndName(this.subBoardCode)); formattedText = format(this.text.loadingPersonalMailText, subBoardGrpAndName(this.subBoardCode));
else else
formattedText = format(this.text.searchingSubBoardText, subBoardGrpAndName(this.subBoardCode)); formattedText = format(this.text.searchingSubBoardText, subBoardGrpAndName(this.subBoardCode));
formattedText = replaceAtCodesInStr(formattedText); formattedText = replaceAtCodesAndRemoveCRLFs(formattedText);
formattedText = word_wrap(formattedText, console.screen_columns-1, formattedText.length, false).replace(/\r|\n/g, "\r\n");
while (formattedText.lastIndexOf("\r\n") == formattedText.length-2)
formattedText = formattedText.substr(0, formattedText.length-2);
while (formattedText.lastIndexOf("\r") == formattedText.length-1)
formattedText = formattedText.substr(0, formattedText.length-1);
while (formattedText.lastIndexOf("\n") == formattedText.length-1)
formattedText = formattedText.substr(0, formattedText.length-1);
console.print("\x01n" + formattedText + "\x01n"); console.print("\x01n" + formattedText + "\x01n");
} }
var readingMailUserNum = user.is_sysop ? this.personalMailUserNum : user.number; var readingMailUserNum = user.is_sysop ? this.personalMailUserNum : user.number;
...@@ -2358,7 +2357,7 @@ function DigDistMsgReader_MessageAreaScan(pScanCfgOpt, pScanMode, pScanScopeChar ...@@ -2358,7 +2357,7 @@ function DigDistMsgReader_MessageAreaScan(pScanCfgOpt, pScanMode, pScanScopeChar
{ {
// Prompt the user to scan in the current sub-board, the current message group, // Prompt the user to scan in the current sub-board, the current message group,
// or all. Default to all. // or all. Default to all.
console.print("\x01n"); console.attributes = "N";
console.mnemonics(bbs.text(SubGroupOrAll)); console.mnemonics(bbs.text(SubGroupOrAll));
scanScopeChar = console.getkeys("SGAC").toString(); scanScopeChar = console.getkeys("SGAC").toString();
// If the user just pressed Enter without choosing anything, then abort and return. // If the user just pressed Enter without choosing anything, then abort and return.
...@@ -2445,6 +2444,15 @@ function DigDistMsgReader_MessageAreaScan(pScanCfgOpt, pScanMode, pScanScopeChar ...@@ -2445,6 +2444,15 @@ function DigDistMsgReader_MessageAreaScan(pScanCfgOpt, pScanMode, pScanScopeChar
this.setSubBoardCode(subBoardsToScan[subCodeIdx]); // Needs to be set before getting the last read/scan pointer index this.setSubBoardCode(subBoardsToScan[subCodeIdx]); // Needs to be set before getting the last read/scan pointer index
if (msg_area.sub[this.subBoardCode].can_read && ((msg_area.sub[this.subBoardCode].scan_cfg & pScanCfgOpt) == pScanCfgOpt)) if (msg_area.sub[this.subBoardCode].can_read && ((msg_area.sub[this.subBoardCode].scan_cfg & pScanCfgOpt) == pScanCfgOpt))
{ {
// If running a new message scan (not new-to-you), output which sub-board that is currently being scanned
if (pScanCfgOpt == SCAN_CFG_NEW && pScanMode == SCAN_NEW)
{
var statusText = format(this.text.searchingSubBoardText, subBoardGrpAndName(this.subBoardCode));
console.print("\x01n" + replaceAtCodesAndRemoveCRLFs(statusText) + "\x01n");
console.crlf();
console.line_counter = 0; // Prevent pausing for screen output and when displaying a message
}
var grpIndex = msg_area.sub[this.subBoardCode].grp_index; var grpIndex = msg_area.sub[this.subBoardCode].grp_index;
var subIndex = msg_area.sub[this.subBoardCode].index; var subIndex = msg_area.sub[this.subBoardCode].index;
// Sub-board description: msg_area.grp_list[grpIndex].sub_list[subIndex].description // Sub-board description: msg_area.grp_list[grpIndex].sub_list[subIndex].description
...@@ -7659,8 +7667,10 @@ function DigDistMsgReader_DisplayMsgListHelp(pChgSubBoardAllowed, pPauseAtEnd) ...@@ -7659,8 +7667,10 @@ function DigDistMsgReader_DisplayMsgListHelp(pChgSubBoardAllowed, pPauseAtEnd)
   
// If pPauseAtEnd is true, then output a newline and // If pPauseAtEnd is true, then output a newline and
// prompt the user whether or not to continue. // prompt the user whether or not to continue.
if (pPauseAtEnd) if (pPauseAtEnd && !console.aborted)
console.pause(); console.pause();
console.aborted = false;
} }
// For the DigDistMsgReader Class: Displays help for the traditional-interface // For the DigDistMsgReader Class: Displays help for the traditional-interface
// message list // message list
...@@ -7758,8 +7768,11 @@ function DigDistMsgReader_DisplayTraditionalMsgListHelp(pDisplayHeader, pChgSubB ...@@ -7758,8 +7768,11 @@ function DigDistMsgReader_DisplayTraditionalMsgListHelp(pDisplayHeader, pChgSubB
   
// If pPauseAtEnd is true, then output a newline and // If pPauseAtEnd is true, then output a newline and
// prompt the user whether or not to continue. // prompt the user whether or not to continue.
if (pPauseAtEnd) if (pPauseAtEnd && !console.aborted)
console.pause(); console.pause();
// Don't set this here - This is only ever called by DisplayMsgListHelp()
//console.aborted = false;
} }
// For the DigDistMsgReader Class: Displays help for the lightbar message list // For the DigDistMsgReader Class: Displays help for the lightbar message list
// //
...@@ -7849,8 +7862,11 @@ function DigDistMsgReader_DisplayLightbarMsgListHelp(pDisplayHeader, pChgSubBoar ...@@ -7849,8 +7862,11 @@ function DigDistMsgReader_DisplayLightbarMsgListHelp(pDisplayHeader, pChgSubBoar
console.print("\x01n\x01h\x01c?" + this.colors["tradInterfaceHelpScreenColor"] + ": Show this help screen\r\n"); console.print("\x01n\x01h\x01c?" + this.colors["tradInterfaceHelpScreenColor"] + ": Show this help screen\r\n");
   
// If pPauseAtEnd is true, then pause. // If pPauseAtEnd is true, then pause.
if (pPauseAtEnd) if (pPauseAtEnd && !console.aborted)
console.pause(); console.pause();
// Don't set this here - This is only ever called by DisplayMsgListHelp()
//console.aborted = false;
} }
// For the DigDistMsgReader class: Displays the message list notes for the // For the DigDistMsgReader class: Displays the message list notes for the
// help screens. // help screens.
...@@ -8092,7 +8108,8 @@ function DigDistMsgReader_SetEnhancedReaderHelpLine() ...@@ -8092,7 +8108,8 @@ function DigDistMsgReader_SetEnhancedReaderHelpLine()
var helpLineScreenLen = (console.strlen(this.enhReadHelpLine) - numHotkeyChars); var helpLineScreenLen = (console.strlen(this.enhReadHelpLine) - numHotkeyChars);
var numCharsRemaining = console.screen_columns - helpLineScreenLen - 1; var numCharsRemaining = console.screen_columns - helpLineScreenLen - 1;
var frontPaddingLen = Math.floor(numCharsRemaining/2); var frontPaddingLen = Math.floor(numCharsRemaining/2);
var padding = format("%" + frontPaddingLen + "s", ""); //var padding = format("%" + frontPaddingLen + "s", "");
var padding = format("%*s", frontPaddingLen, "");
this.enhReadHelpLine = padding + this.enhReadHelpLine; this.enhReadHelpLine = padding + this.enhReadHelpLine;
this.enhReadHelpLine = "\x01n" + this.colors.enhReaderHelpLineBkgColor + this.enhReadHelpLine; this.enhReadHelpLine = "\x01n" + this.colors.enhReaderHelpLineBkgColor + this.enhReadHelpLine;
if (console.screen_columns > 80) if (console.screen_columns > 80)
...@@ -8104,7 +8121,10 @@ function DigDistMsgReader_SetEnhancedReaderHelpLine() ...@@ -8104,7 +8121,10 @@ function DigDistMsgReader_SetEnhancedReaderHelpLine()
// Adding 3 as a correction factor for wide terminals (this is a kludge) // Adding 3 as a correction factor for wide terminals (this is a kludge)
numCharsRemaining = console.screen_columns - helpLineScreenLen + 3; numCharsRemaining = console.screen_columns - helpLineScreenLen + 3;
if (numCharsRemaining > 0) if (numCharsRemaining > 0)
this.enhReadHelpLine += format("%" + numCharsRemaining + "s", ""); {
//this.enhReadHelpLine += format("%" + numCharsRemaining + "s", "");
this.enhReadHelpLine += format("%*s", numCharsRemaining, "");
}
} }
   
// Create a version without the change area option // Create a version without the change area option
...@@ -8151,7 +8171,8 @@ function DigDistMsgReader_SetEnhancedReaderHelpLine() ...@@ -8151,7 +8171,8 @@ function DigDistMsgReader_SetEnhancedReaderHelpLine()
if (numCharsRemaining > 0) if (numCharsRemaining > 0)
{ {
frontPaddingLen = Math.floor(numCharsRemaining/2); frontPaddingLen = Math.floor(numCharsRemaining/2);
padding = format("%" + frontPaddingLen + "s", ""); //padding = format("%" + frontPaddingLen + "s", "");
padding = format("%*s", frontPaddingLen, "");
this.enhReadHelpLineWithoutChgArea = padding + this.enhReadHelpLineWithoutChgArea; this.enhReadHelpLineWithoutChgArea = padding + this.enhReadHelpLineWithoutChgArea;
} }
this.enhReadHelpLineWithoutChgArea = "\x01n" + this.colors.enhReaderHelpLineBkgColor + this.enhReadHelpLineWithoutChgArea; this.enhReadHelpLineWithoutChgArea = "\x01n" + this.colors.enhReaderHelpLineBkgColor + this.enhReadHelpLineWithoutChgArea;
...@@ -8161,7 +8182,10 @@ function DigDistMsgReader_SetEnhancedReaderHelpLine() ...@@ -8161,7 +8182,10 @@ function DigDistMsgReader_SetEnhancedReaderHelpLine()
// Adding 3 as a correction factor for wide terminals (this is a kludge) // Adding 3 as a correction factor for wide terminals (this is a kludge)
numCharsRemaining = console.screen_columns - helpLineScreenLen + 3; numCharsRemaining = console.screen_columns - helpLineScreenLen + 3;
if (numCharsRemaining > 0) if (numCharsRemaining > 0)
this.enhReadHelpLineWithoutChgArea += format("%" + numCharsRemaining + "s", ""); {
//this.enhReadHelpLineWithoutChgArea += format("%" + numCharsRemaining + "s", "");
this.enhReadHelpLineWithoutChgArea += format("%*s", numCharsRemaining, "");
}
} }
} }
function stripCtrlFromEnhReadHelpLine_ReplaceArrowChars(pHelpLine) function stripCtrlFromEnhReadHelpLine_ReplaceArrowChars(pHelpLine)
...@@ -10417,6 +10441,8 @@ function DigDistMsgReader_DisplayEnhancedReaderHelp(pDisplayChgAreaOpt, pDisplay ...@@ -10417,6 +10441,8 @@ function DigDistMsgReader_DisplayEnhancedReaderHelp(pDisplayChgAreaOpt, pDisplay
// I'm not sure the above is needed anymore. Should be able to use // I'm not sure the above is needed anymore. Should be able to use
// console.pause(), which easily supports custom pause scripts being loaded. // console.pause(), which easily supports custom pause scripts being loaded.
console.pause(); console.pause();
console.aborted = false;
} }
   
// For the DigDistMsgReader class: Displays the enhanced reader mode message // For the DigDistMsgReader class: Displays the enhanced reader mode message
...@@ -13096,7 +13122,7 @@ function DigDistMsgReader_FindThreadNextOffset(pMsgHdr, pThreadType, pPositionCu ...@@ -13096,7 +13122,7 @@ function DigDistMsgReader_FindThreadNextOffset(pMsgHdr, pThreadType, pPositionCu
{ {
// Look for the next message with the same thread ID. // Look for the next message with the same thread ID.
// Write "Searching.." in case searching takes a while. // Write "Searching.." in case searching takes a while.
console.print("\x01n"); console.attributes = "N";
if (pPositionCursorForStatus) if (pPositionCursorForStatus)
{ {
console.gotoxy(1, console.screen_rows); console.gotoxy(1, console.screen_rows);
...@@ -13192,7 +13218,7 @@ function DigDistMsgReader_FindThreadNextOffset(pMsgHdr, pThreadType, pPositionCu ...@@ -13192,7 +13218,7 @@ function DigDistMsgReader_FindThreadNextOffset(pMsgHdr, pThreadType, pPositionCu
   
// Perform the search // Perform the search
// Write "Searching.." in case searching takes a while. // Write "Searching.." in case searching takes a while.
console.print("\x01n"); console.attributes = "N";
if (pPositionCursorForStatus) if (pPositionCursorForStatus)
{ {
console.gotoxy(1, console.screen_rows); console.gotoxy(1, console.screen_rows);
...@@ -13287,7 +13313,7 @@ function DigDistMsgReader_FindThreadPrevOffset(pMsgHdr, pThreadType, pPositionCu ...@@ -13287,7 +13313,7 @@ function DigDistMsgReader_FindThreadPrevOffset(pMsgHdr, pThreadType, pPositionCu
{ {
// Look for the previous message with the same thread ID. // Look for the previous message with the same thread ID.
// Write "Searching.." in case searching takes a while. // Write "Searching.." in case searching takes a while.
console.print("\x01n"); console.attributes = "N";
if (pPositionCursorForStatus) if (pPositionCursorForStatus)
{ {
console.gotoxy(1, console.screen_rows); console.gotoxy(1, console.screen_rows);
...@@ -13362,7 +13388,7 @@ function DigDistMsgReader_FindThreadPrevOffset(pMsgHdr, pThreadType, pPositionCu ...@@ -13362,7 +13388,7 @@ function DigDistMsgReader_FindThreadPrevOffset(pMsgHdr, pThreadType, pPositionCu
// Synchronet, so I'm not sure of the minimum version where // Synchronet, so I'm not sure of the minimum version where
// this will work. // this will work.
// Write "Searching.." in case searching takes a while. // Write "Searching.." in case searching takes a while.
console.print("\x01n"); console.attributes = "N";
if (pPositionCursorForStatus) if (pPositionCursorForStatus)
{ {
console.gotoxy(1, console.screen_rows); console.gotoxy(1, console.screen_rows);
...@@ -13436,7 +13462,7 @@ function DigDistMsgReader_FindThreadPrevOffset(pMsgHdr, pThreadType, pPositionCu ...@@ -13436,7 +13462,7 @@ function DigDistMsgReader_FindThreadPrevOffset(pMsgHdr, pThreadType, pPositionCu
   
// Perform the search // Perform the search
// Write "Searching.." in case searching takes a while. // Write "Searching.." in case searching takes a while.
console.print("\x01n"); console.attributes = "N";
if (pPositionCursorForStatus) if (pPositionCursorForStatus)
{ {
console.gotoxy(1, console.screen_rows); console.gotoxy(1, console.screen_rows);
...@@ -15531,7 +15557,8 @@ function DigDistMsgReader_RefreshMsgAreaRectangle(pTxtLines, pTopLineIdx, pTopLe ...@@ -15531,7 +15557,8 @@ function DigDistMsgReader_RefreshMsgAreaRectangle(pTxtLines, pTopLineIdx, pTopLe
if (printableTxtLen < pWidth) if (printableTxtLen < pWidth)
{ {
var lenDiff = pWidth - printableTxtLen; var lenDiff = pWidth - printableTxtLen;
lineText += format("\x01n%" + lenDiff + "s", ""); //lineText += format("\x01n%" + lenDiff + "s", "");
lineText += format("\x01n%*s", lenDiff, "");
} }
console.print(lineText); console.print(lineText);
} }
...@@ -20547,6 +20574,30 @@ function attrCodeStr(pAttrCodeCharStr) ...@@ -20547,6 +20574,30 @@ function attrCodeStr(pAttrCodeCharStr)
return str; return str;
} }
   
// Replaces @-codes in a string and removes any newlines and carriage returns from the end
// of the string
//
// Parameters:
// pText: The text to modify
//
// Return value: The text with @-codes replaced and newlines & carriage returns removed
// from the end of the text
function replaceAtCodesAndRemoveCRLFs(pText)
{
if (typeof(pText) !== "string")
return "";
var formattedText = replaceAtCodesInStr(pText);
formattedText = word_wrap(formattedText, console.screen_columns-1, formattedText.length, false).replace(/\r|\n/g, "\r\n");
while (formattedText.lastIndexOf("\r\n") == formattedText.length-2)
formattedText = formattedText.substr(0, formattedText.length-2);
while (formattedText.lastIndexOf("\r") == formattedText.length-1)
formattedText = formattedText.substr(0, formattedText.length-1);
while (formattedText.lastIndexOf("\n") == formattedText.length-1)
formattedText = formattedText.substr(0, formattedText.length-1);
return formattedText;
}
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
   
// For debugging: Writes some text on the screen at a given location with a given pause. // For debugging: Writes some text on the screen at a given location with a given pause.
......
Digital Distortion Message Reader Digital Distortion Message Reader
Version 1.67 Version 1.68
Release date: 2023-03-09 Release date: 2023-03-15
by by
...@@ -176,7 +176,7 @@ Digital Distortion Message Reader is comprised of the following files: ...@@ -176,7 +176,7 @@ Digital Distortion Message Reader is comprised of the following files:
4. ddmr_lm.js Loadable module script for setup in SCFG (only needed 4. ddmr_lm.js Loadable module script for setup in SCFG (only needed
for Synchronet 3.19 and earlier, or Synchronet built for Synchronet 3.19 and earlier, or Synchronet built
before 2023-02-20) before 2023-02-20)
The configuration files are plain text files, so they can be edited using any The configuration files are plain text files, so they can be edited using any
editor. editor.
......
...@@ -5,6 +5,10 @@ Revision History (change log) ...@@ -5,6 +5,10 @@ Revision History (change log)
============================= =============================
Version Date Description Version Date Description
------- ---- ----------- ------- ---- -----------
1.68 2023-03-15 Makes use of console.aborted when displaying help screens
so that screen updates work better after pausing output.
Also, when running a new message scan (not new-to-you),
the current sub-board being scanned is now outputted.
1.67 2023-03-09 Fixes for time zone alignment & list key help for wide 1.67 2023-03-09 Fixes for time zone alignment & list key help for wide
terminals terminals
1.66 2023-03-02 When forwarding a message, the subject can now be edited 1.66 2023-03-02 When forwarding a message, the subject can now be edited
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment