Skip to content
Snippets Groups Projects
Commit 4540ad04 authored by Eric Oulashin's avatar Eric Oulashin Committed by Rob Swindell
Browse files

DDMsgReader: Bug fix for going to a specific message in the message list...

parent e4b6cfaa
No related branches found
No related tags found
2 merge requests!463MRC mods by Codefenix (2024-10-20),!323DDMsgReader: Bug fix for going to a specific message in the message list...
...@@ -146,6 +146,8 @@ ...@@ -146,6 +146,8 @@
* optional. * optional.
* 2023-08-26 Eric Oulashin Version 1.77a * 2023-08-26 Eric Oulashin Version 1.77a
* When saving a message on the local BBS PC without all the headers, the date is now included * When saving a message on the local BBS PC without all the headers, the date is now included
* 2023-08-30 Eric Oulashin Version 1.78
* Bug fix for going to a specific message in the message list (especially for lightbar mode)
*/ */
   
"use strict"; "use strict";
...@@ -252,8 +254,8 @@ var ansiterm = require("ansiterm_lib.js", 'expand_ctrl_a'); ...@@ -252,8 +254,8 @@ var ansiterm = require("ansiterm_lib.js", 'expand_ctrl_a');
   
   
// Reader version information // Reader version information
var READER_VERSION = "1.77a"; var READER_VERSION = "1.78";
var READER_DATE = "2023-08-26"; var READER_DATE = "2023-08-30";
   
