/** * Checks if the given line exists in this document. * * @param line The line to check * @return true if the line was found in the document, false otherwise */ private boolean doesLineExist(Object line) { int count = doc.getDefaultRootElement().getElementCount(); for (int i=0;i<count;i++) { if (doc.getDefaultRootElement().getElement(i) == line) { return true; } } return false; }
/** * Initializes the document. * * @param props the properties to obtain the setup from */ public SyntaxDocument(Properties props) { m_Self = this; m_RootElement = m_Self.getDefaultRootElement(); m_Keywords = new HashMap<String, MutableAttributeSet>(); m_FontSize = DEFAULT_FONT_SIZE; m_FontName = DEFAULT_FONT_FAMILY; putProperty(DefaultEditorKit.EndOfLineStringProperty, "\n"); setup(props); }
/** * Initializes the document. * * @param props the properties to obtain the setup from */ public SyntaxDocument(Properties props) { m_Self = this; m_RootElement = m_Self.getDefaultRootElement(); m_Keywords = new HashMap<String, MutableAttributeSet>(); m_FontSize = DEFAULT_FONT_SIZE; m_FontName = DEFAULT_FONT_FAMILY; putProperty(DefaultEditorKit.EndOfLineStringProperty, "\n"); setup(props); }
/** * Searches the Document for all lines by the given user. * * @param nick * @return */ private ArrayList<Integer> getLinesFromUser(User user, String id, boolean onlyUserMessages) { Element root = doc.getDefaultRootElement(); ArrayList<Integer> result = new ArrayList<>(); for (int i=0;i<root.getElementCount();i++) { Element line = root.getElement(i); if (isLineFromUserAndId(line, user, id, onlyUserMessages)) { result.add(i); } } return result; }
/** * Removes some chat lines from the top, depending on the current * scroll position. */ private void clearSomeChat() { if (scrollManager.fixedChat) { return; } if (!scrollManager.isScrollPositionNearEnd()) { return; } int count = doc.getDefaultRootElement().getElementCount(); int max = styles.bufferSize(); if (count > max) { removeFirstLines(2); } }
private java.util.List<Userline> getUserLines(User searchUser) { java.util.List<Userline> result = new ArrayList<>(); Element root = doc.getDefaultRootElement(); for (int i = root.getElementCount() - 1; i >= 0; i--) { Element line = root.getElement(i); Element userElement = getUserElementFromLine(line, false); if (userElement != null) { User foundUser = (User)userElement.getAttributes().getAttribute(Attribute.USER); if (searchUser == null || foundUser == searchUser) { result.add(new Userline(searchUser, userElement, line)); } } } return result; }
public void removeOldLines() { if (messageTimeout > 0) { Element paragraph = doc.getDefaultRootElement().getElement(0); if (doc.getLength() > 1 && getTimeAgo(paragraph) > messageTimeout * 1000) { // removeFirstLines(1); // Don't use doc.remove() for this, since removing one line with // it seems to copy paragraph attributes to the follow line // (visible if alternating backgrounds are showing) if (doc.getDefaultRootElement().getElementCount() > 1) { // Can't use this if it's the last element doc.removeElement(doc.getDefaultRootElement().getElement(0)); } else { clearAll(); } scrollDownIfNecessary(); resetNewlineRequired(); } } }
int count = doc.getDefaultRootElement().getElementCount(); if (currentSelection != null && !doesLineExist(currentSelection)) { currentSelection = null; Element element = doc.getDefaultRootElement().getElement(i); User user = getUserFromLine(element); if (element == currentSelection) {
/** * Remove text from chat, while also handling Emotes in the removed section * correctly. * * @param start Start offset * @param len Length of section to remove * @throws BadLocationException */ private void remove(int start, int len) throws BadLocationException { Debugging.edt(); int startLine = doc.getDefaultRootElement().getElementIndex(start); int endLine = doc.getDefaultRootElement().getElementIndex(start+len); Set<Long> before = Util.getImageIds(doc, startLine, endLine); doc.remove(start, len); if (!before.isEmpty()) { Set<Long> after = Util.getImageIds(doc, startLine, endLine); if (Debugging.isEnabled("gifd", "gifd2")) { Debugging.println(String.format("Removed %d+%d (Before: %s After: %s)", start, len, before, after)); } before.removeAll(after); for (long id : before) { kit.clearImage(id); } } }
/** * Try to select the given line. Only selects chat messages. Also * selects all other messages in the buffer from the same user and * unselects any previously selected. * * @param line The line to select * @return true if the line was selected (if it is a chat message), * false otherwise */ private boolean select(Element line) { if (isMessageLine(line)) { User user = getUserFromLine(line); clearSearchResult(); highlightLine(line, true); currentSelection = line; currentUser = user; ArrayList<Integer> lines = getLinesFromUser(user, null, true); for (Integer lineNumber : lines) { Element otherLine = doc.getDefaultRootElement().getElement(lineNumber); if (otherLine != currentSelection) { highlightLine(otherLine, false); } } return true; } return false; }
amount = 1; if (doc.getDefaultRootElement().getElementCount() == 0) { return; Element firstToRemove = doc.getDefaultRootElement().getElement(0); Element lastToRemove = doc.getDefaultRootElement().getElement(amount - 1);
int count = doc.getDefaultRootElement().getElementCount(); if (lastSearchPos != null && !doesLineExist(lastSearchPos)) { Element element = doc.getDefaultRootElement().getElement(i); if (element == lastSearchPos) {
Element root = doc.getDefaultRootElement(); for (int i = 0; i < root.getElementCount(); i++) { Element paragraph = root.getElement(i);
Element root = doc.getDefaultRootElement(); for (int i=root.getElementCount()-1;i>=0;i--) { Element line = root.getElement(i);
rootElement = doc.getDefaultRootElement(); putProperty( DefaultEditorKit.EndOfLineStringProperty, "\n" );
BranchElement rootElement = (BranchElement) getDefaultRootElement();
private boolean printModLogInfo(ModLogInfo info) { Element root = doc.getDefaultRootElement(); String command = info.makeCommand().trim(); Debugging.println("modlog", "ModLog Command: %s", command);