org.fife.ui.rsyntaxtextarea.folding.LatexFoldParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rsyntaxtextarea Show documentation
Show all versions of rsyntaxtextarea Show documentation
RSyntaxTextArea is the syntax highlighting text editor for Swing applications. Features include syntax highlighting for 40+ languages, code folding, code completion, regex find and replace, macros, code templates, undo/redo, line numbering and bracket matching.
/*
* 04/24/2012
*
* LatexFoldParser.java - Fold parser for LaTeX.
*
* This library is distributed under a modified BSD license. See the included
* RSyntaxTextArea.License.txt file for details.
*/
package org.fife.ui.rsyntaxtextarea.folding;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
import javax.swing.text.BadLocationException;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.fife.ui.rsyntaxtextarea.Token;
/**
* A fold parser for LaTeX documents. This is likely incomplete and/or not
* quite right; feedback is appreciated.
*
* @author Robert Futrell
* @version 1.0
*/
public class LatexFoldParser implements FoldParser {
private static final char[] BEGIN = "\\begin".toCharArray();
private static final char[] END = "\\end".toCharArray();
/**
* {@inheritDoc}
*/
@Override
public List getFolds(RSyntaxTextArea textArea) {
List folds = new ArrayList();
Stack expectedStack = new Stack();
Fold currentFold = null;
int lineCount = textArea.getLineCount();
try {
for (int line=0; line