rsyntaxtextarea-2.0.1

16:51:13.507 INFO  jd.cli.Main - Decompiling rsyntaxtextarea-2.0.1.jar
package org.fife.io;

import java.io.Reader;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.Segment;

public class DocumentReader
  extends Reader
{
  private long position;
  private long mark;
  private Document document;
  private Segment segment;
  
  public DocumentReader(Document paramDocument)
  {
    position = 0L;
    mark = -1L;
    document = paramDocument;
    segment = new Segment();
  }
  
  public void close() {}
  
  public void mark(int paramInt)
  {
    mark = position;
  }
  
  public boolean markSupported()
  {
    return true;
  }
  
  public int read()
  {
    if (position >= document.getLength()) {
      return -1;
    }
    try
    {
      document.getText((int)position, 1, segment);
      position += 1L;
      return segment.array[segment.offset];
    }
    catch (BadLocationException localBadLocationException)
    {
      localBadLocationException.printStackTrace();
    }
    return -1;
  }
  
  public int read(char[] paramArrayOfChar)
  {
    return read(paramArrayOfChar, 0, paramArrayOfChar.length);
  }
  
  public int read(char[] paramArrayOfChar, int paramInt1, int paramInt2)
  {
    if (position >= document.getLength()) {
      return -1;
    }
    int i = paramInt2;
    if (position + i >= document.getLength()) {
      i = document.getLength() - (int)position;
    }
    if (paramInt1 + i >= paramArrayOfChar.length) {
      i = paramArrayOfChar.length - paramInt1;
    }
    try
    {
      document.getText((int)position, i, segment);
      position += i;
      System.arraycopy(segment.array, segment.offset, paramArrayOfChar, paramInt1, i);
      
      return i;
    }
    catch (BadLocationException localBadLocationException) {}
    return -1;
  }
  
  public boolean ready()
  {
    return true;
  }
  
  public void reset()
  {
    if (mark == -1L)
    {
      position = 0L;
    }
    else
    {
      position = mark;
      mark = -1L;
    }
  }
  
  public long skip(long paramLong)
  {
    if (position + paramLong <= document.getLength())
    {
      position += paramLong;
      return paramLong;
    }
    long l = position;
    position = document.getLength();
    return document.getLength() - l;
  }
  
  public void seek(long paramLong)
  {
    position = Math.min(paramLong, document.getLength());
  }
}

