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

void org::gjt::sp::jedit::textarea::TextArea::addExplicitFold (  )  throws TextAreaException [inline]

Surrounds the selection with explicit fold markers.

Exceptions:
TextAreaException an exception thrown if the folding mode is not explicit
Since:
jEdit 4.0pre3

Reimplemented in org::gjt::sp::jedit::textarea::JEditTextArea.

Definition at line 3980 of file TextArea.java.

References org::gjt::sp::jedit::buffer::JEditBuffer::beginCompoundEdit(), org::gjt::sp::jedit::textarea::Selection::end, org::gjt::sp::jedit::buffer::JEditBuffer::endCompoundEdit(), org::gjt::sp::jedit::textarea::Selection::endLine, getSelection(), getSelectionCount(), org::gjt::sp::jedit::buffer::JEditBuffer::getStringProperty(), org::gjt::sp::jedit::buffer::JEditBuffer::isEditable(), setCaretPosition(), org::gjt::sp::jedit::textarea::Selection::start, and org::gjt::sp::jedit::textarea::Selection::startLine.

      {
            if(!buffer.isEditable())
            {
                  getToolkit().beep();
                  return;
            }
            if(!buffer.getStringProperty("folding").equals("explicit"))
            {
                  throw new TextAreaException("folding-not-explicit");
            }

            try
            {
                  buffer.beginCompoundEdit();

                  if (getSelectionCount() == 0)
                  {
                        addExplicitFold(caret, caret, caretLine, caretLine);
                  }
                  else
                  {
                        Selection[] selections = getSelection();
                        Selection selection = null;
                        int caretBack = 0;
                        for (int i = 0; i < selections.length; i++)
                        {
                              selection = selections[i];
                              caretBack = addExplicitFold(selection.start, selection.end, selection.startLine,selection.endLine);
                        }
                        // Selection cannot be null because there is at least 1 selection
                        assert selection != null;
                        setCaretPosition(selection.start - caretBack, false);
                  }
            }
            finally
            {
                  buffer.endCompoundEdit();
            }
      } //}}}


Generated by  Doxygen 1.6.0   Back to index