<http://forum.pspad.com/read.php?f=2&i=12129&t=12082>
----------------------------------------------------------------
Hi, Ricky,
Thanks. I agree (Ctrl+Shift+A) is very convenient.
I don't know jscript. Is your code self-containing? If I save the code as
\Script\JScript\AA.js, how to use them under pspad?
Am I right to add another "else if" for a new language, say Fortran?
var ed = curEditor();// hand made function to insert in your script
var ext = getFileExtension( ed.FileName()); // hand made function to
insert in your script
var selText = ed.selText();
if ( selText == "") {
if ( ext == "js") {
ed.CaretX( 1);
ed.lineText( "//" + ed.lineText());
} else if ( ext == "xml" || ext == "xsl") {
ed.CaretX( 1);
ed.lineText( "<!-- " + ed.lineText() + " -->");
}
// Set comment for Fortran
else if ( ext == "f" || ext == "f90") {
ed.CaretX( 1);
ed.lineText( "! " + ed.lineText());
}
} else {
selLines = selText.split( "\n");
selText = "";
if ( ext == "js") {
for ( i=0; i<selLines.length; i++)
if ( selLines[ i] != "") selText = selText + "//" + elLines[ i];
ed.selText( selText);
} else if ( ext == "xml" || ext == "xsl") {
selText = "<!-- \n";
for ( i=0; i<selLines.length; i++)
if ( selLines[ i] != "") selText = selText + selLines[ i];
ed.selText( selText + "\n -->\n");
}
// Set comment for Fortran
else if (ext == "f" || ext == "f90"){
for ( i=0; i<selLines.length; i++)
if ( selLines[ i] != "") selText = selText + "!" + elLines[ i];
ed.selText( selText);
}
}
--
PSPad freeware editor http://www.pspad.com