use of javax.swing.text.Element in project binnavi by google.
the class ConsoleCodeDocument method setCurrentLine.
/**
* Insert a line in the text element containing the passed position skipping a number of character
* from the beginning of the element. The function of the skipping of characters is to "jump" over
* the prompt in the beginning of a line.
*
* @param pos the position from which to retrieve the element that contains it
* @param skip how many characters are skipped from the beginning of the element when inserting
* the string
* @param line the line to insert
*/
public void setCurrentLine(final int pos, final int skip, final String line) {
final Element element = getParagraphElement(pos);
final int start = element.getStartOffset();
final int end = element.getEndOffset();
try {
remove(start + skip, end - (start + skip + 1));
super.insertString(start + skip, line, normal);
} catch (final BadLocationException e) {
System.out.println("Bad location!");
e.printStackTrace();
}
}
use of javax.swing.text.Element in project binnavi by google.
the class ConsoleHelpers method getCurrentLine.
/**
* Get the text of the element containing the given position.
*
* @param pos the global document position at which to find the element containing it.
* @return the text contained within the element
*/
public String getCurrentLine(final int pos) {
final Element element = document.getParagraphElement(pos);
String line = "";
try {
line = document.getText(element.getStartOffset(), element.getEndOffset() - element.getStartOffset());
} catch (final BadLocationException e) {
System.out.println("Bad location!");
e.printStackTrace();
}
return line;
}
use of javax.swing.text.Element in project binnavi by google.
the class TextHelpers method getLineAtCaret.
public static int getLineAtCaret(final JTextComponent component) {
final int caretPosition = component.getCaretPosition();
final Element root = component.getDocument().getDefaultRootElement();
return root.getElementIndex(caretPosition) + 1;
}
use of javax.swing.text.Element in project android-classyshark by google.
the class BatchDocument method appendBatchLineFeed.
public void appendBatchLineFeed(AttributeSet a) {
batch.add(new ElementSpec(a, ElementSpec.ContentType, EOL_ARRAY, 0, 1));
Element paragraph = getParagraphElement(0);
AttributeSet pattern = paragraph.getAttributes();
batch.add(new ElementSpec(null, ElementSpec.EndTagType));
batch.add(new ElementSpec(pattern, ElementSpec.StartTagType));
}
use of javax.swing.text.Element in project languagetool by languagetool-org.
the class ResultAreaHelper method appendMain.
private void appendMain(String html) {
HTMLDocument d = (HTMLDocument) statusPane.getDocument();
Element e = d.getElement(MAIN);
try {
d.insertBeforeEnd(e, html);
} catch (BadLocationException ex) {
Tools.showError(ex);
} catch (IOException ex) {
Tools.showError(ex);
}
}
Aggregations