/* Location:
 * Qualified Name:     org.fife.io.DocumentReader
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.fife.io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PushbackInputStream;
import java.io.Reader;

public class UnicodeReader
  extends Reader
{
  private InputStreamReader internalIn = null;
  private String encoding;
  private static final int BOM_SIZE = 4;
  
  public UnicodeReader(String paramString)
    throws IOException, FileNotFoundException, SecurityException
  {
    this(new File(paramString));
  }
  
  public UnicodeReader(File paramFile)
    throws IOException, FileNotFoundException, SecurityException
  {
    this(new FileInputStream(paramFile));
  }
  
  public UnicodeReader(File paramFile, String paramString)
    throws IOException, FileNotFoundException, SecurityException
  {
    this(new FileInputStream(paramFile), paramString);
  }
  
  public UnicodeReader(InputStream paramInputStream)
    throws IOException
  {
    this(paramInputStream, null);
  }
  
  public UnicodeReader(InputStream paramInputStream, String paramString)
    throws IOException
  {
    init(paramInputStream, paramString);
  }
  
  public void close()
    throws IOException
  {
    internalIn.close();
  }
  
  public String getEncoding()
  {
    return encoding;
  }
  
  protected void init(InputStream paramInputStream, String paramString)
    throws IOException
  {
    PushbackInputStream localPushbackInputStream = new PushbackInputStream(paramInputStream, 4);
    
    byte[] arrayOfByte = new byte[4];
    
    int i = localPushbackInputStream.read(arrayOfByte, 0, arrayOfByte.length);
    int j;
    if ((arrayOfByte[0] == 0) && (arrayOfByte[1] == 0) && (arrayOfByte[2] == -2) && (arrayOfByte[3] == -1))
    {
      encoding = "UTF-32BE";
      j = i - 4;
    }
    else if ((i == 4) && (arrayOfByte[0] == -1) && (arrayOfByte[1] == -2) && (arrayOfByte[2] == 0) && (arrayOfByte[3] == 0))
    {
      encoding = "UTF-32LE";
      j = i - 4;
    }
    else if ((arrayOfByte[0] == -17) && (arrayOfByte[1] == -69) && (arrayOfByte[2] == -65))
    {
      encoding = "UTF-8";
      j = i - 3;
    }
    else if ((arrayOfByte[0] == -2) && (arrayOfByte[1] == -1))
    {
      encoding = "UTF-16BE";
      j = i - 2;
    }
    else if ((arrayOfByte[0] == -1) && (arrayOfByte[1] == -2))
    {
      encoding = "UTF-16LE";
      j = i - 2;
    }
    else
    {
      encoding = paramString;
      j = i;
    }
    if (j > 0) {
      localPushbackInputStream.unread(arrayOfByte, i - j, j);
    } else if (j < -1) {
      localPushbackInputStream.unread(arrayOfByte, 0, 0);
    }
    if (encoding == null)
    {
      internalIn = new InputStreamReader(localPushbackInputStream);
      encoding = internalIn.getEncoding();
    }
    else
    {
      internalIn = new InputStreamReader(localPushbackInputStream, encoding);
    }
  }
  
  public int read(char[] paramArrayOfChar, int paramInt1, int paramInt2)
    throws IOException
  {
    return internalIn.read(paramArrayOfChar, paramInt1, paramInt2);
  }
}

/* Location:
 * Qualified Name:     org.fife.io.UnicodeReader
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.fife.io;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;

public class UnicodeWriter
  extends Writer
{
  public static final String PROPERTY_WRITE_UTF8_BOM = "UnicodeWriter.writeUtf8BOM";
  private OutputStreamWriter internalOut;
  private static final byte[] UTF8_BOM = { -17, -69, -65 };
  private static final byte[] UTF16LE_BOM = { -1, -2 };
  private static final byte[] UTF16BE_BOM = { -2, -1 };
  private static final byte[] UTF32LE_BOM = { -1, -2, 0, 0 };
  private static final byte[] UTF32BE_BOM = { 0, 0, -2, -1 };
  
  public UnicodeWriter(String paramString1, String paramString2)
    throws UnsupportedEncodingException, IOException
  {
    this(new FileOutputStream(paramString1), paramString2);
  }
  
  public UnicodeWriter(File paramFile, String paramString)
    throws UnsupportedEncodingException, IOException
  {
    this(new FileOutputStream(paramFile), paramString);
  }
  
  public UnicodeWriter(OutputStream paramOutputStream, String paramString)
    throws UnsupportedEncodingException, IOException
  {
    init(paramOutputStream, paramString);
  }
  
  public void close()
    throws IOException
  {
    internalOut.close();
  }
  
  public void flush()
    throws IOException
  {
    internalOut.flush();
  }
  
  public String getEncoding()
  {
    return internalOut.getEncoding();
  }
  
  public static boolean getWriteUtf8BOM()
  {
    String str = System.getProperty("UnicodeWriter.writeUtf8BOM");
    if ((str != null) && (Boolean.valueOf(str).equals(Boolean.FALSE))) {
      return false;
    }
    return true;
  }
  
  private void init(OutputStream paramOutputStream, String paramString)
    throws UnsupportedEncodingException, IOException
  {
    internalOut = new OutputStreamWriter(paramOutputStream, paramString);
    if ("UTF-8".equals(paramString))
    {
      if (getWriteUtf8BOM()) {
        paramOutputStream.write(UTF8_BOM, 0, UTF8_BOM.length);
      }
    }
    else if ("UTF-16LE".equals(paramString)) {
      paramOutputStream.write(UTF16LE_BOM, 0, UTF16LE_BOM.length);
    } else if ("UTF-16BE".equals(paramString)) {
      paramOutputStream.write(UTF16BE_BOM, 0, UTF16BE_BOM.length);
    } else if ("UTF-32LE".equals(paramString)) {
      paramOutputStream.write(UTF32LE_BOM, 0, UTF32LE_BOM.length);
    } else if (("UTF-32".equals(paramString)) || ("UTF-32BE".equals(paramString))) {
      paramOutputStream.write(UTF32BE_BOM, 0, UTF32BE_BOM.length);
    }
  }
  
  public void write(char[] paramArrayOfChar, int paramInt1, int paramInt2)
    throws IOException
  {
    internalOut.write(paramArrayOfChar, paramInt1, paramInt2);
  }
  
  public void write(int paramInt)
    throws IOException
  {
    internalOut.write(paramInt);
  }
  
  public void write(String paramString, int paramInt1, int paramInt2)
    throws IOException
  {
    internalOut.write(paramString, paramInt1, paramInt2);
  }
}

/* Location:
 * Qualified Name:     org.fife.io.UnicodeWriter
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.fife.print;

import java.awt.FontMetrics;
import javax.swing.text.TabExpander;

class RPrintUtilities$RPrintTabExpander
  implements TabExpander
{
  public float nextTabStop(float paramFloat, int paramInt)
  {
    if (RPrintUtilities.access$000() == 0) {
      return paramFloat;
    }
    int i = RPrintUtilities.access$000() * RPrintUtilities.access$100().charWidth(' ');
    int j = ((int)paramFloat - RPrintUtilities.access$200()) / i;
    return RPrintUtilities.access$200() + (j + 1) * i;
  }
}

/* Location:
 * Qualified Name:     org.fife.print.RPrintUtilities.RPrintTabExpander
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.fife.print;

import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.print.PageFormat;
import java.io.PrintStream;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.Element;
import javax.swing.text.JTextComponent;
import javax.swing.text.Segment;
import javax.swing.text.TabExpander;
import javax.swing.text.Utilities;

public abstract class RPrintUtilities
{
  private static int currentDocLineNumber;
  private static int numDocLines;
  private static Element rootElement;
  private static final char[] breakChars = { ' ', '\t', ',', '.', ';', '?', '!' };
  private static int xOffset;
  private static int tabSizeInSpaces;
  private static FontMetrics fm;
  
  private static int getLineBreakPoint(String paramString, int paramInt)
  {
    int i = -1;
    for (int j = 0; j < breakChars.length; j++)
    {
      int k = paramString.lastIndexOf(breakChars[j], paramInt - 1);
      if (k > i) {
        i = k;
      }
    }
    return i == -1 ? paramInt - 1 : i;
  }
  
  public static int printDocumentMonospaced(Graphics paramGraphics, Document paramDocument, int paramInt1, int paramInt2, PageFormat paramPageFormat, int paramInt3)
  {
    paramGraphics.setColor(Color.BLACK);
    paramGraphics.setFont(new Font("Monospaced", 0, paramInt1));
    
    tabSizeInSpaces = paramInt3;
    fm = paramGraphics.getFontMetrics();
    
    int i = fm.charWidth('w');
    int j = fm.getHeight();
    
    int k = (int)paramPageFormat.getImageableWidth() / i;
    int m = (int)paramPageFormat.getImageableHeight() / j;
    
    int n = m * paramInt2;
    
    xOffset = (int)paramPageFormat.getImageableX();
    int i1 = (int)paramPageFormat.getImageableY() + fm.getAscent() + 1;
    
    int i2 = 0;
    
    currentDocLineNumber = 0;
    rootElement = paramDocument.getDefaultRootElement();
    numDocLines = rootElement.getElementCount();
    while (currentDocLineNumber < numDocLines)
    {
      Element localElement = rootElement.getElement(currentDocLineNumber);
      int i3 = localElement.getStartOffset();
      try
      {
        str1 = paramDocument.getText(i3, localElement.getEndOffset() - i3);
      }
      catch (BadLocationException localBadLocationException)
      {
        localBadLocationException.printStackTrace();
        return 1;
      }
      String str1 = str1.replaceAll("\n", "");
      if (tabSizeInSpaces == 0)
      {
        str1 = str1.replaceAll("\t", "");
      }
      else
      {
        int i4 = str1.indexOf('\t');
        while (i4 > -1)
        {
          int i5 = tabSizeInSpaces - i4 % tabSizeInSpaces;
          String str2 = "";
          for (int i6 = 0; i6 < i5; i6++) {
            str2 = str2 + ' ';
          }
          str1 = str1.replaceFirst("\t", str2);
          i4 = str1.indexOf('\t');
        }
      }
      while (str1.length() > k)
      {
        i2++;
        if (i2 > n)
        {
          paramGraphics.drawString(str1.substring(0, k), xOffset, i1);
          i1 += j;
          if (i2 == n + m) {
            return 0;
          }
        }
        str1 = str1.substring(k, str1.length());
      }
      currentDocLineNumber += 1;
      
      i2++;
      if (i2 > n)
      {
        paramGraphics.drawString(str1, xOffset, i1);
        i1 += j;
        if (i2 == n + m) {
          return 0;
        }
      }
    }
    if (i2 > n) {
      return 0;
    }
    return 1;
  }
  
  public static int printDocumentMonospacedWordWrap(Graphics paramGraphics, Document paramDocument, int paramInt1, int paramInt2, PageFormat paramPageFormat, int paramInt3)
  {
    paramGraphics.setColor(Color.BLACK);
    paramGraphics.setFont(new Font("Monospaced", 0, paramInt1));
    
    tabSizeInSpaces = paramInt3;
    fm = paramGraphics.getFontMetrics();
    
    int i = fm.charWidth('w');
    int j = fm.getHeight();
    
    int k = (int)paramPageFormat.getImageableWidth() / i;
    int m = (int)paramPageFormat.getImageableHeight() / j;
    
    int n = m * paramInt2;
    
    xOffset = (int)paramPageFormat.getImageableX();
    int i1 = (int)paramPageFormat.getImageableY() + fm.getAscent() + 1;
    
    int i2 = 0;
    
    currentDocLineNumber = 0;
    rootElement = paramDocument.getDefaultRootElement();
    numDocLines = rootElement.getElementCount();
    while (currentDocLineNumber < numDocLines)
    {
      Element localElement = rootElement.getElement(currentDocLineNumber);
      int i3 = localElement.getStartOffset();
      try
      {
        str1 = paramDocument.getText(i3, localElement.getEndOffset() - i3);
      }
      catch (BadLocationException localBadLocationException)
      {
        localBadLocationException.printStackTrace();
        return 1;
      }
      String str1 = str1.replaceAll("\n", "");
      int i4;
      if (tabSizeInSpaces == 0)
      {
        str1 = str1.replaceAll("\t", "");
      }
      else
      {
        i4 = str1.indexOf('\t');
        while (i4 > -1)
        {
          int i5 = tabSizeInSpaces - i4 % tabSizeInSpaces;
          String str2 = "";
          for (int i6 = 0; i6 < i5; i6++) {
            str2 = str2 + ' ';
          }
          str1 = str1.replaceFirst("\t", str2);
          i4 = str1.indexOf('\t');
        }
      }
      while (str1.length() > k)
      {
        i4 = getLineBreakPoint(str1, k) + 1;
        
        i2++;
        if (i2 > n)
        {
          paramGraphics.drawString(str1.substring(0, i4), xOffset, i1);
          i1 += j;
          if (i2 == n + m) {
            return 0;
          }
        }
        str1 = str1.substring(i4, str1.length());
      }
      currentDocLineNumber += 1;
      
      i2++;
      if (i2 > n)
      {
        paramGraphics.drawString(str1, xOffset, i1);
        i1 += j;
        if (i2 == n + m) {
          return 0;
        }
      }
    }
    if (i2 > n) {
      return 0;
    }
    return 1;
  }
  
  public static int printDocumentWordWrap(Graphics paramGraphics, JTextComponent paramJTextComponent, Font paramFont, int paramInt1, PageFormat paramPageFormat, int paramInt2)
  {
    paramGraphics.setColor(Color.BLACK);
    paramGraphics.setFont(paramFont != null ? paramFont : paramJTextComponent.getFont());
    
    tabSizeInSpaces = paramInt2;
    fm = paramGraphics.getFontMetrics();
    int i = fm.getHeight();
    
    int j = (int)paramPageFormat.getImageableWidth();
    int k = (int)paramPageFormat.getImageableHeight() / i;
    
    int m = k * paramInt1;
    
    RPrintTabExpander localRPrintTabExpander = new RPrintTabExpander();
    
    xOffset = (int)paramPageFormat.getImageableX();
    int n = (int)paramPageFormat.getImageableY() + fm.getAscent() + 1;
    
    int i1 = 0;
    
    Document localDocument = paramJTextComponent.getDocument();
    rootElement = localDocument.getDefaultRootElement();
    numDocLines = rootElement.getElementCount();
    currentDocLineNumber = 0;
    int i2 = 0;
    while (currentDocLineNumber < numDocLines)
    {
      Segment localSegment = new Segment();
      
      Element localElement = rootElement.getElement(currentDocLineNumber);
      int i3 = localElement.getStartOffset();
      int i4 = localElement.getEndOffset();
      try
      {
        localDocument.getText(i3 + i2, i4 - (i3 + i2), localSegment);
      }
      catch (BadLocationException localBadLocationException1)
      {
        System.err.println("BadLocationException in print (where there shouldn't be one!): " + localBadLocationException1);
        return 1;
      }
      localSegment = removeEndingWhitespace(localSegment);
      
      int i5 = Utilities.getTabbedTextWidth(localSegment, fm, 0, localRPrintTabExpander, 0);
      if (i5 <= j)
      {
        currentDocLineNumber += 1;
        i2 = 0;
      }
      else
      {
        int i6 = -1;
        while (i5 > j)
        {
          localSegment = removeEndingWhitespace(localSegment);
          
          i6 = -1;
          String str = localSegment.toString();
          for (int i7 = 0; i7 < breakChars.length; i7++)
          {
            int i8 = str.lastIndexOf(breakChars[i7]) + 1;
            if (i8 > 0) {
              if (((i8 > i6 ? 1 : 0) & (i8 != str.length() ? 1 : 0)) != 0) {
                i6 = i8;
              }
            }
          }
          if (i6 == -1)
          {
            i6 = 0;
            do
            {
              i6++;
              try
              {
                localDocument.getText(i3 + i2, i6, localSegment);
              }
              catch (BadLocationException localBadLocationException2)
              {
                System.err.println(localBadLocationException2);
                return 1;
              }
              i5 = Utilities.getTabbedTextWidth(localSegment, fm, 0, localRPrintTabExpander, 0);
            } while (i5 <= j);
            i6--;
          }
          try
          {
            localDocument.getText(i3 + i2, i6, localSegment);
          }
          catch (BadLocationException localBadLocationException3)
          {
            System.err.println("BadLocationException in print (a):");
            System.err.println("==> currentLineStart: " + i3 + "; startingOffset: " + i2 + "; currentPos: " + i6);
            
            System.err.println("==> Range: " + (i3 + i2) + " - " + (i3 + i2 + i6));
            
            localBadLocationException3.printStackTrace();
            return 1;
          }
          i5 = Utilities.getTabbedTextWidth(localSegment, fm, 0, localRPrintTabExpander, 0);
        }
        i2 += i6;
      }
      i1++;
      if (i1 > m)
      {
        Utilities.drawTabbedText(localSegment, xOffset, n, paramGraphics, localRPrintTabExpander, 0);
        n += i;
        if (i1 == m + k) {
          return 0;
        }
      }
    }
    if (i1 > m) {
      return 0;
    }
    return 1;
  }
  
  private static Segment removeEndingWhitespace(Segment paramSegment)
  {
    int i = 0;
    int j = paramSegment.setIndex(paramSegment.getEndIndex() - 1);
    while (((j == 32) || (j == 9)) && (j != 65535))
    {
      i++;
      j = paramSegment.previous();
    }
    String str1 = paramSegment.toString();
    String str2 = str1.substring(0, str1.length() - i);
    return new Segment(str2.toCharArray(), 0, str2.length());
  }
  
  private static class RPrintTabExpander
    implements TabExpander
  {
    public float nextTabStop(float paramFloat, int paramInt)
    {
      if (RPrintUtilities.tabSizeInSpaces == 0) {
        return paramFloat;
      }
      int i = RPrintUtilities.tabSizeInSpaces * RPrintUtilities.fm.charWidth(' ');
      int j = ((int)paramFloat - RPrintUtilities.xOffset) / i;
      return RPrintUtilities.xOffset + (j + 1) * i;
    }
  }
}

/* Location:
 * Qualified Name:     org.fife.print.RPrintUtilities
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.fife.ui.rsyntaxtextarea;

class AbstractJFlexCTokenMaker$1 {}

/* Location:
 * Qualified Name:     org.fife.ui.rsyntaxtextarea.AbstractJFlexCTokenMaker.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.fife.ui.rsyntaxtextarea;

import java.awt.event.ActionEvent;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import javax.swing.text.BadLocationException;
import org.fife.ui.rtextarea.RTextArea;

class AbstractJFlexCTokenMaker$InsertBreakAction
  extends RSyntaxTextAreaEditorKit.InsertBreakAction
{
  AbstractJFlexCTokenMaker$InsertBreakAction(AbstractJFlexCTokenMaker.1 param1)
  {
    this();
  }
  
  private static final Pattern p = Pattern.compile("([ \\t]*)(/?[\\*]+)([ \\t]*)");
  
  public void actionPerformedImpl(ActionEvent paramActionEvent, RTextArea paramRTextArea)
  {
    if ((!paramRTextArea.isEditable()) || (!paramRTextArea.isEnabled()))
    {
      UIManager.getLookAndFeel().provideErrorFeedback(paramRTextArea);
      return;
    }
    RSyntaxTextArea localRSyntaxTextArea = (RSyntaxTextArea)getTextComponent(paramActionEvent);
    RSyntaxDocument localRSyntaxDocument = (RSyntaxDocument)localRSyntaxTextArea.getDocument();
    
    int i = paramRTextArea.getCaretLineNumber();
    int j = localRSyntaxDocument.getLastTokenTypeOnLine(i);
    if ((j == 3) || (j == 2)) {
      insertBreakInMLC(paramActionEvent, localRSyntaxTextArea, i);
    } else {
      handleInsertBreak(localRSyntaxTextArea, true);
    }
  }
  
  private boolean appearsNested(RSyntaxTextArea paramRSyntaxTextArea, int paramInt1, int paramInt2)
  {
    int i = paramInt1;
    while (paramInt1 < paramRSyntaxTextArea.getLineCount())
    {
      Token localToken = paramRSyntaxTextArea.getTokenListForLine(paramInt1);
      int j = 0;
      if (paramInt1++ == i)
      {
        localToken = RSyntaxUtilities.getTokenAtOffset(localToken, paramInt2);
        if (localToken == null) {
          continue;
        }
        j = localToken.documentToToken(paramInt2);
      }
      else
      {
        j = textOffset;
      }
      while (j < textOffset + textCount - 1)
      {
        if ((text[j] == '/') && (text[(j + 1)] == '*')) {
          return true;
        }
        j++;
      }
      if (localToken.getNextToken() != null) {
        return false;
      }
    }
    return true;
  }
  
  private void insertBreakInMLC(ActionEvent paramActionEvent, RSyntaxTextArea paramRSyntaxTextArea, int paramInt)
  {
    Matcher localMatcher = null;
    int i = -1;
    int j = -1;
    try
    {
      i = paramRSyntaxTextArea.getLineStartOffset(paramInt);
      j = paramRSyntaxTextArea.getLineEndOffset(paramInt);
      String str1 = paramRSyntaxTextArea.getText(i, j - i);
      localMatcher = p.matcher(str1);
    }
    catch (BadLocationException localBadLocationException)
    {
      UIManager.getLookAndFeel().provideErrorFeedback(paramRSyntaxTextArea);
      localBadLocationException.printStackTrace();
      return;
    }
    if (localMatcher.lookingAt())
    {
      String str2 = localMatcher.group(1);
      String str3 = localMatcher.group(2);
      
      int k = paramRSyntaxTextArea.getCaretPosition();
      if ((k >= i) && (k < i + str2.length() + str3.length()))
      {
        if (str3.charAt(0) == '/')
        {
          handleInsertBreak(paramRSyntaxTextArea, true);
          return;
        }
        paramRSyntaxTextArea.setCaretPosition(j - 1);
      }
      int m = str3.charAt(0) == '/' ? 1 : 0;
      boolean bool = appearsNested(paramRSyntaxTextArea, paramInt, i + str2.length() + 2);
      
      String str4 = str2 + (m != 0 ? " * " : "*") + localMatcher.group(3);
      
      paramRSyntaxTextArea.replaceSelection("\n" + str4);
      if (bool)
      {
        k = paramRSyntaxTextArea.getCaretPosition();
        paramRSyntaxTextArea.insert("\n" + str2 + " */", k);
        paramRSyntaxTextArea.setCaretPosition(k);
      }
    }
    else
    {
      handleInsertBreak(paramRSyntaxTextArea, true);
    }
  }
  
  private AbstractJFlexCTokenMaker$InsertBreakAction() {}
}

