Hi,
i am trying to implement an editor for the syntax scheme. Any hints how I can connect to a style of a selected character?
thanks
best
Roland
Moderator: robert
int type = 0;
int line = textArea.getCaretLineNumber();
Token t = textArea.getTokenListForLine(line);
t = RSyntaxUtilities.getTokenAtOffset(t, textArea.getCaretPosition());
if (t!=null) { // Should always be true
type = t.type;
}
Style style = textArea.getSyntaxScheme().styles[type];
int offs = textArea.viewToModel(e.getPoint());
BTW: why not making SyntaxScheme serializable? Or do you already have some serializing mechanism for syntax schemes?
public static SyntaxScheme loadFromString(String string);
public String toCommaSeparatedString();
public static SyntaxScheme load(Font baseFont, InputStream in) throws IOException;
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Syntax scheme that mimics Eclipse's defaults.
-->
<SyntaxScheme>
<styles>
<style token="IDENTIFIER" fg="#000000"/>
<style token="RESERVED_WORD" fg="#7f0055"/>
<style token="COMMENT_EOL" fg="#3f7f5f"/>
<style token="COMMENT_MULTILINE" fg="#3f7f5f"/>
<style token="COMMENT_DOCUMENTATION" fg="#3f5fbf"/>
<style token="VARIABLE" fg="#ae9fbf"/>
<style token="DATA_TYPE" fg="#7f007f" bold="true"/>
</styles>
</SyntaxScheme>
Users browsing this forum: Google [Bot] and 0 guests