Examples of RSyntaxDocument


Examples of org.fife.ui.rsyntaxtextarea.RSyntaxDocument

   
    this.session = session;
   
// RSyntaxDocument doc = new RSyntaxDocument(new RenjinTokenMakerFactory(), RenjinTokenMakerFactory.SYNTAX_STYLE_R);
   
    RSyntaxDocument doc = new RSyntaxDocument(TokenMakerFactory.getDefaultInstance(), "text/plain");
   
    textArea = new RSyntaxTextArea(doc, null, 20, 60);
    textArea.setCodeFoldingEnabled(true);
    textArea.setAntiAliasingEnabled(true);
    textArea.setText("f<-function() { \n\t42\n}");
View Full Code Here

Examples of org.fife.ui.rsyntaxtextarea.RSyntaxDocument


  private CompletionProvider getProviderFor(JTextComponent comp) {

    RSyntaxTextArea rsta = (RSyntaxTextArea)comp;
    RSyntaxDocument doc = (RSyntaxDocument)rsta.getDocument();
    int line = rsta.getCaretLineNumber();
    Token t = doc.getTokenListForLine(line);
    if (t==null) {
      return getDefaultCompletionProvider();
    }

    int dot = rsta.getCaretPosition();
    Token curToken = RSyntaxUtilities.getTokenAtOffset(t, dot);

    if (curToken==null) { // At end of the line

      int type = doc.getLastTokenTypeOnLine(line);
      if (type==Token.NULL) {
        Token temp = t.getLastPaintableToken();
        if (temp==null) {
          return getDefaultCompletionProvider();
        }
View Full Code Here

Examples of org.fife.ui.rsyntaxtextarea.RSyntaxDocument

   protected Document createDefaultModel()
   {
      // Is called from the super class constructor.
      // That is why initialization takes place here.
      _rSyntaxHighlightTokenMatcherProxy = new RSyntaxHighlightTokenMatcherProxy();
      RSyntaxDocument ret = new RSyntaxDocument(new SquirrelTokenMarkerFactory(this, _rSyntaxHighlightTokenMatcherProxy), SYNTAX_STYLE_SQL);
      return ret;
   }
View Full Code Here

Examples of org.fife.ui.rsyntaxtextarea.RSyntaxDocument

   * @return The completion provider to use.
   */
  private CompletionProvider getProviderFor(JTextComponent comp) {

    RSyntaxTextArea rsta = (RSyntaxTextArea)comp;
    RSyntaxDocument doc = (RSyntaxDocument)rsta.getDocument();
    int line = rsta.getCaretLineNumber();
    Token t = doc.getTokenListForLine(line);
    if (t==null) {
      return getDefaultCompletionProvider();
    }

    int dot = rsta.getCaretPosition();
    Token curToken = RSyntaxUtilities.getTokenAtOffset(t, dot);

    if (curToken==null) { // At end of the line

      int type = doc.getLastTokenTypeOnLine(line);
      if (type==Token.NULL) {
        Token temp = t.getLastPaintableToken();
        if (temp==null) {
          return getDefaultCompletionProvider();
        }
View Full Code Here

Examples of org.fife.ui.rsyntaxtextarea.RSyntaxDocument

    Caret c = textArea.getCaret();
    int dot = c.getDot();
    int mark = c.getMark();
    int p0 = Math.min(dot, mark);
    int p1 = Math.max(dot, mark);
    RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument();
    Element map = doc.getDefaultRootElement();

    int lineNum = map.getElementIndex(dot);
    Element line = map.getElement(lineNum);
    int start = line.getStartOffset();
    int end = line.getEndOffset()-1; // Why always "-1"?
    String s = textArea.getText(start,end-start);
    int len = s.length();

    // endWS is the end of the leading whitespace
    // of the current line.
    int endWS = 0;
    while (endWS<len && RSyntaxUtilities.isWhitespace(s.charAt(endWS))) {
      endWS++;
    }
    s = s.substring(0, endWS);
    p0 -= getID().length();
    String beforeText = getBeforeTextIndented(s);
    String afterText = getAfterTextIndented(s);
    doc.replace(p0,p1-p0, beforeText+afterText, null);
    textArea.setCaretPosition(p0+beforeText.length());

  }
View Full Code Here

Examples of org.fife.ui.rsyntaxtextarea.RSyntaxDocument

  }

  private CompletionProvider getProviderFor(JTextComponent comp) {

    RSyntaxTextArea rsta = (RSyntaxTextArea)comp;
    RSyntaxDocument doc = (RSyntaxDocument)rsta.getDocument();
    int line = rsta.getCaretLineNumber();
    Token t = doc.getTokenListForLine(line);
    if (t==null) {
      return this.defaultProvider;
    }


    int dot = rsta.getCaretPosition();

    //Token curToken = RSyntaxUtilities.getTokenAtOffset(t, dot);
    Token curToken = RSyntaxUtilities.getTokenAtOffset(t, dot);

    if (curToken==null) { // At end of the line

      int type = doc.getLastTokenTypeOnLine(line);
      if (type==Token.NULL) {
        Token temp = t.getLastPaintableToken();
        if (temp==null) {
          return this.defaultProvider;
        }
View Full Code Here

Examples of org.fife.ui.rsyntaxtextarea.RSyntaxDocument

// get the text of the current line (the line over which the caret is placed)
   public  String  getCurrentLine() {
       if (docVar == null)
           updateDocument();

       RSyntaxDocument  myDoc = syntaxDocument;  // the RSyntaxDocument being edited

       int caretpos = editorPane.getCaretPosition()// the caret's current position
       int startpos = editorPane.getCaretOffsetFromLineStart()// offset of caret from the start of line
       // subtract the offset from the start of line, in order scanpos to be the position of the start of the line
       int scanpos = caretpos-startpos;  
        // scan until a newline accumulating the line
       String s = "";
       try {
            char ch = myDoc.charAt(scanpos);
       while (ch!='\n') {
           s += myDoc.charAt(scanpos);
           scanpos += 1;
           ch = myDoc.charAt(scanpos);
       }
       } catch (BadLocationException ex) {
                ex.printStackTrace();
            }
View Full Code Here

Examples of org.fife.ui.rsyntaxtextarea.RSyntaxDocument

    Caret c = textArea.getCaret();
    int dot = c.getDot();
    int mark = c.getMark();
    int p0 = Math.min(dot, mark);
    int p1 = Math.max(dot, mark);
    RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument();
    Element map = doc.getDefaultRootElement();

    int lineNum = map.getElementIndex(dot);
    Element line = map.getElement(lineNum);
    int start = line.getStartOffset();
    int end = line.getEndOffset()-1; // Why always "-1"?
    String s = textArea.getText(start,end-start);
    int len = s.length();

    // endWS is the end of the leading whitespace
    // of the current line.
    int endWS = 0;
    while (endWS<len && RSyntaxUtilities.isWhitespace(s.charAt(endWS))) {
      endWS++;
    }
    s = s.substring(0, endWS);
    p0 -= getID().length();
    String beforeText = getBeforeTextIndented(s);
    String afterText = getAfterTextIndented(s);
    doc.replace(p0,p1-p0, beforeText+afterText, null);
    textArea.setCaretPosition(p0+beforeText.length());

  }
View Full Code Here

Examples of org.fife.ui.rsyntaxtextarea.RSyntaxDocument

   {
      String selectedText = this.textArea.getSelectedText();
      // If text is selected just use that, otherwise select the nearest token.
      if (selectedText == null)
      {
         RSyntaxDocument doc = (RSyntaxDocument) textArea.getDocument();
         doc.readLock();
         try
         {
            // Get the token at the caret position.
            int line = textArea.getCaretLineNumber();
            Token tokenList = textArea.getTokenListForLine(line);
            int dot = this.textArea.getCaret().getDot();
            Token t = RSyntaxUtilities.getTokenAtOffset(tokenList, dot);
            if (t == null)
            {
               // Try to the "left" of the caret.
               dot--;
               try
               {
                  if (dot >= textArea.getLineStartOffset(line))
                  {
                     t = RSyntaxUtilities.getTokenAtOffset(tokenList, dot);
                  }
               }
               catch (BadLocationException ble)
               {
                  ble.printStackTrace(); // Never happens
               }

            }
            if (t != null)
            {
               try
               {
                  // A bug in this method sometimes throws a null pointer exception.
                  selectedText = t.getLexeme();
               }
               catch (NullPointerException e)
               {}
            }
         }
         finally
         {
            doc.readUnlock();
         }
      }
      if (selectedText == null)
         return "";
      else
View Full Code Here

Examples of org.fife.ui.rsyntaxtextarea.RSyntaxDocument

    Caret c = textArea.getCaret();
    int dot = c.getDot();
    int mark = c.getMark();
    int p0 = Math.min(dot, mark);
    int p1 = Math.max(dot, mark);
    RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument();
    Element map = doc.getDefaultRootElement();

    int lineNum = map.getElementIndex(dot);
    Element line = map.getElement(lineNum);
    int start = line.getStartOffset();
    int end = line.getEndOffset()-1; // Why always "-1"?
    String s = textArea.getText(start,end-start);
    int len = s.length();

    // endWS is the end of the leading whitespace
    // of the current line.
    int endWS = 0;
    while (endWS<len && RSyntaxUtilities.isWhitespace(s.charAt(endWS))) {
      endWS++;
    }
    s = s.substring(0, endWS);
    p0 -= getID().length();
    String beforeText = getBeforeTextIndented(s);
    String afterText = getAfterTextIndented(s);
    doc.replace(p0,p1-p0, beforeText+afterText, null);
    textArea.setCaretPosition(p0+beforeText.length());

  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.