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

void org::gjt::sp::jedit::textarea::TextArea::deleteLine (  )  [inline]

Deletes the line containing the caret.

Since:
jEdit 2.7pre2

Definition at line 3479 of file TextArea.java.

References org::gjt::sp::jedit::buffer::JEditBuffer::beginCompoundEdit(), end(), org::gjt::sp::jedit::buffer::JEditBuffer::endCompoundEdit(), org::gjt::sp::jedit::textarea::DisplayManager::getLastVisibleLine(), org::gjt::sp::jedit::buffer::JEditBuffer::getLength(), getLineEndOffset(), org::gjt::sp::jedit::buffer::JEditBuffer::getLineStartOffset(), getLineStartOffset(), getSelectedLines(), org::gjt::sp::jedit::buffer::JEditBuffer::isEditable(), org::gjt::sp::jedit::buffer::JEditBuffer::remove(), setCaretPosition(), org::gjt::sp::jedit::textarea::ChunkCache::subregionOffsetToX(), and org::gjt::sp::jedit::textarea::ChunkCache::xToSubregionOffset().

      {
            if(!buffer.isEditable())
            {
                  getToolkit().beep();
                  return;
            }

            int x = chunkCache.subregionOffsetToX(caretLine,caret - getLineStartOffset(caretLine));
            int[] lines = getSelectedLines();

            try
            {
                  buffer.beginCompoundEdit();

                  for (int i = lines.length - 1; i >= 0; i--)
                  {
                        int start = getLineStartOffset(lines[i]);
                        int end = getLineEndOffset(lines[i]);
                        if (end > buffer.getLength())
                        {
                              if (start != 0)
                                    start--;
                              end--;
                        }
                        buffer.remove(start,end - start);
                  }
            }
            finally
            {
                  buffer.endCompoundEdit();
            }

            int lastLine = displayManager.getLastVisibleLine();

            if(caretLine == lastLine)
            {
                  int offset = chunkCache.xToSubregionOffset(lastLine,0,x,true);
                  setCaretPosition(buffer.getLineStartOffset(lastLine)
                  + offset);
            }
            else
            {
                  int offset = chunkCache.xToSubregionOffset(caretLine,0,x,true);
                  setCaretPosition(getLineStartOffset(caretLine) + offset);
            }
      } //}}}


Generated by  Doxygen 1.6.0   Back to index