// 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);
...@@ -3466,7 +3468,7 @@ function DigDistMsgReader_ListMessages_Traditional(pAllowChgSubBoard) ...@@ -3466,7 +3468,7 @@ function DigDistMsgReader_ListMessages_Traditional(pAllowChgSubBoard)
var returnObj = this.EditExistingMsg(msgNum-1); var returnObj = this.EditExistingMsg(msgNum-1);
else else
{ {
console.print("\x01n\r\n\x01h\x01yThat message isn't editable.\n"); console.print("\x01n\r\n\x01h\x01yThat message isn't editable.\x01n");
console.crlf(); console.crlf();
console.pause(); console.pause();
} }
...@@ -3479,7 +3481,7 @@ function DigDistMsgReader_ListMessages_Traditional(pAllowChgSubBoard) ...@@ -3479,7 +3481,7 @@ function DigDistMsgReader_ListMessages_Traditional(pAllowChgSubBoard)
} }
} }
// G: Go to a specific message by # (place that message on the top) // G: Go to a specific message by # (place that message on the top)
else if (retvalObj.userInput == "G") else if (retvalObj.userInput == this.msgListKeys.goToMsg)
{ {
var msgNum = this.PromptForMsgNum(curpos, "\x01n" + replaceAtCodesInStr(this.text.goToMsgNumPromptText), false, ERROR_PAUSE_WAIT_MS, false); var msgNum = this.PromptForMsgNum(curpos, "\x01n" + replaceAtCodesInStr(this.text.goToMsgNumPromptText), false, ERROR_PAUSE_WAIT_MS, false);
if (msgNum > 0) if (msgNum > 0)
...@@ -3743,6 +3745,11 @@ function DigDistMsgReader_ListMessages_Lightbar(pAllowChgSubBoard) ...@@ -3743,6 +3745,11 @@ function DigDistMsgReader_ListMessages_Lightbar(pAllowChgSubBoard)
// Create a DDLightbarMenu for the message list and list messages // Create a DDLightbarMenu for the message list and list messages
// and let the user choose one // and let the user choose one
var msgListMenu = this.CreateLightbarMsgListMenu(); var msgListMenu = this.CreateLightbarMsgListMenu();
// numMessages & numMessagesPerPage are used with msgListMenu.CalcPageForItemAndSetTopItemIdx() when
// going to a specific message. They're optional, but it can be faster to get them just once instead of
// every time.
var numMessages = msgListMenu.NumItems();
var numMessagesPerPage = msgListMenu.GetNumItemsPerPage();
var msgHeader = null; var msgHeader = null;
var drawMenu = true; var drawMenu = true;
var continueOn = true; var continueOn = true;
...@@ -3948,7 +3955,7 @@ function DigDistMsgReader_ListMessages_Lightbar(pAllowChgSubBoard) ...@@ -3948,7 +3955,7 @@ function DigDistMsgReader_ListMessages_Lightbar(pAllowChgSubBoard)
else else
drawMenu = false; // No need to re-draw the menu drawMenu = false; // No need to re-draw the menu
} }
// G: Go to a specific message by # (highlight or place that message on the top) // G: Go to a specific message by # (highlight or place that message on the top, or in the page if can't put it on top)
else if (lastUserInputUpper == this.msgListKeys.goToMsg) else if (lastUserInputUpper == this.msgListKeys.goToMsg)
{ {
// Move the cursor to the bottom of the screen and // Move the cursor to the bottom of the screen and
...@@ -3974,6 +3981,7 @@ function DigDistMsgReader_ListMessages_Lightbar(pAllowChgSubBoard) ...@@ -3974,6 +3981,7 @@ function DigDistMsgReader_ListMessages_Lightbar(pAllowChgSubBoard)
{ {
this.lightbarListSelectedMsgIdx = chosenMsgIndex; this.lightbarListSelectedMsgIdx = chosenMsgIndex;
msgListMenu.selectedItemIdx = this.lightbarListSelectedMsgIdx; msgListMenu.selectedItemIdx = this.lightbarListSelectedMsgIdx;
msgListMenu.CalcPageForItemAndSetTopItemIdx(numMessagesPerPage, numMessages);
} }
else else
{ {
...@@ -9327,43 +9335,42 @@ function DigDistMsgReader_PromptForMsgNum(pCurPos, pPromptText, pClearToEOLAfter ...@@ -9327,43 +9335,42 @@ function DigDistMsgReader_PromptForMsgNum(pCurPos, pPromptText, pClearToEOLAfter
pCurPos.hasOwnProperty("y") && (typeof(pCurPos.y) == "number")); pCurPos.hasOwnProperty("y") && (typeof(pCurPos.y) == "number"));
var useCurPos = (console.term_supports(USER_ANSI) && curPosValid); var useCurPos = (console.term_supports(USER_ANSI) && curPosValid);
   
var msgNum = 0; var msgNum = 0;
var promptCount = 0; var promptCount = 0;
var lastErrorLen = 0; // The length of the last error message var lastErrorLen = 0; // The length of the last error message
var promptTextLen = console.strlen(pPromptText); var promptTextLen = console.strlen(pPromptText);
var continueAskingMsgNum = false; var continueAskingMsgNum = false;
do do
{ {
++promptCount; ++promptCount;
msgNum = 0; msgNum = 0;
if (promptTextLen > 0) if (promptTextLen > 0)
console.print(pPromptText); console.print(pPromptText);
if (pClearToEOLAfterPrompt && useCurPos) if (pClearToEOLAfterPrompt && useCurPos)
{ {
// The first time the user is being prompted, clear the line to the // The first time the user is being prompted, clear the line to the
// end of the line. For subsequent times, clear the line from the // end of the line. For subsequent times, clear the line from the
// prompt text length to the error text length; // prompt text length to the error text length;
if (promptCount == 1) if (promptCount == 1)
console.cleartoeol("\x01n"); console.cleartoeol("\x01n");
else else
{ {
if (lastErrorLen > promptTextLen) if (lastErrorLen > promptTextLen)
{ {
console.print("\x01n"); console.print("\x01n");
console.gotoxy(pCurPos.x+promptTextLen, pCurPos.y); console.gotoxy(pCurPos.x + promptTextLen, pCurPos.y);
var clearLen = lastErrorLen - promptTextLen; var clearLen = lastErrorLen - promptTextLen;
for (var counter = 0; counter < clearLen; ++counter) printf("%-*s", clearLen, "");
console.print(" "); }
} }
} console.gotoxy(pCurPos.x + promptTextLen, pCurPos.y);
console.gotoxy(pCurPos.x+promptTextLen, pCurPos.y); }
} msgNum = console.getnum(this.NumMessages()); // this.HighestMessageNum()
msgNum = console.getnum(this.HighestMessageNum()); // If the message number is invalid, then output an error message.
// If the message number is invalid, then output an error message. if (msgNum != 0)
if (msgNum != 0) {
{ if (!this.IsValidMessageNum(msgNum) && msgNum != -1) // msgNum would be -1 if the user pressed Q to quit
if (!this.IsValidMessageNum(msgNum)) {
{
// Output an error message that the message number is invalid // Output an error message that the message number is invalid
if (useCurPos) if (useCurPos)
{ {
...@@ -9373,8 +9380,8 @@ function DigDistMsgReader_PromptForMsgNum(pCurPos, pPromptText, pClearToEOLAfter ...@@ -9373,8 +9380,8 @@ function DigDistMsgReader_PromptForMsgNum(pCurPos, pPromptText, pClearToEOLAfter
// message number to read - I don't want this to clear the whole line // message number to read - I don't want this to clear the whole line
// because that would erase the scrollbar character on the right. // because that would erase the scrollbar character on the right.
writeWithPause(pCurPos.x, pCurPos.y, writeWithPause(pCurPos.x, pCurPos.y,
"\x01n" + replaceAtCodesInStr(format(this.text.invalidMsgNumText, msgNum)) + "\x01n", "\x01n" + replaceAtCodesInStr(format(this.text.invalidMsgNumText, msgNum)) + "\x01n",
pErrorPauseTimeMS, "\x01n", true); pErrorPauseTimeMS, "\x01n", true);
console.gotoxy(pCurPos); console.gotoxy(pCurPos);
} }
else else
...@@ -9387,17 +9394,16 @@ function DigDistMsgReader_PromptForMsgNum(pCurPos, pPromptText, pClearToEOLAfter ...@@ -9387,17 +9394,16 @@ function DigDistMsgReader_PromptForMsgNum(pCurPos, pPromptText, pClearToEOLAfter
// Set msgNum back to 0 to signify that the user didn't enter a (valid) // Set msgNum back to 0 to signify that the user didn't enter a (valid)
// message number. // message number.
msgNum = 0; msgNum = 0;
lastErrorLen = 24 + msgNum.toString().length; lastErrorLen = 24 + msgNum.toString().length;
continueAskingMsgNum = pRepeat; continueAskingMsgNum = pRepeat;
} }
else else
continueAskingMsgNum = false; continueAskingMsgNum = false;
} }
else else
continueAskingMsgNum = false; continueAskingMsgNum = false;
} } while (continueAskingMsgNum);
while (continueAskingMsgNum) return msgNum;
return msgNum;
} }
   
// For the DigDistMsgReader class: Looks for complex @-code strings in a text line and // For the DigDistMsgReader class: Looks for complex @-code strings in a text line and
......
Digital Distortion Message Reader Digital Distortion Message Reader
Version 1.77a Version 1.78
Release date: 2023-08-26 Release date: 2023-08-30
by by
......
...@@ -5,6 +5,8 @@ Revision History (change log) ...@@ -5,6 +5,8 @@ Revision History (change log)
============================= =============================
Version Date Description Version Date Description
------- ---- ----------- ------- ---- -----------
1.78 2023-08-30 Bug fix for going to a specific message in the message
list (especially for lightbar mode)
1.77a 2023-08-26 When saving a message on the local BBS PC without all the 1.77a 2023-08-26 When saving a message on the local BBS PC without all the
headers, the date is now included headers, the date is now included
1.77 2023-08-20 Including all message headers when saving a message (sysop 1.77 2023-08-20 Including all message headers when saving a message (sysop
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment