Tabnine Logo
SyntaxDocument
Code IndexAdd Tabnine to your IDE (free)

How to use
SyntaxDocument
in
com.ochafik.swing.syntaxcoloring

Best Java code snippets using com.ochafik.swing.syntaxcoloring.SyntaxDocument (Showing top 20 results out of 315)

origin: nativelibs4java/JNAerator

/**
 * Sets the document this text area is editing.
 * @param document The document
 */
public void setDocument(SyntaxDocument document)
{
  if(this.document == document)
    return;
  if(this.document != null)
    this.document.removeDocumentListener(documentHandler);
  this.document = document;
  document.addDocumentListener(documentHandler);
  select(0,0);
  updateScrollBars();
  painter.repaint();
}
origin: nativelibs4java/JNAerator

/**
 * Sets the entire text of this text area.
 */
public void setText(String text)
{
  try
  {
    document.beginCompoundEdit();
    document.remove(0,document.getLength());
    document.insertString(0,text,null);
  }
  catch(BadLocationException bl)
  {
    bl.printStackTrace();
  }
  finally
  {
    document.endCompoundEdit();
  }
}
origin: nativelibs4java/JNAerator

/**
 * Returns the number of lines in the document.
 */
public final int getLineCount()
{
  return document.getDefaultRootElement().getElementCount();
}
origin: nativelibs4java/JNAerator

/**
 * Reparses the document, by passing all lines to the token
 * marker. This should be called after the document is first
 * loaded.
 */
public void tokenizeLines()
{
  tokenizeLines(0,getDefaultRootElement().getElementCount());
}
origin: nativelibs4java/JNAerator

/**
 * Returns the entire text of this text area.
 */
public String getText()
{
  try
  {
    return document.getText(0,document.getLength());
  }
  catch(BadLocationException bl)
  {
    bl.printStackTrace();
    return null;
  }
}
origin: nativelibs4java/JNAerator

String noWordSep = (String)textArea.getDocument().getProperty("noWordSep");
caret = TextUtilities.findWordEnd(lineText,caret,noWordSep);
textArea.getDocument().remove(start,
  (caret + lineStart) - start);
origin: com.nativelibs4java/jnaerator

