/* */
line of code
line of code
/* */
and here it is commented out:
Thanks to Rickard and crafty GetSelection() function we can now learn selection coordinates, which allowed me to write this little script:/* * /
line of code
line of code
/* */
Code: Select all
// turn off screen updating
Document.BeginUpdate();
// turn word-wrap off
if (Document.Wordwrap) {
Document.Wordwrap = false;
}
// make sure variables are integers
var startX = 0, startY = 0, endX = 0, endY = 0;
var temp = 0, docLastY = 0; last = false;
// find selection's coordinates
Document.GetSelection(startX, startY, endX, endY);
// if selection was made upwards, switch startY and endY
if (startY > endY) {
temp = startY;
startY = endY;
endY = temp;
}
// find if selection ends at the last line of the document
Document.CursorDocEnd(false);
docLastY = Document.CursorY();
if (endY == docLastY) {
last = true;
Document.InsertText("\n");
}
// add upper marks
Document.CursorY() = startY;
Document.CursorX() = 0;
Document.InsertText("/* */\n");
// add lower marks
Document.CursorY() = endY + 2;
Document.CursorX() = 0;
if (last) {
Document.InsertText("/* */");
} else {
Document.InsertText("/* */\n");
}
// move cursor to the upper marks
Document.CursorY() = startY;
Document.CursorX() = 4;
// turn on screen updating
Document.EndUpdate();
(I put the code on-line, as addition to the zipfile, since attachments on the forum get lost after some time and you can't download them anymore
