当前位置: 首页>>代码示例>>Java>>正文


Java RSyntaxUtilities类代码示例

本文整理汇总了Java中org.fife.ui.rsyntaxtextarea.RSyntaxUtilities的典型用法代码示例。如果您正苦于以下问题:Java RSyntaxUtilities类的具体用法?Java RSyntaxUtilities怎么用?Java RSyntaxUtilities使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RSyntaxUtilities类属于org.fife.ui.rsyntaxtextarea包,在下文中一共展示了RSyntaxUtilities类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: actionPerformed

import org.fife.ui.rsyntaxtextarea.RSyntaxUtilities; //导入依赖的package包/类
public void actionPerformed(ActionEvent e) {

			RSyntaxTextArea textArea = (RSyntaxTextArea)getTextComponent(e);
			RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument();
			Caret c = textArea.getCaret();

			int dot = c.getDot(); // Get before "<" insertion
			boolean selection = dot!=c.getMark(); // Me too
			textArea.replaceSelection(">");

			// Don't automatically complete a tag if there was a selection
			if (!selection && getAutoAddClosingTags()) {

				Token t = doc.getTokenListForLine(textArea.getCaretLineNumber());
				t = RSyntaxUtilities.getTokenAtOffset(t, dot);
				if (t!=null && t.isSingleChar(Token.MARKUP_TAG_DELIMITER, '>')) {
					String tagName = discoverTagName(doc, dot);
					if (tagName!=null) {
						textArea.replaceSelection("</" + tagName + ">");
						textArea.setCaretPosition(dot+1);
					}
				}

			}

		}
 
开发者ID:pyros2097,项目名称:GdxStudio,代码行数:27,代码来源:AbstractMarkupLanguageSupport.java

示例2: getDescription

import org.fife.ui.rsyntaxtextarea.RSyntaxUtilities; //导入依赖的package包/类
private static String getDescription(BufferedReader r) throws IOException {
	StringBuffer desc = new StringBuffer();
	String line = null;
	while ((line=r.readLine())!=null) {
		if (line.startsWith(" *")) {
			int nextSpace = line.indexOf(' ', 1);
			line = line.substring(nextSpace+1).trim();
			desc.append(line).append(' ');
		}
		else {
			break;
		}
	}
	String temp = desc.toString();
	if (temp.startsWith("<html>")) {
		return temp.substring("<html>".length());
	}
	return RSyntaxUtilities.escapeForHtml(temp, "<br>", false);
}
 
开发者ID:bobbylight,项目名称:ZScriptLanguageSupport,代码行数:20,代码来源:CodeCompletionLoader.java

示例3: LineNumberList

import org.fife.ui.rsyntaxtextarea.RSyntaxUtilities; //导入依赖的package包/类
/**
 * Constructs a new <code>LineNumberList</code>.
 *
 * @param textArea The text component for which line numbers will be
 *        displayed.
 * @param numberColor The color to use for the line numbers.  If this is
 *        <code>null</code>, gray will be used.
 */
public LineNumberList(RTextArea textArea, Color numberColor) {

	super(textArea);

	if (numberColor!=null) {
		setForeground(numberColor);
	}
	else {
		setForeground(Color.GRAY);
	}

	// Initialize currentLine; otherwise, the current line won't start
	// off as highlighted.
	currentLine = 0;
	setLineNumberingStartIndex(1);

	visibleRect = new Rectangle(); // Must be initialized

	addMouseListener(this);
	addMouseMotionListener(this);

	aaHints = RSyntaxUtilities.getDesktopAntiAliasHints();

}
 
开发者ID:Nanonid,项目名称:RSyntaxTextArea,代码行数:33,代码来源:LineNumberList.java

示例4: paintEnabledText

import org.fife.ui.rsyntaxtextarea.RSyntaxUtilities; //导入依赖的package包/类
@Override
protected void paintEnabledText(JLabel l, Graphics g, String s, 
		int textX, int textY) {
	XmlTreeCellRenderer r = (XmlTreeCellRenderer)l;
	Graphics2D g2d = (Graphics2D)g;
	Map<?,?> hints = RSyntaxUtilities.getDesktopAntiAliasHints();
	if (hints!=null) {
		g2d.addRenderingHints(hints);
	}
	g2d.setColor(l.getForeground());
	g2d.drawString(r.elem, textX, textY);
	if (r.attr!=null) {
		textX += g2d.getFontMetrics().stringWidth(r.elem + " ");
		if (!r.selected) {
			g2d.setColor(ATTR_COLOR);
		}
		g2d.drawString(r.attr, textX, textY);
	}
	g2d.dispose();
}
 