sourceArea.getDocument().addDocumentListener(new SimpleDocumentAdapter() {
  @Override
  public void updated(DocumentEvent e) {
origin: nativelibs4java/JNAerator

.getDocument().getProperty(
PlainDocument.tabSizeAttribute)).intValue();
  .getTokenMarker();
int x = textArea.getHorizontalOffset();
origin: nativelibs4java/JNAerator

/**
 * Reparses the document, by passing the specified lines to the
 * token marker. This should be called after a large quantity of
 * text is first inserted.
 * @param start The first line to parse
 * @param len The number of lines, after the first one to parse
 */
public void tokenizeLines(int start, int len)
{
  if(tokenMarker == null || !tokenMarker.supportsMultilineTokens())
    return;
  Segment lineSegment = new Segment();
  Element map = getDefaultRootElement();
  len += start;
  try
  {
    for(int i = start; i < len; i++)
    {
      Element lineElement = map.getElement(i);
      int lineStart = lineElement.getStartOffset();
      getText(lineStart,lineElement.getEndOffset()
        - lineStart - 1,lineSegment);
      tokenMarker.markTokens(lineSegment,i);
    }
  }
  catch(BadLocationException bl)
  {
    bl.printStackTrace();
  }
}
origin: nativelibs4java/JNAerator

char ch = lineText.charAt(Math.max(0,offset - 1));
String noWordSep = (String)document.getProperty("noWordSep");
if(noWordSep == null)
  noWordSep = "";
origin: nativelibs4java/JNAerator

/**
 * Copies the specified substring of the document into a segment.
 * If the offsets are invalid, the segment will contain a null string.
 * @param start The start offset
 * @param len The length of the substring
 * @param segment The segment
 */
public final void getText(int start, int len, Segment segment)
{
  try
  {
    document.getText(start,len,segment);
  }
  catch(BadLocationException bl)
  {
    bl.printStackTrace();
    segment.offset = segment.count = 0;
  }
}
origin: nativelibs4java/JNAerator

/**
 * Returns the length of the document. Equivalent to calling
 * <code>getDocument().getLength()</code>.
 */
public final int getDocumentLength()
{
  return document.getLength();
}
origin: nativelibs4java/JNAerator

/**
 * Returns the document's token marker. Equivalent to calling
 * <code>getDocument().getTokenMarker()</code>.
 */
public final TokenMarker getTokenMarker()
{
  return document.getTokenMarker();
}
origin: nativelibs4java/JNAerator

DEFAULTS.document = new SyntaxDocument();
DEFAULTS.editable = true;
origin: nativelibs4java/JNAerator

painter.invalidateLineRange(newStartLine,newEndLine);
document.addUndoableEdit(new CaretUndo(
  selectionStart,selectionEnd));
origin: nativelibs4java/JNAerator

/**
 * Sets the token marker that is to be used to split lines of
 * this document up into tokens. May throw an exception if
 * this is not supported for this type of document.
 * @param tm The new token marker
 */
public void setTokenMarker(TokenMarker tm)
{
  tokenMarker = tm;
  if(tm == null)
    return;
  tokenMarker.insertLines(0,getDefaultRootElement()
    .getElementCount());
  tokenizeLines();
}
origin: nativelibs4java/JNAerator

String noWordSep = (String)textArea.getDocument().getProperty("noWordSep");
caret = TextUtilities.findWordStart(lineText,caret,noWordSep);
textArea.getDocument().remove(
    caret + lineStart,
    start - (caret + lineStart));
origin: nativelibs4java/JNAerator

sourceArea.getDocument().addDocumentListener(new SimpleDocumentAdapter() {
  @Override
  public void updated(DocumentEvent e) {
origin: nativelibs4java/JNAerator

  public void actionPerformed(ActionEvent evt)
  {
    JEditTextArea textArea = getTextArea(evt);
    int caret = textArea.getCaretPosition();
    int line = textArea.getCaretLine();
    int lineStart = textArea.getLineStartOffset(line);
    caret -= lineStart;
    String lineText = textArea.getLineText(textArea
      .getCaretLine());
    if(caret == lineText.length())
    {
      if(lineStart + caret == textArea.getDocumentLength())
      {
        textArea.getToolkit().beep();
        return;
      }
      caret++;
    }
    else
    {
      String noWordSep = (String)textArea.getDocument().getProperty("noWordSep");
      caret = TextUtilities.findWordEnd(lineText,caret,noWordSep);
    }
    if(select)
      textArea.select(textArea.getMarkPosition(),
        lineStart + caret);
    else
      textArea.setCaretPosition(lineStart + caret);
  }
}
origin: nativelibs4java/JNAerator

/**
 * Returns the specified substring of the document.
 * @param start The start offset
 * @param len The length of the substring
 * @return The substring, or null if the offsets are invalid
 */
public final String getText(int start, int len)
{
  try
  {
    return document.getText(start,len);
  }
  catch(BadLocationException bl)
  {
    bl.printStackTrace();
    return null;
  }
}
com.ochafik.swing.syntaxcoloringSyntaxDocument

Javadoc

A document implementation that can be tokenized by the syntax highlighting system.

Most used methods

  • addDocumentListener
  • <init>
  • addUndoableEdit
    Adds an undoable edit to this document's undo list. The edit should be ignored if something is curre
  • beginCompoundEdit
    Starts a compound edit that can be undone in one operation. Subclasses that implement undo should ov
  • endCompoundEdit
    Ends a compound edit that can be undone in one operation. Subclasses that implement undo should over
  • getDefaultRootElement
  • getLength
  • getProperty
  • getText
  • getTokenMarker
    Returns the token marker that is to be used to split lines of this document up into tokens. May retu
  • insertString
  • remove
  • insertString,
  • remove,
  • removeDocumentListener,
  • setTokenMarker,
  • tokenizeLines

Popular in Java

  • Start an intent from android
  • getApplicationContext (Context)
  • runOnUiThread (Activity)
  • getSharedPreferences (Context)
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • JFrame (javax.swing)
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now