//////////////////////////////////////////////////////////////////////// // Helper function to check, if text contains only white space // characters or empty // sText - string to be checked // result - true, if text, contains only white space function isWhiteText(sText) { var bWhiteSpace = true; for (var i = 0; i < sText.length && bWhiteSpace; ++i) { var c = sText.charAt(i); bWhiteSpace = c == " " || c == "\t"; } return bWhiteSpace; } //////////////////////////////////////////////////////////////////////// // Helper function to check if line contain only white space // doc - document object // nLine - line index to be checked // result - true, if line, contains only white space function isEmptyLine(doc, nLine) { return isWhiteText(doc.GetLine(nLine)); } //////////////////////////////////////////////////////////////////////// // Often, selection ends up in 0 char of next line, // when we want to work only with lines above // but algorithms do not know that, so we help them by // correcting bottom bound of the range // doc - document object // selRange - range to be adjusted function AdjustSelection(doc, selRange) { if ( selRange.Height > 0 && selRange.Right == 0) doc.MovePositionLine(selRange.end, -1); return selRange; }