开发者ID:bobbylight,项目名称:RSTALanguageSupport,代码行数:21,代码来源:XmlTreeCellRenderer.java

示例5: getReplacementText

import org.fife.ui.rsyntaxtextarea.RSyntaxUtilities; //导入依赖的package包/类
@Override
protected String getReplacementText(Completion c, Document doc,
		int start, int len) {
	
	String replacement = super.getReplacementText(c, doc, start, len);
	if(c instanceof JavaScriptShorthandCompletion)
	{
		try
		{
			int caret = textArea.getCaretPosition();
			String leadingWS = RSyntaxUtilities.getLeadingWhitespace(doc, caret);
			if (replacement.indexOf('\n')>-1) {
				replacement = replacement.replaceAll("\n", "\n" + leadingWS);
			}
			
		}
		catch(BadLocationException ble){}
	}
	return replacement;
}
 
开发者ID:bobbylight,项目名称:RSTALanguageSupport,代码行数:21,代码来源:JavaScriptLanguageSupport.java

示例6: actionPerformedImpl

import org.fife.ui.rsyntaxtextarea.RSyntaxUtilities; //导入依赖的package包/类
@Override
public void actionPerformedImpl(ActionEvent e, RTextArea textArea) {
	Gutter gutter = RSyntaxUtilities.getGutter(textArea);
	if (gutter!=null) {
		int line = textArea.getCaretLineNumber();
		try {
			gutter.toggleBookmark(line);
		} catch (BadLocationException ble) { // Never happens
			UIManager.getLookAndFeel().
						provideErrorFeedback(textArea);
			ble.printStackTrace();
		}
	}
}
 
开发者ID:curiosag,项目名称:ftc,代码行数:15,代码来源:RTextAreaEditorKit.java

示例7: invoke

import org.fife.ui.rsyntaxtextarea.RSyntaxUtilities; //导入依赖的package包/类
/**
 * Invokes this code template.  The changes are made to the given text
 * area.
 *
 * @param textArea The text area to operate on.
 * @throws BadLocationException If something bad happens.
 */