/* Location:
 * Qualified Name:     org.fife.ui.rsyntaxtextarea.AbstractJFlexCTokenMaker.InsertBreakAction
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.fife.ui.rsyntaxtextarea;

import java.awt.event.ActionEvent;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.Action;
import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import javax.swing.text.BadLocationException;
import org.fife.ui.rtextarea.RTextArea;

public abstract class AbstractJFlexCTokenMaker
  extends AbstractJFlexTokenMaker
{
  protected static final Action INSERT_BREAK_ACTION = new InsertBreakAction(null);
  
  public boolean getCurlyBracesDenoteCodeBlocks()
  {
    return true;
  }
  
  public Action getInsertBreakAction()
  {
    return INSERT_BREAK_ACTION;
  }
  
  public boolean getMarkOccurrencesOfTokenType(int paramInt)
  {
    return (paramInt == 20) || (paramInt == 8);
  }
  
  public boolean getShouldIndentNextLineAfter(Token paramToken)
  {
    if ((paramToken != null) && (textCount == 1))
    {
      int i = text[textOffset];
      return (i == 123) || (i == 40);
    }
    return false;
  }
  
  private static class InsertBreakAction
    extends RSyntaxTextAreaEditorKit.InsertBreakAction
  {
    InsertBreakAction(AbstractJFlexCTokenMaker.1 param1)
    {
      this();
    }
    
    private static final Pattern p = Pattern.compile("([ \\t]*)(/?[\\*]+)([ \\t]*)");
    
    public void actionPerformedImpl(ActionEvent paramActionEvent, RTextArea paramRTextArea)
    {
      if ((!paramRTextArea.isEditable()) || (!paramRTextArea.isEnabled()))
      {
        UIManager.getLookAndFeel().provideErrorFeedback(paramRTextArea);
        return;
      }
      RSyntaxTextArea localRSyntaxTextArea = (RSyntaxTextArea)getTextComponent(paramActionEvent);
      RSyntaxDocument localRSyntaxDocument = (RSyntaxDocument)localRSyntaxTextArea.getDocument();
      
      int i = paramRTextArea.getCaretLineNumber();
      int j = localRSyntaxDocument.getLastTokenTypeOnLine(i);
      if ((j == 3) || (j == 2)) {
        insertBreakInMLC(paramActionEvent, localRSyntaxTextArea, i);
      } else {
        handleInsertBreak(localRSyntaxTextArea, true);
      }
    }
    
    private boolean appearsNested(RSyntaxTextArea paramRSyntaxTextArea, int paramInt1, int paramInt2)
    {
      int i = paramInt1;
      while (paramInt1 < paramRSyntaxTextArea.getLineCount())
      {
        Token localToken = paramRSyntaxTextArea.getTokenListForLine(paramInt1);
        int j = 0;
        if (paramInt1++ == i)
        {
          localToken = RSyntaxUtilities.getTokenAtOffset(localToken, paramInt2);
          if (localToken == null) {
            continue;
          }
          j = localToken.documentToToken(paramInt2);
        }
        else
        {
          j = textOffset;
        }
        while (j < textOffset + textCount - 1)
        {
          if ((text[j] == '/') && (text[(j + 1)] == '*')) {
            return true;
          }
          j++;
        }
        if (localToken.getNextToken() != null) {
          return false;
        }
      }
      return true;
    }
    
    private void insertBreakInMLC(ActionEvent paramActionEvent, RSyntaxTextArea paramRSyntaxTextArea, int paramInt)
    {
      Matcher localMatcher = null;
      int i = -1;
      int j = -1;
      try
      {
        i = paramRSyntaxTextArea.getLineStartOffset(paramInt);
        j = paramRSyntaxTextArea.getLineEndOffset(paramInt);
        String str1 = paramRSyntaxTextArea.getText(i, j - i);
        localMatcher = p.matcher(str1);
      }
      catch (BadLocationException localBadLocationException)
      {
        UIManager.getLookAndFeel().provideErrorFeedback(paramRSyntaxTextArea);
        localBadLocationException.printStackTrace();
        return;
      }
      if (localMatcher.lookingAt())
      {
        String str2 = localMatcher.group(1);
        String str3 = localMatcher.group(2);
        
        int k = paramRSyntaxTextArea.getCaretPosition();
        if ((k >= i) && (k < i + str2.length() + str3.length()))
        {
          if (str3.charAt(0) == '/')
          {
            handleInsertBreak(paramRSyntaxTextArea, true);
            return;
          }
          paramRSyntaxTextArea.setCaretPosition(j - 1);
        }
        int m = str3.charAt(0) == '/' ? 1 : 0;
        boolean bool = appearsNested(paramRSyntaxTextArea, paramInt, i + str2.length() + 2);
        
        String str4 = str2 + (m != 0 ? " * " : "*") + localMatcher.group(3);
        
        paramRSyntaxTextArea.replaceSelection("\n" + str4);
        if (bool)
        {
          k = paramRSyntaxTextArea.getCaretPosition();
          paramRSyntaxTextArea.insert("\n" + str2 + " */", k);
          paramRSyntaxTextArea.setCaretPosition(k);
        }
      }
      else
      {
        handleInsertBreak(paramRSyntaxTextArea, true);
      }
    }
    
    private InsertBreakAction() {}
  }
}

