Make line comment command act as a toggle.
Submitted by Sunday, 27 June, 2004 - 09:24
on
I modified the JEditTextArea.lineComment method to insert a comment at the very beginning of the selected line(s) if the line(s) didn't already begin with a comment. The comment is removed if it is already there. This allows the "line comment" command to act as a toggle - commenting out uncommented lines, uncommenting lines already commented.
Would this be a useful feature?
Code from JEditTextArea.java (JEdit 4.1 final), beginning at line 4119:
String text = getLineText(lines[i]);
// Toggle comments at beginning of line, add if not there, remove if there.
if (text.startsWith(comment)) {
buffer.remove(getLineStartOffset(lines[i]), comment.length());
}
else {
buffer.insert(getLineStartOffset(lines[i]), comment);
}
// buffer.insert(getLineStartOffset(lines[i]),
// + MiscUtilities.getLeadingWhiteSpace(text),
// comment);
Would this be a useful feature?
Code from JEditTextArea.java (JEdit 4.1 final), beginning at line 4119:
String text = getLineText(lines[i]);
// Toggle comments at beginning of line, add if not there, remove if there.
if (text.startsWith(comment)) {
buffer.remove(getLineStartOffset(lines[i]), comment.length());
}
else {
buffer.insert(getLineStartOffset(lines[i]), comment);
}
// buffer.insert(getLineStartOffset(lines[i]),
// + MiscUtilities.getLeadingWhiteSpace(text),
// comment);