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

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

Joins the current and the next line, or joins all lines in selections.

Since:
jEdit 2.7pre2

Definition at line 4481 of file TextArea.java.

References org::gjt::sp::jedit::buffer::JEditBuffer::beginCompoundEdit(), end(), org::gjt::sp::jedit::buffer::JEditBuffer::endCompoundEdit(), org::gjt::sp::jedit::buffer::JEditBuffer::getLength(), getLineEndOffset(), org::gjt::sp::jedit::buffer::JEditBuffer::isEditable(), joinLineAt(), moveCaretPosition(), multi, and selectNone().

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

            try
            {
                  buffer.beginCompoundEdit();
                  boolean doneForSelection = false;
                  for (Selection selection: selectionManager.getSelection())
                  {
                        while (selection.startLine < selection.endLine)
                        {
                              // Edit from end of selection to
                              // minimize invalidations and
                              // recaluculations of cached line info
                              // such as indent level or fold level.
                              joinLineAt(selection.endLine - 1);
                              doneForSelection = true;
                        }
                  }
                  // If nothing selected or all selections span only
                  // one line, join the line at the caret.
                  if (!doneForSelection)
                  {
                        int end = getLineEndOffset(caretLine);

                        // Nothing to do if the caret is on the last line.
                        if (end > buffer.getLength())
                        {
                              getToolkit().beep();
                              return;
                        }

                        joinLineAt(caretLine);
                        if(!multi)
                              selectNone();
                        moveCaretPosition(end - 1);
                  }
            }
            finally
            {
                  buffer.endCompoundEdit();
            }
      } //}}}


Generated by  Doxygen 1.6.0   Back to index