Package jsyntaxpane

Examples of jsyntaxpane.SyntaxDocument


                        try {
                            String selectedText = getSelectedText();
                            if (selectedText == null) {
                                return;
                            }
                            SyntaxDocument pythonDoc = (SyntaxDocument) doc;
                            // now check if the corresponding line, import exist
                            int lineIndex = yToLine(e.getY());
                            int startIndex = pythonDoc.getDefaultRootElement().getElement(lineIndex + 1).getStartOffset();
                            int endIndex = pythonDoc.getDefaultRootElement().getElement(lineIndex + 1).getEndOffset();
                            String text = pythonDoc.getText(startIndex, endIndex - startIndex);
                            if (selectedText.equals("importTestScript")) {
                                int parenPos = text.indexOf("(");
                                if (parenPos > 0) {
                                    // retrieve the script name
                                    String quoteStr = text.substring(parenPos + 1, parenPos + 2);
View Full Code Here


    public void init() {
        init("text/python");
    }

    public void clearUndos() {
        SyntaxDocument doc = (SyntaxDocument) this.getDocument();
        doc.clearUndos();
    }
View Full Code Here

        }
        return null;
    }

    public void selectLine(int lineNumber) {
        SyntaxDocument pythonDoc = (SyntaxDocument) getDocument();
        javax.swing.text.Element lineElement = pythonDoc.getDefaultRootElement().getElement(lineNumber - 1);
        int startIndex = lineElement.getStartOffset();
        int endIndex = lineElement.getEndOffset() - 1;
        requestFocusInWindow();
        select(startIndex, endIndex);
    }
View Full Code Here

   @Override
   public void propertyChange(PropertyChangeEvent evt) {
    
       if (evt.getPropertyName().equals("document")) {
           if (evt.getOldValue() instanceof SyntaxDocument) {
               SyntaxDocument syntaxDocument = (SyntaxDocument) evt.getOldValue();
               syntaxDocument.removeDocumentListener(this);
           }
           if (evt.getNewValue() instanceof SyntaxDocument && status.equals(Status.INSTALLING)) {
               SyntaxDocument syntaxDocument = (SyntaxDocument) evt.getNewValue();
               syntaxDocument.addDocumentListener(this);
               updateSize();
           }
       } else if (evt.getPropertyName().equals("font")) {
           charHeight = pane.getFontMetrics(pane.getFont()).getHeight();
           charWidth = pane.getFontMetrics(pane.getFont()).charWidth('0');
View Full Code Here

               valid = false;
           }
           else {
               Document doc = pane.getDocument();
               if (doc instanceof SyntaxDocument) {
                   SyntaxDocument pythonDoc = (SyntaxDocument) doc;
                    
                    String text = pythonDoc.getUncommentedText(lineElement.getStartOffset(), lineElement.getEndOffset());
                     // validate the selected line
                     if (text.replaceAll("[\t\n ]", "").length() == 0)
                       valid = false;
               }
           }
View Full Code Here

              NonWrappingTextPane nonWrappingTextPane = (NonWrappingTextPane)jtp;
              int lineIndex = nonWrappingTextPane.yToLine(e.getY());
             
              Document doc = jtp.getDocument();
              if (doc instanceof SyntaxDocument) {
                  SyntaxDocument pythonDoc = (SyntaxDocument) doc;
                    Element lineElement = pythonDoc.getDefaultRootElement().getElement(lineIndex + 1);
                    String text = pythonDoc.getUncommentedText(lineElement.getStartOffset(), lineElement.getEndOffset());
                    // validate the selected line
                    if (text.replaceAll("[\t\n ]", "").length() == 0)
                        return;
                   
                    nonWrappingTextPane.getBreakpointScript().toggleBreakpoint(lineIndex + 2);
View Full Code Here

        }
       
   public  String  getCurrentLine() {
       String currentLine="";
       try {
            SyntaxDocument sd =   (SyntaxDocument)inputTextComponent.getDocument();
            currentLine = sd.getLineAt(inputTextComponent.getCaretPosition());
          
        } catch (BadLocationException ex) {
            System.out.println("Bad Location exception ");
        }
        return currentLine;
View Full Code Here

  public void caretUpdate(CaretEvent e) {
    handle(e.getDot());
  }

  public void handle(int pos) {
    SyntaxDocument doc = ActionUtils.getSyntaxDocument(pane);
    if (doc != null) {
      try {
        doc.readLock();
        Token token = doc.getTokenAt(pos);
        if (token == null || !handle(doc, token)) {
          deHighlight();
        }
      }
      finally {
        doc.readUnlock();
      }
    }
  }
View Full Code Here

TOP

Related Classes of jsyntaxpane.SyntaxDocument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.