public void invoke(RSyntaxTextArea textArea) throws BadLocationException {

	Caret c = textArea.getCaret();
	int dot = c.getDot();
	int mark = c.getMark();
	int p0 = Math.min(dot, mark);
	int p1 = Math.max(dot, mark);
	RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument();
	Element map = doc.getDefaultRootElement();

	int lineNum = map.getElementIndex(dot);
	Element line = map.getElement(lineNum);
	int start = line.getStartOffset();
	int end = line.getEndOffset()-1; // Why always "-1"?
	String s = textArea.getText(start,end-start);
	int len = s.length();

	// endWS is the end of the leading whitespace
	// of the current line.
	int endWS = 0;
	while (endWS<len && RSyntaxUtilities.isWhitespace(s.charAt(endWS))) {
		endWS++;
	}
	s = s.substring(0, endWS);
	p0 -= getID().length();
	String beforeText = getBeforeTextIndented(s);
	String afterText = getAfterTextIndented(s);
	doc.replace(p0,p1-p0, beforeText+afterText, null);
	textArea.setCaretPosition(p0+beforeText.length());

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:39,代码来源:StaticCodeTemplate.java

示例8: invoke

import org.fife.ui.rsyntaxtextarea.RSyntaxUtilities; //导入依赖的package包/类
/**
 * Invokes this code template. The changes are made to the given text area.
 * 
 * @param textArea
 *            The text area to operate on.
 * @throws BadLocationException
 *             If something bad happens.
 */
public void invoke(RSyntaxTextArea textArea) throws BadLocationException {

    Caret c = textArea.getCaret();
    int dot = c.getDot();
    int mark = c.getMark();
    int p0 = Math.min(dot, mark);
    int p1 = Math.max(dot, mark);
    RSyntaxDocument doc = (RSyntaxDocument) textArea.getDocument();
    Element map = doc.getDefaultRootElement();

    int lineNum = map.getElementIndex(dot);
    Element line = map.getElement(lineNum);
    int start = line.getStartOffset();
    int end = line.getEndOffset() - 1; // Why always "-1"?
    String s = textArea.getText(start, end - start);
    int len = s.length();

    // endWS is the end of the leading whitespace
    // of the current line.
    int endWS = 0;
    while (endWS < len && RSyntaxUtilities.isWhitespace(s.charAt(endWS))) {
        endWS++;
    }
    s = s.substring(0, endWS);
    p0 -= getID().length();
    String beforeText = getBeforeTextIndented(s);
    String afterText = getAfterTextIndented(s);
    doc.replace(p0, p1 - p0, beforeText + afterText, null);
    textArea.setCaretPosition(p0 + beforeText.length());

}
 
开发者ID:intuit,项目名称:Tank,代码行数:40,代码来源:StaticCodeTemplate.java

示例9: checkStringLiteralMember

import org.fife.ui.rsyntaxtextarea.RSyntaxUtilities; //导入依赖的package包/类
/**
 * Checks whether the user is typing a completion for a String member after
 * a String literal.
 *
 * @param comp The text component.
 * @param alreadyEntered The text already entered.
 * @param cu The compilation unit being parsed.
 * @param set The set to add possible completions to.
 * @return Whether the user is indeed typing a completion for a String
 *         literal member.
 */
private boolean checkStringLiteralMember(JTextComponent comp,
										String alreadyEntered,
										CompilationUnit cu, Set set) {

	boolean stringLiteralMember = false;

	int offs = comp.getCaretPosition() - alreadyEntered.length() - 1;
	if (offs>1) {
		RSyntaxTextArea textArea = (RSyntaxTextArea)comp;
		RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument();
		try {
			//System.out.println(doc.charAt(offs) + ", " + doc.charAt(offs+1));
			if (doc.charAt(offs)=='"' && doc.charAt(offs+1)=='.') {
				int curLine = textArea.getLineOfOffset(offs);
				Token list = textArea.getTokenListForLine(curLine);
				Token prevToken = RSyntaxUtilities.getTokenAtOffset(list, offs);
				if (prevToken!=null &&
						prevToken.getType()==Token.LITERAL_STRING_DOUBLE_QUOTE) {
					ClassFile cf = getClassFileFor(cu, "java.lang.String");
					addCompletionsForExtendedClass(set, cu, cf,
												cu.getPackageName(), null);
					stringLiteralMember = true;
				}
				else {
					System.out.println(prevToken);
				}
			}
		} catch (BadLocationException ble) { // Never happens
			ble.printStackTrace();
		}
	}

	return stringLiteralMember;

}
 
开发者ID:pyros2097,项目名称:GdxStudio,代码行数:47,代码来源:SourceCompletionProvider.java

示例10: filter

import org.fife.ui.rsyntaxtextarea.RSyntaxUtilities; //导入依赖的package包/类
/**
 * Filters visible tree nodes based on the specified prefix.
 *
 * @param pattern The prefix, as a wildcard expression.  If this is
 *        <code>null</code>, all possible children are shown.
 */
public void filter(String pattern) {
	if ((pattern==null && this.pattern!=null) ||
			(pattern!=null && this.pattern==null) ||
			(pattern!=null && !pattern.equals(this.pattern.pattern()))) {
		this.pattern = (pattern==null || pattern.length()==0) ? null :
			RSyntaxUtilities.wildcardToPattern("^" + pattern, false, false);
		Object root = getModel().getRoot();
		if (root instanceof SourceTreeNode) {
			((SourceTreeNode)root).filter(this.pattern);
		}
		((DefaultTreeModel)getModel()).reload();
		expandInitialNodes();
	}
}
 
开发者ID:pyros2097,项目名称:GdxStudio,代码行数:21,代码来源:AbstractSourceTree.java

示例11: gotoElementAtPath

import org.fife.ui.rsyntaxtextarea.RSyntaxUtilities; //导入依赖的package包/类
private void gotoElementAtPath(TreePath path) {
	DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.
												getLastPathComponent();
	Object obj = node.getUserObject();
	if (obj instanceof AbstractNode) {
		AbstractNode astNode = (AbstractNode)obj;
		int start = astNode.getStartOffset();
		int end = astNode.getEndOffset();
		DocumentRange range = new DocumentRange(start, end);
		RSyntaxUtilities.selectAndPossiblyCenter(textArea, range, true);
	}
}
 
开发者ID:bobbylight,项目名称:ZScriptLanguageSupport,代码行数:13,代码来源:ZScriptOutlineTree.java

示例12: actionPerformedImpl

import org.fife.ui.rsyntaxtextarea.RSyntaxUtilities; //导入依赖的package包/类
public void actionPerformedImpl(ActionEvent e, RTextArea textArea) {
	Gutter gutter = RSyntaxUtilities.getGutter(textArea);
	if (gutter!=null) {
		int line = textArea.getCaretLineNumber();
		try {
			gutter.toggleBookmark(line);
		} catch (BadLocationException ble) { // Never happens
			UIManager.getLookAndFeel().
						provideErrorFeedback(textArea);
			ble.printStackTrace();
		}
	}
}
 
开发者ID:Nanonid,项目名称:RSyntaxTextArea,代码行数:14,代码来源:RTextAreaEditorKit.java

示例13: gotoElementAtPath

import org.fife.ui.rsyntaxtextarea.RSyntaxUtilities; //导入依赖的package包/类
private void gotoElementAtPath(TreePath path) {
	DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.
												getLastPathComponent();
	Object obj = node.getUserObject();
	if (obj instanceof ASTNode) {
		ASTNode astNode = (ASTNode)obj;
		int start = astNode.getNameStartOffset();
		int end = astNode.getNameEndOffset();
		DocumentRange range = new DocumentRange(start, end);
		RSyntaxUtilities.selectAndPossiblyCenter(textArea, range, true);
	}
}
 
开发者ID:bobbylight,项目名称:RSTALanguageSupport,代码行数:13,代码来源:JavaOutlineTree.java

示例14: checkStringLiteralMember

import org.fife.ui.rsyntaxtextarea.RSyntaxUtilities; //导入依赖的package包/类
/**
 * Checks whether the user is typing a completion for a String member after
 * a String literal.
 *
 * @param comp The text component.
 * @param alreadyEntered The text already entered.
 * @param cu The compilation unit being parsed.
 * @param set The set to add possible completions to.
 * @return Whether the user is indeed typing a completion for a String
 *         literal member.
 */
private boolean checkStringLiteralMember(JTextComponent comp,
						String alreadyEntered,
						CompilationUnit cu, Set<Completion> set) {

	boolean stringLiteralMember = false;

	int offs = comp.getCaretPosition() - alreadyEntered.length() - 1;
	if (offs>1) {
		RSyntaxTextArea textArea = (RSyntaxTextArea)comp;
		RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument();
		try {
			//System.out.println(doc.charAt(offs) + ", " + doc.charAt(offs+1));
			if (doc.charAt(offs)=='"' && doc.charAt(offs+1)=='.') {
				int curLine = textArea.getLineOfOffset(offs);
				Token list = textArea.getTokenListForLine(curLine);
				Token prevToken = RSyntaxUtilities.getTokenAtOffset(list, offs);
				if (prevToken!=null &&
						prevToken.getType()==Token.LITERAL_STRING_DOUBLE_QUOTE) {
					ClassFile cf = getClassFileFor(cu, "java.lang.String");
					addCompletionsForExtendedClass(set, cu, cf,
												cu.getPackageName(), null);
					stringLiteralMember = true;
				}
				else {
					System.out.println(prevToken);
				}
			}
		} catch (BadLocationException ble) { // Never happens
			ble.printStackTrace();
		}
	}

	return stringLiteralMember;

}
 
开发者ID:bobbylight,项目名称:RSTALanguageSupport,代码行数:47,代码来源:SourceCompletionProvider.java

示例15: gotoElementAtPath

import org.fife.ui.rsyntaxtextarea.RSyntaxUtilities; //导入依赖的package包/类
private void gotoElementAtPath(TreePath path) {
	Object node = path.getLastPathComponent();
	if (node instanceof XmlTreeNode) {
		XmlTreeNode xtn = (XmlTreeNode)node;
		DocumentRange range = new DocumentRange(xtn.getStartOffset(),
				xtn.getEndOffset());
		RSyntaxUtilities.selectAndPossiblyCenter(textArea, range, true);
	}
}
 
开发者ID:bobbylight,项目名称:RSTALanguageSupport,代码行数:10,代码来源:XmlOutlineTree.java


注:本文中的org.fife.ui.rsyntaxtextarea.RSyntaxUtilities类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。