/* Location:
 * Qualified Name:     org.fife.ui.rsyntaxtextarea.AbstractJFlexCTokenMaker
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.fife.ui.rsyntaxtextarea;

import javax.swing.text.Segment;

public abstract class AbstractJFlexTokenMaker
  extends TokenMakerBase
{
  protected Segment s;
  protected int start;
  protected int offsetShift;
}

/* Location:
 * Qualified Name:     org.fife.ui.rsyntaxtextarea.AbstractJFlexTokenMaker
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.fife.ui.rsyntaxtextarea;

public abstract class AbstractTokenMaker
  extends TokenMakerBase
{
  protected TokenMap wordsToHighlight;
  
  public AbstractTokenMaker()
  {
    wordsToHighlight = getWordsToHighlight();
  }
  
  public abstract TokenMap getWordsToHighlight();
  
  public void removeLastToken()
  {
    if (previousToken == null)
    {
      firstToken = (currentToken = null);
    }
    else
    {
      currentToken = previousToken;
      currentToken.setNextToken(null);
    }
  }
}

/* Location:
 * Qualified Name:     org.fife.ui.rsyntaxtextarea.AbstractTokenMaker
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.fife.ui.rsyntaxtextarea;

import java.util.Map;
import java.util.Set;

public abstract class AbstractTokenMakerFactory
  extends TokenMakerFactory
{
  private Map tokenMakerMap;
  
  protected AbstractTokenMakerFactory()
  {
    tokenMakerMap = createTokenMakerKeyToClassNameMap();
  }
  
  protected abstract Map createTokenMakerKeyToClassNameMap();
  
  protected TokenMaker getTokenMakerImpl(String paramString)
  {
    String str = (String)tokenMakerMap.get(paramString);
    if (str != null) {
      try
      {
        return (TokenMaker)Class.forName(str).newInstance();
      }
      catch (RuntimeException localRuntimeException)
      {
        throw localRuntimeException;
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
      }
    }
    return null;
  }
  
  public Set keySet()
  {
    return tokenMakerMap.keySet();
  }
  
  public String putMapping(String paramString1, String paramString2)
  {
    return (String)tokenMakerMap.put(paramString1, paramString2);
  }
}

/* Location:
 * Qualified Name:     org.fife.ui.rsyntaxtextarea.AbstractTokenMakerFactory
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.fife.ui.rsyntaxtextarea;

import java.util.EventObject;

public class ActiveLineRangeEvent
  extends EventObject
{
  private int min;
  private int max;
  
  public ActiveLineRangeEvent(RSyntaxTextArea paramRSyntaxTextArea, int paramInt1, int paramInt2)
  {
    super(paramRSyntaxTextArea);
    min = paramInt1;
    max = paramInt2;
  }
  
  public int getMax()
  {
    return max;
  }
  
  public int getMin()
  {
    return min;
  }
}

/* Location:
 * Qualified Name:     org.fife.ui.rsyntaxtextarea.ActiveLineRangeEvent
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.fife.ui.rsyntaxtextarea;

import java.util.EventListener;

public abstract interface ActiveLineRangeListener
  extends EventListener
{
  public abstract void activeLineRangeChanged(ActiveLineRangeEvent paramActiveLineRangeEvent);
}

/* Location:
 * Qualified Name:     org.fife.ui.rsyntaxtextarea.ActiveLineRangeListener
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.fife.ui.rsyntaxtextarea;

import java.awt.Color;
import javax.swing.text.DefaultHighlighter.DefaultHighlightPainter;

class ChangeableColorHighlightPainter
  extends DefaultHighlighter.DefaultHighlightPainter
{
  private Color color;
  
  public ChangeableColorHighlightPainter(Color paramColor)
  {
    super(paramColor);
    setColor(paramColor);
  }
  
  public Color getColor()
  {
    return color;
  }
  
  public void setColor(Color paramColor)
  {
    if (paramColor == null) {
      throw new IllegalArgumentException("color cannot be null");
    }
    color = paramColor;
  }
}

/* Location:
 * Qualified Name:     org.fife.ui.rsyntaxtextarea.ChangeableColorHighlightPainter
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.fife.ui.rsyntaxtextarea;

class CodeTemplateManager$1 {}

/* Location:
 * Qualified Name:     org.fife.ui.rsyntaxtextarea.CodeTemplateManager.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.fife.ui.rsyntaxtextarea;

import java.io.Serializable;
import java.util.Comparator;
import javax.swing.text.Segment;
import org.fife.ui.rsyntaxtextarea.templates.CodeTemplate;

class CodeTemplateManager$TemplateComparator
  implements Comparator, Serializable
{
  CodeTemplateManager$TemplateComparator(CodeTemplateManager.1 param1)
  {
    this();
  }
  
  public int compare(Object paramObject1, Object paramObject2)
  {
    CodeTemplate localCodeTemplate = (CodeTemplate)paramObject1;
    char[] arrayOfChar1 = localCodeTemplate.getID().toCharArray();
    int i = 0;
    int j = arrayOfChar1.length;
    
    Segment localSegment = (Segment)paramObject2;
    char[] arrayOfChar2 = array;
    int k = count;
    int m = offset + k - 1;
    while ((m >= offset) && (CodeTemplateManager.isValidChar(arrayOfChar2[m]))) {
      m--;
    }
    m++;
    int n = m - offset;
    k -= n;
    
    int i1 = Math.min(j, k);
    while (i1-- != 0)
    {
      int i2 = arrayOfChar1[(i++)];
      int i3 = arrayOfChar2[(m++)];
      if (i2 != i3) {
        return i2 - i3;
      }
    }
    return j - k;
  }
  
  private CodeTemplateManager$TemplateComparator() {}
}

/* Location:
 * Qualified Name:     org.fife.ui.rsyntaxtextarea.CodeTemplateManager.TemplateComparator
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.fife.ui.rsyntaxtextarea;

import java.io.File;
import java.io.FileFilter;

class CodeTemplateManager$XMLFileFilter
  implements FileFilter
{
  CodeTemplateManager$XMLFileFilter(CodeTemplateManager.1 param1)
  {
    this();
  }
  
  public boolean accept(File paramFile)
  {
    return paramFile.getName().toLowerCase().endsWith(".xml");
  }
  
  private CodeTemplateManager$XMLFileFilter() {}
}

/* Location:
 * Qualified Name:     org.fife.ui.rsyntaxtextarea.CodeTemplateManager.XMLFileFilter
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.fife.ui.rsyntaxtextarea;

import java.beans.XMLDecoder;
import java.beans.XMLEncoder;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import javax.swing.KeyStroke;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.Segment;
import org.fife.ui.rsyntaxtextarea.templates.CodeTemplate;

public class CodeTemplateManager
{
  private int maxTemplateIDLength;
  private List templates;
  private KeyStroke insertTrigger;
  private String insertTriggerString;
  private Segment s;
  private TemplateComparator comparator;
  private File directory;
  private static final int mask = 3;
  static final KeyStroke TEMPLATE_KEYSTROKE = KeyStroke.getKeyStroke(32, 3);
  
  public CodeTemplateManager()
  {
    setInsertTrigger(TEMPLATE_KEYSTROKE);
    
    s = new Segment();
    comparator = new TemplateComparator(null);
    templates = new ArrayList();
  }
  
  public synchronized void addTemplate(CodeTemplate paramCodeTemplate)
  {
    if (paramCodeTemplate == null) {
      throw new IllegalArgumentException("template cannot be null");
    }
    templates.add(paramCodeTemplate);
    sortTemplates();
  }
  
  public KeyStroke getInsertTrigger()
  {
    return insertTrigger;
  }
  
  public String getInsertTriggerString()
  {
    return insertTriggerString;
  }
  
  public synchronized CodeTemplate getTemplate(RSyntaxTextArea paramRSyntaxTextArea)
  {
    int i = paramRSyntaxTextArea.getCaretPosition();
    int j = Math.min(i, maxTemplateIDLength);
    try
    {
      Document localDocument = paramRSyntaxTextArea.getDocument();
      localDocument.getText(i - j, j, s);
      int k = Collections.binarySearch(templates, s, comparator);
      return k >= 0 ? (CodeTemplate)templates.get(k) : null;
    }
    catch (BadLocationException localBadLocationException)
    {
      localBadLocationException.printStackTrace();
      throw new InternalError("Error in CodeTemplateManager");
    }
  }
  
  public synchronized int getTemplateCount()
  {
    return templates.size();
  }
  
  public synchronized CodeTemplate[] getTemplates()
  {
    CodeTemplate[] arrayOfCodeTemplate = new CodeTemplate[templates.size()];
    return (CodeTemplate[])templates.toArray(arrayOfCodeTemplate);
  }
  
  public static final boolean isValidChar(char paramChar)
  {
    return (RSyntaxUtilities.isLetterOrDigit(paramChar)) || (paramChar == '_');
  }
  
  public synchronized boolean removeTemplate(CodeTemplate paramCodeTemplate)
  {
    if (paramCodeTemplate == null) {
      throw new IllegalArgumentException("template cannot be null");
    }
    return templates.remove(paramCodeTemplate);
  }
  
  public synchronized CodeTemplate removeTemplate(String paramString)
  {
    if (paramString == null) {
      throw new IllegalArgumentException("id cannot be null");
    }
    for (Iterator localIterator = templates.iterator(); localIterator.hasNext();)
    {
      CodeTemplate localCodeTemplate = (CodeTemplate)localIterator.next();
      if (paramString.equals(localCodeTemplate.getID()))
      {
        localIterator.remove();
        return localCodeTemplate;
      }
    }
    return null;
  }
  
  public synchronized void replaceTemplates(CodeTemplate[] paramArrayOfCodeTemplate)
  {
    templates.clear();
    if (paramArrayOfCodeTemplate != null) {
      for (int i = 0; i < paramArrayOfCodeTemplate.length; i++) {
        templates.add(paramArrayOfCodeTemplate[i]);
      }
    }
    sortTemplates();
  }
  
  public synchronized boolean saveTemplates()
  {
    if (templates == null) {
      return true;
    }
    if ((directory == null) || (!directory.isDirectory())) {
      return false;
    }
    File[] arrayOfFile = directory.listFiles(new XMLFileFilter(null));
    if (arrayOfFile == null) {
      return false;
    }
    int i = arrayOfFile.length;
    for (int j = 0; j < i; j++) {
      arrayOfFile[j].delete();
    }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd