diff --git a/docs/slyedit_readme.txt b/docs/slyedit_readme.txt index 31bb222db7a96b89c097c8711c50d866f3cd2d39..672486496aefeb8ae767c5e47b87530b9a1e6a90 100644 --- a/docs/slyedit_readme.txt +++ b/docs/slyedit_readme.txt @@ -1,6 +1,6 @@ SlyEdit message editor Version 1.86 - Release date: 2023-07-26 + Release date: 2023-08-15 by diff --git a/exec/SlyEdit.js b/exec/SlyEdit.js index 301b7231d42d1d5aa9b6426fe9167d4c8ee6d5d6..0303c11f7da9c212644d877827ccd5b624bcb48b 100644 --- a/exec/SlyEdit.js +++ b/exec/SlyEdit.js @@ -39,6 +39,8 @@ * various messages. * 2023-07-26 Eric Oulashin Version 1.86 * Releasing this version + * 2023-08-15 Eric Oulashin Version 1.87 + * Improvement to paragraph/line breaks in quote line wrapping */ "use strict"; @@ -136,8 +138,8 @@ if (console.screen_columns < 80) } // Version information -var EDITOR_VERSION = "1.86"; -var EDITOR_VER_DATE = "2023-07-26"; +var EDITOR_VERSION = "1.87"; +var EDITOR_VER_DATE = "2023-08-15"; // Program variables diff --git a/exec/SlyEdit_Misc.js b/exec/SlyEdit_Misc.js index 3e39b1783c550c719f643592c83f0ab60e263d22..1ab7a3f35c68b1699805cc6788e10cdd3e14782b 100644 --- a/exec/SlyEdit_Misc.js +++ b/exec/SlyEdit_Misc.js @@ -2903,10 +2903,28 @@ function wrapTextLinesForQuoting(pTextLines, pQuotePrefix, pIndentQuoteLines, pT if (!nextLineIsBlank) nextLineIsOriginOrTearLine = msgLineIsTearLineOrOriginLine(nextLineTrimmed); } + // Get the length of the current line (if it needs wrapping, then wrap it & get the + // length of the last line after wrapping), so that if that length is short, we might + // put a CRLF at the end to signify the end of the paragraph/section + var lineLength = 0; + var currentLineScreenLen = console.strlen(pTextLines[textLineIdx]); + if (currentLineScreenLen < console.screen_columns - 1) + lineLength = currentLineScreenLen; + else + { + var currentLine = pTextLines[textLineIdx]; + if (trimSpacesFromQuoteLines) + currentLine = currentLine.trim(); + var paragraphLines = lfexpand(word_wrap(currentLine, console.screen_columns-1, null, true)).split("\r\n"); + paragraphLines.pop(); // There will be an extra empty line at the end; remove it + lineLength = console.strlen(paragraphLines[paragraphLines.length-1]); + } + // Put a CRLF at the end in certain conditions if (nextLineIsOriginOrTearLine) sectionText += "\r\n"; // Append a CRLF if the line isn't blank and its length is less than 85% of the user's terminal width - else if (numLinesInSection > 1 && !nextLineIsBlank && console.strlen(pTextLines[textLineIdx]) < Math.floor(console.screen_columns * 0.85)) + //else if (numLinesInSection > 1 && !nextLineIsBlank && console.strlen(pTextLines[textLineIdx]) < Math.floor(console.screen_columns * 0.85)) + else if (numLinesInSection > 1 && !nextLineIsBlank && lineLength < Math.floor(console.screen_columns * 0.85)) sectionText += "\r\n"; else if (nextLineIsBlank) sectionText += "\r\n";