Commit aa1d4280 authored by Eric Oulashin's avatar Eric Oulashin
Browse files

SlyEdit Version 1.78: Removed high-ascii characters from the SlyEdit JS files;...

SlyEdit Version 1.78: 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.
parent f184b682
Pipeline #3104 passed with stage
in 10 minutes and 9 seconds
......@@ -146,6 +146,10 @@
* Fixed a few instances where SlyEdit was trying to access
* sub-board information with an empty sub-board code (in the rare
* case when no sub-boards are configured).
* 2022-06-09 Eric Oulashin Version 1.78
* 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.
*/
/* Command-line arguments:
......@@ -242,8 +246,8 @@ if (console.screen_columns < 80)
}
// Constants
const EDITOR_VERSION = "1.77";
const EDITOR_VER_DATE = "2022-05-27";
const EDITOR_VERSION = "1.78";
const EDITOR_VER_DATE = "2022-06-09";
// Program variables
......@@ -481,6 +485,8 @@ var gTextLineIndex = 0; // Index into the current text line being edited
// Format strings used for printf() to display text in the edit area
const gFormatStr = "%-" + gEditWidth + "s";
const gFormatStrWithAttr = "%s%-" + gEditWidth + "s";
// Will contain valid word characters, for spell checking
var gValidWordChars = "";
// Whether or not a message file was uploaded (if so, then SlyEdit won't
// do the line re-wrapping at the end before saving the message).
......@@ -4150,6 +4156,7 @@ function doSpellCheck(pCurpos, pConfirmSpellcheck)
return retObj;
}
// Helper for doSpellCheck(): Checks a word from an array of words (split from an edit line)
// and inputs a correction from the user if needed.
//
......@@ -4185,9 +4192,9 @@ function spellCheckWordInLine(pDictionaries, pEditLineIdx, pWordArray, pWordIdx,
// Ensure the word to test is all lowercase for case-insensitive matching
var currentWord = pWordArray[pWordIdx].toLowerCase();
// Ensure the word we're checking only has letters and/or an apostrophe.
var currentWord = currentWord.replace(/^[^a-zA-ZÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜáíóúñÑß']*([a-zA-ZÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜáíóúñÑß']+)[^a-zA-ZÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜáíóúñÑß']*$/, "$1");
// Now, ensure the word only certain characters: Letters, apostrophe. Skip it if not.
if (!/^[a-zA-ZÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜáíóúñÑß']+$/g.test(currentWord))
var currentWord = removeNonWordCharsFromStr(currentWord);
// Now, ensure the word has only certain characters: Letters, apostrophe. Skip it if not.
if (!strIsAllWordChars(currentWord))
{
retObj.skipped = true;
return retObj;
......@@ -4273,6 +4280,73 @@ function spellCheckWordInLine(pDictionaries, pEditLineIdx, pWordArray, pWordIdx,
return retObj;
}
// Helper for spellCheckWordInLine(): Returns whether a string contains only word characters
// (letters
function strIsAllWordChars(pStr)
{
if (typeof(pStr) !== "string" || pStr.length == 0)
return false;
if (gValidWordChars.length == 0)
gValidWordChars = getStrOfWordChars();
var onlyWordCharsFound = true;
for (var i = 0; i < pStr.length && onlyWordCharsFound; ++i)
onlyWordCharsFound = (gValidWordChars.indexOf(pStr.charAt(i)) > -1);
return onlyWordCharsFound;
}
// Helper for spellCheckWordInLine(): Removes non-word characters from a string
function removeNonWordCharsFromStr(pStr)
{
if (typeof(pStr) !== "string" || pStr.length == 0)
return "";
if (gValidWordChars.length == 0)
gValidWordChars = getStrOfWordChars();
var filteredStr = pStr;
var continueOn = true;
while (continueOn)
{
var startIdx = -1;
var endIdx = -1;
for (var i = 0; i < filteredStr.length; ++i)
{
if (gValidWordChars.indexOf(filteredStr.charAt(i)) == -1)
{
if (startIdx == -1)
startIdx = i;
else
endIdx = i;
break;
}
}
if (startIdx > -1 && endIdx >= startIdx)
filteredStr = filteredStr.substring(0, startIdx) + filteredStr.substring(endIdx+1);
else if (startIdx > -1 && endIdx == -1)
filteredStr = filteredStr.substring(0, startIdx) + filteredStr.substring(startIdx+1);
else if (startIdx == -1 && endIdx == -1)
continueOn = false;
}
return filteredStr;
}
// Builds & returns a string of valid word characters
function getStrOfWordChars()
{
// First valid character is an apostrophe
var validChars = "'";
// a-z
for (var i = 97; i <= 122; ++i)
validChars += ascii(i);
// A-Z
for (var i = 65; i <= 90; ++i)
validChars += ascii(i);
var validCharsRegexStr = "^[a-zA-Z";
var additionalASCIIVals = [129,154,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,147,148,149,150,151,152,153,160,161,162,163,164,165,225];
for (var i = 0; i < additionalASCIIVals.length; ++i)
validChars += ascii(additionalASCIIVals[i]);
return validChars;
}
// Helper for doSpellCheck(): Displays a text area on the screen with a misspelled
// word in the title of the box and a text input to correct it
//
......@@ -4488,7 +4562,7 @@ function doColorSelection(pTxtAttrs, pCurpos, pCurrentWordLength)
console.cleartoeol("\1n");
console.crlf();
console.clearline("\1n");
console.print("\1cSpecial: \1w\1hH:\1n\1hHigh Intensity \1wI:\1n\1iBlinking \1n\1w\1hN:\1nNormal \1h\1gþ \1n\1cChoose colors/attributes\1h\1g: \1c");
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");
// 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).
......
......@@ -62,47 +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 = "";
var HORIZONTAL_SINGLE = "";
var UPPER_RIGHT_SINGLE = "";
var VERTICAL_SINGLE = "";
var LOWER_LEFT_SINGLE = "";
var LOWER_RIGHT_SINGLE = "";
var T_SINGLE = "";
var LEFT_T_SINGLE = "";
var RIGHT_T_SINGLE = "";
var BOTTOM_T_SINGLE = "";
var CROSS_SINGLE = "";
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);
// Box-drawing/border characters: Double-line
var UPPER_LEFT_DOUBLE = "";
var HORIZONTAL_DOUBLE = "";
var UPPER_RIGHT_DOUBLE = "";
var VERTICAL_DOUBLE = "";
var LOWER_LEFT_DOUBLE = "";
var LOWER_RIGHT_DOUBLE = "";
var T_DOUBLE = "";
var LEFT_T_DOUBLE = "";
var RIGHT_T_DOUBLE = "";
var BOTTOM_T_DOUBLE = "";
var CROSS_DOUBLE = "";
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);
// Box-drawing/border characters: Vertical single-line with horizontal double-line
var UPPER_LEFT_VSINGLE_HDOUBLE = "";
var UPPER_RIGHT_VSINGLE_HDOUBLE = "";
var LOWER_LEFT_VSINGLE_HDOUBLE = "";
var LOWER_RIGHT_VSINGLE_HDOUBLE = "";
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);
// Other special characters
var DOT_CHAR = "";
var CHECK_CHAR = "";
var THIN_RECTANGLE_LEFT = "";
var THIN_RECTANGLE_RIGHT = "";
var BLOCK1 = ""; // Dimmest block
var BLOCK2 = "";
var BLOCK3 = "";
var BLOCK4 = ""; // Brightest block
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
// Navigational keys
var UP_ARROW = "";
var DOWN_ARROW = "";
var UP_ARROW = ascii(24);
var DOWN_ARROW = ascii(25);
// CTRL keys
var CTRL_A = "\x01";
var CTRL_B = "\x02";
......@@ -1379,7 +1380,7 @@ function displayCommandList(pDisplayHeader, pClear, pPause, pCanCrossPost, pIsSy
// 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", "", "");
printf("\1k\1h%-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);
......@@ -1393,7 +1394,7 @@ function displayCommandList(pDisplayHeader, pClear, pPause, pCanCrossPost, pIsSy
printf(" \1c\1h%-7s\1g \1n\1c%s", "", "", "/?", "Show help");
console.crlf();
// Command/edit keys
console.print("\1n\1gCommand/edit keys\r\n\1k\1h\r\n");
console.print("\1n\1gCommand/edit keys\r\n\1k\1h" + 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);
......@@ -1414,6 +1415,23 @@ function displayCommandList(pDisplayHeader, pClear, pPause, pCanCrossPost, pIsSy
if (pPause)
console.pause();
}
// Returns a string with a character repeated a given number of times
//
// Parameters:
// pChar: The character to repeat in the string
// pNumTimes: The number of times to repeat the character
//
// Return value: A string with the given character repeated the given number of times
function charStr(pChar, pNumTimes)
{
if (typeof(pChar) !== "string" || pChar.length == 0 || typeof(pNumTimes) !== "number" || pNumTimes < 1)
return "";
var str = "";
for (var i = 0; i < pNumTimes; ++i)
str += pChar;
return str;
}
// Displays the general help screen.
//
......@@ -1469,26 +1487,14 @@ function displayProgramInfo(pClear, pPause)
function displayProgramExitInfo(pClearScreen)
{
if (pClearScreen)
console.clear("n");
/*console.print("ncYou have been using:\r\n");
console.print("hk70\r\n");
console.print("7 nb7 hk0\r\n");
console.print("7 nb7 hk0\r\n");
console.print("7 nb7 hk0\r\n");
console.print("7 nb7 hk0\r\n");
console.print("7 nb7 hk0\r\n");
console.print("7 nb7 hk0\r\n");
console.print("\r\n");
console.print("ngVersion hy" + EDITOR_VERSION + " nm(" +
EDITOR_VER_DATE + ")");*/
console.print("ncYou have been using hSlyEdit ncversion g" + EDITOR_VERSION +
" nm(" + EDITOR_VER_DATE + ")");
console.clear("\1n");
console.print("\1n\1cYou have been using \1hSlyEdit \1n\1cversion \1g" + EDITOR_VERSION + " \1n\1m(" + EDITOR_VER_DATE + ")");
console.crlf();
console.print("ncby Eric Oulashin of chDncigital hDncistortion hBncBS");
console.print("\1n\1cby Eric Oulashin of \1c\1hD\1n\1cigital \1hD\1n\1cistortion \1hB\1n\1cBS");
console.crlf();
console.crlf();
console.print("ncAcknowledgements for look & feel go to the following people:");
console.print("\1n\1cAcknowledgements for look & feel go to the following people:");
console.crlf();
console.print("Dan Traczynski: Creator of DCT Edit");
console.crlf();
......@@ -1507,13 +1513,13 @@ function displayProgramExitInfo(pClearScreen)
// If not specified, defaults to normal attribute.
function writeWithPause(pX, pY, pText, pPauseMS, pClearLineAttrib)
{
var clearLineAttrib = "n";
if ((pClearLineAttrib != null) && (typeof(pClearLineAttrib) == "string"))
clearLineAttrib = pClearLineAttrib;
console.gotoxy(pX, pY);
console.cleartoeol(clearLineAttrib);
console.print(pText);
mswait(pPauseMS);
var clearLineAttrib = "\1n";
if ((pClearLineAttrib != null) && (typeof(pClearLineAttrib) == "string"))
clearLineAttrib = pClearLineAttrib;
console.gotoxy(pX, pY);
console.cleartoeol(clearLineAttrib);
console.print(pText);
mswait(pPauseMS);
}
// Prompts the user for a yes/no question.
......@@ -3828,7 +3834,17 @@ function moveGenColorsToGenSettings(pColorsArray, pCfgObj)
// Return value: Boolean - Whether or not the character is a letter
function charIsLetter(pChar)
{
return /^[ABCDEFGHIJKLMNOPQRSTUVWXYZ]$/.test(pChar.toUpperCase());
if (typeof(charIsLetter.regex) === "undefined")
{
var regexStr = "^[A-Z";
var highASCIICodes = [192, 200, 204, 210, 217, 224, 232, 236, 242, 249, 193, 201, 205, 211, 218, 221, 225, 233, 237, 243, 250, 253, 194, 202, 206, 212, 219, 226, 234, 238, 244, 251, 195, 209, 213, 227, 241, 245, 196, 203, 207, 214, 220, 228, 235, 239, 246, 252, 231, 199, 223, 216, 248, 197, 229, 198, 230, 222, 254, 208, 240];
for (var i = 0; i < highASCIICodes.length; ++i)
regexStr += ascii(highASCIICodes[i]);
regexStr += "]$";
charIsLetter.regex = new RegExp(regexStr);
}
return charIsLetter.regex.test(pChar.toUpperCase());
}
// For configuration files, this function returns a fully-pathed filename.
......@@ -4692,14 +4708,16 @@ function getLanguageNameFromDictFilename(pFilenameFullPath)
isSupplemental = true;
languageNameLower = languageNameLower.substr(0, 5);
}
var lower_n_tilde = ascii(164);
var lower_e_forward_accent = ascii(130);
if (languageNameLower == "en")
languageName = "English (General)";
else if (languageNameLower == "fr")
languageName = "French (General)";
else if (languageNameLower == "es")
languageName = "Espa" + ascii(164) + "ol (General)";
languageName = "Espa" + lower_n_tilde + "ol (General)";
else if (languageNameLower == "pt")
languageName = "Portug" + ascii(130) + "s (General)";
languageName = "Portug" + lower_e_forward_accent + "s (General)";
else if (languageNameLower == "de")
languageName = "Deutsch (General)";
else if (languageNameLower == "nl")
......@@ -4745,19 +4763,19 @@ function getLanguageNameFromDictFilename(pFilenameFullPath)
else if (languageNameLower == "it-it")
languageName = "Italian (Italy)";
else if (languageNameLower == "pt-pt")
languageName = "Portug" + ascii(130) + "s (Portugal)";
languageName = "Portug" + lower_e_forward_accent + "s (Portugal)";
else if (languageNameLower == "pt-br")
languageName = "Portug" + ascii(130) + "s (BR)";
languageName = "Portug" + lower_e_forward_accent + "s (BR)";
else if (languageNameLower == "es-es")
languageName = "Espa" + ascii(164) + "ol (Espaa)";
languageName = "Espa" + lower_n_tilde + "ol (Espa" + lower_n_tilde + "a)";
else if (languageNameLower == "es-co")
languageName = "Espa" + ascii(164) + "ol (CO)";
languageName = "Espa" + lower_n_tilde + "ol (CO)";
else if (languageNameLower == "es-cl")
languageName = "Espa" + ascii(164) + "ol (CL)";
languageName = "Espa" + lower_n_tilde + "ol (CL)";
else if (languageNameLower == "es-us")
languageName = "Espa" + ascii(164) + "ol (US)";
languageName = "Espa" + lower_n_tilde + "ol (US)";
else if (languageNameLower == "es-005")
languageName = "Espa" + ascii(164) + "ol (South America)";
languageName = "Espa" + lower_n_tilde + "ol (South America)";
else if (languageNameLower == "zh-cn")
languageName = "Chinese (China)";
else if (languageNameLower == "zh-tw")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment