Logo Search packages:      
Sourcecode: jedit version File versions  Download package

void org::gjt::sp::jedit::textarea::TextArea::rangeLineComment (  )  [inline, private]

This method will surround each selected line with a range comment. This is used when calling line comment if the edit mode doesn't have a line comment property

Since:
jEdit 4.3pre10

Definition at line 5925 of file TextArea.java.

References org::gjt::sp::jedit::buffer::JEditBuffer::beginCompoundEdit(), org::gjt::sp::jedit::buffer::JEditBuffer::endCompoundEdit(), org::gjt::sp::jedit::buffer::JEditBuffer::getContextSensitiveProperty(), getLineEndOffset(), getLineStartOffset(), getLineText(), getSelectedLines(), org::gjt::sp::jedit::buffer::JEditBuffer::insert(), and org::gjt::sp::jedit::buffer::JEditBuffer::isEditable().

Referenced by lineComment().

      {
            String commentStart = buffer.getContextSensitiveProperty(caret,"commentStart");
            String commentEnd = buffer.getContextSensitiveProperty(caret,"commentEnd");
            if(!buffer.isEditable() || commentStart == null || commentEnd == null
                  || commentStart.length() == 0 || commentEnd.length() == 0)
            {
                  getToolkit().beep();
                  return;
            }

            commentStart += ' ';
            commentEnd = ' ' + commentEnd;


            try
            {
                  buffer.beginCompoundEdit();
                  int[] lines = getSelectedLines();
                  for(int i = 0; i < lines.length; i++)
                  {
                        String text = getLineText(lines[i]);
                        if (text.trim().length() == 0)
                              continue;
                        buffer.insert(getLineEndOffset(lines[i]) - 1,
                              commentEnd);
                        buffer.insert(getLineStartOffset(lines[i])
                              + StandardUtilities.getLeadingWhiteSpace(text),
                              commentStart);
                  }
            }
            finally
            {
                  buffer.endCompoundEdit();
            }
      } //}}}


Generated by  Doxygen 1.6.0   Back to index