libjsyntaxpane-java-0.9.6~r156/0000755000175000017500000000000012127321547017202 5ustar sylvestresylvestrelibjsyntaxpane-java-0.9.6~r156/nbactions.xml0000644000175000017500000000330212127321547021702 0ustar sylvestresylvestre run process-classes org.codehaus.mojo:exec-maven-plugin:1.1:exec -classpath %classpath jsyntaxpane.SyntaxTester java debug process-classes org.codehaus.mojo:exec-maven-plugin:1.1:exec -Xdebug -Djava.compiler=none -Xnoagent -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath jsyntaxpane.SyntaxTester true java profile jar process-classes org.codehaus.mojo:exec-maven-plugin:1.1:exec ${profiler.args} -classpath %classpath jsyntaxpane.SyntaxTester profile ${profiler.java} libjsyntaxpane-java-0.9.6~r156/CHANGELOG.txt0000644000175000017500000001144012127321547021232 0ustar sylvestresylvestreVersion 0.9.5 - Java Reflection Completions additions * Configuration class overhaul. Each kit now has its own COnfiguration file which merges the superclass(es) Configurations. * Usable Reflect Completions Dialog (Java with F1 or Menu) * Java ENTER key responds properly to multi line comments * Font can be changed for each Kit * Kits for XHTML and Xpath added. XHTML has a simple Preview Action. * Added Execute Script to JacaScript (can also be used for Groovy if Groovy Scripting support is installed properly). * Hotkeys for actions are displayed in Popup Menus * Word Completion action can also do CamelCase matches * Smart Home Action (and Smart Home Extend Selection) * Enhanced JavaScript support. Issue 115 * Better Undo grouping * Replace DIalog ENhancement. Only for updatedable editors and added single replace. * Added append method to SyntaxDocument * Fixed Issue 130 - Compound Undo on multiple lines. Version 0.9.4 - IntelliSense additions * Adding IntelliSense to Java with simple List of selectable keywords * Added Toggle Comment Actions using Control SLASH * Fixed Issue 47. * Added Clojure, Scala, DOS Batch and 'nix bash support * Added Configurable Popup menus with default Tango Desktop icons * Added configurable format for the CaretMonitor class * Toggle Comments Action selects the lines affected after being performed * Added multi-line support in ActionUtils.insertMagicSTring method. * GotoLine dialog responds to ESC key Version 0.9.3 - Start of scripts for the document: * Added new methods getLine() to SyntaxDocument * SyntaxDocument getIndexOf methods deprecated, use getMatchers instead * Added Line Numbering to Java * Added CaretMonitor Class * Merged Find And Replace dialogs into one. * Created SyntaxComponent interface and have all UI components implement that interface. DefaultSyntaxKit will use config.properties class to dynamically install these components. * Added Right Margin option and Single Color Selection Options * Added Python, C and C++ Support * Added Ruby Syntax Support * Fixed Issue 37 (NPE for LineNumbersRuler) * Fixed Issue 39 (Highlighting Tokens overrides selection highlights) * Fixed some JavaDoc comments. * Fixed Line Numbers being displayed for the height of the editor and now just for the actual available lines. * Fixed Margin typo in all project. Issue 43 * Changing Actions to be more configurable: * SyntaxActions renamed to ActionUtils * Removed all inner classes from SyntaxActions * Will create new SyntaxAction interface that will allow dynamic addition actions (in the addKeyActions of DefaultSyntaxKit * Added Text AA property to SyntaxView Version 0.9.2: * Fixing Java Indentation and Un-Indentattion Actions * Added and used (in the Tester) clearUndoes on the SyntaxDocument * Added Basic JFlex Syntax * Added getContentTypes to DefaultSyntaxKit to get all registered ContentTypes. This is now also used in the SyntaxTester instead of hardcoding the types. * Cleanup and optimization of Lexers by removing duplicate Java Code (replaced with Regex OR) * Removed calls to deprecated calls in SyntaxView * Modified the SyntaxDOcument to override the fireXXX methods and parse the document at that time instead of overriding the inserUpdate method. This fixes issue 24. * Added Groovy GString expression highlights * Removed getLanguages method from Lexer interface and implementations. * Added WARNING and ERROR TokenTypes and added their default styles. * Moved Keymaps and install methods to SyntaxKits instead of the Lexers * Removed deprecated methods from SyntaxActions class * Split SyntaxActions into new package and moved inner classes to the new package * Added Token HighLighter to Java * Added Pairs Highlighter to Java * Token class made immutable (all final fields) * Added Find and Replace Dialogs and Action to Java (mapped to C-F and C-H ) * Added pair matching to XML tags * Added CDATA matching and pair highlights for XML * Added Comment Pair Highlighting in XML * Fixed highlighting with selections so the selection always appears * Merged Find and Replace Dialogs into one * Fixed issue 33 (undable to add new line after final closing brace for Java) * Added Groovy Multi-Line strings and fixed Comments as Regex issue. * Fixes to empty find text field causing NPE Version 0.9.1 * Fixed empty strings in XML syntax Issue 29 * Fixed TAL lexer using incorrect package name Version 0.9.0 * Initial version after major overhaullibjsyntaxpane-java-0.9.6~r156/pom.xml0000644000175000017500000000517212127321547020524 0ustar sylvestresylvestre 4.0.0 jsyntaxpane jsyntaxpane jar 0.9.6 jsyntaxpane A very simple to use and extend JEditorKit that supports few languages. The main goal is to make it easy to have nice looking Java Swing Editors with support for Syntax Highlighting. http://jsyntaxpane.googlecode.com/ The Apache Software License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0 repo http://jsyntaxpane.googlecode.com/svn/ jflex JFlex repository http://jflex.sourceforge.net/repo/ maven-compiler-plugin 2.3 1.6 1.6 org.apache.maven.plugins maven-jar-plugin **/Thumbs.db jsyntaxpane.SyntaxTester jsyntaxpane true development ${pom.url} de.jflex maven-jflex-plugin generate UTF-8 libjsyntaxpane-java-0.9.6~r156/src/0000755000175000017500000000000012127321546017770 5ustar sylvestresylvestrelibjsyntaxpane-java-0.9.6~r156/src/main/0000755000175000017500000000000012127321547020715 5ustar sylvestresylvestrelibjsyntaxpane-java-0.9.6~r156/src/main/jflex/0000755000175000017500000000000012127321546022024 5ustar sylvestresylvestrelibjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/0000755000175000017500000000000012127321546024370 5ustar sylvestresylvestrelibjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/0000755000175000017500000000000012127321547025673 5ustar sylvestresylvestrelibjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/lua.flex0000644000175000017500000002253012127321547027336 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.lexers; import jsyntaxpane.Token; import jsyntaxpane.TokenType; %% %public %class LuaLexer %extends DefaultJFlexLexer %final %unicode %char %type Token %{ /** * Create an empty lexer, yyrset will be called later to reset and assign * the reader */ public LuaLexer() { super(); } @Override public int yychar() { return yychar; } private static final byte PARAN = 1; private static final byte BRACKET = 2; private static final byte CURLY = 3; private static final byte ENDBLOCK = 4; private static final byte REPEATBLOCK = 5; TokenType longType; int longLen; %} /* main character classes */ LineTerminator = \r|\n|\r\n WhiteSpace = {LineTerminator} | [ \t\f]+ LongStart = \[=*\[ LongEnd = \]=*\] /* identifiers */ Identifier = [:jletter:][:jletterdigit:]* /* integer literals */ DecIntegerLiteral = [0-9]+ HexDigit = [0-9a-fA-F] HexIntegerLiteral = 0x{HexDigit}+ /* floating point literals */ DoubleLiteral = ({FLit1}|{FLit2}) {Exponent}? FLit1 = [0-9]+(\.[0-9]*)? FLit2 = \.[0-9]+ Exponent = [eE] [+-]? [0-9]+ /* string and character literals */ StringCharacter1 = [^\r\n\"\\] StringCharacter2 = [^\r\n\'\\] %state STRING1 %state STRING2 %state LONGSTRING %state COMMENT %state LINECOMMENT %% { /* keywords */ "and" | "break" | "for" | "if" | "in" | "local" | "not" | "or" | "return" | "while" | /* boolean literals */ "true" | "false" | /* nil literal */ "nil" { return token(TokenType.KEYWORD); } "repeat" { return token(TokenType.KEYWORD, REPEATBLOCK); } "until" { return token(TokenType.KEYWORD, -REPEATBLOCK); } "function" { return token(TokenType.KEYWORD, ENDBLOCK); } "then" { return token(TokenType.KEYWORD, ENDBLOCK); } "do" { return token(TokenType.KEYWORD, ENDBLOCK); } "else" { return token(TokenType.KEYWORD); } "elseif" { return token(TokenType.KEYWORD); } "end" { return token(TokenType.KEYWORD, -ENDBLOCK); } /* operators */ "+" | "-" | "*" | "/" | "%" | "^" | "#" | "==" | "~=" | "<=" | ">=" | "<" | ">" | "=" | ";" | ":" | "," | "." | ".." | "..." { return token(TokenType.OPERATOR); } "(" { return token(TokenType.OPERATOR, PARAN); } ")" { return token(TokenType.OPERATOR, -PARAN); } "{" { return token(TokenType.OPERATOR, CURLY); } "}" { return token(TokenType.OPERATOR, -CURLY); } "[" { return token(TokenType.OPERATOR, BRACKET); } "]" { return token(TokenType.OPERATOR, -BRACKET); } {LongStart} { longType = TokenType.STRING; yybegin(LONGSTRING); tokenStart = yychar; tokenLength = yylength(); longLen = tokenLength; } "--" { yybegin(COMMENT); tokenStart = yychar; tokenLength = yylength(); } /* string literal */ \" { yybegin(STRING1); tokenStart = yychar; tokenLength = 1; } \' { yybegin(STRING2); tokenStart = yychar; tokenLength = 1; } /* numeric literals */ {DecIntegerLiteral} | {HexIntegerLiteral} | {DoubleLiteral} { return token(TokenType.NUMBER); } /* whitespace */ {WhiteSpace} { } /* identifiers */ {Identifier} { return token(TokenType.IDENTIFIER); } } { {LongEnd} { if (longLen == yylength()) { tokenLength += yylength(); yybegin(YYINITIAL); return token(longType, tokenStart, tokenLength); } else { tokenLength++; yypushback(yylength() - 1); } } {LineTerminator} { tokenLength += yylength(); } . { tokenLength++; } <> { yybegin(YYINITIAL); return token(longType, tokenStart, tokenLength); } } { {LongStart} { longType = TokenType.COMMENT; yybegin(LONGSTRING); tokenLength += yylength(); longLen = yylength(); } {LineTerminator} { yybegin(YYINITIAL); return token(TokenType.COMMENT, tokenStart, tokenLength); } . { yybegin(LINECOMMENT); tokenLength += yylength(); } <> { yybegin(YYINITIAL); return token(TokenType.COMMENT, tokenStart, tokenLength); } } { {LineTerminator} { yybegin(YYINITIAL); tokenLength += yylength(); return token(TokenType.COMMENT, tokenStart, tokenLength); } {LineTerminator} { tokenLength += yylength(); } . { tokenLength++; } <> { yybegin(YYINITIAL); return token(TokenType.COMMENT, tokenStart, tokenLength); } } { \" { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.STRING, tokenStart, tokenLength + 1); } {StringCharacter1}+ { tokenLength += yylength(); } /* escape sequences */ \\. { tokenLength += 2; } {LineTerminator} { yybegin(YYINITIAL); } <> { yybegin(YYINITIAL); return token(TokenType.STRING, tokenStart, tokenLength); } } { \' { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.STRING, tokenStart, tokenLength + 1); } {StringCharacter2}+ { tokenLength += yylength(); } /* escape sequences */ \\. { tokenLength += 2; } {LineTerminator} { yybegin(YYINITIAL); } <> { yybegin(YYINITIAL); return token(TokenType.STRING, tokenStart, tokenLength); } } /* error fallback */ .|\n { } <> { return null; } libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/cpp.flex0000644000175000017500000001243412127321547027341 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * Copyright 2006 Arnout Engelen . * Copyright 2000-2006 Omnicore Software, Hans Kratz & Dennis Strein GbR, * Geert Bevin . * Distributed under the terms of either: * - the common development and distribution license (CDDL), v1.0; or * - the GNU Lesser General Public License, v2.1 or later */ package jsyntaxpane.lexers; import jsyntaxpane.Token; import jsyntaxpane.TokenType; %% %public %class CppLexer %extends DefaultJFlexLexer %final %unicode %char %type Token %{ public CppLexer() { super(); } @Override public int yychar() { return yychar; } private static final byte PARAN = 1; private static final byte BRACKET = 2; private static final byte CURLY = 3; %} /* main character classes */ LineTerminator = \r|\n|\r\n InputCharacter = [^\r\n] /* comments */ Comment = {TraditionalComment} | {EndOfLineComment} TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/" EndOfLineComment = "//" {InputCharacter}* {LineTerminator}? /* identifiers */ ConstantIdentifier = {SimpleConstantIdentifier} SimpleConstantIdentifier = [#A-Z0-9_]+ Identifier = [:jletter:][:jletterdigit:]* /* int literals */ DecLiteral = 0 | [1-9][0-9]* {IntegerSuffix} HexLiteral = 0 [xX] 0* {HexDigit}* {IntegerSuffix} HexDigit = [0-9a-fA-F] OctLiteral = 0+ {OctDigit}* {IntegerSuffix} OctDigit = [0-7] IntegerSuffix = [uU]? [lL]? [uU]? /* float literals */ FloatLiteral = ({FLit1}|{FLit2}|{FLit3}|{FLit4}) ([fF]|[dD])? FLit1 = [0-9]+ \. [0-9]* {Exponent}? FLit2 = \. [0-9]+ {Exponent}? FLit3 = [0-9]+ {Exponent} FLit4 = [0-9]+ {Exponent}? Exponent = [eE] [+\-]? [0-9]+ %% { /* keywords */ "break" | "case" | "catch" | "continue" | "default" | "do" | "else" | "for" | "goto" | "enum" | "if" | "inline" | "mutable" | "noinline" | "return" | "safecast" | "sealed" | "selectany" | "sizeof" | "static_cast" | "switch" | "template" | "this" | "thread" | "throw" | "try" | "typedef" | "typeid" | "typename" | "using" | "uuid" | "value" | "virtual" | "while" | /* C++ Keywords */ "new" | "delete" | "this" | "friend" | "using" | "throw" | "try" | "catch" | "class" | "typename" | "template" | "namespace" { return token(TokenType.KEYWORD); } "static" | "struct" | "union" | "volatile" | "register" | "extern" | "const" | "signed" | "unsigned" | "bool" | "char" | "double" | "int" | "long" | "float" | "short" | "void" | "public" | "protected" | "private" | "virtual" | "inline" | "virtual" | "explicit" | "export" | "bool" | "wchar_t" { return token(TokenType.TYPE); } /* literals */ (\" ( [^\"\n\\] | \\[^\n] )* (\n | \\\n | \")) | (\' ( [^\'\n\\] | \\[^\n] )* (\n | \\\n | \')) { return token(TokenType.STRING); } "true" | "false" | {DecLiteral} | {OctLiteral} | {HexLiteral} | {FloatLiteral} { return token(TokenType.NUMBER); } /* preprocessor symbols */ "#define" | "#elif" | "#else" | "#endif" | "#error" | "#ifdef" | "#ifndef" | "#if" | "#import" | "#include" | "#line" | "#pragma" | "#undef" | "#using" { return token(TokenType.KEYWORD2); } /* separators */ "(" { return token(TokenType.OPERATOR, PARAN); } ")" { return token(TokenType.OPERATOR, -PARAN); } "{" { return token(TokenType.OPERATOR, CURLY); } "}" { return token(TokenType.OPERATOR, -CURLY); } "[" { return token(TokenType.OPERATOR, BRACKET); } "]" { return token(TokenType.OPERATOR, -BRACKET); } /* operators */ "=" | ";" | "," | "." | ">" | "<" | "!" | "~" | "?" | ":" | "+" | "-" | "*" | "/" | "&" | "|" | "^" | "%" | ">>" | "<<" | "operator" | "typeid" | "and" | "bitor" | "or" | "xor" | "compl" | "bitand" | "and_eq" | "or_eq" | "xor_eq" | "not" | "not_eq" { return token(TokenType.OPERATOR); } /** C++ standard and built-in objects */ "cin" | "cout" { return token(TokenType.TYPE2); } {ConstantIdentifier} { return token(TokenType.TYPE); } {Identifier} { return token(TokenType.IDENTIFIER); } {Comment} { return token(TokenType.COMMENT); } } /* error fallback */ .|\n { } <> { return null; } libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/ruby.flex0000644000175000017500000002073312127321547027541 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.lexers; import jsyntaxpane.Token; import jsyntaxpane.TokenType; %% %public %class RubyLexer %extends DefaultJFlexLexer %final %unicode %char %type Token %{ /** * Create an empty lexer, yyrset will be called later to reset and assign * the reader */ public RubyLexer() { super(); } @Override public int yychar() { return yychar; } private static final byte PARAN = 1; private static final byte BRACKET = 2; private static final byte CURLY = 3; private static final byte WORD = 4; %} /* main character classes */ LineTerminator = \r|\n|\r\n InputCharacter = [^\r\n] WhiteSpace = {LineTerminator} | [ \t\f]+ /* comments */ Comment = "#" {InputCharacter}* {LineTerminator}? /* identifiers */ Identifier = [a-zA-Z][a-zA-Z0-9_]* /* integer literals */ DecIntegerLiteral = 0 | [1-9][0-9]* DecLongLiteral = {DecIntegerLiteral} [lL] HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] HexDigit = [0-9a-fA-F] OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15} OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] OctDigit = [0-7] /* floating point literals */ FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? FLit1 = [0-9]+ \. [0-9]* FLit2 = \. [0-9]+ FLit3 = [0-9]+ Exponent = [eE] [+-]? [0-9]+ /* string and character literals */ StringCharacter = [^\r\n\"\\] %state STRING, ML_STRING %% { /* keywords */ "BEGIN" | "ensure" | "assert" | "nil" | "self" | "when" | "END" | "false" | "not" | "super" | "alias" | "defined" | "or" | "then" | "yield" | "and" | "redo" | "true" | "else" | "in" | "rescue" | "undef" | "break" | "elsif" | "module" | "retry" | "unless" | "next" | "return" { return token(TokenType.KEYWORD); } "begin" | "case" | "class" | "def" | "for" | "while" | "until" | "do" | "if" { return token(TokenType.KEYWORD, WORD); } "end" { return token(TokenType.KEYWORD, -WORD); } /* Built-in Types*/ "self" | "nil" | "true" | "false" | "__FILE__" | "__LINE__" { return token(TokenType.TYPE); } /* operators */ "(" { return token(TokenType.OPERATOR, PARAN); } ")" { return token(TokenType.OPERATOR, -PARAN); } "{" { return token(TokenType.OPERATOR, CURLY); } "}" { return token(TokenType.OPERATOR, -CURLY); } "[" { return token(TokenType.OPERATOR, BRACKET); } "]" { return token(TokenType.OPERATOR, -BRACKET); } "+" | "-" | "*" | "**" | "/" | "//" | "%" | "<<" | ">>" | "&" | "|" | "^" | "~" | "<" | ">" | "<=" | ">=" | "==" | "!=" | "<>" | "@" | "," | ":" | "." | ".." | "`" | "=" | ";" | "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "&=" | "|=" | "^=" | ">>=" | "<<=" | "**=" { return token(TokenType.OPERATOR); } /* string literal */ \"{3} { yybegin(ML_STRING); tokenStart = yychar; tokenLength = 3; } \" { yybegin(STRING); tokenStart = yychar; tokenLength = 1; } /* numeric literals */ {DecIntegerLiteral} | {DecLongLiteral} | {HexIntegerLiteral} | {HexLongLiteral} | {OctIntegerLiteral} | {OctLongLiteral} | {FloatLiteral} | {DoubleLiteral} | {FloatLiteral}[jJ] { return token(TokenType.NUMBER); } /* comments */ {Comment} { return token(TokenType.COMMENT); } /* whitespace */ {WhiteSpace} { } /* identifiers */ {Identifier}"?" { return token(TokenType.TYPE2); } {Identifier} { return token(TokenType.IDENTIFIER); } } { \" { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.STRING, tokenStart, tokenLength + 1); } {StringCharacter}+ { tokenLength += yylength(); } \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } /* escape sequences */ \\. { tokenLength += 2; } {LineTerminator} { yybegin(YYINITIAL); } } { \"{3} { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.STRING, tokenStart, tokenLength + 3); } {StringCharacter}+ { tokenLength += yylength(); } \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } /* escape sequences */ \\. { tokenLength += 2; } {LineTerminator} { tokenLength ++; } } /* error fallback */ .|\n { } <> { return null; } libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/groovy.flex0000644000175000017500000004164212127321547030107 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.lexers; import jsyntaxpane.Token; import jsyntaxpane.TokenType; %% %public %class GroovyLexer %extends DefaultJFlexLexer %final %unicode %char %type Token %{ /** * Default constructor is needed as we will always call the yyreset */ public GroovyLexer() { super(); } @Override public int yychar() { return yychar; } private static final byte PARAN = 1; private static final byte BRACKET = 2; private static final byte CURLY = 3; %} /* main character classes */ LineTerminator = \r|\n|\r\n InputCharacter = [^\r\n] WhiteSpace = {LineTerminator} | [ \t\f] /* comments */ Comment = {TraditionalComment} | {EndOfLineComment} TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/" EndOfLineComment = "//" {InputCharacter}* {LineTerminator}? /* identifiers */ Identifier = [:jletter:][:jletterdigit:]* /* Groovy and generally Java types have first UpperCase Letter */ // Type = [:uppercase:][:jletterdigit:]* /* integer literals */ DecIntegerLiteral = 0 | [1-9][0-9]* DecLongLiteral = {DecIntegerLiteral} [lL] HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] HexDigit = [0-9a-fA-F] OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15} OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] OctDigit = [0-7] /* floating point literals */ FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? FLit1 = [0-9]+ \. [0-9]* FLit2 = \. [0-9]+ FLit3 = [0-9]+ Exponent = [eE] [+-]? [0-9]+ /* string and character literals */ StringCharacter = [^\r\n\"\\\$] SingleCharacter = [^\r\n\'\\] RegexCharacter = [^\r\n\/] %state STRING, CHARLITERAL, REGEX, GSTRING_EXPR, CHARLITERAL, JDOC, JDOC_TAG %state ML_STRING, ML_STRING_EXPR %% { /* keywords */ "abstract" | "boolean" | "break" | "byte" | "case" | "catch" | "char" | "class" | "const" | "continue" | "do" | "double" | "enum" | "else" | "extends" | "final" | "finally" | "float" | "for" | "default" | "implements" | "import" | "instanceof" | "int" | "interface" | "long" | "native" | "new" | "goto" | "if" | "public" | "short" | "super" | "switch" | "synchronized" | "package" | "private" | "protected" | "transient" | "return" | "void" | "static" | "while" | "this" | "throw" | "throws" | "try" | "volatile" | "strictfp" | /* Groovy reserved words not in Java */ "as" | "asssert" | "def" | "in" | "threadsafe" | /* Booleans and null */ "true" | "false" | "null" { return token(TokenType.KEYWORD); } /* Builtin Types and Object Wrappers */ "Boolean" | "Byte" | "Character" | "Double" | "Float" | "Integer" | "Object" | "Short" | "String" | "Void" | "Class" | "Number" | "Package" | "StringBuffer" | "StringBuilder" | "CharSequence" | "Thread" | "Regex" { return token(TokenType.TYPE); } /* Some Java standard Library Types */ "Throwable" | "Cloneable" | "Comparable" | "Serializable" | "Runnable" { return token(TokenType.TYPE); } /* Groovy commonly used methods */ "print" | "println" { return token(TokenType.KEYWORD); } /* Frequently used Standard Exceptions */ "ArithmeticException" | "ArrayIndexOutOfBoundsException" | "ClassCastException" | "ClassNotFoundException" | "CloneNotSupportedException" | "Exception" | "IllegalAccessException" | "IllegalArgumentException" | "IllegalStateException" | "IllegalThreadStateException" | "IndexOutOfBoundsException" | "InstantiationException" | "InterruptedException" | "NegativeArraySizeException" | "NoSuchFieldException" | "NoSuchMethodException" | "NullPointerException" | "NumberFormatException" | "RuntimeException" | "SecurityException" | "StringIndexOutOfBoundsException" | "UnsupportedOperationException" { return token(TokenType.TYPE2); } /* operators */ "(" { return token(TokenType.OPERATOR, PARAN); } ")" { return token(TokenType.OPERATOR, -PARAN); } "{" { return token(TokenType.OPERATOR, CURLY); } "}" { return token(TokenType.OPERATOR, -CURLY); } "[" { return token(TokenType.OPERATOR, BRACKET); } "]" { return token(TokenType.OPERATOR, -BRACKET); } ";" | "," | "." | "@" | "=" | ">" | "<" | "!" | "~" | "?" | ":" | "==" | "<=" | ">=" | "!=" | "&&" | "||" | "++" | "--" | "+" | "-" | "*" | "/" | "&" | "|" | "^" | "%" | "<<" | ">>" | ">>>" | "+=" | "-=" | "*=" | "/=" | "&=" | "|=" | "^=" | "%=" | "<<=" | ">>=" | ">>>=" { return token(TokenType.OPERATOR); } "~=" | "?." { return token(TokenType.OPERATOR); } /* string literal */ \"{3} { yybegin(ML_STRING); tokenStart = yychar; tokenLength = 3; } /* string literal */ \" { yybegin(STRING); tokenStart = yychar; tokenLength = 1; } /* character literal */ \' { yybegin(CHARLITERAL); tokenStart = yychar; tokenLength = 1; } /* numeric literals */ {DecIntegerLiteral} | {DecLongLiteral} | {HexIntegerLiteral} | {HexLongLiteral} | {OctIntegerLiteral} | {OctLongLiteral} | {FloatLiteral} | {DoubleLiteral} | {DoubleLiteral}[dD] { return token(TokenType.NUMBER); } // JavaDoc comments need a state so that we can highlight the @ controls "/**" { yybegin(JDOC); tokenStart = yychar; tokenLength = 3; } /* comments */ {Comment} { return token(TokenType.COMMENT); } /* whitespace */ {WhiteSpace}+ { /* skip */ } /* identifiers */ {Identifier} { return token(TokenType.IDENTIFIER); } /* Groovy Regex -- state cannot be easily used here due to / by itself being a valid operator. So if we flip into the REGEX state, we cannot distinguish a regular / */ "/" [^*] {RegexCharacter}+ "/" { return token(TokenType.REGEX); } } { \" { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.STRING, tokenStart, tokenLength + 1); } "${" { yybegin(GSTRING_EXPR); // length also includes the trailing quote int s = tokenStart; int l = tokenLength; tokenStart = yychar; tokenLength = 2; return token(TokenType.STRING, s, l); } {StringCharacter}+ { tokenLength += yylength(); } \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } /* escape sequences */ \\. { tokenLength += 2; } {LineTerminator} { yybegin(YYINITIAL); } } { "}" { yybegin(STRING); // length also includes the trailing quote int s = tokenStart; int l = tokenLength + 1; tokenStart = yychar + 1; tokenLength = 0; return token(TokenType.STRING2, s, l); } {StringCharacter} { tokenLength ++; } } { \"{3} { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.STRING, tokenStart, tokenLength + 3); } "${" { yybegin(ML_STRING_EXPR); // length also includes the trailing quote int s = tokenStart; int l = tokenLength; tokenStart = yychar; tokenLength = 2; return token(TokenType.STRING, s, l); } \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } /* escape sequences */ \\. { tokenLength += 2; } .|{LineTerminator} { tokenLength += yylength(); } } { "}" { yybegin(ML_STRING); // length also includes the trailing quote int s = tokenStart; int l = tokenLength + 1; tokenStart = yychar + 1; tokenLength = 0; return token(TokenType.STRING2, s, l); } .|\n|\r { tokenLength ++; } } { \' { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.STRING, tokenStart, tokenLength + 1); } {SingleCharacter}+ { tokenLength += yylength(); } /* escape sequences */ \\. { tokenLength += 2; } {LineTerminator} { yybegin(YYINITIAL); } } { "*/" { yybegin(YYINITIAL); return token(TokenType.COMMENT, tokenStart, tokenLength + 2); } "@" { yybegin(JDOC_TAG); int start = tokenStart; tokenStart = yychar; int len = tokenLength; tokenLength = 1; return token(TokenType.COMMENT, start, len); } .|\n { tokenLength ++; } } { ([:letter:])+ ":"? { tokenLength += yylength(); } "*/" { yybegin(YYINITIAL); return token(TokenType.COMMENT, tokenStart, tokenLength + 2); } .|\n { yybegin(JDOC); // length also includes the trailing quote int start = tokenStart; tokenStart = yychar; int len = tokenLength; tokenLength = 1; return token(TokenType.COMMENT2, start, len); } } { "/" { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.REGEX, tokenStart, tokenLength + 1); } {RegexCharacter}+ { tokenLength += yylength(); } /* escape sequences */ \\. { tokenLength += 2; } {LineTerminator} { yybegin(YYINITIAL); } } /* error fallback */ .|\n { } <> { return null; } libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/java.flex0000644000175000017500000003104012127321547027472 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.lexers; import jsyntaxpane.Token; import jsyntaxpane.TokenType; %% %public %class JavaLexer %extends DefaultJFlexLexer %final %unicode %char %type Token %{ /** * Create an empty lexer, yyrset will be called later to reset and assign * the reader */ public JavaLexer() { super(); } @Override public int yychar() { return yychar; } private static final byte PARAN = 1; private static final byte BRACKET = 2; private static final byte CURLY = 3; %} /* main character classes */ LineTerminator = \r|\n|\r\n InputCharacter = [^\r\n] WhiteSpace = {LineTerminator} | [ \t\f]+ /* comments */ Comment = {TraditionalComment} | {EndOfLineComment} TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/" EndOfLineComment = "//" {InputCharacter}* {LineTerminator}? /* identifiers */ Identifier = [:jletter:][:jletterdigit:]* /* integer literals */ DecIntegerLiteral = 0 | [1-9][0-9]* DecLongLiteral = {DecIntegerLiteral} [lL] HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] HexDigit = [0-9a-fA-F] OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15} OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] OctDigit = [0-7] /* floating point literals */ FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? FLit1 = [0-9]+ \. [0-9]* FLit2 = \. [0-9]+ FLit3 = [0-9]+ Exponent = [eE] [+-]? [0-9]+ /* string and character literals */ StringCharacter = [^\r\n\"\\] SingleCharacter = [^\r\n\'\\] %state STRING, CHARLITERAL, JDOC, JDOC_TAG %% { /* keywords */ "abstract" | "boolean" | "break" | "byte" | "case" | "catch" | "char" | "class" | "const" | "continue" | "do" | "double" | "enum" | "else" | "extends" | "final" | "finally" | "float" | "for" | "default" | "implements" | "import" | "instanceof" | "int" | "interface" | "long" | "native" | "new" | "goto" | "if" | "public" | "short" | "super" | "switch" | "synchronized" | "package" | "private" | "protected" | "transient" | "return" | "void" | "static" | "while" | "this" | "throw" | "throws" | "try" | "volatile" | "strictfp" | "true" | "false" | "null" { return token(TokenType.KEYWORD); } /* Java Built in types and wrappers */ "Boolean" | "Byte" | "Character" | "Double" | "Float" | "Integer" | "Object" | "Short" | "Void" | "Class" | "Number" | "Package" | "StringBuffer" | "StringBuilder" | "CharSequence" | "Thread" | "String" { return token(TokenType.TYPE); } /* Some Java standard Library Types */ "Throwable" | "Cloneable" | "Comparable" | "Serializable" | "Runnable" { return token(TokenType.TYPE); } "WARNING" { return token(TokenType.WARNING); } "ERROR" { return token(TokenType.ERROR); } /* Frequently used Standard Exceptions */ "ArithmeticException" | "ArrayIndexOutOfBoundsException" | "ClassCastException" | "ClassNotFoundException" | "CloneNotSupportedException" | "Exception" | "IllegalAccessException" | "IllegalArgumentException" | "IllegalStateException" | "IllegalThreadStateException" | "IndexOutOfBoundsException" | "InstantiationException" | "InterruptedException" | "NegativeArraySizeException" | "NoSuchFieldException" | "NoSuchMethodException" | "NullPointerException" | "NumberFormatException" | "RuntimeException" | "SecurityException" | "StringIndexOutOfBoundsException" | "UnsupportedOperationException" { return token(TokenType.TYPE2); } /* operators */ "(" { return token(TokenType.OPERATOR, PARAN); } ")" { return token(TokenType.OPERATOR, -PARAN); } "{" { return token(TokenType.OPERATOR, CURLY); } "}" { return token(TokenType.OPERATOR, -CURLY); } "[" { return token(TokenType.OPERATOR, BRACKET); } "]" { return token(TokenType.OPERATOR, -BRACKET); } ";" | "," | "." | "=" | ">" | "<" | "!" | "~" | "?" | ":" | "==" | "<=" | ">=" | "!=" | "&&" | "||" | "++" | "--" | "+" | "-" | "*" | "/" | "&" | "|" | "^" | "%" | "<<" | ">>" | ">>>" | "+=" | "-=" | "*=" | "/=" | "&=" | "|=" | "^=" | "%=" | "<<=" | ">>=" | ">>>=" { return token(TokenType.OPERATOR); } /* string literal */ \" { yybegin(STRING); tokenStart = yychar; tokenLength = 1; } /* character literal */ \' { yybegin(CHARLITERAL); tokenStart = yychar; tokenLength = 1; } /* numeric literals */ {DecIntegerLiteral} | {DecLongLiteral} | {HexIntegerLiteral} | {HexLongLiteral} | {OctIntegerLiteral} | {OctLongLiteral} | {FloatLiteral} | {DoubleLiteral} | {DoubleLiteral}[dD] { return token(TokenType.NUMBER); } // JavaDoc comments need a state so that we can highlight the @ controls "/**" { yybegin(JDOC); tokenStart = yychar; tokenLength = 3; } /* comments */ {Comment} { return token(TokenType.COMMENT); } /* whitespace */ {WhiteSpace} { } /* identifiers */ {Identifier} { return token(TokenType.IDENTIFIER); } } { \" { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.STRING, tokenStart, tokenLength + 1); } {StringCharacter}+ { tokenLength += yylength(); } \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } /* escape sequences */ \\. { tokenLength += 2; } {LineTerminator} { yybegin(YYINITIAL); } } { \' { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.STRING, tokenStart, tokenLength + 1); } {SingleCharacter}+ { tokenLength += yylength(); } /* escape sequences */ \\. { tokenLength += 2; } {LineTerminator} { yybegin(YYINITIAL); } } { "*/" { yybegin(YYINITIAL); return token(TokenType.COMMENT, tokenStart, tokenLength + 2); } "@" { yybegin(JDOC_TAG); int start = tokenStart; tokenStart = yychar; int len = tokenLength; tokenLength = 1; return token(TokenType.COMMENT, start, len); } .|\n { tokenLength ++; } } { ([:letter:])+ ":"? { tokenLength += yylength(); } "*/" { yybegin(YYINITIAL); return token(TokenType.COMMENT, tokenStart, tokenLength + 2); } .|\n { yybegin(JDOC); // length also includes the trailing quote int start = tokenStart; tokenStart = yychar; int len = tokenLength; tokenLength = 1; return token(TokenType.COMMENT2, start, len); } } /* error fallback */ .|\n { } <> { return null; } libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/scala.flex0000644000175000017500000002546512127321547027652 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.lexers; import jsyntaxpane.Token; import jsyntaxpane.TokenType; %% %public %class ScalaLexer %extends DefaultJFlexLexer %final %unicode %char %type Token %{ /** * Create an empty lexer, yyrset will be called later to reset and assign * the reader */ public ScalaLexer() { super(); } @Override public int yychar() { return yychar; } private static final byte PARAN = 1; private static final byte BRACKET = 2; private static final byte CURLY = 3; %} /* main character classes */ LineTerminator = \r|\n|\r\n InputCharacter = [^\r\n] WhiteSpace = {LineTerminator} | [ \t\f]+ /* comments */ Comment = {TraditionalComment} | {EndOfLineComment} TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/" EndOfLineComment = "//" {InputCharacter}* {LineTerminator}? /* identifiers */ Identifier = [:jletter:][:jletterdigit:]* /* integer literals */ DecIntegerLiteral = 0 | [1-9][0-9]* DecLongLiteral = {DecIntegerLiteral} [lL] HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] HexDigit = [0-9a-fA-F] OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15} OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] OctDigit = [0-7] /* floating point literals */ FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? FLit1 = [0-9]+ \. [0-9]* FLit2 = \. [0-9]+ FLit3 = [0-9]+ Exponent = [eE] [+-]? [0-9]+ /* string and character literals */ StringCharacter = [^\r\n\"\\] SingleCharacter = [^\r\n\'\\] %state STRING, CHARLITERAL, JDOC, JDOC_TAG %% { /* keywords */ "def" | "import" | "package" | "if" | "then" | "else" | "while" | "for" | "do" | "boolean" | "int" | "double" | "byte" | "short" | "char" | "long" | "float" | "unit" | "val" | "with" | "type" | "var" | "yield" | "return" | "true" | "false" | "null" | "this" | "super" | "String" | "Array" | "private" | "protected" | "override" | "abstract" | "final" | "sealed" | "throw" | "try" | "catch" | "finally" | "extends" { return token(TokenType.KEYWORD); } /* Java Built in types and wrappers */ "object" | "Boolean" | "Byte" | "Character" | "Double" | "Float" | "Integer" | "Object" | "Short" | "Void" | "Class" | "Number" | "Package" | "StringBuffer" | "StringBuilder" | "CharSequence" | "Thread" | "String" { return token(TokenType.TYPE); } /* Some Scala predefines */ "println" { return token(TokenType.KEYWORD2); } /* Some Java standard Library Types */ "Throwable" | "Cloneable" | "Comparable" | "Serializable" | "Runnable" { return token(TokenType.TYPE); } "WARNING" { return token(TokenType.WARNING); } "ERROR" { return token(TokenType.ERROR); } /* operators */ "(" { return token(TokenType.OPERATOR, PARAN); } ")" { return token(TokenType.OPERATOR, -PARAN); } "{" { return token(TokenType.OPERATOR, CURLY); } "}" { return token(TokenType.OPERATOR, -CURLY); } "[" { return token(TokenType.OPERATOR, BRACKET); } "]" { return token(TokenType.OPERATOR, -BRACKET); } ";" | "," | "." | "=" | ">" | "<" | "!" | "~" | "?" | ":" | "==" | "<=" | ">=" | "!=" | "&&" | "||" | "++" | "--" | "+" | "-" | "*" | "/" | "&" | "|" | "^" | "%" | "<<" | ">>" | ">>>" | "+=" | "-=" | "*=" | "/=" | "&=" | "|=" | "^=" | "%=" | "<<=" | ">>=" | ">>>=" { return token(TokenType.OPERATOR); } /* string literal */ \" { yybegin(STRING); tokenStart = yychar; tokenLength = 1; } /* character literal */ \' { yybegin(CHARLITERAL); tokenStart = yychar; tokenLength = 1; } /* numeric literals */ {DecIntegerLiteral} | {DecLongLiteral} | {HexIntegerLiteral} | {HexLongLiteral} | {OctIntegerLiteral} | {OctLongLiteral} | {FloatLiteral} | {DoubleLiteral} | {DoubleLiteral}[dD] { return token(TokenType.NUMBER); } // JavaDoc comments need a state so that we can highlight the @ controls "/**" { yybegin(JDOC); tokenStart = yychar; tokenLength = 3; } /* comments */ {Comment} { return token(TokenType.COMMENT); } /* whitespace */ {WhiteSpace} { } /* identifiers */ {Identifier} { return token(TokenType.IDENTIFIER); } } { \" { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.STRING, tokenStart, tokenLength + 1); } {StringCharacter}+ { tokenLength += yylength(); } \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } /* escape sequences */ \\. { tokenLength += 2; } {LineTerminator} { yybegin(YYINITIAL); } } { \' { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.STRING, tokenStart, tokenLength + 1); } {SingleCharacter}+ { tokenLength += yylength(); } /* escape sequences */ \\. { tokenLength += 2; } {LineTerminator} { yybegin(YYINITIAL); } } { "*/" { yybegin(YYINITIAL); return token(TokenType.COMMENT, tokenStart, tokenLength + 2); } "@" { yybegin(JDOC_TAG); int start = tokenStart; tokenStart = yychar; int len = tokenLength; tokenLength = 1; return token(TokenType.COMMENT, start, len); } .|\n { tokenLength ++; } } { ([:letter:])+ ":"? { tokenLength += yylength(); } "*/" { yybegin(YYINITIAL); return token(TokenType.COMMENT, tokenStart, tokenLength + 2); } .|\n { yybegin(JDOC); // length also includes the trailing quote int start = tokenStart; tokenStart = yychar; int len = tokenLength; tokenLength = 1; return token(TokenType.COMMENT2, start, len); } } /* error fallback */ .|\n { } <> { return null; } libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/jflex.flex0000644000175000017500000003201012127321547027657 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.lexers; import jsyntaxpane.Token; import jsyntaxpane.TokenType; %% %public %class JFlexLexer %extends DefaultJFlexLexer %final %unicode %char %type Token %{ /** * Create an empty lexer, yyrset will be called later to reset and assign * the reader */ public JFlexLexer() { super(); } @Override public int yychar() { return yychar; } %} /* main character classes */ LineTerminator = \r|\n|\r\n InputCharacter = [^\r\n] WhiteSpace = {LineTerminator} | [ \t\f]+ /* comments */ Comment = {TraditionalComment} | {EndOfLineComment} TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/" EndOfLineComment = "//" {InputCharacter}* {LineTerminator}? /* identifiers */ Identifier = [:jletter:][:jletterdigit:]* /* integer literals */ DecIntegerLiteral = 0 | [1-9][0-9]* DecLongLiteral = {DecIntegerLiteral} [lL] HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] HexDigit = [0-9a-fA-F] OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15} OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] OctDigit = [0-7] /* floating point literals */ FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? FLit1 = [0-9]+ \. [0-9]* FLit2 = \. [0-9]+ FLit3 = [0-9]+ Exponent = [eE] [+-]? [0-9]+ /* string and character literals */ StringCharacter = [^\r\n\"\\] SingleCharacter = [^\r\n\'\\] %state STRING, CHARLITERAL, JDOC, JDOC_TAG %% { /* keywords */ "abstract" | "boolean" | "break" | "byte" | "case" | "catch" | "char" | "class" | "const" | "continue" | "do" | "double" | "enum" | "else" | "extends" | "final" | "finally" | "float" | "for" | "default" | "implements" | "import" | "instanceof" | "int" | "interface" | "long" | "native" | "new" | "goto" | "if" | "public" | "short" | "super" | "switch" | "synchronized" | "package" | "private" | "protected" | "transient" | "return" | "void" | "static" | "while" | "this" | "throw" | "throws" | "try" | "volatile" | "strictfp" | "true" | "false" | "null" { return token(TokenType.KEYWORD); } /* JFlex special types */ "<>" | "[:jletter:]" | "[:jletterdigit:]" | "[:letter:]" | "[:digit:]" | "[:uppercase:]" | "[:lowercase:]" | "<" [a-zA-Z][a-zA-Z0-9_]* ">" { return token(TokenType.TYPE2); } /* JFlex Specials */ "%%" | "%{" | "%}" | "%class" | "%implements" | "%extends" | "%public" | "%final" | "%abstract" | "%apiprivate" | "%init{" | "%init}" | "%initthrow{" | "%initthrow}" | "%initthrow" | "%ctorarg" | "%scanerror" | "%buffer" | "%include" | "%function" | "%integer" | "%int" | "%intwrap" | "%yylexthrow{" | "%yylexthrow}" | "%yylexthrow" | "%eofval{" | "%eofval}" | "%eof{" | "%eof}" | "%eofthrow{" | "%eofthrow}" | "%eofthrow" | "%eofclose" | "%debug" | "%standalone" | "%cup" | "%cupsym" | "%cupdebug" | "%byacc" | "%switch" | "%table" | "%pack" | "%7bit" | "%8bit" | "%full" | "%unicode" | "%16bit" | "%caseless" | "%ignorecase" | "%char" | "%line" | "%column" | "%notunix" | "%yyeof" | "%s" | "%state" | "%x" | "%xstate" | "%type" { return token(TokenType.KEYWORD2); } /* Java Built in types and wrappers */ "Boolean" | "Byte" | "Double" | "Float" | "Integer" | "Object" | "Short" | "String" { return token(TokenType.TYPE); } /* operators */ "(" | ")" | "{" | "}" | "[" | "]" | ";" | "," | "." | "=" | ">" | "<" | "!" | "~" | "?" | ":" | "==" | "<=" | ">=" | "!=" | "&&" | "||" | "++" | "--" | "+" | "-" | "*" | "/" | "&" | "|" | "^" | "%" | "<<" | ">>" | ">>>" | "+=" | "-=" | "*=" | "/=" | "&=" | "|=" | "^=" | "%=" | "<<=" | ">>=" | ">>>=" { return token(TokenType.OPERATOR); } /* string literal */ \" { yybegin(STRING); tokenStart = yychar; tokenLength = 1; } /* character literal */ \' { yybegin(CHARLITERAL); tokenStart = yychar; tokenLength = 1; } /* numeric literals */ {DecIntegerLiteral} | {DecLongLiteral} | {HexIntegerLiteral} | {HexLongLiteral} | {OctIntegerLiteral} | {OctLongLiteral} | {FloatLiteral} | {DoubleLiteral} | {DoubleLiteral}[dD] { return token(TokenType.NUMBER); } // JavaDoc comments need a state so that we can highlight the @ controls "/**" { yybegin(JDOC); tokenStart = yychar; tokenLength = 3; } /* comments */ {Comment} { return token(TokenType.COMMENT); } /* whitespace */ {WhiteSpace} { } /* identifiers */ {Identifier} { return token(TokenType.IDENTIFIER); } } { \" { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.STRING, tokenStart, tokenLength + 1); } {StringCharacter}+ { tokenLength += yylength(); } \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } /* escape sequences */ \\. { tokenLength += 2; } {LineTerminator} { yybegin(YYINITIAL); } } { \' { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.STRING, tokenStart, tokenLength + 1); } {SingleCharacter}+ { tokenLength += yylength(); } /* escape sequences */ \\. { tokenLength += 2; } {LineTerminator} { yybegin(YYINITIAL); } } { "*/" { yybegin(YYINITIAL); return token(TokenType.COMMENT, tokenStart, tokenLength + 2); } "@" { yybegin(JDOC_TAG); int start = tokenStart; tokenStart = yychar; int len = tokenLength; tokenLength = 1; return token(TokenType.COMMENT, start, len); } .|\n { tokenLength ++; } } { ([:letter:])+ ":"? { tokenLength += yylength(); } "*/" { yybegin(YYINITIAL); return token(TokenType.COMMENT, tokenStart, tokenLength + 2); } .|\n { yybegin(JDOC); // length also includes the trailing quote int start = tokenStart; tokenStart = yychar; int len = tokenLength; tokenLength = 1; return token(TokenType.COMMENT2, start, len); } } /* error fallback */ .|\n { } <> { return null; } libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/xhtml.flex0000644000175000017500000002460612127321547027717 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.lexers; import jsyntaxpane.Token; import jsyntaxpane.TokenType; %% %public %class XHTMLLexer %extends DefaultJFlexLexer %final %unicode %char %type Token %ignorecase %{ /** * Create an empty lexer, yyrset will be called later to reset and assign * the reader */ public XHTMLLexer() { super(); } @Override public int yychar() { return yychar; } private static final byte TAG_OPEN = 1; private static final byte TAG_CLOSE = -1; private static final byte INSTR_OPEN = 2; private static final byte INSTR_CLOSE = -2; private static final byte CDATA_OPEN = 3; private static final byte CDATA_CLOSE = -3; private static final byte COMMENT_OPEN = 4; private static final byte COMMENT_CLOSE = -4; %} %xstate COMMENT, CDATA, TAG, INSTR, DOCTYPE /* main character classes */ /* white space */ S = (\u0020 | \u0009 | \u000D | \u000A)+ /* characters */ // Char = \u0009 | \u000A | \u000D | [\u0020-\uD7FF] | [\uE000-\uFFFD] | [\u10000-\u10FFFF] /* comments */ CommentStart = "" NameStartChar = ":" | [A-Z] | "_" | [a-z] NameChar = {NameStartChar} | "-" | "." | [0-9] | \u00B7 Name = {NameStartChar} {NameChar}* /* XML Processing Instructions */ InstrStart = "" DocTypeStart = "" /* Tags */ OpenTagStart = "<" {Name} OpenTagClose = "/>" OpenTagEnd = ">" CloseTag = "" /* attribute */ Attribute = {Name} "=" /* HTML specifics */ HTMLTagName = "address" | "applet" | "area" | "a" | "b" | "base" | "basefont" | "big" | "blockquote" | "body" | "br" | "caption" | "center" | "cite" | "code" | "dd" | "dfn" | "dir" | "div" | "dl" | "dt" | "font" | "form" | "h"[1-6] | "head" | "hr" | "html" | "img" | "input" | "isindex" | "kbd" | "li" | "link" | "LINK" | "map" | "META" | "menu" | "meta" | "ol" | "option" | "param" | "pre" | "p" | "samp" | "span" | "select" | "small" | "strike" | "sub" | "sup" | "table" | "td" | "textarea" | "th" | "title" | "tr" | "tt" | "ul" | "var" | "xmp" | "script" | "noscript" | "style" HTMLAttrName = "action" | "align" | "alink" | "alt" | "archive" | "background" | "bgcolor" | "border" | "bordercolor" | "cellpadding" | "cellspacing" | "checked" | "class" | "clear" | "code" | "codebase" | "color" | "cols" | "colspan" | "content" | "coords" | "enctype" | "face" | "gutter" | "height" | "hspace" | "href" | "id" | "link" | "lowsrc" | "marginheight" | "marginwidth" | "maxlength" | "method" | "name" | "prompt" | "rel" | "rev" | "rows" | "rowspan" | "scrolling" | "selected" | "shape" | "size" | "src" | "start" | "target" | "text" | "type" | "url" | "usemap" | "ismap" | "valign" | "value" | "vlink" | "vspace" | "width" | "wrap" | "abbr" | "accept" | "accesskey" | "axis" | "char" | "charoff" | "charset" | "cite" | "classid" | "codetype" | "compact" | "data" | "datetime" | "declare" | "defer" | "dir" | "disabled" | "for" | "frame" | "headers" | "hreflang" | "lang" | "language" | "longdesc" | "multiple" | "nohref" | "nowrap" | "object" | "profile" | "readonly" | "rules" | "scheme" | "scope" | "span" | "standby" | "style" | "summary" | "tabindex" | "valuetype" | "version" HTMLOpenTagStart = "<" {HTMLTagName} HTMLCloseTag = "" HTMLAttribute = {HTMLAttrName} "=" /* string and character literals */ DQuoteStringChar = [^\r\n\"] SQuoteStringChar = [^\r\n\'] %% { "&" [a-z]+ ";" | "&#" [:digit:]+ ";" { return token(TokenType.KEYWORD2); } {InstrStart} { yybegin(INSTR); return token(TokenType.TYPE2, INSTR_OPEN); } {DocTypeStart} { yybegin(DOCTYPE); return token(TokenType.TYPE2, INSTR_OPEN); } {HTMLOpenTagStart} { yybegin(TAG); return token(TokenType.KEYWORD2, TAG_OPEN); } {HTMLCloseTag} { return token(TokenType.KEYWORD2, TAG_CLOSE); } {OpenTagStart} { yybegin(TAG); return token(TokenType.KEYWORD, TAG_OPEN); } {CloseTag} { return token(TokenType.KEYWORD, TAG_CLOSE); } {CommentStart} { yybegin(COMMENT); return token(TokenType.COMMENT2, COMMENT_OPEN); } {CDataStart} { yybegin(CDATA); return token(TokenType.COMMENT2, CDATA_OPEN); } } { {Attribute} { return token(TokenType.IDENTIFIER); } \"{DQuoteStringChar}*\" | \'{SQuoteStringChar}*\' { return token(TokenType.STRING); } {InstrEnd} { yybegin(YYINITIAL); return token(TokenType.TYPE2, INSTR_CLOSE); } } { [^>]* { } {OpenTagEnd} { yybegin(YYINITIAL); return token(TokenType.TYPE2, INSTR_CLOSE); } } { {HTMLAttribute} { return token(TokenType.KEYWORD2); } {Attribute} { return token(TokenType.IDENTIFIER); } \"{DQuoteStringChar}*\" | \'{SQuoteStringChar}*\' { return token(TokenType.STRING); } {OpenTagClose} { yybegin(YYINITIAL); return token(TokenType.KEYWORD, TAG_CLOSE); } {OpenTagEnd} { yybegin(YYINITIAL); return token(TokenType.KEYWORD); } } { {CommentEnd} { yybegin(YYINITIAL); return token(TokenType.COMMENT2, COMMENT_CLOSE); } ~{CommentEnd} { yypushback(3); return token(TokenType.COMMENT); } } { {CDataEnd} { yybegin(YYINITIAL); return token(TokenType.COMMENT2, CDATA_CLOSE); } ~{CDataEnd} { yypushback(3); return token(TokenType.COMMENT); } } { /* error fallback */ .|\n { } <> { return null; } } libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/tal.flex0000644000175000017500000001105012127321547027330 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.lexers; import jsyntaxpane.Token; import jsyntaxpane.TokenType; %% %public %class TALLexer %extends DefaultJFlexLexer %final %unicode %char %type Token %caseless %{ /** * Create an empty lexer, yyrset will be called later to reset and assign * the reader */ public TALLexer() { super(); } @Override public int yychar() { return yychar; } %} /* main character classes */ LineTerminator = \r|\n|\r\n InputCharacter = [^\r\n] WhiteSpace = {LineTerminator} | [ \t\f]+ /* comments */ Comment = {TraditionalComment} | {EndOfLineComment} TraditionalComment = "!" [^\r\n!]* ( "!" | {LineTerminator} ) EndOfLineComment = "--" {InputCharacter}* {LineTerminator}? /* identifiers */ Identifier = [A-Za-z_][A-Za-z0-9\^_]* /* integer literals */ DecIntegerLiteral = 0 | [1-9][0-9]* HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] HexDigit = [0-9a-fA-F] OctIntegerLiteral = "%" [1-3]? {OctDigit} {1,15} OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] OctDigit = [0-7] FixedLiteral = DecIntegerLiteral [fF] DoubleLiteral = DecIntegerLiteral [dD] /* string and character literals */ StringCharacter = [^\r\n\"\\] SingleCharacter = [^\r\n\'\\] %% { /* keywords */ "begin" | "end" | "struct" | "fieldalign" | "shared" | "shared2" | "literal" | "for" | "do" | "while" | "?page" | "?section" { return token(TokenType.KEYWORD); } "int" | "string" | "int(32)" | "fixed" | "byte" | "float" | "filler" { return token(TokenType.TYPE); } "(" | ")" | "{" | "}" | "[" | "]" | ";" | "," | "." | "=" | ">" | "<" | "!" | "?" | ":" | ":=" | "':='" | "'=:'" | "<>" | "+" | "-" | "*" | "/" | "<<" | ">>" { return token(TokenType.OPERATOR); } /* string literal */ \"{StringCharacter}+\" { return token(TokenType.STRING); } /* character literal */ \'{SingleCharacter}\' { return token(TokenType.STRING); } /* numeric literals */ {DecIntegerLiteral} | {HexIntegerLiteral} | {HexLongLiteral} | {OctIntegerLiteral} | {OctLongLiteral} | {FixedLiteral} | {DoubleLiteral} { return token(TokenType.NUMBER); } /* comments */ {Comment} { return token(TokenType.COMMENT); } /* whitespace */ {WhiteSpace} { } /* identifiers */ {Identifier} { return token(TokenType.IDENTIFIER); } } /* error fallback */ .|\n { } <> { return null; } libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/clojure.flex0000644000175000017500000003606312127321547030226 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.lexers; import jsyntaxpane.Token; import jsyntaxpane.TokenType; %% %public %class ClojureLexer %extends DefaultJFlexLexer %final %unicode %char %type Token %{ /** * Create an empty lexer, yyrset will be called later to reset and assign * the reader */ public ClojureLexer() { super(); } @Override public int yychar() { return yychar; } private static final byte PARAN = 1; private static final byte BRACKET = 2; private static final byte CURLY = 3; %} /* main character classes */ LineTerminator = \r|\n|\r\n InputCharacter = [^\r\n] WhiteSpace = {LineTerminator} | [ \t\f]+ /* comments */ Comment = {EndOfLineComment} EndOfLineComment = ";" {InputCharacter}* {LineTerminator}? /* identifiers */ Identifier = [:jletter:][:jletterdigit:]* /* integer literals */ DecIntegerLiteral = 0 | [1-9][0-9]* DecLongLiteral = {DecIntegerLiteral} [lL] HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] HexDigit = [0-9a-fA-F] OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15} OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] OctDigit = [0-7] /* floating point literals */ FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? FLit1 = [0-9]+ \. [0-9]* FLit2 = \. [0-9]+ FLit3 = [0-9]+ Exponent = [eE] [+-]? [0-9]+ /* string and character literals */ StringCharacter = [^\r\n\"\\] SingleCharacter = [^\r\n\'\\] %state STRING, CHARLITERAL %% { /* keywords */ "fn" | "fn*" | "if" | "def" | "let" | "let*" | "loop*" | "new" | "nil" | "recur" | "loop" | "do" | "quote" | "the-var" | "identical?" | "throw" | "set!" | "monitor-enter" | "monitor-exit" | "try" | "catch" | "finally" | "in-ns" { return token(TokenType.KEYWORD); } /* Built-ins */ "*agent*" | "*command-line-args*" | "*in*" | "*macro-meta*" | "*ns*" | "*out*" | "*print-meta*" | "*print-readably*" | "*proxy-classes*" | "*warn-on-reflection*" | "+" | "-" | "->" | ".." | "/" | "<" | "<=" | "=" | "==" | ">" | ">=" | "accessor" | "agent" | "agent-errors" | "aget" | "alength" | "all-ns" | "alter" | "and" | "apply" | "array-map" | "aset" | "aset-boolean" | "aset-byte" | "aset-char" | "aset-double" | "aset-float" | "aset-int" | "aset-long" | "aset-short" | "assert" | "assoc" | "await" | "await-for" | "bean" | "binding" | "bit-and" | "bit-not" | "bit-or" | "bit-shift-left" | "bit-shift-right" | "bit-xor" | "boolean" | "butlast" | "byte" | "cast" | "char" | "class" | "clear-agent-errors" | "comment" | "commute" | "comp" | "comparator" | "complement" | "concat" | "cond" | "conj" | "cons" | "constantly" | "construct-proxy" | "contains?" | "count" | "create-ns" | "create-struct" | "cycle" | "dec" | "defmacro" | "defmethod" | "defmulti" | "defn" | "defn-" | "defstruct" | "deref" | "destructure" | "disj" | "dissoc" | "distinct" | "doall" | "doc" | "dorun" | "doseq" | "dosync" | "dotimes" | "doto" | "double" | "drop" | "drop-while" | "ensure" | "eval" | "every?" | "false?" | "ffirst" | "file-seq" | "filter" | "find" | "find-doc" | "find-ns" | "find-var" | "first" | "float" | "flush" | "fnseq" | "for" | "frest" | "gensym" | "gen-class" | "gen-interface" | "get" | "get-proxy-class" | "hash-map" | "hash-set" | "identity" | "if-let" | "import" | "inc" | "instance?" | "int" | "interleave" | "into" | "into-array" | "iterate" | "key" | "keys" | "keyword" | "keyword?" | "last" | "lazy-cat" | "lazy-cons" | "line-seq" | "list" | "list*" | "load" | "load-file" | "locking" | "long" | "macroexpand" | "macroexpand-1" | "make-array" | "map" | "map?" | "mapcat" | "max" | "max-key" | "memfn" | "merge" | "merge-with" | "meta" | "min" | "min-key" | "name" | "namespace" | "neg?" | "newline" | "nil?" | "not" | "not-any?" | "not-every?" | "not=" | "ns-imports" | "ns-interns" | "ns-map" | "ns-name" | "ns-publics" | "ns-refers" | "ns-resolve" | "ns-unmap" | "nth" | "nthrest" | "or" | "partial" | "peek" | "pmap" | "pop" | "pos?" | "pr" | "pr-str" | "print" | "print-doc" | "print-str" | "println" | "println-str" | "prn" | "prn-str" | "proxy" | "proxy-mappings" | "quot" | "rand" | "rand-int" | "range" | "re-find" | "re-groups" | "re-matcher" | "re-matches" | "re-pattern" | "re-seq" | "read" | "read-line" | "reduce" | "ref" | "ref-set" | "refer" | "rem" | "remove-method" | "remove-ns" | "repeat" | "replace" | "replicate" | "require" | "resolve" | "rest" | "resultset-seq" | "reverse" | "rfirst" | "rrest" | "rseq" | "scan" | "second" | "select-keys" | "send" | "send-off" | "seq" | "seq?" | "set" | "short" | "slurp" | "some" | "sort" | "sort-by" | "sorted-map" | "sorted-map-by" | "sorted-set" | "special-symbol?" | "split-at" | "split-with" | "str" | "string?" | "struct" | "struct-map" | "subs" | "subvec" | "symbol" | "symbol?" | "sync" | "take" | "take-nth" | "take-while" | "test" | "time" | "to-array" | "to-array-2d" | "touch" | "tree-seq" | "true?" | "update-proxy" | "val" | "vals" | "var-get" | "var-set" | "var?" | "vector" | "vector?" | "when" | "when-first" | "when-let" | "when-not" | "while" | "with-local-vars" | "with-meta" | "with-open" | "with-out-str" | "xml-seq" | "zero?" | "zipmap" | "repeatedly" | "add-classpath" | "vec" | "hash" { return token(TokenType.KEYWORD2); } /* operators */ "(" { return token(TokenType.OPERATOR, PARAN); } ")" { return token(TokenType.OPERATOR, -PARAN); } "{" { return token(TokenType.OPERATOR, CURLY); } "}" { return token(TokenType.OPERATOR, -CURLY); } "[" { return token(TokenType.OPERATOR, BRACKET); } "]" { return token(TokenType.OPERATOR, -BRACKET); } /* string literal */ \" { yybegin(STRING); tokenStart = yychar; tokenLength = 1; } /* character literal */ \' { yybegin(CHARLITERAL); tokenStart = yychar; tokenLength = 1; } /* numeric literals */ {DecIntegerLiteral} | {DecLongLiteral} | {HexIntegerLiteral} | {HexLongLiteral} | {OctIntegerLiteral} | {OctLongLiteral} | {FloatLiteral} | {DoubleLiteral} | {DoubleLiteral}[dD] { return token(TokenType.NUMBER); } /* comments */ {Comment} { return token(TokenType.COMMENT); } /* whitespace */ {WhiteSpace} { } /* identifiers */ {Identifier} { return token(TokenType.IDENTIFIER); } } { \" { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.STRING, tokenStart, tokenLength + 1); } {StringCharacter}+ { tokenLength += yylength(); } \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } /* escape sequences */ \\. { tokenLength += 2; } {LineTerminator} { yybegin(YYINITIAL); } } { \' { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.STRING, tokenStart, tokenLength + 1); } {SingleCharacter}+ { tokenLength += yylength(); } /* escape sequences */ \\. { tokenLength += 2; } {LineTerminator} { yybegin(YYINITIAL); } } /* error fallback */ .|\n { } <> { return null; } libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/javascript.flex0000644000175000017500000002056112127321547030725 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.lexers; import jsyntaxpane.Token; import jsyntaxpane.TokenType; %% %public %class JavaScriptLexer %extends DefaultJFlexLexer %final %unicode %char %type Token %{ /** * Create an empty lexer, yyrset will be called later to reset and assign * the reader */ public JavaScriptLexer() { super(); } @Override public int yychar() { return yychar; } private static final byte PARAN = 1; private static final byte BRACKET = 2; private static final byte CURLY = 3; %} /* main character classes */ LineTerminator = \r|\n|\r\n InputCharacter = [^\r\n] WhiteSpace = {LineTerminator} | [ \t\f]+ /* comments */ Comment = {TraditionalComment} | {EndOfLineComment} TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/" EndOfLineComment = "//" {InputCharacter}* {LineTerminator}? /* identifiers */ Identifier = [:jletter:][:jletterdigit:]* /* integer literals */ DecIntegerLiteral = 0 | [1-9][0-9]* DecLongLiteral = {DecIntegerLiteral} [lL] HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] HexDigit = [0-9a-fA-F] OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15} OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] OctDigit = [0-7] /* floating point literals */ FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? FLit1 = [0-9]+ \. [0-9]* FLit2 = \. [0-9]+ FLit3 = [0-9]+ Exponent = [eE] [+-]? [0-9]+ /* string and character literals */ StringCharacter = [^\r\n\"\\] SStringCharacter = [^\r\n\'\\] %state STRING SSTRING %% { /* keywords */ "break" | "case" | "catch" | "continue" | "do" | "else" | "finally" | "for" | "default" | "delete" | "new" | "goto" | "if" | "switch" | "return" | "while" | "this" | "try" | "var" | "function" | "with" | "in" | /* boolean literals */ "true" | "false" | /* null literal */ "null" { return token(TokenType.KEYWORD); } /* standard / builtin functions */ "Infinity" | "NaN" | "undefined" | "decodeURI" | "encodeURIComponent" | "escape" | "eval" | "isFinite" | "isNaN" | "parseFloat" | "parseInt" | "unescape" { return token(TokenType.KEYWORD2); } /* Built-in Types*/ "Array" | "Boolean" | "Date" | "Math" | "Number" | "Object" | "RegExp" | "String" | {Identifier} ":" { return token(TokenType.TYPE); } /* operators */ "(" { return token(TokenType.OPERATOR, PARAN); } ")" { return token(TokenType.OPERATOR, -PARAN); } "{" { return token(TokenType.OPERATOR, CURLY); } "}" { return token(TokenType.OPERATOR, -CURLY); } "[" { return token(TokenType.OPERATOR, BRACKET); } "]" { return token(TokenType.OPERATOR, -BRACKET); } ";" | "," | "." | "=" | ">" | "<" | "!" | "~" | "?" | ":" | "==" | "<=" | ">=" | "!=" | "&&" | "||" | "++" | "--" | "+" | "-" | "*" | "/" | "&" | "|" | "^" | "%" | "<<" | ">>" | ">>>" | "+=" | "-=" | "*=" | "/=" | "&=" | "|=" | "^=" | "%=" | "<<=" | ">>=" | ">>>=" { return token(TokenType.OPERATOR); } /* string literal */ \" { yybegin(STRING); tokenStart = yychar; tokenLength = 1; } \' { yybegin(SSTRING); tokenStart = yychar; tokenLength = 1; } /* numeric literals */ {DecIntegerLiteral} | {DecLongLiteral} | {HexIntegerLiteral} | {HexLongLiteral} | {OctIntegerLiteral} | {OctLongLiteral} | {FloatLiteral} | {DoubleLiteral} | {DoubleLiteral}[dD] { return token(TokenType.NUMBER); } /* comments */ {Comment} { return token(TokenType.COMMENT); } /* whitespace */ {WhiteSpace} { } /* identifiers */ {Identifier} { return token(TokenType.IDENTIFIER); } } { \" { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.STRING, tokenStart, tokenLength + 1); } {StringCharacter}+ { tokenLength += yylength(); } \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } /* escape sequences */ \\. { tokenLength += 2; } {LineTerminator} { yybegin(YYINITIAL); } } { \' { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.STRING, tokenStart, tokenLength + 1); } {SStringCharacter}+ { tokenLength += yylength(); } \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } /* escape sequences */ \\. { tokenLength += 2; } {LineTerminator} { yybegin(YYINITIAL); } } /* error fallback */ .|\n { } <> { return null; } libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/c.flex0000644000175000017500000001153212127321547026777 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * Copyright 2006 Arnout Engelen . * Copyright 2000-2006 Omnicore Software, Hans Kratz & Dennis Strein GbR, * Geert Bevin . * Distributed under the terms of either: * - the common development and distribution license (CDDL), v1.0; or * - the GNU Lesser General Public License, v2.1 or later */ package jsyntaxpane.lexers; import jsyntaxpane.Token; import jsyntaxpane.TokenType; %% %public %class CLexer %extends DefaultJFlexLexer %final %unicode %char %type Token %{ public CLexer() { super(); } private static final byte PARAN = 1; private static final byte BRACKET = 2; private static final byte CURLY = 3; @Override public int yychar() { return yychar; } %} /* main character classes */ LineTerminator = \r|\n|\r\n InputCharacter = [^\r\n] WhiteSpace = {LineTerminator} | [ \t\f]+ /* comments */ Comment = {TraditionalComment} | {EndOfLineComment} TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/" EndOfLineComment = "//" {InputCharacter}* {LineTerminator}? /* identifiers */ ConstantIdentifier = {SimpleConstantIdentifier} SimpleConstantIdentifier = [#A-Z0-9_]+ Identifier = [:jletter:][:jletterdigit:]* TypeIdentifier = {SimpleTypeIdentifier} SimpleTypeIdentifier = [A-Z][:jletterdigit:]* /* int literals */ DecLiteral = 0 | [1-9][0-9]* {IntegerSuffix} HexLiteral = 0 [xX] 0* {HexDigit}* {IntegerSuffix} HexDigit = [0-9a-fA-F] OctLiteral = 0+ {OctDigit}* {IntegerSuffix} OctDigit = [0-7] IntegerSuffix = [uU]? [lL]? [uU]? /* float literals */ FloatLiteral = ({FLit1}|{FLit2}|{FLit3}|{FLit4}) ([fF]|[dD])? FLit1 = [0-9]+ \. [0-9]* {Exponent}? FLit2 = \. [0-9]+ {Exponent}? FLit3 = [0-9]+ {Exponent} FLit4 = [0-9]+ {Exponent}? Exponent = [eE] [+\-]? [0-9]+ %% { /* keywords */ "break" | "case" | "catch" | "continue" | "default" | "do" | "else" | "for" | "goto" | "enum" | "if" | "inline" | "mutable" | "noinline" | "return" | "safecast" | "sealed" | "selectany" | "sizeof" | "static_cast" | "switch" | "template" | "this" | "thread" | "throw" | "try" | "typedef" | "typeid" | "typename" | "using" | "uuid" | "value" | "virtual" | "while" { return token(TokenType.KEYWORD); } "static" | "struct" | "union" | "volatile" | "register" | "extern" | "const" | "signed" | "unsigned" | "bool" | "char" | "double" | "int" | "long" | "float" | "short" | "void" { return token(TokenType.TYPE); } /* literals */ (\" ( [^\"\n\\] | \\[^\n] )* (\n | \\\n | \")) | (\' ( [^\'\n\\] | \\[^\n] )* (\n | \\\n | \')) { return token(TokenType.STRING); } "true" | "false" | {DecLiteral} | {OctLiteral} | {HexLiteral} | {FloatLiteral} { return token(TokenType.NUMBER); } /* preprocessor symbols */ "#define" | "#elif" | "#else" | "#endif" | "#error" | "#ifdef" | "#ifndef" | "#if" | "#import" | "#include" | "#line" | "#pragma" | "#undef" | "#using" { return token(TokenType.KEYWORD2); } /* separators */ "(" { return token(TokenType.OPERATOR, PARAN); } ")" { return token(TokenType.OPERATOR, -PARAN); } "{" { return token(TokenType.OPERATOR, CURLY); } "}" { return token(TokenType.OPERATOR, -CURLY); } "[" { return token(TokenType.OPERATOR, BRACKET); } "]" { return token(TokenType.OPERATOR, -BRACKET); } /* operators */ "=" | ";" | "," | "." | ">" | "<" | "!" | "~" | "?" | ":" | "+" | "-" | "*" | "/" | "&" | "|" | "^" | ">>" | "<<" | "%" { return token(TokenType.OPERATOR); } {ConstantIdentifier} { return token(TokenType.IDENTIFIER); } {TypeIdentifier} { return token(TokenType.IDENTIFIER); } \n | {Identifier} | {WhiteSpace} { return token(TokenType.IDENTIFIER); } {Comment} { return token(TokenType.COMMENT); } } /* error fallback */ .|\n { } <> { return null; } libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/xpath.flex0000644000175000017500000002437312127321547027710 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * This flex file originally donated to the project by HeyChinaski * */ package jsyntaxpane.lexers; import jsyntaxpane.Token; import jsyntaxpane.TokenType; %% %public %class XPathLexer %extends DefaultJFlexLexer %final %unicode %char %type Token %{ /** * Create an empty lexer, yyrset will be called later to reset and assign * the reader */ public XPathLexer() { super(); } @Override public int yychar() { return yychar; } private static final byte PARAN = 1; private static final byte BRACKET = 2; private static final byte CURLY = 3; %} Digits = [0-9]+ Letter = {BaseChar} | {Ideographic} BaseChar = [\u0041-\u005A] | [\u0061-\u007A] | [\u00C0-\u00D6] | [\u00D8-\u00F6] | [\u00F8-\u00FF] | [\u0100-\u0131] | [\u0134-\u013E] | [\u0141-\u0148] | [\u014A-\u017E] | [\u0180-\u01C3] | [\u01CD-\u01F0] | [\u01F4-\u01F5] | [\u01FA-\u0217] | [\u0250-\u02A8] | [\u02BB-\u02C1] | \u0386 | [\u0388-\u038A] | \u038C | [\u038E-\u03A1] | [\u03A3-\u03CE] | [\u03D0-\u03D6] | \u03DA | \u03DC | \u03DE | \u03E0 | [\u03E2-\u03F3] | [\u0401-\u040C] | [\u040E-\u044F] | [\u0451-\u045C] | [\u045E-\u0481] | [\u0490-\u04C4] | [\u04C7-\u04C8] | [\u04CB-\u04CC] | [\u04D0-\u04EB] | [\u04EE-\u04F5] | [\u04F8-\u04F9] | [\u0531-\u0556] | \u0559 | [\u0561-\u0586] | [\u05D0-\u05EA] | [\u05F0-\u05F2] | [\u0621-\u063A] | [\u0641-\u064A] | [\u0671-\u06B7] | [\u06BA-\u06BE] | [\u06C0-\u06CE] | [\u06D0-\u06D3] | \u06D5 | [\u06E5-\u06E6] | [\u0905-\u0939] | \u093D | [\u0958-\u0961] | [\u0985-\u098C] | [\u098F-\u0990] | [\u0993-\u09A8] | [\u09AA-\u09B0] | \u09B2 | [\u09B6-\u09B9] | [\u09DC-\u09DD] | [\u09DF-\u09E1] | [\u09F0-\u09F1] | [\u0A05-\u0A0A] | [\u0A0F-\u0A10] | [\u0A13-\u0A28] | [\u0A2A-\u0A30] | [\u0A32-\u0A33] | [\u0A35-\u0A36] | [\u0A38-\u0A39] | [\u0A59-\u0A5C] | \u0A5E | [\u0A72-\u0A74] | [\u0A85-\u0A8B] | \u0A8D | [\u0A8F-\u0A91] | [\u0A93-\u0AA8] | [\u0AAA-\u0AB0] | [\u0AB2-\u0AB3] | [\u0AB5-\u0AB9] | \u0ABD | \u0AE0 | [\u0B05-\u0B0C] | [\u0B0F-\u0B10] | [\u0B13-\u0B28] | [\u0B2A-\u0B30] | [\u0B32-\u0B33] | [\u0B36-\u0B39] | \u0B3D | [\u0B5C-\u0B5D] | [\u0B5F-\u0B61] | [\u0B85-\u0B8A] | [\u0B8E-\u0B90] | [\u0B92-\u0B95] | [\u0B99-\u0B9A] | \u0B9C | [\u0B9E-\u0B9F] | [\u0BA3-\u0BA4] | [\u0BA8-\u0BAA] | [\u0BAE-\u0BB5] | [\u0BB7-\u0BB9] | [\u0C05-\u0C0C] | [\u0C0E-\u0C10] | [\u0C12-\u0C28] | [\u0C2A-\u0C33] | [\u0C35-\u0C39] | [\u0C60-\u0C61] | [\u0C85-\u0C8C] | [\u0C8E-\u0C90] | [\u0C92-\u0CA8] | [\u0CAA-\u0CB3] | [\u0CB5-\u0CB9] | \u0CDE | [\u0CE0-\u0CE1] | [\u0D05-\u0D0C] | [\u0D0E-\u0D10] | [\u0D12-\u0D28] | [\u0D2A-\u0D39] | [\u0D60-\u0D61] | [\u0E01-\u0E2E] | \u0E30 | [\u0E32-\u0E33] | [\u0E40-\u0E45] | [\u0E81-\u0E82] | \u0E84 | [\u0E87-\u0E88] | \u0E8A | \u0E8D | [\u0E94-\u0E97] | [\u0E99-\u0E9F] | [\u0EA1-\u0EA3] | \u0EA5 | \u0EA7 | [\u0EAA-\u0EAB] | [\u0EAD-\u0EAE] | \u0EB0 | [\u0EB2-\u0EB3] | \u0EBD | [\u0EC0-\u0EC4] | [\u0F40-\u0F47] | [\u0F49-\u0F69] | [\u10A0-\u10C5] | [\u10D0-\u10F6] | \u1100 | [\u1102-\u1103] | [\u1105-\u1107] | \u1109 | [\u110B-\u110C] | [\u110E-\u1112] | \u113C | \u113E | \u1140 | \u114C | \u114E | \u1150 | [\u1154-\u1155] | \u1159 | [\u115F-\u1161] | \u1163 | \u1165 | \u1167 | \u1169 | [\u116D-\u116E] | [\u1172-\u1173] | \u1175 | \u119E | \u11A8 | \u11AB | [\u11AE-\u11AF] | [\u11B7-\u11B8] | \u11BA | [\u11BC-\u11C2] | \u11EB | \u11F0 | \u11F9 | [\u1E00-\u1E9B] | [\u1EA0-\u1EF9] | [\u1F00-\u1F15] | [\u1F18-\u1F1D] | [\u1F20-\u1F45] | [\u1F48-\u1F4D] | [\u1F50-\u1F57] | \u1F59 | \u1F5B | \u1F5D | [\u1F5F-\u1F7D] | [\u1F80-\u1FB4] | [\u1FB6-\u1FBC] | \u1FBE | [\u1FC2-\u1FC4] | [\u1FC6-\u1FCC] | [\u1FD0-\u1FD3] | [\u1FD6-\u1FDB] | [\u1FE0-\u1FEC] | [\u1FF2-\u1FF4] | [\u1FF6-\u1FFC] | \u2126 | [\u212A-\u212B] | \u212E | [\u2180-\u2182] | [\u3041-\u3094] | [\u30A1-\u30FA] | [\u3105-\u312C] | [\uAC00-\uD7A3] Ideographic = [\u4E00-\u9FA5] | \u3007 | [\u3021-\u3029] NCNameStartChar = {Letter} | "_" NameStartCharMinusColon = [A-Z] | "_" | [a-z] | [\uC0-\uD6] | [\uD8-\uF6] | [\uF8-\u2FF] | [\u370-\u37D] | [\u37F-\u1FFF] | [\u200C-\u200D] | [\u2070-\u218F] | [\u2C00-\u2FEF] | [\u3001-\uD7FF] | [\uF900-\uFDCF] | [\uFDF0-\uFFFD] NCNameChar = {NameStartCharMinusColon} | "-" | "." | [0-9] | \uB7 | [\u0300-\u036F] | [\u203F-\u2040] NCName = {NCNameStartChar} {NCNameChar}* LocalPart = {NCName} UnprefixedName = {LocalPart} Prefix = {NCName} PrefixedName = {Prefix} ":" {LocalPart} QName = {PrefixedName} | {UnprefixedName} NameTest = "*" | {NCName} ":" "*" | {QName} VariableReference = "$" {QName} LineTerminator = \r|\n|\r\n NodeType = "comment" | "text" | "processing-instruction" | "node" OperatorName = "and" | "or" | "mod" | "div" Operator = {OperatorName} | "*" | "/" | "//" | "|" | "+" | "-" | "=" | "!=" | "<" | "<=" | ">" | ">=" FunctionName = {QName} XPathFunction = "default" | "node-name" | "nilled" | "data" | "base-uri" | "document-uri" | "error" | "trace" | "number" | "abs" | "ceiling" | "floor" | "round" | "round-half-to-even" | "string" | "codepoints-to-string" | "string-to-codepoints" | "codepoint-equal" | "compare" | "concat" | "string-join" | "substring" | "string-length" | "normalize-space" | "normalize-unicode" | "upper-case" | "lower-case" | "translate" | "escape-uri" | "contains" | "starts-with" | "ends-with" | "substring-before" | "substring-after" | "matches" | "replace" | "tokenize" | "resolve-uri" | "boolean" | "not" | "true" | "false" | "dateTime" | "years-from-duration" | "months-from-duration" | "days-from-duration" | "hours-from-duration" | "minutes-from-duration" | "seconds-from-duration" | "year-from-dateTime" | "month-from-dateTime" | "day-from-dateTime" | "hours-from-dateTime" | "minutes-from-dateTime" | "seconds-from-dateTime" | "timezone-from-dateTime" | "year-from-date" | "month-from-date" | "day-from-date" | "timezone-from-date" | "hours-from-time" | "minutes-from-time" | "seconds-from-time" | "timezone-from-time" | "adjust-dateTime-to-timezone" | "adjust-date-to-timezone" | "adjust-time-to-timezone" | "QName" | "local-name-from-QName" | "namespace-uri-from-QName" | "namespace-uri-for-prefix" | "in-scope-prefixes" | "resolve-QName" | "name" | "local-name" | "namespace-uri" | "lang" | "root" | "index-of" | "remove" | "empty" | "exists" | "distinct-values" | "insert-before" | "reverse" | "subsequence" | "unordered" | "zero-or-one" | "one-or-more" | "exactly-one" | "deep-equal" | "count" | "avg" | "max" | "min" | "sum" | "id" | "idref" | "doc" | "doc-available" | "collection" | "position" | "last" | "current-dateTime" | "current-date" | "current-time" | "implicit-timezone" | "default-collation" | "static-base-uri" AxisName = "ancestor" | "ancestor-or-self" | "attribute" | "child" | "descendant" | "descendant-or-self" | "following" | "following-sibling" | "namespace" | "parent" | "preceding" | "preceding-sibling" | "self" Number = {Digits} | {Digits} "." {Digits} S = [\u20] | [\u9] | [\uD] | [\uA] %state STRING_DOUBLE, STRING_SINGLE %% { {VariableReference} { return token(TokenType.IDENTIFIER); } {Number} { return token(TokenType.NUMBER); } {AxisName} { return token(TokenType.TYPE); } "(" { return token(TokenType.OPERATOR, PARAN); } ")" { return token(TokenType.OPERATOR, -PARAN); } "{" { return token(TokenType.OPERATOR, CURLY); } "}" { return token(TokenType.OPERATOR, -CURLY); } "[" { return token(TokenType.OPERATOR, BRACKET); } "]" { return token(TokenType.OPERATOR, -BRACKET); } "." | ".." | "@" | "," | "::" { return token(TokenType.OPERATOR); } {Operator} { return token(TokenType.OPERATOR); } {NodeType} { return token(TokenType.KEYWORD); } {XPathFunction} { return token(TokenType.KEYWORD2); } {FunctionName} { return token(TokenType.IDENTIFIER); } {NameTest} { return token(TokenType.IDENTIFIER); } /* string literal */ \" { yybegin(STRING_DOUBLE); tokenStart = yychar; tokenLength = 1; } /* string literal */ \' { yybegin(STRING_SINGLE); tokenStart = yychar; tokenLength = 1; } ":" | {S} | "\"" {} . | {LineTerminator} { /* skip */ } } { \" { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.STRING, tokenStart, tokenLength + 1); } [^\"] { tokenLength += yylength(); } } { \' { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.STRING, tokenStart, tokenLength + 1); } [^\'] { tokenLength += yylength(); } } libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/sql.flex0000644000175000017500000002472012127321547027357 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.lexers; import jsyntaxpane.Token; import jsyntaxpane.TokenType; %% %public %class SqlLexer %extends DefaultJFlexLexer %final %unicode %char %type Token %caseless %{ /** * Default constructor is needed as we will always call the yyreset */ public SqlLexer() { super(); } @Override public int yychar() { return yychar; } %} /* main character classes */ LineTerminator = \r|\n|\r\n InputCharacter = [^\r\n] WhiteSpace = {LineTerminator} | [ \t\f] /* comments */ Comment = {TraditionalComment} | {EndOfLineComment} | {DocumentationComment} TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/" DocumentationComment = "/**" {CommentContent} "*"+ "/" CommentContent = ( [^*] | \*+ [^/*] )* EndOfLineComment = "--" {InputCharacter}* {LineTerminator}? /* identifiers */ Identifier = [:jletter:][:jletterdigit:]* /* integer literals */ DecIntegerLiteral = 0 | [1-9][0-9]* /* floating point literals */ FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] FLit1 = [0-9]+ \. [0-9]* FLit2 = \. [0-9]+ FLit3 = [0-9]+ Exponent = [eE] [+-]? [0-9]+ /* string and character literals */ StringCharacter = [^\r\n\"\\] SingleCharacter = [^\r\n\'\\] // Create states for Double Quoted and Single Quoted Strings %state DQ_STRING, SQ_STRING Reserved = "ADD" | "ALL" | "ALLOW REVERSE SCANS" | "ALTER" | "ANALYZE" | "AND" | "AS" | "ASC" | "AUTOMATIC" | "BEGIN" | "BEFORE" | "BETWEEN" | "BIGINT" | "BINARY" | "BLOB" | "BOTH" | "BUFFERPOOL" | "BY" | "CACHE" | "CALL" | "CASCADE" | "CASE" | "CHANGE" | "CHAR" | "CHARACTER" | "CHECK" | "COLLATE" | "COLUMN" | "COMMIT" | "CONDITION" | "CONSTANT" | "CONSTRAINT" | "CONTINUE" | "CONVERT" | "CREATE" | "CROSS" | "CURSOR" | "DATE" | "DATABASE" | "DATABASES" | "DEC" | "DECIMAL" | "DECODE" | "DECLARE" | "DEFAULT" | "DELAYED" | "DELETE" | "DESC" | "DESCRIBE" | "DETERMINISTIC" | "DISTINCT" | "DISTINCTROW" | "DIV" | "DOUBLE" | "DROP" | "DUAL" | "EACH" | "ELSE" | "ELSEIF" | "ENCLOSED" | "END" | "ESCAPED" | "EXCEPTION" | "EXISTS" | "EXIT" | "EXPLAIN" | "FALSE" | "FETCH" | "FLOAT" | "FLOAT4" | "FLOAT8" | "FOR" | "FORCE" | "FOREIGN" | "FROM" | "FUNCTION" | "FULLTEXT" | "GLOBAL TEMPORARY" | "GRANT" | "GROUP" | "HAVING" | "IF" | "IGNORE" | "IN" | "INDEX" | "INFILE" | "INNER" | "INOUT" | "INSENSITIVE" | "INSERT" | "INT" | "INTEGER" | "INTERVAL" | "INTO" | "IS" | "IS REF CURSOR" | "ITERATE" | "JOIN" | "KEY" | "KEYS" | "KILL" | "LEADING" | "LEAVE" | "LEFT" | "LIKE" | "LIMIT" | "LINES" | "LOAD" | "LOCK" | "LONG" | "LOOP" | "MATCH" | "MERGE" | "MINVALUE" | "MAXVALUE" | "MOD" | "MODIFIES" | "NATURAL" | "NOCYCLE" | "NOORDER" | "NOT" | "NULL" | "NUMERIC" | "NUMBER" | "ON" | "OPEN" | "OPTIMIZE" | "OPTION" | "OPTIONALLY" | "OR" | "ORDER" | "OTHERS" | "OUT" | "OUTER" | "OUTFILE" | "PACKAGE" | "PACKAGE BODY" | "PAGESIZE" | "PLS_INTEGER" | "PRAGMA" | "PRECISION" | "PRIMARY" | "PROCEDURE" | "PURGE" | "RAISE" | "READ" | "READS" | "REAL" | "REFERENCES" | "REGEXP" | "RELEASE" | "RENAME" | "REPEAT" | "REPLACE" | "REQUIRE" | "RESTRICT" | "RETURN" | "REVOKE" | "RIGHT" | "RLIKE" | "ROLLBACK" | "ROWCOUNT" | "ROWTYPE" | "SIZE" | "SCHEMA" | "SCHEMAS" | "SELECT" | "SENSITIVE" | "SEPARATOR" | "SEQUENCE" | "SET" | "SHOW" | "SMALLINT" | "SONAME" | "SPATIAL" | "SPECIFIC" | "SQL" | "SQLEXCEPTION" | "SQLSTATE" | "SQLWARNING" | "STARTING" | "SYSDATE" | "TABLE" | "TABLESPACE" | "TERMINATED" | "THEN" | "TO" | "TO_CHAR" | "TO_DATE" | "TRAILING" | "TRIGGER" | "TRUE" | "TRUNCATE" | "TYPE" | "UNDO" | "UNION" | "UNIQUE" | "UNLOCK" | "UNSIGNED" | "UPDATE" | "USAGE" | "USE" | "USER" | "USING" | "VALUES" | "VARBINARY" | "VARCHAR" | "VARCHAR2" | "VARCHARACTER" | "VARYING" | "WHEN" | "WHERE" | "WHILE" | "WITH" | "WRITE" | "XOR" | "ZEROFILL" %% { /* keywords */ {Reserved} { return token(TokenType.KEYWORD); } /* operators */ "(" | ")" | "{" | "}" | "[" | "]" | ";" | "," | "." | "@" | "=" | ">" | "<" | "!" | "~" | "?" | ":" { return token(TokenType.OPERATOR); } /* string literal */ \" { yybegin(DQ_STRING); tokenStart = yychar; tokenLength = 1; } \' { yybegin(SQ_STRING); tokenStart = yychar; tokenLength = 1; } /* numeric literals */ {DecIntegerLiteral} | {FloatLiteral} { return token(TokenType.NUMBER); } /* comments */ {Comment} { return token(TokenType.COMMENT); } /* whitespace */ {WhiteSpace}+ { /* skip */ } /* identifiers */ {Identifier} { return token(TokenType.IDENTIFIER); } } { {StringCharacter}+ { tokenLength += yylength(); } \"\" { tokenLength += 2; } \\. { tokenLength += 2; } {LineTerminator} { yybegin(YYINITIAL); } \" { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.STRING, tokenStart, tokenLength + 1); } } { {SingleCharacter}+ { tokenLength += yylength(); } \'\' { tokenLength += 2; } \\. { tokenLength += 2; } {LineTerminator} { yybegin(YYINITIAL); } \' { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.STRING, tokenStart, tokenLength + 1); } } /* error fallback */ .|\n { } <> { return null; } libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/xml.flex0000644000175000017500000001343512127321547027361 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.lexers; import jsyntaxpane.Token; import jsyntaxpane.TokenType; %% %public %class XmlLexer %extends DefaultJFlexLexer %final %unicode %char %type Token %{ /** * Create an empty lexer, yyrset will be called later to reset and assign * the reader */ public XmlLexer() { super(); } @Override public int yychar() { return yychar; } private static final byte TAG_OPEN = 1; private static final byte TAG_CLOSE = -1; private static final byte INSTR_OPEN = 2; private static final byte INSTR_CLOSE = -2; private static final byte CDATA_OPEN = 3; private static final byte CDATA_CLOSE = -3; private static final byte COMMENT_OPEN = 4; private static final byte COMMENT_CLOSE = -4; %} %xstate COMMENT, CDATA, TAG, INSTR /* main character classes */ /* white space */ S = (\u0020 | \u0009 | \u000D | \u000A)+ /* characters */ Char = \u0009 | \u000A | \u000D | [\u0020-\uD7FF] | [\uE000-\uFFFD] | [\u10000-\u10FFFF] /* comments */ CommentStart = "" NameStartChar = ":" | [A-Z] | "_" | [a-z] NameStartCharUnicode = [\u00C0-\u00D6] | [\u00D8-\u00F6] | [\u00F8-\u02FF] | [\u0370-\u037D] | [\u037F-\u1FFF] | [\u200C-\u200D] | [\u2070-\u218F] | [\u2C00-\u2FEF] | [\u3001-\uD7FF] | [\uF900-\uFDCF] | [\uFDF0-\uFFFD] | [\u10000-\uEFFFF] NameChar = {NameStartChar} | "-" | "." | [0-9] | \u00B7 NameCharUnicode = [\u0300-\u036F] | [\u0203F-\u2040] Name = {NameStartChar} {NameChar}* NameUnicode = ({NameStartChar}|{NameStartCharUnicode}) ({NameChar}|{NameCharUnicode})* /* XML Processing Instructions */ InstrStart = "" /* CDATA */ CDataStart = "" /* Tags */ OpenTagStart = "<" {Name} OpenTagClose = "/>" OpenTagEnd = ">" CloseTag = "" /* attribute */ Attribute = {Name} "=" /* string and character literals */ DQuoteStringChar = [^\r\n\"] SQuoteStringChar = [^\r\n\'] %% { "&" [a-z]+ ";" | "&#" [:digit:]+ ";" { return token(TokenType.KEYWORD2); } {InstrStart} { yybegin(INSTR); return token(TokenType.TYPE2, INSTR_OPEN); } {OpenTagStart} { yybegin(TAG); return token(TokenType.TYPE, TAG_OPEN); } {CloseTag} { return token(TokenType.TYPE, TAG_CLOSE); } {CommentStart} { yybegin(COMMENT); return token(TokenType.COMMENT2, COMMENT_OPEN); } {CDataStart} { yybegin(CDATA); return token(TokenType.COMMENT2, CDATA_OPEN); } } { {Attribute} { return token(TokenType.IDENTIFIER); } \"{DQuoteStringChar}*\" | \'{SQuoteStringChar}*\' { return token(TokenType.STRING); } {InstrEnd} { yybegin(YYINITIAL); return token(TokenType.TYPE2, INSTR_CLOSE); } } { {Attribute} { return token(TokenType.IDENTIFIER); } \"{DQuoteStringChar}*\" | \'{SQuoteStringChar}*\' { return token(TokenType.STRING); } {OpenTagClose} { yybegin(YYINITIAL); return token(TokenType.TYPE, TAG_CLOSE); } {OpenTagEnd} { yybegin(YYINITIAL); return token(TokenType.TYPE); } } { {CommentEnd} { yybegin(YYINITIAL); return token(TokenType.COMMENT2, COMMENT_CLOSE); } ~{CommentEnd} { yypushback(3); return token(TokenType.COMMENT); } } { {CDataEnd} { yybegin(YYINITIAL); return token(TokenType.COMMENT2, CDATA_CLOSE); } ~{CDataEnd} { yypushback(3); return token(TokenType.COMMENT); } } { /* error fallback */ .|\n { } <> { return null; } } libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/dosbatch.flex0000644000175000017500000000767712127321547030363 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.lexers; import jsyntaxpane.Token; import jsyntaxpane.TokenType; %% %public %class DOSBatchLexer %extends DefaultJFlexLexer %final %unicode %char %type Token %ignorecase %state ECHO_TEXT %{ /** * Create an empty lexer, yyrset will be called later to reset and assign * the reader */ public DOSBatchLexer() { super(); } @Override public int yychar() { return yychar; } %} StartComment = "rem" LineTerminator = \r|\n|\r\n InputCharacter = [^\r\n] Comment = {StartComment} {InputCharacter}* {LineTerminator}? %% { /* DOS keywords */ "@" | "goto" | "call" | "exit" | "if" | "else" | "for" | "copy" | "set" | "dir" | "cd" | "set" | "errorlevel" { return token(TokenType.KEYWORD); } "%" [:jletter:] [:jletterdigit:]* "%" { return token(TokenType.STRING2); } "%" [:digit:]+ { return token(TokenType.KEYWORD2); } "echo" { yybegin(ECHO_TEXT); return token(TokenType.KEYWORD); } /* DOS commands */ "append" | "assoc" | "at" | "attrib" | "break" | "cacls" | "cd" | "chcp" | "chdir" | "chkdsk" | "chkntfs" | "cls" | "cmd" | "color" | "comp" | "compact" | "convert" | "copy" | "date" | "del" | "dir" | "diskcomp" | "diskcopy" | "doskey" | "exist" | "endlocal" | "erase" | "fc" | "find" | "findstr" | "format" | "ftype" | "graftabl" | "help" | "keyb" | "label" | "md" | "mkdir" | "mode" | "more" | "move" | "path" | "pause" | "popd" | "print" | "prompt" | "pushd" | "rd" | "recover" | "rem" | "ren" | "rename" | "replace" | "restore" | "rmdir" | "set" | "setlocal" | "shift" | "sort" | "start" | "subst" | "time" | "title" | "tree" | "type" | "ver" | "verify" | "vol" | "xcopy" { return token(TokenType.KEYWORD); } [:jletterdigit:]+ { return token(TokenType.IDENTIFIER); } /* labels */ ":" [a-zA-Z][a-zA-Z0-9_]* { return token(TokenType.TYPE3); } /* comments */ {Comment} { return token(TokenType.COMMENT); } . | {LineTerminator} { /* skip */ } } { "%" [:jletter:] [:jletterdigit:]* "%" { return token(TokenType.STRING2); } "%" [:digit:]+ { return token(TokenType.KEYWORD2); } . * { return token(TokenType.STRING); } {LineTerminator} { yybegin(YYINITIAL) ; } } <> { return null; }libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/properties.flex0000644000175000017500000000304212127321547030746 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.lexers; import jsyntaxpane.Token; import jsyntaxpane.TokenType; %% %public %class PropertiesLexer %extends DefaultJFlexLexer %final %unicode %char %type Token %{ /** * Create an empty lexer, yyrset will be called later to reset and assign * the reader */ public PropertiesLexer() { super(); } @Override public int yychar() { return yychar; } %} StartComment = # WhiteSpace = [ \t] LineTerminator = \r|\n|\r\n InputCharacter = [^\r\n] KeyCharacter = [a-zA-Z0-9._ ] %% { {KeyCharacter}+{WhiteSpace}*= { return token(TokenType.KEYWORD); } {StartComment} {InputCharacter}* {LineTerminator}? { return token(TokenType.COMMENT); } . | {LineTerminator} { /* skip */ } } <> { return null; }libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/bash.flex0000644000175000017500000002673412127321547027504 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.lexers; import jsyntaxpane.Token; import jsyntaxpane.TokenType; %% %public %class BashLexer %extends DefaultJFlexLexer %final %unicode %char %type Token %{ /** * Create an empty lexer, yyrset will be called later to reset and assign * the reader */ public BashLexer() { super(); } private static final byte PARAN = 1; private static final byte BRACKET = 2; private static final byte CURLY = 3; private static final byte DO = 4; private static final byte CASE = 5; private static final byte IF = 5; private static final byte INT_EXPR = 6; @Override public int yychar() { return yychar; } %} LineTerminator = \r|\n|\r\n InputCharacter = [^\r\n] Identifier = [a-zA-Z][a-zA-Z0-9_]* Comment = "#" {InputCharacter}* {LineTerminator}? Shebang = "#!" {InputCharacter}* {LineTerminator}? StringCharacter = [^\r\n\"\\] SingleCharacter = [^\r\n\'\\] BackQuoteChars = [^\r\n\`\\] %% { /* Bash keywords */ "if" { return token(TokenType.KEYWORD, IF); } "fi" { return token(TokenType.KEYWORD, -IF); } "do" { return token(TokenType.KEYWORD, DO); } "done" { return token(TokenType.KEYWORD, -DO); } "case" { return token(TokenType.KEYWORD, CASE); } "esac" { return token(TokenType.KEYWORD, -CASE); } "$((" { return token(TokenType.KEYWORD, INT_EXPR); } "))" { return token(TokenType.KEYWORD, -INT_EXPR); } "(" { return token(TokenType.OPERATOR, PARAN); } ")" { return token(TokenType.OPERATOR, -PARAN); } "{" { return token(TokenType.OPERATOR, CURLY); } "}" { return token(TokenType.OPERATOR, -CURLY); } "[" { return token(TokenType.OPERATOR, BRACKET); } "]" { return token(TokenType.OPERATOR, -BRACKET); } "-eq" | "-ne" | "-lt" | "-gt" | "-ge" | "-le" | ">=" | "<=" | "==" | "!=" | "-z" | "-n" | "=~" | "$" | "#" | "&" | "." | ";" | "+" | "-" | "=" | "/" | "++" | "@" { return token(TokenType.OPERATOR); } "then" | "else" | "elif" | "for" | "in" | "until" | "while" | "break" | "local" | "continue" { return token(TokenType.KEYWORD); } /* string literal */ \"{StringCharacter}+\" | \'{SingleCharacter}+\ { return token(TokenType.STRING); } \`{BackQuoteChars}+\` { return token(TokenType.STRING2); } /* Other commands */ "alias" | "apropos" | "apt" | "aspell" | "awk" | "bash" | "basename" | "bc" | "bg" | "builtin" | "bzip2" | "cal" | "cat" | "cd" | "cfdisk" | "chgrp" | "chmod" | "chown" | "chroot" | "chkconfig" | "cksum" | "clear" | "cmp" | "comm" | "command" | "continue" | "cp" | "cron" | "crontab" | "csplit" | "cut" | "date" | "dc" | "dd" | "ddrescue" | "declare" | "df" | "diff" | "diff3" | "dig" | "dir" | "dircolors" | "dirname" | "dirs" | "dmesg" | "du" | "echo" | "egrep" | "eject" | "enable" | "env" | "ethtool" | "eval" | "exec" | "exit" | "expect" | "expand" | "export" | "expr" | "false" | "fdformat" | "fdisk" | "fg" | "fgrep" | "file" | "find" | "fmt" | "fold" | "format" | "free" | "fsck" | "ftp" | "function" | "gawk" | "getopts" | "grep" | "groups" | "gzip" | "hash" | "head" | "history" | "hostname" | "id" | "ifconfig" | "ifdown" | "ifup" | "import" | "install" | "join" | "kill" | "killall" | "less" | "let" | "ln" | "locate" | "logname" | "logout" | "look" | "lpc" | "lpr" | "lprint" | "lprintd" | "lprintq" | "lprm" | "ls" | "lsof" | "man" | "mkdir" | "mkfifo" | "mkisofs" | "mknod" | "more" | "mount" | "mtools" | "mv" | "mmv" | "netstat" | "nice" | "nl" | "nohup" | "nslookup" | "open" | "op" | "passwd" | "paste" | "pathchk" | "ping" | "popd" | "pr" | "printcap" | "printenv" | "printf" | "ps" | "pushd" | "pwd" | "quota" | "quotacheck" | "quotactl" | "ram" | "rcp" | "read" | "readonly" | "reboot" | "renice" | "remsync" | "return" | "rev" | "rm" | "rmdir" | "rsync" | "screen" | "scp" | "sdiff" | "sed" | "select" | "seq" | "set" | "sftp" | "shift" | "shopt" | "shutdown" | "sleep" | "slocate" | "sort" | "source" | "split" | "ssh" | "strace" | "su" | "sudo" | "sum" | "symlink" | "sync" | "tail" | "tar" | "tee" | "test" | "time" | "times" | "touch" | "top" | "traceroute" | "trap" | "tr" | "true" | "tsort" | "tty" | "type" | "ulimit" | "umask" | "umount" | "unalias" | "uname" | "unexpand" | "uniq" | "units" | "unset" | "unshar" | "useradd" | "usermod" | "users" | "uuencode" | "uudecode" | "v" | "vdir" | "vi" | "vmstat" | "watch" | "wc" | "whereis" | "which" | "who" | "whoami" | "Wget" | "write" | "xargs" | "yes" { return token(TokenType.KEYWORD); } {Identifier} { return token(TokenType.IDENTIFIER); } /* labels */ ":" [a-zA-Z][a-zA-Z0-9_]* { return token(TokenType.TYPE); } /* comments */ {Shebang} { return token(TokenType.COMMENT2); } {Comment} { return token(TokenType.COMMENT); } . | {LineTerminator} { /* skip */ } } <> { return null; }libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/python.flex0000644000175000017500000003071312127321547030100 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.lexers; import jsyntaxpane.Token; import jsyntaxpane.TokenType; %% %public %class PythonLexer %extends DefaultJFlexLexer %final %unicode %char %type Token %{ /** * Create an empty lexer, yyrset will be called later to reset and assign * the reader */ public PythonLexer() { super(); } @Override public int yychar() { return yychar; } private static final byte PARAN = 1; private static final byte BRACKET = 2; private static final byte CURLY = 3; %} /* main character classes */ LineTerminator = \r|\n|\r\n InputCharacter = [^\r\n] WhiteSpace = {LineTerminator} | [ \t\f]+ /* comments */ Comment = "#" {InputCharacter}* {LineTerminator}? /* identifiers */ Identifier = [a-zA-Z][a-zA-Z0-9_]* /* integer literals */ DecIntegerLiteral = 0 | [1-9][0-9]* DecLongLiteral = {DecIntegerLiteral} [lL] HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] HexDigit = [0-9a-fA-F] OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15} OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] OctDigit = [0-7] /* floating point literals */ FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? FLit1 = [0-9]+ \. [0-9]* FLit2 = \. [0-9]+ FLit3 = [0-9]+ Exponent = [eE] [+-]? [0-9]+ /* string and character literals */ StringCharacter = [^\r\n\"\\] SQStringCharacter = [^\r\n\'\\] %state STRING, ML_STRING, SQSTRING, SQML_STRING %% { /* keywords */ "and" | "as" | "assert" | "break" | "class" | "continue" | "def" | "del" | "elif" | "else" | "except" | "exec" | "finally" | "for" | "from" | "global" | "if" | "import" | "in" | "is" | "lambda" | "not" | "or" | "pass" | "print" | "self" | /* not exactly keyword, but almost */ "raise" | "return" | "try" | "while" | "with" | "yield" { return token(TokenType.KEYWORD); } /* Built-in Types*/ "yield" | "Ellipsis" | "False" | "None" | "NotImplemented" | "True" | "__import__" | "__name__" | "abs" | "apply" | "bool" | "buffer" | "callable" | "chr" | "classmethod" | "cmp" | "coerce" | "compile" | "complex" | "delattr" | "dict" | "dir" | "divmod" | "enumerate" | "eval" | "execfile" | "file" | "filter" | "float" | "frozenset" | "getattr" | "globals" | "hasattr" | "hash" | "help" | "hex" | "id" | "input" | "int" | "intern" | "isinstance" | "issubclass" | "iter" | "len" | "list" | "locals" | "long" | "map" | "max" | "min" | "object" | "oct" | "open" | "ord" | "pow" | "property" | "range" | "raw_input" | "reduce" | "reload" | "repr" | "reversed" | "round" | "set" | "setattr" | "slice" | "sorted" | "staticmethod" | "str" | "sum" | "super" | "tuple" | "type" | "unichr" | "unicode" | "vars" | "xrange" | "zip" { return token(TokenType.TYPE); } /* operators */ "(" { return token(TokenType.OPERATOR, PARAN); } ")" { return token(TokenType.OPERATOR, -PARAN); } "{" { return token(TokenType.OPERATOR, CURLY); } "}" { return token(TokenType.OPERATOR, -CURLY); } "[" { return token(TokenType.OPERATOR, BRACKET); } "]" { return token(TokenType.OPERATOR, -BRACKET); } "+" | "-" | "*" | "**" | "/" | "//" | "%" | "<<" | ">>" | "&" | "|" | "^" | "~" | "<" | ">" | "<=" | ">=" | "==" | "!=" | "<>" | "@" | "," | ":" | "." | "`" | "=" | ";" | "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "&=" | "|=" | "^=" | ">>=" | "<<=" | "**=" { return token(TokenType.OPERATOR); } /* string literal */ \"{3} { yybegin(ML_STRING); tokenStart = yychar; tokenLength = 3; } \" { yybegin(STRING); tokenStart = yychar; tokenLength = 1; } \'{3} { yybegin(SQML_STRING); tokenStart = yychar; tokenLength = 3; } \' { yybegin(SQSTRING); tokenStart = yychar; tokenLength = 1; } /* numeric literals */ {DecIntegerLiteral} | {DecLongLiteral} | {HexIntegerLiteral} | {HexLongLiteral} | {OctIntegerLiteral} | {OctLongLiteral} | {FloatLiteral} | {DoubleLiteral} | {FloatLiteral}[jJ] { return token(TokenType.NUMBER); } /* comments */ {Comment} { return token(TokenType.COMMENT); } /* whitespace */ {WhiteSpace} { } /* identifiers */ {Identifier} { return token(TokenType.IDENTIFIER); } "$" | "?" { return token(TokenType.ERROR); } } { \" { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.STRING, tokenStart, tokenLength + 1); } {StringCharacter}+ { tokenLength += yylength(); } \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } /* escape sequences */ \\. { tokenLength += 2; } {LineTerminator} { yybegin(YYINITIAL); } } { \"{3} { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.STRING, tokenStart, tokenLength + 3); } {StringCharacter}+ { tokenLength += yylength(); } \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } \" { tokenLength ++; } /* escape sequences */ \\. { tokenLength += 2; } {LineTerminator} { tokenLength ++; } } { "'" { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.STRING, tokenStart, tokenLength + 1); } {SQStringCharacter}+ { tokenLength += yylength(); } \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } /* escape sequences */ \\. { tokenLength += 2; } {LineTerminator} { yybegin(YYINITIAL); } } { \'{3} { yybegin(YYINITIAL); // length also includes the trailing quote return token(TokenType.STRING, tokenStart, tokenLength + 3); } {SQStringCharacter}+ { tokenLength += yylength(); } \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } \' { tokenLength ++; } /* escape sequences */ \\. { tokenLength += 2; } {LineTerminator} { tokenLength ++; } } /* error fallback */ .|\n { } <> { return null; } libjsyntaxpane-java-0.9.6~r156/src/main/java/0000755000175000017500000000000012127321546021635 5ustar sylvestresylvestrelibjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/0000755000175000017500000000000012127321546024201 5ustar sylvestresylvestrelibjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/components/0000755000175000017500000000000012127321546026366 5ustar sylvestresylvestrelibjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/components/LineNumbersRuler.java0000644000175000017500000002346712127321546032502 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.components; import java.awt.Color; import java.awt.Container; import java.awt.Dimension; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Insets; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.BorderFactory; import javax.swing.JEditorPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.SwingUtilities; import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.text.BadLocationException; import javax.swing.text.Element; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; import jsyntaxpane.SyntaxView; import jsyntaxpane.actions.ActionUtils; import jsyntaxpane.actions.gui.GotoLineDialog; import jsyntaxpane.util.Configuration; /** * This class will display line numbers for a related text component. The text * component must use the same line height for each line. * * This class was designed to be used as a component added to the row header * of a JScrollPane. * * Original code from http://tips4java.wordpress.com/2009/05/23/text-component-line-number/ * * @author Rob Camick * * Revised for jsyntaxpane * * @author Ayman Al-Sairafi */ public class LineNumbersRuler extends JPanel implements CaretListener, DocumentListener, PropertyChangeListener, SyntaxComponent { public static final String PROPERTY_BACKGROUND = "LineNumbers.Background"; public static final String PROPERTY_FOREGROUND = "LineNumbers.Foreground"; public static final String PROPERTY_CURRENT_BACK = "LineNumbers.CurrentBack"; public static final String PROPERTY_LEFT_MARGIN = "LineNumbers.LeftMargin"; public static final String PROPERTY_RIGHT_MARGIN = "LineNumbers.RightMargin"; public static final String PROPERTY_Y_OFFSET = "LineNumbers.YOFFset"; public static final int DEFAULT_R_MARGIN = 5; public static final int DEFAULT_L_MARGIN = 5; private Status status; private final static int MAX_HEIGHT = Integer.MAX_VALUE - 1000000; // Text component this TextTextLineNumber component is in sync with private JEditorPane editor; private int minimumDisplayDigits = 2; // Keep history information to reduce the number of times the component // needs to be repainted private int lastDigits; private int lastHeight; private int lastLine; private MouseListener mouseListener = null; // The formatting to use for displaying numbers. Use in String.format(numbersFormat, line) private String numbersFormat = "%3d"; private Color currentLineColor; /** * Get the JscrollPane that contains this EditorPane, or null if no * JScrollPane is the parent of this editor * @param editorPane * @return */ public JScrollPane getScrollPane(JTextComponent editorPane) { Container p = editorPane.getParent(); while (p != null) { if (p instanceof JScrollPane) { return (JScrollPane) p; } p = p.getParent(); } return null; } @Override public void config(Configuration config) { int right = config.getInteger(PROPERTY_RIGHT_MARGIN, DEFAULT_R_MARGIN); int left = config.getInteger(PROPERTY_LEFT_MARGIN, DEFAULT_L_MARGIN); Color foreground = config.getColor(PROPERTY_FOREGROUND, Color.BLACK); setForeground(foreground); Color back = config.getColor(PROPERTY_BACKGROUND, Color.WHITE); setBackground(back); setBorder(BorderFactory.createEmptyBorder(0, left, 0, right)); currentLineColor = config.getColor(PROPERTY_CURRENT_BACK, back); } @Override public void install(final JEditorPane editor) { this.editor = editor; setFont(editor.getFont()); // setMinimumDisplayDigits(3); editor.getDocument().addDocumentListener(this); editor.addCaretListener(this); editor.addPropertyChangeListener(this); JScrollPane sp = getScrollPane(editor); sp.setRowHeaderView(this); mouseListener = new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { GotoLineDialog.showForEditor(editor); } }; addMouseListener(mouseListener); status = Status.INSTALLING; documentChanged(); } @Override public void deinstall(JEditorPane editor) { removeMouseListener(mouseListener); status = Status.DEINSTALLING; this.editor.getDocument().removeDocumentListener(this); editor.removeCaretListener(this); editor.removePropertyChangeListener(this); JScrollPane sp = getScrollPane(editor); if (sp != null) { editor.getDocument().removeDocumentListener(this); sp.setRowHeaderView(null); } } /** * Gets the minimum display digits * * @return the minimum display digits */ public int getMinimumDisplayDigits() { return minimumDisplayDigits; } /** * Specify the minimum number of digits used to calculate the preferred * width of the component. Default is 3. * * @param minimumDisplayDigits the number digits used in the preferred * width calculation */ public void setMinimumDisplayDigits(int minimumDisplayDigits) { this.minimumDisplayDigits = minimumDisplayDigits; setPreferredWidth(); } /** * Calculate the width needed to display the maximum line number */ private void setPreferredWidth() { int lines = ActionUtils.getLineCount(editor); int digits = Math.max(String.valueOf(lines).length(), minimumDisplayDigits); // Update sizes when number of digits in the line number changes if (lastDigits != digits) { lastDigits = digits; numbersFormat = "%" + digits + "d"; FontMetrics fontMetrics = getFontMetrics(getFont()); int width = fontMetrics.charWidth('0') * digits; Insets insets = getInsets(); int preferredWidth = insets.left + insets.right + width; Dimension d = getPreferredSize(); d.setSize(preferredWidth, MAX_HEIGHT); setPreferredSize(d); setSize(d); } } /** * Draw the line numbers */ @Override public void paintComponent(Graphics g) { super.paintComponent(g); FontMetrics fontMetrics = editor.getFontMetrics(editor.getFont()); Insets insets = getInsets(); int currentLine = -1; try { // get current line, and add one as we start from 1 for the display currentLine = ActionUtils.getLineNumber(editor, editor.getCaretPosition()) + 1; } catch (BadLocationException ex) { // this wont happen, even if it does, we can ignore it and we will not have // a current line to worry about... } int lh = fontMetrics.getHeight(); int maxLines = ActionUtils.getLineCount(editor); SyntaxView.setRenderingHits((Graphics2D) g); int topLine = (int) (g.getClip().getBounds().getY() / lh) + 1; int bottomLine = (int) (g.getClip().getBounds().getHeight()) + topLine; for (int line = topLine; line <= bottomLine; line++) { String lineNumber = String.format(numbersFormat, line); int y = line * lh; if (line == currentLine) { g.setColor(currentLineColor); g.fillRect(0, y - lh + fontMetrics.getDescent() - 1, getWidth(), lh); g.setColor(getForeground()); g.drawString(lineNumber, insets.left, y); } else { g.drawString(lineNumber, insets.left, y); } } } // // Implement CaretListener interface // @Override public void caretUpdate(CaretEvent e) { // Get the line the caret is positioned on int caretPosition = editor.getCaretPosition(); Element root = editor.getDocument().getDefaultRootElement(); int currentLine = root.getElementIndex(caretPosition); // Need to repaint so the correct line number can be highlighted if (lastLine != currentLine) { repaint(); lastLine = currentLine; } } // // Implement DocumentListener interface // @Override public void changedUpdate(DocumentEvent e) { documentChanged(); } @Override public void insertUpdate(DocumentEvent e) { documentChanged(); } @Override public void removeUpdate(DocumentEvent e) { documentChanged(); } /* * A document change may affect the number of displayed lines of text. * Therefore the lines numbers will also change. */ private void documentChanged() { // Preferred size of the component has not been updated at the time // the DocumentEvent is fired SwingUtilities.invokeLater(new Runnable() { @Override public void run() { int preferredHeight = editor.getPreferredSize().height; // Document change has caused a change in the number of lines. // Repaint to reflect the new line numbers if (lastHeight != preferredHeight) { setPreferredWidth(); repaint(); lastHeight = preferredHeight; } } }); } /** * Implement PropertyChangeListener interface */ @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("document")) { if (evt.getOldValue() instanceof SyntaxDocument) { SyntaxDocument syntaxDocument = (SyntaxDocument) evt.getOldValue(); syntaxDocument.removeDocumentListener(this); } if (evt.getNewValue() instanceof SyntaxDocument && status.equals(Status.INSTALLING)) { SyntaxDocument syntaxDocument = (SyntaxDocument) evt.getNewValue(); syntaxDocument.addDocumentListener(this); setPreferredWidth(); repaint(); } } else if (evt.getNewValue() instanceof Font) { setPreferredWidth(); repaint(); } } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/components/SyntaxComponent.java0000644000175000017500000000317212127321546032405 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.components; import javax.swing.JEditorPane; import jsyntaxpane.util.Configuration; /** * A Component that is installed to the EditorKit to perform GUI operations * on the Editor. * * @author Ayman Al-Sairafi */ public interface SyntaxComponent { /** * Configure the component using the given properties. The keys * needed for configuration will be prefixed by the given prefix * @param config configuration data */ public void config(Configuration config); /** * Called to install the component on an editor * @param editor */ public void install(JEditorPane editor); /** * Called when the component is to be removed from the editor * @param editor */ public void deinstall(JEditorPane editor); /** * The status is used to have proper propertyCHange support. We need to know if we are INSTALLING * the component or DE-INSTALLING it */ static enum Status { INSTALLING, DEINSTALLING } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/components/Markers.java0000644000175000017500000001156012127321546030640 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.components; import jsyntaxpane.actions.*; import java.awt.Color; import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.swing.text.BadLocationException; import javax.swing.text.DefaultHighlighter; import javax.swing.text.Highlighter; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; import jsyntaxpane.Token; /** * This class contains static utility methods to make highliting in text * components easier. * * @author Ayman Al-Sairafi */ public class Markers { // This subclass is used in our highlighting code public static class SimpleMarker extends DefaultHighlighter.DefaultHighlightPainter { public SimpleMarker(Color color) { super(color); } } /** * Removes only our private highlights * This is public so that we can remove the highlights when the editorKit * is unregistered. SimpleMarker can be null, in which case all instances of * our Markers are removed. * @param component the text component whose markers are to be removed * @param marker the SimpleMarker to remove */ public static void removeMarkers(JTextComponent component, SimpleMarker marker) { Highlighter hilite = component.getHighlighter(); Highlighter.Highlight[] hilites = hilite.getHighlights(); for (int i = 0; i < hilites.length; i++) { if (hilites[i].getPainter() instanceof SimpleMarker) { SimpleMarker hMarker = (SimpleMarker) hilites[i].getPainter(); if (marker == null || hMarker.equals(marker)) { hilite.removeHighlight(hilites[i]); } } } } /** * Remove all the markers from an JEditorPane * @param editorPane */ public static void removeMarkers(JTextComponent editorPane) { removeMarkers(editorPane, null); } /** * add highlights for the given Token on the given pane * @param pane * @param token * @param marker */ public static void markToken(JTextComponent pane, Token token, SimpleMarker marker) { markText(pane, token.start, token.end(), marker); } /** * add highlights for the given region on the given pane * @param pane * @param start * @param end * @param marker */ public static void markText(JTextComponent pane, int start, int end, SimpleMarker marker) { try { Highlighter hiliter = pane.getHighlighter(); int selStart = pane.getSelectionStart(); int selEnd = pane.getSelectionEnd(); // if there is no selection or selection does not overlap if(selStart == selEnd || end < selStart || start > selStart) { hiliter.addHighlight(start, end, marker); return; } // selection starts within the highlight, highlight before slection if(selStart > start && selStart < end ) { hiliter.addHighlight(start, selStart, marker); } // selection ends within the highlight, highlight remaining if(selEnd > start && selEnd < end ) { hiliter.addHighlight(selEnd, end, marker); } } catch (BadLocationException ex) { // nothing we can do if the request is out of bound LOG.log(Level.SEVERE, null, ex); } } /** * Mark all text in the document that matches the given pattern * @param pane control to use * @param pattern pattern to match * @param marker marker to use for highlighting */ public static void markAll(JTextComponent pane, Pattern pattern, SimpleMarker marker) { SyntaxDocument sDoc = ActionUtils.getSyntaxDocument(pane); if(sDoc == null || pattern == null) { return; } Matcher matcher = sDoc.getMatcher(pattern); // we may not have any matcher (due to undo or something, so don't do anything. if(matcher==null) { return; } while(matcher.find()) { markText(pane, matcher.start(), matcher.end(), marker); } } private static final Logger LOG = Logger.getLogger(Markers.class.getName()); } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/components/PairsMarker.java0000644000175000017500000000602712127321546031456 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.components; import java.awt.Color; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import jsyntaxpane.actions.*; import javax.swing.JEditorPane; import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; import jsyntaxpane.Token; import jsyntaxpane.util.Configuration; /** * This class highlights any pairs of the given language. Pairs are defined * with the Token.pairValue. * * @author Ayman Al-Sairafi */ public class PairsMarker implements CaretListener, SyntaxComponent, PropertyChangeListener { public static final String PROPERTY_COLOR = "PairMarker.Color"; private JTextComponent pane; private Markers.SimpleMarker marker; private Status status; public PairsMarker() { } @Override public void caretUpdate(CaretEvent e) { removeMarkers(); int pos = e.getDot(); SyntaxDocument doc = ActionUtils.getSyntaxDocument(pane); Token token = doc.getTokenAt(pos); if (token != null && token.pairValue != 0) { Markers.markToken(pane, token, marker); Token other = doc.getPairFor(token); if (other != null) { Markers.markToken(pane, other, marker); } } } /** * Remove all the highlights from the editor pane. This should be called * when the editorkit is removed. */ public void removeMarkers() { Markers.removeMarkers(pane, marker); } @Override public void config(Configuration config) { Color markerColor = config.getColor(PROPERTY_COLOR, new Color(0xeeee33)); this.marker = new Markers.SimpleMarker(markerColor); } @Override public void install(JEditorPane editor) { pane = editor; pane.addCaretListener(this); status = Status.INSTALLING; } @Override public void deinstall(JEditorPane editor) { status = Status.DEINSTALLING; pane.removeCaretListener(this); removeMarkers(); } @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("document")) { pane.removeCaretListener(this); if (status.equals(Status.INSTALLING)) { pane.addCaretListener(this); removeMarkers(); } } } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/components/TokenMarker.java0000644000175000017500000001133012127321546031451 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.components; import java.beans.PropertyChangeEvent; import jsyntaxpane.actions.*; import java.awt.Color; import java.beans.PropertyChangeListener; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import java.util.logging.Logger; import javax.swing.JEditorPane; import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; import jsyntaxpane.SyntaxDocument; import jsyntaxpane.Token; import jsyntaxpane.TokenType; import jsyntaxpane.util.Configuration; /** * This class highlights Tokens within a document whenever the caret is moved * to a TokenType provided in the config file. * * @author Ayman Al-Sairafi */ public class TokenMarker implements SyntaxComponent, CaretListener, PropertyChangeListener { public static final String DEFAULT_TOKENTYPES = "IDENTIFIER, TYPE, TYPE2, TYPE3"; public static final String PROPERTY_COLOR = "TokenMarker.Color"; public static final String PROPERTY_TOKENTYPES = "TokenMarker.TokenTypes"; private static final Color DEFAULT_COLOR = new Color(0xFFEE66); private JEditorPane pane; private Set tokenTypes = new HashSet(); private Markers.SimpleMarker marker; private Status status; /** * Constructs a new Token highlighter */ public TokenMarker() { } @Override public void caretUpdate(CaretEvent e) { markTokenAt(e.getDot()); } public void markTokenAt(int pos) { SyntaxDocument doc = ActionUtils.getSyntaxDocument(pane); if (doc != null) { Token token = doc.getTokenAt(pos); removeMarkers(); if (token != null && tokenTypes.contains(token.type)) { addMarkers(token); } } } /** * removes all markers from the pane. */ public void removeMarkers() { Markers.removeMarkers(pane, marker); } /** * add highlights for the given pattern * @param pattern */ void addMarkers(Token tok) { SyntaxDocument sDoc = (SyntaxDocument) pane.getDocument(); sDoc.readLock(); // we need to create a STring, because the CharSequence does not have an // equals method and Object.equals is called. It will not match String text = tok.getText(sDoc).toString(); Iterator it = sDoc.getTokens(0, sDoc.getLength()); while (it.hasNext()) { Token nextToken = it.next(); String nextText = nextToken.getText(sDoc).toString(); if (text.equals(nextText)) { Markers.markToken(pane, nextToken, marker); } } sDoc.readUnlock(); } @Override public void config(Configuration config) { Color markerColor = config.getColor( PROPERTY_COLOR, DEFAULT_COLOR); this.marker = new Markers.SimpleMarker(markerColor); String types = config.getString( PROPERTY_TOKENTYPES, DEFAULT_TOKENTYPES); for (String type : types.split("\\s*,\\s*")) { try { TokenType tt = TokenType.valueOf(type); tokenTypes.add(tt); } catch (IllegalArgumentException e) { LOG.warning("Error in setting up TokenMarker " + " - Invalid TokenType: " + type); } } } @Override public void install(JEditorPane editor) { this.pane = editor; pane.addCaretListener(this); markTokenAt(editor.getCaretPosition()); status = Status.INSTALLING; } @Override public void deinstall(JEditorPane editor) { status = Status.DEINSTALLING; removeMarkers(); pane.removeCaretListener(this); } private static final Logger LOG = Logger.getLogger(TokenMarker.class.getName()); @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("document")) { pane.removeCaretListener(this); if (status.equals(Status.INSTALLING)) { pane.addCaretListener(this); removeMarkers(); } } } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/SyntaxStyles.java0000644000175000017500000001132012127321546027533 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.util.HashMap; import java.util.Map; import java.util.Properties; import java.util.logging.Logger; import java.util.regex.Pattern; import javax.swing.text.Segment; import javax.swing.text.TabExpander; import jsyntaxpane.util.Configuration; import jsyntaxpane.util.JarServiceProvider; /** * The Styles to use for each TokenType. The defaults are created here, and * then the resource META-INF/services/syntaxstyles.properties is read and * merged. You can also pass a properties instance and merge your prefered * styles into the default styles. * * Text is drawn by forwarding the drawText request to the SyntaxStyle for the * that matches the given TokenType * * @author Ayman Al-Sairafi */ public class SyntaxStyles { public static final Pattern STYLE_PATTERN = Pattern.compile("Style\\.(\\w+)"); /** * You can call the mergeStyles method with a Properties file to customize * the existing styles. Any existing styles will be overwritten by the * styles you provide. * @param styles */ public void mergeStyles(Properties styles) { for (Map.Entry e : styles.entrySet()) { String tokenType = e.getKey().toString(); String style = e.getValue().toString(); try { TokenType tt = TokenType.valueOf(tokenType); SyntaxStyle tokenStyle = new SyntaxStyle(style); put(tt, tokenStyle); } catch (IllegalArgumentException ex) { LOG.warning("illegal token type or style for: " + tokenType); } } } Map styles; private static SyntaxStyles instance = createInstance(); private static final Logger LOG = Logger.getLogger(SyntaxStyles.class.getName()); private static SyntaxStyle DEFAULT_STYLE = new SyntaxStyle(Color.BLACK, Font.PLAIN); private SyntaxStyles() { } /** * Create default styles * @return */ private static SyntaxStyles createInstance() { SyntaxStyles syntaxstyles = new SyntaxStyles(); Properties styles = JarServiceProvider.readProperties(SyntaxStyles.class); syntaxstyles.mergeStyles(styles); return syntaxstyles; } /** * Returns the Default Singleton * @return */ public static SyntaxStyles getInstance() { return instance; } public static SyntaxStyles read(Configuration config) { SyntaxStyles ss = createInstance(); // Configuration styleConf = config.subConfig(STYLE_PROPERTY_KEY); for (Configuration.StringKeyMatcher m : config.getKeys(STYLE_PATTERN)) { String type = m.group1; try { ss.put(TokenType.valueOf(type), new SyntaxStyle(m.value)); } catch (IllegalArgumentException e) { Logger.getLogger(SyntaxStyles.class.getName()).warning( String.format("Invalid Token Type [%s] for Style of ", type)); } } return ss; } public void put(TokenType type, SyntaxStyle style) { if (styles == null) { styles = new HashMap(); } styles.put(type, style); } /** * Return the style for the given TokenType * @param type * @return */ public SyntaxStyle getStyle(TokenType type) { if (styles != null && styles.containsKey(type)) { return styles.get(type); } else { return DEFAULT_STYLE; } } /** * Draw the given Token. This will simply find the proper SyntaxStyle for * the TokenType and then asks the proper Style to draw the text of the * Token. * @param segment * @param x * @param y * @param graphics * @param e * @param token * @return */ public int drawText(Segment segment, int x, int y, Graphics graphics, TabExpander e, Token token) { SyntaxStyle s = getStyle(token.type); return s.drawText(segment, x, y, graphics, e, token.start); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/Lexer.java0000644000175000017500000000267612127321546026136 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane; import java.util.List; import javax.swing.text.Segment; /** * Lexers must implement these methods. These are used in the Tokenizer * * A Lexer should be tied to one document. * * @author Ayman Al-Sairafi */ public interface Lexer { /** * This is the only method a Lexer needs to implement. It will be passed * a Reader, and it should return non-overlapping Tokens for each recognized token * in the stream. * @param segment Text to parse. * @param ofst offset to add to start of each token (useful for nesting) * @param tokens List of Tokens to be added. This is done so that the caller creates the * appropriate List implementation and size. The parse method just adds to the list */ public void parse(Segment segment, int ofst, List tokens); } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/Token.java0000644000175000017500000001107512127321546026130 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane; import java.io.Serializable; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.text.BadLocationException; import javax.swing.text.Document; import javax.swing.text.Segment; /** * A Token in a Document. Tokens do NOT store a reference to the * underlying SyntaxDocument, and must generally be obtained from * the SyntaxDocument methods. The reason for not storing the * SyntaxDocument is simply for memory, as the number of Tokens * per document can be large, you may end up with twice the memory * in a SyntaxDocument with Tokens than a simple PlainDocument. * * @author Ayman Al-Sairafi */ public class Token implements Serializable, Comparable { public final TokenType type; public final int start; public final int length; /** * the pair value to use if this token is one of a pair: * This is how it is used: * The openning part will have a positive number X * The closing part will have a negative number X * X should be unique for a pair: * e.g. for [ pairValue = +1 * for ] pairValue = -1 */ public final byte pairValue; /** * The kind of the Document. This is only needed if proper Parsing * of a document is needed and it makes certain operations faster. * You can use any of the supplied Generic Values, or create your * language specific uses by using USER_FIRST + x; */ public final short kind = 0; /** * Constructs a new token * @param type * @param start * @param length */ public Token(TokenType type, int start, int length) { this.type = type; this.start = start; this.length = length; this.pairValue = 0; } /** * Construct a new part of pair token * @param type * @param start * @param length * @param pairValue */ public Token(TokenType type, int start, int length, byte pairValue) { this.type = type; this.start = start; this.length = length; this.pairValue = pairValue; } @Override public boolean equals(Object obj) { if (obj instanceof Object) { Token token = (Token) obj; return ((this.start == token.start) && (this.length == token.length) && (this.type.equals(token.type))); } else { return false; } } @Override public int hashCode() { return start; } @Override public String toString() { if (pairValue == 0) { return String.format("%s (%d, %d)", type, start, length); } else { return String.format("%s (%d, %d) (%d)", type, start, length, pairValue); } } @Override public int compareTo(Object o) { Token t = (Token) o; if (this.start != t.start) { return (this.start - t.start); } else if (this.length != t.length) { return (this.length - t.length); } else { return this.type.compareTo(t.type); } } /** * return the end position of the token. * @return start + length */ public int end() { return start + length; } /** * Get the text of the token from this document * @param doc * @return */ public CharSequence getText(Document doc) { Segment text = new Segment(); try { doc.getText(start, length, text); } catch (BadLocationException ex) { Logger.getLogger(Token.class.getName()).log(Level.SEVERE, null, ex); } finally { return text; } } public String getString(Document doc) { String result = ""; try { result = doc.getText(start, length); } catch (BadLocationException ex) { Logger.getLogger(Token.class.getName()).log(Level.SEVERE, null, ex); } finally { return result; } } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/SyntaxTester.form0000644000175000017500000001603212127321546027545 0ustar sylvestresylvestre
libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/DefaultSyntaxKit.java0000644000175000017500000005472512127321546030324 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane; import java.awt.Color; import java.awt.Container; import java.util.logging.Level; import java.awt.Font; import java.awt.GraphicsEnvironment; import java.awt.Toolkit; import java.awt.event.KeyEvent; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Properties; import java.util.Set; import java.util.WeakHashMap; import java.util.logging.Logger; import java.util.regex.Pattern; import javax.swing.Action; import javax.swing.ActionMap; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.InputMap; import javax.swing.JButton; import javax.swing.JCheckBoxMenuItem; import javax.swing.JEditorPane; import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.JPopupMenu; import javax.swing.JToolBar; import javax.swing.KeyStroke; import javax.swing.text.DefaultEditorKit; import javax.swing.text.Document; import javax.swing.text.EditorKit; import javax.swing.text.Element; import javax.swing.text.JTextComponent; import javax.swing.text.View; import javax.swing.text.ViewFactory; import jsyntaxpane.actions.DefaultSyntaxAction; import jsyntaxpane.actions.SyntaxAction; import jsyntaxpane.components.SyntaxComponent; import jsyntaxpane.util.Configuration; import jsyntaxpane.util.JarServiceProvider; /** * The DefaultSyntaxKit is the main entry to SyntaxPane. To use the package, just * set the EditorKit of the EditorPane to a new instance of this class. * * You need to pass a proper lexer to the class. * * @author ayman */ public class DefaultSyntaxKit extends DefaultEditorKit implements ViewFactory { public static final String CONFIG_CARETCOLOR = "CaretColor"; public static final String CONFIG_SELECTION = "SelectionColor"; public static final String CONFIG_COMPONENTS = "Components"; public static final String CONFIG_MENU = "PopupMenu"; public static final String CONFIG_TOOLBAR = "Toolbar"; public static final String CONFIG_TOOLBAR_ROLLOVER = "Toolbar.Buttons.Rollover"; public static final String CONFIG_TOOLBAR_BORDER = "Toolbar.Buttons.BorderPainted"; public static final String CONFIG_TOOLBAR_OPAQUE = "Toolbar.Buttons.Opaque"; public static final String CONFIG_TOOLBAR_BORDER_SIZE = "Toolbar.Buttons.BorderSize"; private static final Pattern ACTION_KEY_PATTERN = Pattern.compile("Action\\.((\\w|-)+)"); private static final Pattern DEFAULT_ACTION_PATTERN = Pattern.compile("(DefaultAction.((\\w|-)+)).*"); private static Font DEFAULT_FONT; private static Set CONTENT_TYPES = new HashSet(); private static Boolean initialized = false; private static Map abbrvs; private static String MENU_MASK_STRING = "control "; private Lexer lexer; private static final Logger LOG = Logger.getLogger(DefaultSyntaxKit.class.getName()); private Map> editorComponents = new WeakHashMap>(); private Map popupMenu = new WeakHashMap(); /** * Main Configuration of JSyntaxPane EditorKits */ private static Map, Configuration> CONFIGS; static { // we only need to initialize once. if (!initialized) { initKit(); } int menuMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); if(menuMask == KeyEvent.ALT_DOWN_MASK) { MENU_MASK_STRING = "alt "; } } private static final String ACTION_MENU_TEXT = "MenuText"; /** * Create a new Kit for the given language * @param lexer */ public DefaultSyntaxKit(Lexer lexer) { super(); this.lexer = lexer; } /** * Adds UI components to the pane * @param editorPane */ public void addComponents(JEditorPane editorPane) { // install the components to the editor: String[] components = getConfig().getPropertyList(CONFIG_COMPONENTS); for (String c : components) { installComponent(editorPane, c); } } /** * Creates a SyntaxComponent of the the given classname and installs * it on the pane * @param pane * @param classname */ public void installComponent(JEditorPane pane, String classname) { try { @SuppressWarnings(value = "unchecked") Class compClass = Class.forName(classname); SyntaxComponent comp = (SyntaxComponent) compClass.newInstance(); comp.config(getConfig()); comp.install(pane); if (editorComponents.get(pane) == null) { editorComponents.put(pane, new ArrayList()); } editorComponents.get(pane).add(comp); } catch (InstantiationException ex) { LOG.log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { LOG.log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { LOG.log(Level.SEVERE, null, ex); } } /** * Find the SyntaxCOmponent with given classname that is installed * on the given pane, then deinstalls and removes it fom the * editorComponents list * @param pane * @param classname */ public void deinstallComponent(JEditorPane pane, String classname) { for (SyntaxComponent c : editorComponents.get(pane)) { if (c.getClass().getName().equals(classname)) { c.deinstall(pane); editorComponents.get(pane).remove(c); break; } } } /** * Checks if the component with given classname is installed on the * pane. * @param pane * @param classname * @return true if component is installed, false otherwise */ public boolean isComponentInstalled(JEditorPane pane, String classname) { for (SyntaxComponent c : editorComponents.get(pane)) { if (c.getClass().getName().equals(classname)) { return true; } } return false; } /** * Toggles the component with given classname. If component is found * and installed, then it is deinstalled. Otherwise a new one is * installed * @param pane * @param classname * @return true if component was installed, false if it was removed */ public boolean toggleComponent(JEditorPane pane, String classname) { for (SyntaxComponent c : editorComponents.get(pane)) { if (c.getClass().getName().equals(classname)) { c.deinstall(pane); editorComponents.get(pane).remove(c); return false; } } installComponent(pane, classname); return true; } /** * Adds a popup menu to the editorPane if needed. * * @param editorPane */ public void addPopupMenu(JEditorPane editorPane) { String[] menuItems = getConfig().getPropertyList(CONFIG_MENU); if (menuItems == null || menuItems.length == 0) { return; } popupMenu.put(editorPane, new JPopupMenu()); JMenu stack = null; for (String menuString : menuItems) { // create the Popup menu if (menuString.equals("-")) { popupMenu.get(editorPane).addSeparator(); } else if (menuString.startsWith(">")) { JMenu sub = new JMenu(menuString.substring(1)); popupMenu.get(editorPane).add(sub); stack = sub; } else if (menuString.startsWith("<")) { Container parent = stack.getParent(); if (parent instanceof JMenu) { JMenu jMenu = (JMenu) parent; stack = jMenu; } else { stack = null; } } else { Action action = editorPane.getActionMap().get(menuString); if (action != null) { JMenuItem menuItem; if (action.getValue(Action.SELECTED_KEY) != null) { menuItem = new JCheckBoxMenuItem(action); } else { menuItem = new JMenuItem(action); } // Use our own property if it was set for the menu text if (action.getValue(ACTION_MENU_TEXT) != null) { menuItem.setText((String) action.getValue(ACTION_MENU_TEXT)); } if (stack == null) { popupMenu.get(editorPane).add(menuItem); } else { stack.add(menuItem); } } } } editorPane.setComponentPopupMenu(popupMenu.get(editorPane)); } /** * Add all pop-up menu items to a Toolbar. You need to call the validate method * on the toolbar after this is done to layout the buttons. * Only Actions which have a SMALL_ICON property will be added to the toolbar * There are three Configuration Keys that affect the appearance of the added buttons: * CONFIG_TOOLBAR_ROLLOVER, CONFIG_TOOLBAR_BORDER, CONFIG_TOOLBAR_OPAQUE * * @param editorPane * @param toolbar */ public void addToolBarActions(JEditorPane editorPane, JToolBar toolbar) { String[] toolBarItems = getConfig().getPropertyList(CONFIG_TOOLBAR); if (toolBarItems == null || toolBarItems.length == 0) { toolBarItems = getConfig().getPropertyList(CONFIG_MENU); if (toolBarItems == null || toolBarItems.length == 0) { return; } } boolean btnRolloverEnabled = getConfig().getBoolean(CONFIG_TOOLBAR_ROLLOVER, true); boolean btnBorderPainted = getConfig().getBoolean(CONFIG_TOOLBAR_BORDER, false); boolean btnOpaque = getConfig().getBoolean(CONFIG_TOOLBAR_OPAQUE, false); int btnBorderSize = getConfig().getInteger(CONFIG_TOOLBAR_BORDER_SIZE, 2); for (String menuString : toolBarItems) { if (menuString.equals("-") || menuString.startsWith("<") || menuString.startsWith(">")) { toolbar.addSeparator(); } else { Action action = editorPane.getActionMap().get(menuString); if (action != null && action.getValue(Action.SMALL_ICON) != null) { JButton b = toolbar.add(action); b.setRolloverEnabled(btnRolloverEnabled); b.setBorderPainted(btnBorderPainted); b.setOpaque(btnOpaque); b.setFocusable(false); b.setBorder(BorderFactory.createEmptyBorder(btnBorderSize, btnBorderSize, btnBorderSize, btnBorderSize)); } } } } @Override public ViewFactory getViewFactory() { return this; } @Override public View create(Element element) { return new SyntaxView(element, getConfig()); } /** * Install the View on the given EditorPane. This is called by Swing and * can be used to do anything you need on the JEditorPane control. Here * I set some default Actions. * * @param editorPane */ @Override public void install(JEditorPane editorPane) { super.install(editorPane); // get our font String fontName = getProperty("DefaultFont"); Font font = DEFAULT_FONT; if (fontName != null) { font = Font.decode(fontName); } editorPane.setFont(font); Configuration conf = getConfig(); Color caretColor = conf.getColor(CONFIG_CARETCOLOR, Color.BLACK); editorPane.setCaretColor(caretColor); Color selectionColor = getConfig().getColor(CONFIG_SELECTION, new Color(0x99ccff)); editorPane.setSelectionColor(selectionColor); addActions(editorPane); addComponents(editorPane); addPopupMenu(editorPane); } @Override public void deinstall(JEditorPane editorPane) { List l = editorComponents.get(editorPane); for (SyntaxComponent c : editorComponents.get(editorPane)) { c.deinstall(editorPane); } editorComponents.clear(); editorPane.getInputMap().clear(); editorPane.getActionMap().clear(); } /** * Add keyboard actions to this control using the Configuration we have * This is revised to properly use InputMap and ActionMap of the component * instead of using the KeyMaps directly. * @param editorPane */ public void addActions(JEditorPane editorPane) { InputMap imap = new InputMap(); imap.setParent(editorPane.getInputMap()); ActionMap amap = new ActionMap(); amap.setParent(editorPane.getActionMap()); for (Configuration.StringKeyMatcher m : getConfig().getKeys(ACTION_KEY_PATTERN)) { String[] values = Configuration.COMMA_SEPARATOR.split( m.value); String actionClass = values[0]; String actionName = m.group1; SyntaxAction action = createAction(actionClass); // The configuration keys will need to be prefixed by Action // to make it more readable in the Configuration files. action.config(getConfig(), DefaultSyntaxAction.ACTION_PREFIX + actionName); // Add the action to the component also amap.put(actionName, action); // Now bind all the keys to the Action we have using the InputMap for (int i = 1; i < values.length; i++) { String keyStrokeString = values[i].replace("menu ", MENU_MASK_STRING); KeyStroke ks = KeyStroke.getKeyStroke(keyStrokeString); // we may have more than onr value ( for key action ), but we will use the // last one in the single value here. This will display the key in the // popup menus. Pretty neat. if (ks == null) { throw new IllegalArgumentException("Invalid KeyStroke: " + keyStrokeString); } action.putValue(Action.ACCELERATOR_KEY, ks); imap.put(ks, actionName); } } // Now configure the Default actions for better display in the popup menu for (Configuration.StringKeyMatcher m : getConfig().getKeys(DEFAULT_ACTION_PATTERN)) { String name = m.matcher.group(2); Action action = editorPane.getActionMap().get(name); if (action != null) { configActionProperties(action, name, m.group1); } // The below commented block does find the keys for the default Actions // using InputMap, however there are multiple bound keys for the // default actions that displaying them in the menu will probably not // be the most obvious binding /* for (KeyStroke key : imap.allKeys()) { Object o = imap.get(key); if(name.equals(o)) { action.putValue(Action.ACCELERATOR_KEY, key); break; } } */ } editorPane.setActionMap(amap); editorPane.setInputMap(JTextComponent.WHEN_FOCUSED, imap); } private void configActionProperties(Action action, String actionName, String configKey) { // if we have an icon, then load it: String iconLoc = getConfig().getString(configKey + ".SmallIcon", actionName + ".png"); URL loc = this.getClass().getResource(DefaultSyntaxAction.SMALL_ICONS_LOC_PREFIX + iconLoc); if (loc != null) { ImageIcon i = new ImageIcon(loc); action.putValue(Action.SMALL_ICON, i); } // Set the menu text. Use the Action.NAME property, unless it is // already set. // The NAME would be set for default actions, and we should not change those names. // so we will put another property and use it for the menu text String name = getProperty(configKey + ".MenuText"); if (action.getValue(Action.NAME) == null) { action.putValue(Action.NAME, name); } else { action.putValue(ACTION_MENU_TEXT, name); } // Set the menu tooltips String shortDesc = getProperty(configKey + ".ToolTip"); if (shortDesc != null) { action.putValue(Action.SHORT_DESCRIPTION, shortDesc); } else { action.putValue(Action.SHORT_DESCRIPTION, name); } } private SyntaxAction createAction(String actionClassName) { SyntaxAction action = null; try { Class clazz = Class.forName(actionClassName); action = (SyntaxAction) clazz.newInstance(); } catch (InstantiationException ex) { throw new IllegalArgumentException("Cannot create action class: " + actionClassName + ". Ensure it has default constructor.", ex); } catch (IllegalAccessException ex) { throw new IllegalArgumentException("Cannot create action class: " + actionClassName, ex); } catch (ClassNotFoundException ex) { throw new IllegalArgumentException("Cannot create action class: " + actionClassName, ex); } catch (ClassCastException ex) { throw new IllegalArgumentException("Cannot create action class: " + actionClassName, ex); } return action; } /** * This is called by Swing to create a Document for the JEditorPane document * This may be called before you actually get a reference to the control. * We use it here to create a proper lexer and pass it to the * SyntaxDcument we return. * @return */ @Override public Document createDefaultDocument() { return new SyntaxDocument(lexer); } /** * This is called to initialize the list of Lexers we have. * You can call this at initialization, or it will be called when needed. * The method will also add the appropriate EditorKit classes to the * corresponding ContentType of the JEditorPane. After this is called, * you can simply call the editor.setCOntentType("text/java") on the * control and you will be done. */ public synchronized static void initKit() { // attempt to find a suitable default font String defaultFont = getConfig(DefaultSyntaxKit.class).getString("DefaultFont"); if (defaultFont != null) { DEFAULT_FONT = Font.decode(defaultFont); } else { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); String[] fonts = ge.getAvailableFontFamilyNames(); Arrays.sort(fonts); if (Arrays.binarySearch(fonts, "Courier New") >= 0) { DEFAULT_FONT = new Font("Courier New", Font.PLAIN, 12); } else if (Arrays.binarySearch(fonts, "Courier") >= 0) { DEFAULT_FONT = new Font("Courier", Font.PLAIN, 12); } else if (Arrays.binarySearch(fonts, "Monospaced") >= 0) { DEFAULT_FONT = new Font("Monospaced", Font.PLAIN, 13); } } // read the Default Kits and their associated types Properties kitsForTypes = JarServiceProvider.readProperties("jsyntaxpane/kitsfortypes"); for (Map.Entry e : kitsForTypes.entrySet()) { String type = e.getKey().toString(); String classname = e.getValue().toString(); registerContentType(type, classname); } initialized = true; } /** * Register the given content type to use the given class name as its kit * When this is called, an entry is added into the private HashMap of the * registered editors kits. This is needed so that the SyntaxPane library * has it's own registration of all the EditorKits * @param type * @param classname */ public static void registerContentType(String type, String classname) { try { // ensure the class is available and that it does supply a no args // constructor. This saves debugging later if the classname is incorrect // or does not behave correctly: Class c = Class.forName(classname); // attempt to create the class, if we cannot with an empty argument // then the class is invalid Object kit = c.newInstance(); if (!(kit instanceof EditorKit)) { throw new IllegalArgumentException("Cannot register class: " + classname + ". It does not extend EditorKit"); } JEditorPane.registerEditorKitForContentType(type, classname); CONTENT_TYPES.add(type); } catch (InstantiationException ex) { throw new IllegalArgumentException("Cannot register class: " + classname + ". Ensure it has Default Constructor.", ex); } catch (IllegalAccessException ex) { throw new IllegalArgumentException("Cannot register class: " + classname, ex); } catch (ClassNotFoundException ex) { throw new IllegalArgumentException("Cannot register class: " + classname, ex); } catch (RuntimeException ex) { throw new IllegalArgumentException("Cannot register class: " + classname, ex); } } /** * Return all the content types supported by this library. This will be the * content types in the file WEB-INF/services/resources/jsyntaxpane/kitsfortypes * @return sorted array of all registered content types */ public static String[] getContentTypes() { String[] types = CONTENT_TYPES.toArray(new String[0]); Arrays.sort(types); return types; } /** * Merges the given properties with the configurations for this Object * * @param config */ public void setConfig(Properties config) { getConfig().putAll(config); } /** * Sets the given property to the given value. If the kit is not * initialized, then calls initKit * @param key * @param value */ public void setProperty(String key, String value) { getConfig().put(key, value); } /** * Return the property with the given key. If the kit is not * initialized, then calls initKit * Be careful when changing property as the default property may be used * @param key * @return value for given key */ public String getProperty(String key) { return getConfig().getString(key); } /** * Get the configuration for this Object * @return */ public Configuration getConfig() { return getConfig(this.getClass()); } /** * Return the Configurations object for a Kit. Perfrom lazy creation of a * Configuration object if nothing is created. * * @param kit * @return */ public static synchronized Configuration getConfig(Class kit) { if (CONFIGS == null) { CONFIGS = new WeakHashMap, Configuration>(); Configuration defaultConfig = new Configuration(DefaultSyntaxKit.class); loadConfig(defaultConfig, DefaultSyntaxKit.class); CONFIGS.put(DefaultSyntaxKit.class, defaultConfig); } if (CONFIGS.containsKey(kit)) { return CONFIGS.get(kit); } else { // recursive call until we read the Super duper DefaultSyntaxKit Class superKit = kit.getSuperclass(); @SuppressWarnings("unchecked") Configuration defaults = getConfig(superKit); Configuration mine = new Configuration(kit, defaults); loadConfig(mine, kit); CONFIGS.put(kit, mine); return mine; } } public Map getAbbreviations() { // if we have not loaded the abbreviations, then load them now: if (abbrvs == null) { String cl = this.getClass().getName().replace('.', '/').toLowerCase(); abbrvs = JarServiceProvider.readStringsMap(cl + "/abbreviations.properties"); } return abbrvs; } /** * Adds an abbrevisation to this kit's abbreviations. * @param abbr * @param template */ public static void addAbbreviation(String abbr, String template) { if (abbrvs == null) { abbrvs = new HashMap(); } abbrvs.put(abbr, template); } /** * Get the template for the given abbreviation * @param abbr * @return */ public static String getAbbreviation(String abbr) { return abbrvs == null ? null : abbrvs.get(abbr); } private static void loadConfig(Configuration conf, Class kit) { String url = kit.getName().replace(".", "/") + "/config"; Properties p = JarServiceProvider.readProperties(url, Locale.getDefault()); if (p.size() == 0) { LOG.log(Level.INFO, "unable to load configuration for: {0} from: {1}.properties", new Object[]{kit, url}); } else { conf.putAll(p); } } @Override public String getContentType() { return "text/" + this.getClass().getSimpleName().replace("SyntaxKit", "").toLowerCase(); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/JavaRegexKit.java0000644000175000017500000000163512127321546027375 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane; import java.io.IOException; import jsyntaxpane.lexers.SimpleRegexLexer; /** * * @author Ayman Al-Sairafi */ public class JavaRegexKit extends DefaultSyntaxKit { public JavaRegexKit() throws IOException { super(new SimpleRegexLexer("javaRegex.properties")); } }libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/util/0000755000175000017500000000000012127321546025156 5ustar sylvestresylvestrelibjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/util/StringUtils.java0000644000175000017500000000366412127321546030321 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.util; import java.io.Serializable; import java.util.Comparator; /** * Don't we all need one of those? * * @author Ayman Al-Sairafi */ public class StringUtils { /** * Perfrom a String startsWith match with support for CamelCase. * @param word full word * @param abbr abbriviated word * @return true if the word startsWith abbr, or if any uppercase char in abbr * matches the next uppercase char in word * * FIXME: not so effecient as it creates a StringBuilder, but works * FIXME: add {@code Comparator} */ public static boolean camelCaseMatch(String word, String abbr) { StringBuilder sb = new StringBuilder(); sb.append(word.charAt(0)); for (int i = 1; i < word.length(); i++) { char c = word.charAt(i); if (Character.isUpperCase(c)) { sb.append(c); } } String cc = sb.toString(); if (cc.startsWith(abbr)) { return true; } else { return word.startsWith(abbr); } } static class CamelCaseCompare implements Comparator, Serializable { @Override public int compare(String o1, String o2) { throw new UnsupportedOperationException("Not supported yet."); } } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/util/ReflectUtils.java0000644000175000017500000003037212127321546030433 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.util; import java.io.File; import java.io.IOException; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Member; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.net.URL; import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; /** * Reflection Utility methods * @author Ayman Al-Sairafi */ public class ReflectUtils { /** * Adds all methods (from Class.getMethodCalls) to the list * @param aClass * @param list * @return number of methods added */ public static int addMethods(Class aClass, List list) { Method[] methods = aClass.getMethods(); for (Method m : methods) { list.add(m); } return methods.length; } /** * Adds all static methods (from Class.getMethodCalls) to the list * @param aClass * @param list * @return number of methods added */ public static int addStaticMethods(Class aClass, List list) { Method[] methods = aClass.getMethods(); for (Method m : methods) { if (Modifier.isStatic(m.getModifiers())) { list.add(m); } } return methods.length; } /** * Adds all static Fields (from Class.getFields) to the list * @param aClass * @param list * @return number of fields added */ public static int addStaticFields(Class aClass, List list) { Field[] fields = aClass.getFields(); for (Field f : fields) { if (Modifier.isStatic(f.getModifiers())) { list.add(f); } } return fields.length; } /** * Adds all Fields (from Class.getFields) to the list * @param aClass * @param list * @return number of fields added */ public static int addFields(Class aClass, List list) { Field[] fields = aClass.getFields(); for (Field f : fields) { list.add(f); } return fields.length; } /** * Adds all Constructor (from Class.getConstructorCalls) to the list * @param aClass * @param list * @return number of constructors added */ public static int addConstrcutors(Class aClass, List list) { Constructor[] constructors = aClass.getConstructors(); for (Constructor c : constructors) { list.add(c); } return constructors.length; } /** * Convert the constructor to a Java Code String * (arguments are replaced by the simple types) * @param c Constructor * @return */ public static String getJavaCallString(Constructor c) { StringBuilder call = new StringBuilder(); call.append(c.getDeclaringClass().getSimpleName()); addParamsString(call, c.getParameterTypes()); return call.toString(); } /** * Convert the Method to a Java Code String * (arguments are replaced by the simple types) * @param method Method * @return */ public static String getJavaCallString(Method method) { StringBuilder call = new StringBuilder(); call.append(method.getName()); addParamsString(call, method.getParameterTypes()); return call.toString(); } /** * Adds the class SimpleNames, comma sepearated and surrounded by paranthesis to the * call StringBuffer * @param call * @param params * @return */ public static StringBuilder addParamsString(StringBuilder call, Class[] params) { call.append("("); boolean firstArg = true; for (Class arg : params) { if (firstArg) { firstArg = false; } else { call.append(", "); } call.append(arg.getSimpleName()); } call.append(")"); return call; } /** * Gets a String array of all method calls for the given class * @param aClass * @return */ public static String[] getMethodCalls(Class aClass) { String[] methods = new String[aClass.getMethods().length]; int i = 0; for (Method method : aClass.getMethods()) { methods[i++] = getJavaCallString(method); } return methods; } /** * Gets an array of all Constructor calls for the given class * @param aClass * @return */ public static String[] getConstructorCalls(Class aClass) { Constructor[] constructors = aClass.getConstructors(); String[] cons = new String[constructors.length]; int i = 0; for (Constructor c : constructors) { cons[i++] = getJavaCallString(c); } return cons; } /** * Return a paranthesis enclosed, comma sepearated String of all * SimpleClass names in params. * @param params * @return */ public static String getParamsString(Class[] params) { StringBuilder sb = new StringBuilder(); addParamsString(sb, params); return sb.toString(); } /** * Scans all classes accessible from the context class loader which belong to the given package and subpackages. * * @param packageName The base package * @return The classes * @throws ClassNotFoundException * @throws IOException */ private static Class[] getClasses(String packageName) throws ClassNotFoundException, IOException { // ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); ClassLoader classLoader = ClassLoader.getSystemClassLoader(); assert classLoader != null; String path = packageName.replace('.', '/'); Enumeration resources = classLoader.getResources(path); List dirs = new ArrayList(); while (resources.hasMoreElements()) { URL resource = resources.nextElement(); dirs.add(new File(resource.getFile())); } ArrayList classes = new ArrayList(); for (File directory : dirs) { classes.addAll(findClasses(directory, packageName)); } return classes.toArray(new Class[classes.size()]); } /** * Recursive method used to find all classes in a given directory and subdirs. * * @param directory The base directory * @param packageName The package name for classes found inside the base directory * @return The classes * @throws ClassNotFoundException */ private static List findClasses(File directory, String packageName) throws ClassNotFoundException { List classes = new ArrayList(); if (!directory.exists()) { return classes; } File[] files = directory.listFiles(); for (File file : files) { if (file.isDirectory()) { assert !file.getName().contains("."); classes.addAll(findClasses(file, packageName + "." + file.getName())); } else if (file.getName().endsWith(".class")) { classes.add(Class.forName(packageName + '.' + file.getName().substring(0, file.getName().length() - 6))); } } return classes; } /** * Attempt to find the given className within any of the packages. * If the class is not found, then null is returned * @param className Fully or partially qualified classname within any of the packages * @param packages List of packages for search * @return CLass object or null if not found. */ public static Class findClass(String className, List packages) { try { return Class.forName(className); } catch (ClassNotFoundException ex) { } catch (NoClassDefFoundError ex) { } for (String pack : packages) { try { return Class.forName(pack + "." + className); } catch (ClassNotFoundException ex) { } catch (NoClassDefFoundError ex) { } } return null; } /** * Find a setter method for the give object's property and try to call it. * No exceptions are thrown. You typically call this method because either * you are sure no exceptions will be thrown, or to silently ignore * any that may be thrown. * This will also find a setter that accepts an interface that the value * implements. * This is still not very effcient and should only be called if * performance is not of an issue. * You can check the return value to see if the call was seuccessful or * not. * @param obj Object to receive the call * @param property property name (without set. First letter will be * capitalized) * @param value Value of the property. * @return */ public static boolean callSetter(Object obj, String property, Object value) { String key = String.format("%s.%s(%s)", obj.getClass().getName(), property, value.getClass().getName()); Method m = null; boolean result = false; if(!SETTERS_MAP.containsKey(key)) { m = findMethod(obj, property, value); SETTERS_MAP.put(key, m); } else { m = SETTERS_MAP.get(key); } if(m != null) { try { m.invoke(obj, value); result = true; } catch (IllegalAccessException ex) { Logger.getLogger(ReflectUtils.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalArgumentException ex) { Logger.getLogger(ReflectUtils.class.getName()).log(Level.SEVERE, null, ex); } catch (InvocationTargetException ex) { Logger.getLogger(ReflectUtils.class.getName()).log(Level.SEVERE, null, ex); } } return result; } private static synchronized Method findMethod(Object obj, String property, Object value) { Method m = null; Class theClass = obj.getClass(); String setter = String.format("set%C%s", property.charAt(0), property.substring(1)); Class paramType = value.getClass(); while (paramType != null) { try { m = theClass.getMethod(setter, paramType); return m; } catch (NoSuchMethodException ex) { // try on the interfaces of this class for (Class iface : paramType.getInterfaces()) { try { m = theClass.getMethod(setter, iface); return m; } catch (NoSuchMethodException ex1) { } } paramType = paramType.getSuperclass(); } } return m; } public static final List DEFAULT_PACKAGES = new ArrayList(3); static { DEFAULT_PACKAGES.add("java.lang"); DEFAULT_PACKAGES.add("java.util"); DEFAULT_PACKAGES.add("jsyntaxpane"); } /** * To speed up find setter methods, this map will be used. * The Key String will be of the format objectClass.property(valueclass) * Where: * objectClass = obj.getClass().getName * property = property (as passed in to callSetter), before set is appended * valueCLass = value.getClass().getName() * The Method will be either the method, or null if a search was not and no * method is found. */ private static HashMap SETTERS_MAP = new HashMap(); } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/util/SwingUtils.java0000644000175000017500000000314712127321546030136 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.util; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import javax.swing.JComponent; import javax.swing.KeyStroke; import jsyntaxpane.actions.gui.EscapeListener; /** * As always, some general purpose handy Swing Utility methods * @author Ayman Al-Sairafi */ public class SwingUtils { /** * FIXME: These two addEscapeListener can be called on a new interface * that implements RootPainCOntainer (Swing) and a new method that * is called * @param dialog */ public static void addEscapeListener(final EscapeListener dialog) { ActionListener escListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.escapePressed(); } }; dialog.getRootPane().registerKeyboardAction(escListener, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/util/JarServiceProvider.java0000644000175000017500000002250012127321546031570 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.util; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author subwiz * @author Ayman Al-Sairafi */ public class JarServiceProvider { public static final String SERVICES_ROOT = "META-INF/services/"; private static final Logger LOG = Logger.getLogger(JarServiceProvider.class.getName()); /** * Prevent anyone from instantiating this class. * Just use the static method */ private JarServiceProvider() { } private static ClassLoader getClassLoader() { ClassLoader cl = JarServiceProvider.class.getClassLoader(); return cl == null ? ClassLoader.getSystemClassLoader() : cl; } /** * Return an Object array from the file in META-INF/resources/{classname} * @param cls * @return * @throws java.io.IOException */ public static List getServiceProviders(Class cls) throws IOException { ArrayList l = new ArrayList(); ClassLoader cl = getClassLoader(); String serviceFile = SERVICES_ROOT + cls.getName(); Enumeration e = cl.getResources(serviceFile); while (e.hasMoreElements()) { URL u = e.nextElement(); InputStream is = u.openStream(); BufferedReader br = null; try { br = new BufferedReader( new InputStreamReader(is, Charset.forName("UTF-8"))); String str = null; while ((str = br.readLine()) != null) { int commentStartIdx = str.indexOf("#"); if (commentStartIdx != -1) { str = str.substring(0, commentStartIdx); } str = str.trim(); if (str.length() == 0) { continue; } try { Object obj = cl.loadClass(str).newInstance(); l.add(obj); } catch (Exception ex) { LOG.warning("Could not load: " + str); LOG.warning(ex.getMessage()); } } } finally { if (br != null) { br.close(); } } } return l; } /** * Read a file in the META-INF/services location. File name will be * fully qualified classname, in all lower-case, appended with ".properties" * If no file is found, then a an empty Property instance will be returned * @param clazz * @return Property file read. */ public static Properties readProperties(Class clazz) { return readProperties(clazz.getName()); } /** * Read a file in the META-INF/services named name appended with * ".properties" * * If no file is found, then a an empty Property instance will be returned * @param name name of file (use dots to separate subfolders). * @return Property file read. */ public static Properties readProperties(String name) { Properties props = new Properties(); String serviceFile = name.toLowerCase(); if (!serviceFile.endsWith(".properties")) { serviceFile += ".properties"; } InputStream is = findResource(serviceFile); if (is != null) { try { props.load(new InputStreamReader(is, "UTF-8")); } catch (IOException ex) { Logger.getLogger(JarServiceProvider.class.getName()).log(Level.SEVERE, null, ex); } } return props; } /** * Read language specific files in the META-INF/services named name appended * with ".properties". The contents of the files are merged as follows: *
    *
  • First the default language file (<name>.properties) is read
  • *
  • Then the general language variant of the file * (<name>_<lang>.properties) is read and its * entries are added to/overwrite the entries of the default life
  • *
  • Last the country specific language variant of the file * (<name>_<lang>_<country>.properties) is read and its * entries are added to/overwrite the existing entries
  • *
* Example: You have three files: *
    *
  • config.properties which contains the complete configuration * (most likely with English menus, tooltips)
  • *
  • config_de.properties which only contains menu names and tooltips * in German language
  • *
  • config_de_CH which might just contain entries for specific * Swiss spelling variant of some words in a tooltip
  • *
      * * If no filesis found, then a an empty Property instance will be returned * @param name name of file (use dots to separate subfolders). * @param locale The locale for which to read the files * @return Property file read. */ public static Properties readProperties(String name, Locale locale) { // If name already ends in ".properties", then cut this off name = name.toLowerCase(); int idx = name.lastIndexOf(".properties"); if (idx > 0) { name = name.substring(0, idx); } // 1. Read properties of default langauge Properties props = readProperties(name); // 2. Read properties of general language variant if (locale != null && locale.getLanguage() != null) { name += "_"+locale.getLanguage(); Properties langProps = readProperties(name); props.putAll(langProps); } // 3. Read properties of country specific language variant if (locale != null && locale.getCountry() != null) { name += "_"+locale.getCountry(); Properties countryProps = readProperties(name); props.putAll(countryProps); } return props; } /** * Read a file in the META-INF/services named name appended with * ".properties", and returns it as a Map * If no file is found, then a an empty Property instance will be returned * @param name name of file (use dots to separate subfolders). * @return Map of keys and values */ public static Map readStringsMap(String name) { Properties props = readProperties(name); HashMap map = new HashMap(); if (props != null) { for (Map.Entry e : props.entrySet()) { map.put(e.getKey().toString(), e.getValue().toString()); } } return map; } /** * Read the given URL and returns a List of Strings for each input line * Each line will not have the line terminator. * * The resource is searched in /META-INF/services/url, then in * url, then the url is treated as a location in the current classpath * and an attempt to read it from that location is done. * * @param url location of file to read * @return List of Strings for each line read. or EMPTY_LIST if URL is not found */ @SuppressWarnings("unchecked") public static List readLines(String url) { InputStream is = findResource(url); if (is == null) { return Collections.EMPTY_LIST; } List lines = new ArrayList(); try { BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8")); for (String line = br.readLine(); line != null; line = br.readLine()) { // Trim and unescape some control chars line = line.trim().replace("\\n", "\n").replace("\\t", "\t"); lines.add(line); } } catch (IOException ex) { LOG.log(Level.SEVERE, null, ex); } finally { try { is.close(); } catch (IOException ex) { LOG.log(Level.SEVERE, null, ex); } return lines; } } /** * Attempt to find a location url. The following locations are searched in * sequence: * url, * SERVICES_ROOT/url * all classpath/url * @param url * @param cl classloader * @return InputSTream at that location, or null if not found * @see JarServiceProvider#findResource(java.lang.String) */ public static InputStream findResource(String url, ClassLoader cl) { InputStream is = null; URL loc = cl.getResource(url); if (loc == null) { loc = cl.getResource(url); } if (loc == null) { loc = cl.getResource(SERVICES_ROOT + url); } if (loc == null) { is = ClassLoader.getSystemResourceAsStream(url); } else { try { is = loc.openStream(); } catch (IOException ex) { Logger.getLogger(JarServiceProvider.class.getName()).log(Level.SEVERE, null, ex); } } return is; } /** * Attempt to find a location url. The following locations are searched in * sequence: * url, * SERVICES_ROOT/url * all classpath/url * The System ClassLoader is used. * @param url * @return InputSTream at that location, or null if not found * @see JarServiceProvider#findResource(java.lang.String, java.lang.ClassLoader) */ public static InputStream findResource(String url) { return findResource(url, getClassLoader()); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/util/Configuration.java0000644000175000017500000002565612127321546030646 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.util; import java.awt.Color; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * Wrapper around the Properties class with supprt for Heirarchical confogurations * and more functionality. * * Except for the getXXXX methods, all other Map Interface methods operate on the * current (non-parent) collection and do NOT touch the parent. * * @author Ayman Al-Sairafi */ public class Configuration implements Map { /** * Our parent */ Configuration parent; /** * Our Class for the configuration */ Class clazz; /** * The properties we have, excluding the parents defaults */ Map props; /** * Creates a new COnfiguration that uses parent as its parent * Configuration. * * @param theClass * @param parent */ public Configuration(Class theClass, Configuration parent) { this(theClass); this.parent = parent; } /** * Creates an empty Configuration * @param theClass */ public Configuration(Class theClass) { super(); this.clazz = theClass; } /** * Get a string from this object or one of its parents. If nothing * is found, null is returned. * If the Regex ${key} is found, then it is replaced by the value of that * key within this (or parent's) map. * Special COnstructs in ${}: *
    • class_path will be replaced by the name of the * Configuration (usually ClassName) with "." replaced by "/", and then * converted to all lowercase
    • *
    • class_simpleName
    • is replaced by class.SimpleName * @param key * @return */ public String getString(String key) { String value = null; if (props != null) { value = props.get(key); } for (Configuration p = parent; value == null && p != null; p = p.parent) { value = p.get(key); } // if we have a parent, then perform ${} replacements if (value != null) { Matcher m = PARENT_KEY.matcher(value); StringBuffer sb = new StringBuffer(); while (m.find()) { String p_key = m.group(1); String p_value = getString(p_key); if (p_key.equals("class_path")) { p_value = clazz.getName().replace(".", "/").toLowerCase(); } else if (p_key.equals("class_simpleName")) { p_value = clazz.getSimpleName(); } else { p_value = getString(p_key); if (p_value == null) { Logger.getLogger(this.getClass().getName()).warning( "no value for ${" + p_key + "} is defined"); } } m.appendReplacement(sb, p_value); } m.appendTail(sb); value = sb.toString(); } return value; } /** * Returns a non-null value either by traversing the current * and parent(s) map, or returning the defaultValue * @param key * @param defaultValue * @throws NullPointerException if defaultValue is null * @return */ public String getString(String key, String defaultValue) { if (defaultValue == null) { throw new NullPointerException("defaultValue cannot be null"); } String value = getString(key); return (value == null) ? defaultValue : value; } /** * Gets an integer from the properties. If number cannot be found * or if it cannot be decoded, the default is returned * The integer is decoded using {@link Integer.decode(String)} * @param key * @param Default * @return */ public int getInteger(String key, int Default) { String v = getString(key); if (v == null) { return Default; } try { int i = Integer.decode(v); return i; } catch (NumberFormatException e) { LOG.log(Level.WARNING, null, e); return Default; } } /** * Returns a String[] of the comma separated items in the value. * * Does NOT return null. If the key is not found, * then an empty string array is returned. So the return of this method * can always be used directly in a foreach loop * @param key * @return non-null String[] */ public String[] getPropertyList(String key) { String v = getString(key); if (v == null) { return EMPTY_LIST; } else { return COMMA_SEPARATOR.split(v); } } /** * Returns a boolean from the configuration * @param key * @param Default * @return */ public boolean getBoolean(String key, boolean Default) { String b = getString(key); if (b == null) { return Default; } return Boolean.parseBoolean(b.trim()); } /** * return the Color that has the given key or the Default * @param key * @param Default * @return */ public Color getColor(String key, Color Default) { String c = getString(key); if (c == null) { return Default; } else { try { return Color.decode(c); } catch (NumberFormatException e) { return Default; } } } @SuppressWarnings("unchecked") @Override public void putAll(Map config) { if (props == null) { props = new HashMap(); } props.putAll(config); } /** * Returns ALL property names from this Configuration's parents and * this Configuration. As usual, parents are added first so they * are overriden by children. * * @return Set of all String keys in this and parents */ public Set stringPropertyNames() { Set propNames = new HashSet(); if (parent != null) { propNames.addAll(parent.stringPropertyNames()); } if (props != null) { for (Object k : props.keySet()) { propNames.add(k.toString()); } } return propNames; } @Override public String put(String key, String value) { if (props == null) { props = new HashMap(); } Object old = props.put(key, value); return (old == null) ? null : old.toString(); } @Override public int size() { return (props == null) ? 0 : props.size(); } @Override public boolean isEmpty() { return (props == null) ? true : props.isEmpty(); } @Override public boolean containsKey(Object key) { return (props == null) ? false : props.containsKey(key); } @Override public boolean containsValue(Object value) { return (props == null) ? false : props.containsValue(value); } @Override public String get(Object key) { return (props == null) ? null : props.get(key); } @Override public String remove(Object key) { if (props == null) { return null; } Object old = props.remove(key); return (old == null) ? null : old.toString(); } @Override public void clear() { if (props != null) { props.clear(); } } @Override @SuppressWarnings("unchecked") public Set keySet() { if (props == null) { return Collections.EMPTY_SET; } else { return props.keySet(); } } @Override @SuppressWarnings("unchecked") public Collection values() { if (props == null) { return Collections.EMPTY_SET; } else { return props.values(); } } @Override @SuppressWarnings("unchecked") public Set> entrySet() { if (props == null) { return Collections.EMPTY_SET; } else { return props.entrySet(); } } @Override public String toString() { return "Configuration " + clazz + " for " + parent; } /** * Utility class to hold data for {@link getKeys} method. */ public static class StringKeyMatcher { private StringKeyMatcher(String key, Matcher matcher, String group1, String value) { this.key = key; this.matcher = matcher; this.group1 = group1; this.value = value; } /** * The full key matched */ public final String key; /** * matcher instance for the key */ public final Matcher matcher; /** * Matched group 1. Could be null if no Group 1 is found */ public final String group1; /** * Value for key matched */ public final String value; } /** * Obtain a set of all keys (and parent's keys) that match the given pattern. * If no keys match, then an empty set is returned. * Use this instead of the {@link stringPropertyNames} * @param pattern * @return */ public Set getKeys(Pattern pattern) { Set matched = new HashSet(); Set all = stringPropertyNames(); for (String k : all) { Matcher m = pattern.matcher(k); if (m.matches()) { StringKeyMatcher skm = new StringKeyMatcher(k, m, (m.groupCount() >= 1) ? m.group(1) : null, getString(k)); matched.add(skm); } } return matched; } public static final String[] EMPTY_LIST = new String[0]; public static final Pattern COMMA_SEPARATOR = Pattern.compile("\\s*,\\s*"); private static Pattern PARENT_KEY = Pattern.compile("\\$\\{(\\w+)\\}"); private static final Logger LOG = Logger.getLogger(Configuration.class.getName()); } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/CompoundUndoMan.java0000644000175000017500000001033512127321546030114 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane; import javax.swing.event.UndoableEditEvent; import javax.swing.text.AbstractDocument; import javax.swing.text.AbstractDocument.DefaultDocumentEvent; import javax.swing.undo.CannotUndoException; import javax.swing.undo.CompoundEdit; import javax.swing.undo.UndoManager; import javax.swing.undo.UndoableEdit; /** * A revised UndoManager that groups undos based on positions. If the change is relatively next to the * previous change, like when continuous typing, then the undoes are grouped together. * * This is cutomized from the * * http://www.camick.com/java/source/CompoundUndoMan.java * * from the blog: * * http://tips4java.wordpress.com/2008/10/27/compound-undo-manager/ * * @author Ayman Al-Sairafi */ public class CompoundUndoMan extends UndoManager { private CompoundEdit compoundEdit; // This allows us to start combining operations. // it will be reset after the first change. private boolean startCombine = false; // This holds the start of the last line edited, if edits are on multiple // lines, then they will not be combined. private int lastLine = -1; public CompoundUndoMan(SyntaxDocument doc) { doc.addUndoableEditListener(this); lastLine = doc.getStartPosition().getOffset(); } /** * Whenever an UndoableEdit happens the edit will either be absorbed * by the current compound edit or a new compound edit will be started */ @Override public void undoableEditHappened(UndoableEditEvent e) { // Start a new compound edit AbstractDocument.DefaultDocumentEvent docEvt = (DefaultDocumentEvent) e.getEdit(); if (compoundEdit == null) { compoundEdit = startCompoundEdit(e.getEdit()); startCombine = false; return; } int editLine = ((SyntaxDocument)docEvt.getDocument()).getLineNumberAt(docEvt.getOffset()); // Check for an incremental edit or backspace. // The Change in Caret position and Document length should both be // either 1 or -1. if ((startCombine || Math.abs(docEvt.getLength()) == 1) && editLine == lastLine) { compoundEdit.addEdit(e.getEdit()); startCombine = false; return; } // Not incremental edit, end previous edit and start a new one lastLine = editLine; compoundEdit.end(); compoundEdit = startCompoundEdit(e.getEdit()); } /* ** Each CompoundEdit will store a group of related incremental edits ** (ie. each character typed or backspaced is an incremental edit) */ private CompoundEdit startCompoundEdit(UndoableEdit anEdit) { // Track Caret and Document information of this compound edit AbstractDocument.DefaultDocumentEvent docEvt = (DefaultDocumentEvent) anEdit; // The compound edit is used to store incremental edits compoundEdit = new MyCompoundEdit(); compoundEdit.addEdit(anEdit); // The compound edit is added to the UndoManager. All incremental // edits stored in the compound edit will be undone/redone at once addEdit(compoundEdit); return compoundEdit; } class MyCompoundEdit extends CompoundEdit { @Override public boolean isInProgress() { // in order for the canUndo() and canRedo() methods to work // assume that the compound edit is never in progress return false; } @Override public void undo() throws CannotUndoException { // End the edit so future edits don't get absorbed by this edit if (compoundEdit != null) { compoundEdit.end(); } super.undo(); // Always start a new compound edit after an undo compoundEdit = null; } } /** * Start to combine the next operations together. Only the next operation is combined. * The flag is then automatically reset. */ public void startCombine() { startCombine = true; } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/TokenComparators.java0000644000175000017500000000315712127321546030345 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane; import java.io.Serializable; import java.util.Comparator; /** * Two comparators to compare Tokens. * @author Ayman Al-Sairafi */ public class TokenComparators { public static final Comparator LONGEST_FIRST = new LongestFirst(); public static final Comparator SHORTEST_FIRST = new ShortestFirst(); private static class LongestFirst implements Comparator, Serializable { @Override public int compare(Token t1, Token t2) { if (t1.start != t2.start) { return (t1.start - t2.start); } else if (t1.length != t2.length) { return (t2.length - t1.length); } else { return t1.type.compareTo(t2.type); } } } private static class ShortestFirst implements Comparator, Serializable { @Override public int compare(Token t1, Token t2) { if (t1.start != t2.start) { return (t1.start - t2.start); } else if (t1.length != t2.length) { return (t1.length - t2.length); } else { return t1.type.compareTo(t2.type); } } } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/SyntaxDocument.java0000644000175000017500000003552212127321546030040 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.ListIterator; import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.swing.event.DocumentEvent; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.Element; import javax.swing.text.PlainDocument; import javax.swing.text.Segment; /** * A document that supports being highlighted. The document maintains an * internal List of all the Tokens. The Tokens are updated using * a Lexer, passed to it during construction. * * @author Ayman Al-Sairafi */ public class SyntaxDocument extends PlainDocument { Lexer lexer; List tokens; CompoundUndoMan undo; public SyntaxDocument(Lexer lexer) { super(); putProperty(PlainDocument.tabSizeAttribute, 4); this.lexer = lexer; // Listen for undo and redo events undo = new CompoundUndoMan(this); } /** * Parse the entire document and return list of tokens that do not already * exist in the tokens list. There may be overlaps, and replacements, * which we will cleanup later. * @return list of tokens that do not exist in the tokens field */ private void parse() { // if we have no lexer, then we must have no tokens... if (lexer == null) { tokens = null; return; } List toks = new ArrayList(getLength() / 10); long ts = System.nanoTime(); int len = getLength(); try { Segment seg = new Segment(); getText(0, getLength(), seg); lexer.parse(seg, 0, toks); } catch (BadLocationException ex) { log.log(Level.SEVERE, null, ex); } finally { if (log.isLoggable(Level.FINEST)) { log.finest(String.format("Parsed %d in %d ms, giving %d tokens\n", len, (System.nanoTime() - ts) / 1000000, toks.size())); } tokens = toks; } } @Override protected void fireChangedUpdate(DocumentEvent e) { parse(); super.fireChangedUpdate(e); } @Override protected void fireInsertUpdate(DocumentEvent e) { parse(); super.fireInsertUpdate(e); } @Override protected void fireRemoveUpdate(DocumentEvent e) { parse(); super.fireRemoveUpdate(e); } /** * Replace the token with the replacement string * @param token * @param replacement */ public void replaceToken(Token token, String replacement) { try { replace(token.start, token.length, replacement, null); } catch (BadLocationException ex) { log.log(Level.WARNING, "unable to replace token: " + token, ex); } } /** * This class is used to iterate over tokens between two positions * */ class TokenIterator implements ListIterator { int start; int end; int ndx = 0; @SuppressWarnings("unchecked") private TokenIterator(int start, int end) { this.start = start; this.end = end; if (tokens != null && !tokens.isEmpty()) { Token token = new Token(TokenType.COMMENT, start, end - start); ndx = Collections.binarySearch((List) tokens, token); // we will probably not find the exact token... if (ndx < 0) { // so, start from one before the token where we should be... // -1 to get the location, and another -1 to go back.. ndx = (-ndx - 1 - 1 < 0) ? 0 : (-ndx - 1 - 1); Token t = tokens.get(ndx); // if the prev token does not overlap, then advance one if (t.end() <= start) { ndx++; } } } } @Override public boolean hasNext() { if (tokens == null) { return false; } if (ndx >= tokens.size()) { return false; } Token t = tokens.get(ndx); if (t.start >= end) { return false; } return true; } @Override public Token next() { return tokens.get(ndx++); } @Override public void remove() { throw new UnsupportedOperationException(); } @Override public boolean hasPrevious() { if (tokens == null) { return false; } if (ndx <= 0) { return false; } Token t = tokens.get(ndx); if (t.end() <= start) { return false; } return true; } @Override public Token previous() { return tokens.get(ndx--); } @Override public int nextIndex() { return ndx + 1; } @Override public int previousIndex() { return ndx - 1; } @Override public void set(Token e) { throw new UnsupportedOperationException(); } @Override public void add(Token e) { throw new UnsupportedOperationException(); } } /** * Return an iterator of tokens between p0 and p1. * @param start start position for getting tokens * @param end position for last token * @return Iterator for tokens that overal with range from start to end */ public Iterator getTokens(int start, int end) { return new TokenIterator(start, end); } /** * Find the token at a given position. May return null if no token is * found (whitespace skipped) or if the position is out of range: * @param pos * @return */ public Token getTokenAt(int pos) { if (tokens == null || tokens.isEmpty() || pos > getLength()) { return null; } Token tok = null; Token tKey = new Token(TokenType.DEFAULT, pos, 1); @SuppressWarnings("unchecked") int ndx = Collections.binarySearch((List) tokens, tKey); if (ndx < 0) { // so, start from one before the token where we should be... // -1 to get the location, and another -1 to go back.. ndx = (-ndx - 1 - 1 < 0) ? 0 : (-ndx - 1 - 1); Token t = tokens.get(ndx); if ((t.start <= pos) && (pos <= t.end())) { tok = t; } } else { tok = tokens.get(ndx); } return tok; } public Token getWordAt(int offs, Pattern p) { Token word = null; try { Element line = getParagraphElement(offs); if (line == null) { return word; } int lineStart = line.getStartOffset(); int lineEnd = Math.min(line.getEndOffset(), getLength()); Segment seg = new Segment(); getText(lineStart, lineEnd - lineStart, seg); if (seg.count > 0) { // we need to get the word using the words pattern p Matcher m = p.matcher(seg); int o = offs - lineStart; while (m.find()) { if (m.start() <= o && o <= m.end()) { word = new Token(TokenType.DEFAULT, m.start() + lineStart, m.end() - m.start()); break; } } } } catch (BadLocationException ex) { Logger.getLogger(SyntaxDocument.class.getName()).log(Level.SEVERE, null, ex); } finally { return word; } } /** * Return the token following the current token, or null * This is an expensive operation, so do not use it to update the gui * @param tok * @return */ public Token getNextToken(Token tok) { int n = tokens.indexOf(tok); if ((n >= 0) && (n < (tokens.size() - 1))) { return tokens.get(n + 1); } else { return null; } } /** * Return the token prior to the given token, or null * This is an expensive operation, so do not use it to update the gui * @param tok * @return */ public Token getPrevToken(Token tok) { int n = tokens.indexOf(tok); if ((n > 0) && (!tokens.isEmpty())) { return tokens.get(n - 1); } else { return null; } } /** * This is used to return the other part of a paired token in the document. * A paired part has token.pairValue <> 0, and the paired token will * have the negative of t.pairValue. * This method properly handles nestings of same pairValues, but overlaps * are not checked. * if The document does not contain a paired token, then null is returned. * @param t * @return the other pair's token, or null if nothing is found. */ public Token getPairFor(Token t) { if (t == null || t.pairValue == 0) { return null; } Token p = null; int ndx = tokens.indexOf(t); // w will be similar to a stack. The openners weght is added to it // and the closers are subtracted from it (closers are already negative) int w = t.pairValue; int direction = (t.pairValue > 0) ? 1 : -1; boolean done = false; int v = Math.abs(t.pairValue); while (!done) { ndx += direction; if (ndx < 0 || ndx >= tokens.size()) { break; } Token current = tokens.get(ndx); if (Math.abs(current.pairValue) == v) { w += current.pairValue; if (w == 0) { p = current; done = true; } } } return p; } /** * Perform an undo action, if possible */ public void doUndo() { if (undo.canUndo()) { undo.undo(); parse(); } } /** * Perform a redo action, if possible. */ public void doRedo() { if (undo.canRedo()) { undo.redo(); parse(); } } /** * Return a matcher that matches the given pattern on the entire document * @param pattern * @return matcher object */ public Matcher getMatcher(Pattern pattern) { return getMatcher(pattern, 0, getLength()); } /** * Return a matcher that matches the given pattern in the part of the * document starting at offset start. Note that the matcher will have * offset starting from start * * @param pattern * @param start * @return matcher that MUST be offset by start to get the proper * location within the document */ public Matcher getMatcher(Pattern pattern, int start) { return getMatcher(pattern, start, getLength() - start); } /** * Return a matcher that matches the given pattern in the part of the * document starting at offset start and ending at start + length. * Note that the matcher will have * offset starting from start * * @param pattern * @param start * @param length * @return matcher that MUST be offset by start to get the proper * location within the document */ public Matcher getMatcher(Pattern pattern, int start, int length) { Matcher matcher = null; if (getLength() == 0) { return null; } if (start >= getLength()) { return null; } try { if (start < 0) { start = 0; } if (start + length > getLength()) { length = getLength() - start; } Segment seg = new Segment(); getText(start, length, seg); matcher = pattern.matcher(seg); } catch (BadLocationException ex) { log.log(Level.SEVERE, "Requested offset: " + ex.offsetRequested(), ex); } return matcher; } /** * This will discard all undoable edits */ public void clearUndos() { undo.discardAllEdits(); } /** * Gets the line at given position. The line returned will NOT include * the line terminator '\n' * @param pos Position (usually from text.getCaretPosition() * @return the STring of text at given position * @throws BadLocationException */ public String getLineAt(int pos) throws BadLocationException { Element e = getParagraphElement(pos); Segment seg = new Segment(); getText(e.getStartOffset(), e.getEndOffset() - e.getStartOffset(), seg); char last = seg.last(); if (last == '\n' || last == '\r') { seg.count--; } return seg.toString(); } /** * Deletes the line at given position * @param pos * @throws javax.swing.text.BadLocationException */ public void removeLineAt(int pos) throws BadLocationException { Element e = getParagraphElement(pos); remove(e.getStartOffset(), getElementLength(e)); } /** * Replace the line at given position with the given string, which can span * multiple lines * @param pos * @param newLines * @throws javax.swing.text.BadLocationException */ public void replaceLineAt(int pos, String newLines) throws BadLocationException { Element e = getParagraphElement(pos); replace(e.getStartOffset(), getElementLength(e), newLines, null); } /** * Helper method to get the length of an element and avoid getting * a too long element at the end of the document * @param e * @return */ private int getElementLength(Element e) { int end = e.getEndOffset(); if (end >= (getLength() - 1)) { end--; } return end - e.getStartOffset(); } /** * Gets the text without the comments. For example for the string * { // it's a comment this method will return "{ ". * @param aStart start of the text. * @param anEnd end of the text. * @return String for the line without comments (if exists). */ public synchronized String getUncommentedText(int aStart, int anEnd) { readLock(); StringBuilder result = new StringBuilder(); Iterator iter = getTokens(aStart, anEnd); while (iter.hasNext()) { Token t = iter.next(); if (!TokenType.isComment(t)) { result.append(t.getText(this)); } } readUnlock(); return result.toString(); } /** * Returns the starting position of the line at pos * @param pos * @return starting position of the line */ public int getLineStartOffset(int pos) { return getParagraphElement(pos).getStartOffset(); } /** * Returns the end position of the line at pos. * Does a bounds check to ensure the returned value does not exceed * document length * @param pos * @return */ public int getLineEndOffset(int pos) { int end = 0; end = getParagraphElement(pos).getEndOffset(); if (end >= getLength()) { end = getLength(); } return end; } /** * Return the number of lines in this document * @return */ public int getLineCount() { Element e = getDefaultRootElement(); int cnt = e.getElementCount(); return cnt; } /** * Return the line number at given position. The line numbers are zero based * @param pos * @return */ public int getLineNumberAt(int pos) { int lineNr = getDefaultRootElement().getElementIndex(pos); return lineNr; } @Override public String toString() { return "SyntaxDocument(" + lexer + ", " + ((tokens == null) ? 0 : tokens.size()) + " tokens)@" + hashCode(); } /** * We override this here so that the replace is treated as one operation * by the undomanager * @param offset * @param length * @param text * @param attrs * @throws BadLocationException */ @Override public void replace(int offset, int length, String text, AttributeSet attrs) throws BadLocationException { remove(offset, length); undo.startCombine(); insertString(offset, text, attrs); } /** * Append the given string to the text of this document. * @param str * @return this document */ public SyntaxDocument append(String str) { try { insertString(getLength(), str, null); } catch (BadLocationException ex) { log.log(Level.WARNING, "Error appending str", ex); } return this; } // our logger instance... private static final Logger log = Logger.getLogger(SyntaxDocument.class.getName()); } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/SyntaxView.java0000644000175000017500000001521212127321546027166 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.Shape; import java.awt.Toolkit; import java.util.Iterator; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.text.BadLocationException; import javax.swing.text.Element; import javax.swing.text.PlainView; import javax.swing.text.Segment; import javax.swing.text.ViewFactory; import jsyntaxpane.util.Configuration; public class SyntaxView extends PlainView { public static final String PROPERTY_RIGHT_MARGIN_COLOR = "RightMarginColor"; public static final String PROPERTY_RIGHT_MARGIN_COLUMN = "RightMarginColumn"; public static final String PROPERTY_SINGLE_COLOR_SELECT = "SingleColorSelect"; private static final Logger log = Logger.getLogger(SyntaxView.class.getName()); private SyntaxStyle DEFAULT_STYLE = SyntaxStyles.getInstance().getStyle(TokenType.DEFAULT); private final boolean singleColorSelect; private final int rightMarginColumn; private final Color rightMarginColor; private final SyntaxStyles styles; /** * Construct a new view using the given configuration and prefix given * * @param element * @param config */ public SyntaxView(Element element, Configuration config) { super(element); singleColorSelect = config.getBoolean(PROPERTY_SINGLE_COLOR_SELECT, false); rightMarginColor = new Color(config.getInteger(PROPERTY_RIGHT_MARGIN_COLOR, 0xFF7777)); rightMarginColumn = config.getInteger(PROPERTY_RIGHT_MARGIN_COLUMN, 0); styles = SyntaxStyles.read(config); } @Override protected int drawUnselectedText(Graphics graphics, int x, int y, int p0, int p1) { setRenderingHits((Graphics2D) graphics); Font saveFont = graphics.getFont(); Color saveColor = graphics.getColor(); SyntaxDocument doc = (SyntaxDocument) getDocument(); Segment segment = getLineBuffer(); // Draw the right margin first, if needed. This way the text overalys // the margin if (rightMarginColumn > 0) { int m_x = rightMarginColumn * graphics.getFontMetrics().charWidth('m'); int h = graphics.getFontMetrics().getHeight(); graphics.setColor(rightMarginColor); graphics.drawLine(m_x, y, m_x, y - h); } try { // Colour the parts Iterator i = doc.getTokens(p0, p1); int start = p0; while (i.hasNext()) { Token t = i.next(); // if there is a gap between the next token start and where we // should be starting (spaces not returned in tokens), then draw // it in the default type if (start < t.start) { doc.getText(start, t.start - start, segment); x = DEFAULT_STYLE.drawText(segment, x, y, graphics, this, start); } // t and s are the actual start and length of what we should // put on the screen. assume these are the whole token.... int l = t.length; int s = t.start; // ... unless the token starts before p0: if (s < p0) { // token is before what is requested. adgust the length and s l -= (p0 - s); s = p0; } // if token end (s + l is still the token end pos) is greater // than p1, then just put up to p1 if (s + l > p1) { l = p1 - s; } doc.getText(s, l, segment); x = styles.drawText(segment, x, y, graphics, this, t); start = t.end(); } // now for any remaining text not tokenized: if (start < p1) { doc.getText(start, p1 - start, segment); x = DEFAULT_STYLE.drawText(segment, x, y, graphics, this, start); } } catch (BadLocationException ex) { log.log(Level.SEVERE, "Requested: " + ex.offsetRequested(), ex); } finally { graphics.setFont(saveFont); graphics.setColor(saveColor); } return x; } @Override protected int drawSelectedText(Graphics graphics, int x, int y, int p0, int p1) throws BadLocationException { if (singleColorSelect) { if (rightMarginColumn > 0) { int m_x = rightMarginColumn * graphics.getFontMetrics().charWidth('m'); int h = graphics.getFontMetrics().getHeight(); graphics.setColor(rightMarginColor); graphics.drawLine(m_x, y, m_x, y - h); } return super.drawSelectedText(graphics, x, y, p0, p1); } else { return drawUnselectedText(graphics, x, y, p0, p1); } } /** * Sets the Rendering Hints o nthe Graphics. This is used so that * any painters can set the Rendering Hits to match the view. * @param g2d */ public static void setRenderingHits(Graphics2D g2d) { g2d.addRenderingHints(sysHints); } @Override protected void updateDamage(javax.swing.event.DocumentEvent changes, Shape a, ViewFactory f) { super.updateDamage(changes, a, f); java.awt.Component host = getContainer(); host.repaint(); } /** * The values for the string key for Text Anti-Aliasing */ private static RenderingHints sysHints; static { sysHints = null; try { Toolkit toolkit = Toolkit.getDefaultToolkit(); @SuppressWarnings("unchecked") Map map = (Map) toolkit.getDesktopProperty("awt.font.desktophints"); sysHints = new RenderingHints(map); } catch (Throwable t) { } } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/0000755000175000017500000000000012127321546025641 5ustar sylvestresylvestrelibjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/XmlTagCompleteAction.java0000644000175000017500000000316012127321546032527 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; import jsyntaxpane.Token; import jsyntaxpane.TokenType; /** * Completes an the Tag. * @author Ayman Al-Sairafi */ public class XmlTagCompleteAction extends DefaultSyntaxAction { public XmlTagCompleteAction() { super("XML_TAG_COMPLETE"); } @Override public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) { Token tok = sDoc.getTokenAt(dot); while (tok != null && tok.type != TokenType.TYPE) { tok = sDoc.getPrevToken(tok); } if (tok == null) { target.replaceSelection(">"); } else { CharSequence tag = tok.getText(sDoc); int savepos = target.getSelectionStart(); target.replaceSelection(">"); target.setCaretPosition(savepos + 1); } } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/CompleteWordAction.java0000644000175000017500000000661312127321546032254 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; import jsyntaxpane.Token; import jsyntaxpane.actions.gui.ComboCompletionDialog; import jsyntaxpane.util.StringUtils; /** * This action will try to complete the word at the cursor by * looking for a matching word in this document that starts with * the same letters. * * This makes use of the SyntaxDocument.getWordAt, which requires * a Regexp Pattern. The Pattern should match any word regardless of * the Tokens. * * This Regexp is configurable with {@code ACTION_NAME.WordsRegexp}. * The default Regexp is \w+ (any word char) * * @author Ayman Al-Sairafi */ public class CompleteWordAction extends DefaultSyntaxAction { public CompleteWordAction() { super("COMPLETE_WORD"); } @Override public void actionPerformed(JTextComponent target, SyntaxDocument sdoc, int dot, ActionEvent e) { Token current = sdoc.getWordAt(dot, wordsPattern); if (current == null) { return; } String cw = current.getString(sdoc); target.select(current.start, current.end()); sdoc.readLock(); List matches = new ArrayList(); Matcher m = sdoc.getMatcher(wordsPattern, 0, current.start); addWords(m, cw, matches); m = sdoc.getMatcher(wordsPattern, current.end(), sdoc.getLength() - current.end()); addWords(m, cw, matches); sdoc.readUnlock(); if (matches.size() == 0) { return; } if (matches.size() == 1) { target.replaceSelection(matches.get(0)); return; } if (dlg == null) { dlg = new ComboCompletionDialog(target); } dlg.displayFor(cw, matches); } public void setWordsRegexp(String value) { wordsPattern = Pattern.compile(value); } /** * Add words from the matcher m that match the word abbr to matches * List * @param m matcher instance, could be null, to iterate through * @param abbr abbriviated word * @param matches List of matches */ private void addWords(Matcher m, String abbr, List matches) { while (m != null && m.find()) { String word = m.group(); if (StringUtils.camelCaseMatch(word, abbr)) { if (!matches.contains(word)) { matches.add(word); } } } } private ComboCompletionDialog dlg; private Pattern wordsPattern = DEFAULT_WORDS_REGEXP; private static final Pattern DEFAULT_WORDS_REGEXP = Pattern.compile("\\w+"); } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/CaretMonitor.java0000644000175000017500000000762212127321546031121 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import javax.swing.JLabel; import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; import javax.swing.text.BadLocationException; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; /** * This class can be used to display the caret location in friendly manner for * an EditorPane. * * @author Ayman Al-Sairafi */ public class CaretMonitor implements CaretListener { private JLabel label; private JTextComponent text; /** * The format string to use when there is no selected: * the arguments are: * 1 based line number * 1 based column number * 0 based position */ private String noSelectionFormat = "%d:%d (%d)"; /** * The format string to use when something is selected: * the arguments are: * 1 based line number for selection start * 1 based column number for selection start * 1 based line number for selection end * 1 based column number for selection end * length of selection * 0 based start position * 0 based end position */ private String selectionFormat = "%d:%d - %d:%d (%d)"; public CaretMonitor(JTextComponent text, JLabel label) { this.label = label; this.text = text; text.addCaretListener(this); updateLabel(text.getCaretPosition()); } @Override public void caretUpdate(CaretEvent evt) { updateLabel(evt.getDot()); } protected void updateLabel(int pos) { if (text.getDocument() instanceof SyntaxDocument) { try { if (text.getSelectionStart() == text.getSelectionEnd()) { String loc = String.format(noSelectionFormat, ActionUtils.getLineNumber(text, pos) + 1, ActionUtils.getColumnNumber(text, pos) + 1, pos); label.setText(loc); } else { int start = text.getSelectionStart(); int end = text.getSelectionEnd(); String loc = String.format(selectionFormat, ActionUtils.getLineNumber(text, start) + 1, ActionUtils.getColumnNumber(text, start) + 1, ActionUtils.getLineNumber(text, end) + 1, ActionUtils.getColumnNumber(text, end) + 1, (end - start), start, end); label.setText(loc); } } catch (BadLocationException ex) { label.setText("Ex: " + ex.getMessage()); } } else { label.setText(String.format(noSelectionFormat, 1, 1, 1)); } } @Override protected void finalize() throws Throwable { text.removeCaretListener(this); super.finalize(); } public String getNoSelectionFormat() { return noSelectionFormat; } public void setNoSelectionFormat(String noSelectionFormat) { this.noSelectionFormat = noSelectionFormat; } public String getSelectionFormat() { return selectionFormat; } public void setSelectionFormat(String selectionFormat) { this.selectionFormat = selectionFormat; } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/FindReplaceAction.java0000644000175000017500000000275412127321546032026 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; /** * Finder class. This class contains the general Find, Find Next, * Find Previous, and the Find Marker Actions. * * Note that all Actions are subclasses of this class because all actions * require the find text to be shared among them. This is the best approach * to have all Action classes share this same data. * * @author Ayman Al-Sairafi */ public class FindReplaceAction extends DefaultSyntaxAction { public FindReplaceAction() { super("FIND_REPLACE"); } @Override public void actionPerformed(JTextComponent target, SyntaxDocument sdoc, int dot, ActionEvent e) { DocumentSearchData dsd = DocumentSearchData.getFromEditor(target); dsd.showReplaceDialog(target); } }libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/PairAction.java0000644000175000017500000000347412127321546030545 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import java.util.HashMap; import java.util.Map; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; /** * A Pair action inserts a pair of characters (left and right) around the * current selection, and then places the caret between them * * The pairs are hard-coded here. */ public class PairAction extends DefaultSyntaxAction { public PairAction() { super("PAIR_ACTION"); } @Override public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) { String left = e.getActionCommand(); String right = PAIRS.get(left); String selected = target.getSelectedText(); if (selected != null) { target.replaceSelection(left + selected + right); } else { target.replaceSelection(left + right); target.setCaretPosition(target.getCaretPosition() - right.length()); } } private static Map PAIRS = new HashMap(4); static { PAIRS.put("(", ")"); PAIRS.put("[", "]"); PAIRS.put("\"", "\""); PAIRS.put("'", "'"); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/SmartHomeAction.java0000644000175000017500000000520612127321546031544 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import java.text.CharacterIterator; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.text.BadLocationException; import javax.swing.text.Element; import javax.swing.text.JTextComponent; import javax.swing.text.Segment; import jsyntaxpane.SyntaxDocument; /** * * @author Ayman Al-Sairafi */ public class SmartHomeAction extends DefaultSyntaxAction { public SmartHomeAction() { super("smart-home"); } @Override public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) { try { target.setCaretPosition(getSmartHomeOffset(target, sDoc, dot)); } catch (BadLocationException ex) { Logger.getLogger(SmartHomeAction.class.getName()).log(Level.SEVERE, null, ex); } } static int getSmartHomeOffset(JTextComponent target, SyntaxDocument sDoc, int dot) throws BadLocationException { Element el = sDoc.getParagraphElement(dot); Segment seg = new Segment(); sDoc.getText(el.getStartOffset(), el.getEndOffset() - el.getStartOffset() - 1, seg); int homeOffset = 0; int dotLineOffset = dot - el.getStartOffset(); boolean inText = false; // see the location of first non-space offset for (int i = 0; i < dotLineOffset; i++) { if (!Character.isWhitespace(seg.charAt(i))) { inText = true; break; } } // if we are at first char in line, or we are past the non space // chars in the line, then we move to non-space char // otherwise, we move to first char of line if (dotLineOffset == 0 || inText) { for (char ch = seg.first(); ch != CharacterIterator.DONE && Character.isWhitespace(ch); ch = seg.next()) { homeOffset++; } } return el.getStartOffset() + homeOffset; } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/SyntaxAction.java0000644000175000017500000000301612127321546031130 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import javax.swing.Action; import jsyntaxpane.util.Configuration; /** * All JSyntaxPane Keyboard related actions implement this class. These * classes are created dynamically, and then registered to the SyntaxKit. * * A class may have multiple TextActions that may be related. Each EditorKit * that is installed will have only one instance of each class, even if more * than one action is specified. * * The key value pairs in the COnfiguration are of the form: * * [EditorKit.]Action.NAME = class, keyboard key * * @author Ayman Al-Sairafi */ public interface SyntaxAction extends Action { /** * Configure the actions in this class * @param config * @param name Name of the action, (prefixed by Action.) * will be obtained from the property Key as the * text following the Action. */ public void config(Configuration config, String name); } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/ComboCompletionAction.java0000644000175000017500000000452612127321546032742 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import java.util.List; import java.util.Map; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; import jsyntaxpane.Token; import jsyntaxpane.actions.gui.ComboCompletionDialog; import jsyntaxpane.util.JarServiceProvider; /** * ComboBox like Completion Action: * This will display a list of items to choose from, it can be used similar to * IntelliSense. The List is obtained from a plain text file, each line being * an item in the list. * * @author Ayman Al-Sairafi */ public class ComboCompletionAction extends DefaultSyntaxAction { Map completions; ComboCompletionDialog dlg; private List items; public ComboCompletionAction() { super("COMBO_COMPLETION"); } @Override public void actionPerformed(JTextComponent target, SyntaxDocument sdoc, int dot, ActionEvent e) { if (sdoc == null) { return; } Token token = sdoc.getTokenAt(dot); String abbrev = ""; if (token != null) { abbrev = token.getString(sdoc); target.select(token.start, token.end()); } if (dlg == null) { dlg = new ComboCompletionDialog(target); } dlg.displayFor(abbrev, items); } public void setItemsURL(String value) { items = JarServiceProvider.readLines(value); } /** * Gets the items to display in the combo * @return */ public List getItems() { return items; } /** * Sets the items to display in the combo. * @param items */ public void setItems(List items) { this.items = items; } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/TemplateAction.java0000644000175000017500000000434312127321546031421 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; /** * This action replaces the selection with the configured template in * the config ACTION-NAME.Template * * There are two kinds of templates: *
    • Simple Templates are replaced as is
    • *
    • Whole Line Templates will ensure a whole line is selected. * Each line in the selection will be prefixed, and postfixed with whatever appears * on the line in the template
    • * */ public class TemplateAction extends DefaultSyntaxAction { private String template; private String[] tlines = null; private boolean wholeLines; private boolean mustHaveSelection; public TemplateAction() { super("template"); } @Override public void actionPerformed(JTextComponent target, SyntaxDocument sdoc, int dot, ActionEvent e) { if (mustHaveSelection) { if (target.getSelectionEnd() == target.getSelectionStart()) { return; } } if (wholeLines) { if(tlines == null) { tlines = template.split("\n"); } ActionUtils.insertLinesTemplate(target, tlines); } else { ActionUtils.insertSimpleTemplate(target, template); } } public void setWholeLines(String value) { wholeLines = Boolean.parseBoolean(value); } public void setTemplate(String t) { template = t; } public void setMustHaveSelection(String value) { mustHaveSelection = Boolean.parseBoolean(value); } }libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/DefaultSyntaxAction.java0000644000175000017500000001021712127321546032436 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import java.net.URL; import java.util.regex.Pattern; import javax.swing.ImageIcon; import javax.swing.text.JTextComponent; import javax.swing.text.TextAction; import jsyntaxpane.SyntaxDocument; import jsyntaxpane.util.Configuration; import jsyntaxpane.util.ReflectUtils; /** * The DefaultSyntaxAction. You can extend this class or implement the interface * SyntaxAction to create your own actions. * * @author Ayman Al-Sairafi */ abstract public class DefaultSyntaxAction extends TextAction implements SyntaxAction { public DefaultSyntaxAction(String actionName) { super(actionName); putValue(NAME, actionName); } @Override public void config(Configuration config, String name) { // find setter methods for each property key: String actionName = name.substring(ACTION_PREFIX.length()); for (Configuration.StringKeyMatcher m : config.getKeys( Pattern.compile(Pattern.quote(name) + "\\.((\\w|-)+)"))) { if (!ReflectUtils.callSetter(this, m.group1, m.value)) { putValue(m.group1, m.value); } } // if we did not put a name, use the action name if (getValue(NAME) == null) { putValue(NAME, actionName); } // if we did not put an icon, try and find one using our name if (getValue(SMALL_ICON) == null) { setSmallIcon(actionName + ".png"); } } @Override public void actionPerformed(ActionEvent e) { JTextComponent text = getTextComponent(e); SyntaxDocument sdoc = ActionUtils.getSyntaxDocument(text); if (text != null) { actionPerformed(text, sdoc, text.getCaretPosition(), e); } } /** * Convenience method that will be called if the Action is performed on a * JTextComponent. SyntaxActions should generally override this method. * @param target (non-null JTextComponent from Action.getSource * @param sDoc (SyntaxDOcument of the text component, could be null) * @param dot (position of caret at text document) * @param e actual ActionEvent passed to actionPerformed */ public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) { throw new UnsupportedOperationException("Not yet implemented"); } @Override public String toString() { return "Action " + getValue(NAME) + "of type " + this.getClass().getSimpleName(); } /** * Configure the MenuText for the Action * @param text */ public final void setMenuText(String text) { putValue(NAME, text); // also set the SHORT_DESCRIPTIOn if it was not set, so we have // at least some tooltip for toolbar buttons if (getValue(SHORT_DESCRIPTION) == null) { putValue(SHORT_DESCRIPTION, text); } } /** * Configure the ToolTip for the Action * @param text */ public final void setToolTip(String text) { putValue(SHORT_DESCRIPTION, text); } /** * Sets the Large Icon for this action from given url * * @param url */ public final void setLargeIcon(String url) { URL loc = this.getClass().getResource(LARGE_ICONS_LOC_PREFIX + url); if (loc != null) { ImageIcon i = new ImageIcon(loc); putValue(LARGE_ICON_KEY, i); } } /** * Configure the SmallIcon for the Action * @param url */ public final void setSmallIcon(String url) { URL loc = this.getClass().getResource(SMALL_ICONS_LOC_PREFIX + url); if (loc != null) { ImageIcon i = new ImageIcon(loc); putValue(SMALL_ICON, i); } } public static final String ACTION_PREFIX = "Action."; public static final String SMALL_ICONS_LOC_PREFIX = "/META-INF/images/small-icons/"; public static final String LARGE_ICONS_LOC_PREFIX = "/META-INF/images/large-icons/"; } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/JUnindentAction.java0000644000175000017500000000377212127321546031551 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import javax.swing.text.BadLocationException; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; import jsyntaxpane.Token; public class JUnindentAction extends DefaultSyntaxAction { /** * creates new JUnindentAction. * Initial Code contributed by ser... AT mail.ru */ public JUnindentAction() { super("JUNINDENT"); } /** * {@inheritDoc} */ @Override public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) { int pos = target.getCaretPosition(); int start = sDoc.getParagraphElement(pos).getStartOffset(); String line = ActionUtils.getLine(target); if (ActionUtils.isEmptyOrBlanks(line)) { try { sDoc.insertString(pos, "}", null); Token t = sDoc.getPairFor(sDoc.getTokenAt(pos)); if (null != t) { String pairLine = ActionUtils.getLineAt(target, t.start); String indent = ActionUtils.getIndent(pairLine); sDoc.replace(start, line.length() + 1, indent + "}", null); } } catch (BadLocationException ble) { target.replaceSelection("}"); } } else { target.replaceSelection("}"); } } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/XmlPrettifyAction.java0000644000175000017500000001233312127321546032133 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.Component; import java.awt.event.ActionEvent; import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import javax.swing.text.JTextComponent; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import jsyntaxpane.SyntaxDocument; import org.w3c.dom.Document; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; /** * Attempt to prettify an XML document. * @author Ayman Al-Sairafi */ public class XmlPrettifyAction extends DefaultSyntaxAction { public XmlPrettifyAction() { super("XML_PRETTIFY"); } @Override public void actionPerformed(ActionEvent e) { if (transformer == null) { return; } JTextComponent target = getTextComponent(e); try { SyntaxDocument sdoc = ActionUtils.getSyntaxDocument(target); StringWriter out = new StringWriter(sdoc.getLength()); StringReader reader = new StringReader(target.getText()); InputSource src = new InputSource(reader); Document doc = getDocBuilder().parse(src); //Setup indenting to "pretty print" getTransformer().transform(new DOMSource(doc), new StreamResult(out)); target.setText(out.toString()); } catch (SAXParseException ex) { showErrorMessage(target, String.format("XML error: %s\nat(%d, %d)", ex.getMessage(), ex.getLineNumber(), ex.getColumnNumber())); ActionUtils.setCaretPosition(target, ex.getLineNumber(), ex.getColumnNumber() - 1); } catch (TransformerException ex) { showErrorMessage(target, ex.getMessageAndLocation()); } catch (SAXException ex) { showErrorMessage(target, ex.getLocalizedMessage()); } catch (IOException ex) { showErrorMessage(target, ex.getLocalizedMessage()); } } static Transformer transformer; static DocumentBuilderFactory docBuilderFactory; static DocumentBuilder docBuilder; private static void showErrorMessage(JTextComponent text, String msg) { Component parent = SwingUtilities.getWindowAncestor(text); JOptionPane.showMessageDialog(parent, msg, "JsyntaxPAne XML", JOptionPane.ERROR_MESSAGE); } public static Transformer getTransformer() { if (transformer == null) { TransformerFactory tfactory = TransformerFactory.newInstance(); try { transformer = tfactory.newTransformer(); } catch (TransformerConfigurationException ex) { throw new IllegalArgumentException("Unable to create transformer. ", ex); } } return transformer; } public void setIndent(String text) { getTransformer().setOutputProperty(OutputKeys.INDENT, text); } public void setStandAlone(String text) { getTransformer().setOutputProperty(OutputKeys.STANDALONE, text); } public void setSOmitDeclaration(String text) { getTransformer().setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, text); } public void setIndentAmount(String text) { getTransformer().setOutputProperty("{http://xml.apache.org/xslt}indent-amount", text); } public void setIgnoreComments(String ic) { getDocBuilderFactory().setIgnoringComments(Boolean.parseBoolean(ic)); } public void setIgnoreWhiteSpace(String value) { getDocBuilderFactory().setIgnoringElementContentWhitespace(Boolean.parseBoolean(value)); } public static DocumentBuilderFactory getDocBuilderFactory() { if (docBuilderFactory == null) { docBuilderFactory = DocumentBuilderFactory.newInstance(); } return docBuilderFactory; } public DocumentBuilder getDocBuilder() { if (docBuilder == null) { try { docBuilder = getDocBuilderFactory().newDocumentBuilder(); } catch (ParserConfigurationException ex) { throw new IllegalArgumentException("Unable to create document builder", ex); } } return docBuilder; } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/IndentAction.java0000644000175000017500000000626312127321546031072 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import java.util.Map; import java.util.regex.Pattern; import javax.swing.JEditorPane; import javax.swing.text.EditorKit; import javax.swing.text.JTextComponent; import jsyntaxpane.DefaultSyntaxKit; import jsyntaxpane.SyntaxDocument; import jsyntaxpane.Token; /** * IndentAction is used to replace Tabs with spaces. If there is selected * text, then the lines spanning the selection will be shifted * right by one tab-width space character. * * Since this is also used as an abbreviation completion action, * Abbreviiations are processed by this event. * * FIXME: Move the abbreviation expansion to an ActionUtils proc * @author Ayman Al-Sairafi * */ public class IndentAction extends DefaultSyntaxAction { public IndentAction() { super("insert-tab"); } @Override public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) { String selected = target.getSelectedText(); EditorKit kit = ((JEditorPane) target).getEditorKit(); Map abbrvs = ((DefaultSyntaxKit) kit).getAbbreviations(); if (selected == null) { // Check for abbreviations: Token abbrToken = sDoc.getWordAt(dot, wordsPattern); Integer tabStop = ActionUtils.getTabSize(target); int lineStart = sDoc.getParagraphElement(dot).getStartOffset(); int column = dot - lineStart; int needed = tabStop - (column % tabStop); if (abbrvs == null || abbrToken == null) { target.replaceSelection(ActionUtils.SPACES.substring(0, needed)); } else { String abbr = abbrToken.getString(sDoc); if (abbrvs.containsKey(abbr)) { target.select(abbrToken.start, abbrToken.end()); abbr = abbrvs.get(abbr); String[] abbrLines = abbr.split("\n"); if (abbrLines.length > 1) { ActionUtils.insertLinesTemplate(target, abbrLines); } else { ActionUtils.insertSimpleTemplate(target, abbr); } } else { target.replaceSelection(ActionUtils.SPACES.substring(0, needed)); } } } else { String[] lines = ActionUtils.getSelectedLines(target); int start = target.getSelectionStart(); StringBuilder sb = new StringBuilder(); for (String line : lines) { sb.append(ActionUtils.getTab(target)); sb.append(line); sb.append('\n'); } target.replaceSelection(sb.toString()); target.select(start, start + sb.length()); } } private Pattern wordsPattern = Pattern.compile("\\w+"); public void setWordRegex(String regex) { wordsPattern = Pattern.compile(regex); } public Pattern getWordRegex() { return wordsPattern; } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/gui/0000755000175000017500000000000012127321546026425 5ustar sylvestresylvestrelibjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/gui/GotoLineDialog.java0000644000175000017500000001433012127321546032131 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions.gui; import java.lang.ref.WeakReference; import jsyntaxpane.actions.*; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import javax.swing.text.JTextComponent; import jsyntaxpane.util.SwingUtils; /** * A simple dialog to prompt for a line number and go to it * @author Ayman Al-Sairafi */ public class GotoLineDialog extends javax.swing.JDialog implements EscapeListener { private static final String PROPERTY_KEY = "GOTOLINE_DIALOG"; private WeakReference text; /** * Creates new form GotoLineDialog * @param text */ private GotoLineDialog(JTextComponent text) { super(SwingUtilities.getWindowAncestor(text), ModalityType.APPLICATION_MODAL); initComponents(); this.text = new WeakReference(text); setLocationRelativeTo(text.getRootPane()); getRootPane().setDefaultButton(jBtnOk); text.getDocument().putProperty(PROPERTY_KEY, this); SwingUtils.addEscapeListener(this); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { jCmbLineNumbers = new javax.swing.JComboBox(); jBtnOk = new javax.swing.JButton(); java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle"); // NOI18N setTitle(bundle.getString("GotoLineDialog.title")); // NOI18N setModal(true); setName(""); // NOI18N setResizable(false); jCmbLineNumbers.setEditable(true); jCmbLineNumbers.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCmbLineNumbersActionPerformed(evt); } }); jBtnOk.setAction(jCmbLineNumbers.getAction()); jBtnOk.setText(bundle.getString("GotoLineDialog.jBtnOk.text")); // NOI18N jBtnOk.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBtnOkActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jCmbLineNumbers, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jBtnOk, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jCmbLineNumbers, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jBtnOk, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); pack(); }// //GEN-END:initComponents private void setTextPos() { Object line = jCmbLineNumbers.getSelectedItem(); if (line != null) { try { int lineNr = Integer.parseInt(line.toString()); ActionUtils.insertIntoCombo(jCmbLineNumbers, line); ActionUtils.setCaretPosition(text.get(), lineNr, 0); setVisible(false); } catch (NumberFormatException ex) { JOptionPane.showMessageDialog(this, "Invalid Number: " + line, "Number Error", JOptionPane.ERROR_MESSAGE); } } } private void jCmbLineNumbersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCmbLineNumbersActionPerformed if (evt.getActionCommand().equals("comboBoxEdited")) { setTextPos(); } }//GEN-LAST:event_jCmbLineNumbersActionPerformed private void jBtnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnOkActionPerformed setTextPos(); }//GEN-LAST:event_jBtnOkActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jBtnOk; private javax.swing.JComboBox jCmbLineNumbers; // End of variables declaration//GEN-END:variables /** * Create or return the GotoLine dialog for a given ext component * @param text */ public static void showForEditor(JTextComponent text) { GotoLineDialog dlg = null; if (text.getDocument().getProperty(PROPERTY_KEY) == null) { dlg = new GotoLineDialog(text); } else { dlg = (GotoLineDialog) text.getDocument().getProperty(PROPERTY_KEY); } dlg.jCmbLineNumbers.requestFocusInWindow(); dlg.setVisible(true); } @Override public void escapePressed() { setVisible(false); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/gui/QuickFindDialog.form0000644000175000017500000002356612127321546032323 0ustar sylvestresylvestre
      libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/gui/MemberCell.java0000644000175000017500000002030712127321546031301 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions.gui; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Member; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.net.URL; import java.util.HashMap; import java.util.Map; import javax.swing.ImageIcon; import javax.swing.JList; import javax.swing.JPanel; import jsyntaxpane.SyntaxView; import jsyntaxpane.actions.ActionUtils; import jsyntaxpane.util.ReflectUtils; /** * This class will render a Member. There are Method, Field and Constructor subclasses * @author Ayman Al-Sairafi */ abstract class MemberCell extends JPanel { private final JList list; private final boolean isSelected; private final Color backColor; private final Member member; private final Class theClass; public MemberCell(JList list, boolean isSelected, Color backColor, Member member, Class clazz) { super(); this.list = list; this.isSelected = isSelected; this.backColor = backColor; this.member = member; this.theClass = clazz; } @Override public void paintComponent(Graphics g) { SyntaxView.setRenderingHits((Graphics2D) g); g.setFont(list.getFont()); super.paintComponent(g); FontMetrics fm = g.getFontMetrics(); g.setColor(isSelected ? list.getSelectionBackground() : backColor); g.fillRect(0, 0, getWidth(), getHeight()); g.setColor(isSelected ? list.getSelectionForeground() : list.getForeground()); g.drawImage(getIcon(), 2, 0, null); int x = 6 + getIcon().getWidth(this); int y = fm.getHeight(); if (member.getDeclaringClass().equals(theClass)) { Font bold = list.getFont().deriveFont(Font.BOLD); g.setFont(bold); } x = drawString(getMemberName(), x, y, g); g.setFont(list.getFont()); x = drawString(getArguments(), x, y, g); String right = getReturnType(); int rw = fm.stringWidth(right); g.drawString(right, getWidth() - rw - 4, fm.getAscent()); } @Override public Dimension getPreferredSize() { Font font = list.getFont(); Graphics g = getGraphics(); FontMetrics fm = g.getFontMetrics(font); // total text for this component: String total = getMemberName() + getArguments() + getReturnType() + " "; return new Dimension(fm.stringWidth(total) + 20, Math.max(fm.getHeight(), 16)); } private int drawString(String string, int x, int y, Graphics g) { if(ActionUtils.isEmptyOrBlanks(string)) { return x; } int w = g.getFontMetrics().stringWidth(string); g.drawString(string, x, y); return x + w; } /** * Read all relevant icons and returns the Map. The loc should contain the * fully qualified URL for the icons. The icon names read will have the words * _private, protected, _static, _static_private and _static_protected and the * extension ".png" appended. * @param loc root for icon locations * @return Map (can be used directly with getModifiers & 0xf) */ Map readIcons(String loc) { Map icons = new HashMap(); icons.put(Modifier.PUBLIC, readImage(loc, "")); icons.put(Modifier.PRIVATE, readImage(loc, "_private")); icons.put(Modifier.PROTECTED, readImage(loc, "_protected")); icons.put(Modifier.STATIC | Modifier.PUBLIC, readImage(loc, "_static")); icons.put(Modifier.STATIC | Modifier.PRIVATE, readImage(loc, "_static_private")); icons.put(Modifier.STATIC | Modifier.PROTECTED, readImage(loc, "_static_protected")); return icons; } private Image readImage(String iconLoc, String kind) { String fullPath = iconLoc + kind + ".png"; URL loc = this.getClass().getResource(fullPath); if (loc == null) { return null; } else { Image i = new ImageIcon(loc).getImage(); return i; } } protected String getMemberName() { return member.getName(); } abstract protected String getArguments(); abstract protected String getReturnType(); abstract protected Image getIcon(); } /** * Renders a Method * @author Ayman Al-Sairafi */ class MethodCell extends MemberCell { private final Method method; public MethodCell(JList list, boolean isSelected, Color backColor, Method method, Class clazz) { super(list, isSelected, backColor, method, clazz); this.method = method; } @Override protected String getArguments() { return ReflectUtils.getParamsString(method.getParameterTypes()); } @Override protected String getReturnType() { return method.getReturnType().getSimpleName(); } @Override protected Image getIcon() { int type = method.getModifiers() & 0xf; // only get public/private/protected/static if (icons == null) { icons = readIcons(METHOD_ICON_LOC); } return icons.get(type); } private static Map icons = null; public static final String METHOD_ICON_LOC = "/META-INF/images/completions/method"; } /** * Renders a Field * @author Ayman Al-Sairafi */ class FieldCell extends MemberCell { private final Field field; public FieldCell(JList list, boolean isSelected, Color backColor, Field field, Class clazz) { super(list, isSelected, backColor, field, clazz); this.field = field; } @Override protected String getArguments() { return ""; } @Override protected String getReturnType() { return field.getType().getSimpleName(); } @Override protected Image getIcon() { int type = field.getModifiers() & 0xf; // only get public/private/protected/static if (icons == null) { icons = readIcons(FIELD_ICON_LOC); } if (icons.get(type) == null) { System.err.println("Unable to get icon for type: " + field.getModifiers()); } return icons.get(type); } private static Map icons = null; public static final String FIELD_ICON_LOC = "/META-INF/images/completions/field"; } /** * Renders a Field * @author Ayman Al-Sairafi */ class ConstructorCell extends MemberCell { private final Constructor cons; public ConstructorCell(JList list, boolean isSelected, Color backColor, Constructor cons, Class clazz) { super(list, isSelected, backColor, cons, clazz); this.cons = cons; } @Override protected String getMemberName() { return cons.getDeclaringClass().getSimpleName(); } @Override protected String getArguments() { return ReflectUtils.getParamsString(cons.getParameterTypes()); } @Override protected String getReturnType() { return cons.getDeclaringClass().getSimpleName(); } @Override protected Image getIcon() { int type = cons.getModifiers() & 0x7; // only get public/private/protected, mask out static if (icons == null) { icons = readIcons(FIELD_ICON_LOC); } if (icons.get(type) == null) { System.out.println("Unable to get icon for type: " + cons.getModifiers()); } return icons.get(type); } private static Map icons = null; public static final String FIELD_ICON_LOC = "/META-INF/images/completions/constructor"; }libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/gui/ReplaceDialog.java0000644000175000017500000003366012127321546031773 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions.gui; import jsyntaxpane.actions.*; import jsyntaxpane.components.Markers; import java.awt.Color; import java.awt.HeadlessException; import java.util.regex.Matcher; import java.util.regex.PatternSyntaxException; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; import javax.swing.text.JTextComponent; import jsyntaxpane.util.SwingUtils; /** * A Find and Replace Dialog. The dialog will also act as a listener to * Document changes so that all highlights are updated if the document is * changed. * * @author Ayman Al-Sairafi */ public class ReplaceDialog extends javax.swing.JDialog implements CaretListener, EscapeListener { private JTextComponent textComponent; private DocumentSearchData dsd; private static Markers.SimpleMarker SEARCH_MARKER = new Markers.SimpleMarker(Color.YELLOW); /** * Creates new form FindDialog * @param text * @param dsd DocumentSerachData */ public ReplaceDialog(JTextComponent text, DocumentSearchData dsd) { super(SwingUtilities.getWindowAncestor(text), ModalityType.MODELESS.MODELESS); initComponents(); textComponent = text; this.dsd = dsd; textComponent.addCaretListener(this); setLocationRelativeTo(text.getRootPane()); getRootPane().setDefaultButton(jBtnNext); SwingUtils.addEscapeListener(this); jBtnReplaceAll.setEnabled(text.isEditable() && text.isEnabled()); } /** * updates the highlights in the document when it is updated. * This is called by the DocumentListener methods */ public void updateHighlights() { Markers.removeMarkers(textComponent, SEARCH_MARKER); if (jTglHighlight.isSelected()) { Markers.markAll(textComponent, dsd.getPattern(), SEARCH_MARKER); } } private void showRegexpError(PatternSyntaxException ex) throws HeadlessException { JOptionPane.showMessageDialog(this, "Regexp error: " + ex.getMessage(), "Regular Expression Error", JOptionPane.ERROR_MESSAGE); jCmbFind.requestFocus(); } /** * update the finder object with data from our UI */ private void updateFinder() { String regex = (String) jCmbFind.getSelectedItem(); try { dsd.setPattern(regex, jChkRegex.isSelected(), jChkIgnoreCase.isSelected()); ActionUtils.insertIntoCombo(jCmbFind, regex); } catch (PatternSyntaxException e) { showRegexpError(e); } } /** * This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { jLblFind = new javax.swing.JLabel(); jBtnNext = new javax.swing.JButton(); jBtnPrev = new javax.swing.JButton(); jBtnReplaceAll = new javax.swing.JButton(); jChkWrap = new javax.swing.JCheckBox(); jChkRegex = new javax.swing.JCheckBox(); jChkIgnoreCase = new javax.swing.JCheckBox(); jLblReplace = new javax.swing.JLabel(); jTglHighlight = new javax.swing.JToggleButton(); jCmbReplace = new javax.swing.JComboBox(); jCmbFind = new javax.swing.JComboBox(); jBtnReplace = new javax.swing.JButton(); java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle"); // NOI18N setTitle(bundle.getString("ReplaceDialog.title")); // NOI18N setName(""); // NOI18N setResizable(false); jLblFind.setDisplayedMnemonic('F'); jLblFind.setLabelFor(jCmbFind); jLblFind.setText(bundle.getString("ReplaceDialog.jLblFind.text")); // NOI18N jBtnNext.setIcon(new javax.swing.ImageIcon(getClass().getResource("/META-INF/images/small-icons/go-next.png"))); // NOI18N jBtnNext.setMnemonic('N'); jBtnNext.setText(bundle.getString("ReplaceDialog.jBtnNext.text")); // NOI18N jBtnNext.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBtnNextActionPerformed(evt); } }); jBtnPrev.setIcon(new javax.swing.ImageIcon(getClass().getResource("/META-INF/images/small-icons/go-previous.png"))); // NOI18N jBtnPrev.setMnemonic('N'); jBtnPrev.setText(bundle.getString("ReplaceDialog.jBtnPrev.text")); // NOI18N jBtnPrev.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBtnPrevActionPerformed(evt); } }); jBtnReplaceAll.setIcon(new javax.swing.ImageIcon(getClass().getResource("/META-INF/images/small-icons/edit-find-replace-all.png"))); // NOI18N jBtnReplaceAll.setMnemonic('H'); jBtnReplaceAll.setText(bundle.getString("ReplaceDialog.jBtnReplaceAll.text")); // NOI18N jBtnReplaceAll.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBtnReplaceAllActionPerformed(evt); } }); jChkWrap.setMnemonic('W'); jChkWrap.setText(bundle.getString("ReplaceDialog.jChkWrap.text")); // NOI18N jChkWrap.setToolTipText(bundle.getString("ReplaceDialog.jChkWrap.toolTipText")); // NOI18N jChkRegex.setMnemonic('R'); jChkRegex.setText(bundle.getString("ReplaceDialog.jChkRegex.text")); // NOI18N jChkIgnoreCase.setMnemonic('I'); jChkIgnoreCase.setText(bundle.getString("ReplaceDialog.jChkIgnoreCase.text")); // NOI18N jLblReplace.setDisplayedMnemonic('R'); jLblReplace.setLabelFor(jCmbReplace); jLblReplace.setText(bundle.getString("ReplaceDialog.jLblReplace.text")); // NOI18N jTglHighlight.setIcon(new javax.swing.ImageIcon(getClass().getResource("/META-INF/images/small-icons/highlight.png"))); // NOI18N jTglHighlight.setText(bundle.getString("ReplaceDialog.jTglHighlight.text")); // NOI18N jTglHighlight.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTglHighlightActionPerformed(evt); } }); jCmbReplace.setEditable(true); jCmbFind.setEditable(true); jBtnReplace.setIcon(new javax.swing.ImageIcon(getClass().getResource("/META-INF/images/small-icons/edit-find-replace.png"))); // NOI18N jBtnReplace.setText(bundle.getString("ReplaceDialog.jBtnReplace.text")); // NOI18N jBtnReplace.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBtnReplaceActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLblFind) .addComponent(jLblReplace)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jCmbFind, 0, 289, Short.MAX_VALUE) .addComponent(jCmbReplace, javax.swing.GroupLayout.Alignment.TRAILING, 0, 289, Short.MAX_VALUE) .addComponent(jChkRegex, javax.swing.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE) .addComponent(jChkWrap, javax.swing.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE) .addComponent(jChkIgnoreCase, javax.swing.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jBtnReplace, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 107, Short.MAX_VALUE) .addComponent(jBtnNext, javax.swing.GroupLayout.DEFAULT_SIZE, 107, Short.MAX_VALUE) .addComponent(jBtnPrev, javax.swing.GroupLayout.DEFAULT_SIZE, 107, Short.MAX_VALUE) .addComponent(jTglHighlight, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 107, Short.MAX_VALUE) .addComponent(jBtnReplaceAll, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 107, Short.MAX_VALUE)) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLblFind) .addComponent(jCmbFind, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jBtnNext)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jBtnPrev) .addComponent(jCmbReplace, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLblReplace)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jBtnReplace) .addComponent(jChkWrap, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(3, 3, 3) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jChkRegex) .addComponent(jBtnReplaceAll)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jChkIgnoreCase) .addComponent(jTglHighlight)) .addContainerGap()) ); pack(); }// //GEN-END:initComponents private void jBtnNextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnNextActionPerformed try { updateFinder(); if (!dsd.doFindNext(textComponent)) { dsd.msgNotFound(textComponent); } textComponent.requestFocusInWindow(); } catch (PatternSyntaxException ex) { showRegexpError(ex); } }//GEN-LAST:event_jBtnNextActionPerformed private void jBtnReplaceAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnReplaceAllActionPerformed try { updateFinder(); String replacement = (String) jCmbReplace.getSelectedItem(); if(!jChkRegex.isSelected()) { replacement = Matcher.quoteReplacement(replacement); } ActionUtils.insertIntoCombo(jCmbReplace, replacement); jTglHighlight.setSelected(false); dsd.doReplaceAll(textComponent, replacement); textComponent.requestFocusInWindow(); } catch (PatternSyntaxException ex) { showRegexpError(ex); } }//GEN-LAST:event_jBtnReplaceAllActionPerformed private void jTglHighlightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTglHighlightActionPerformed updateFinder(); updateHighlights(); }//GEN-LAST:event_jTglHighlightActionPerformed private void jBtnPrevActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnPrevActionPerformed updateFinder(); dsd.doFindPrev(textComponent); }//GEN-LAST:event_jBtnPrevActionPerformed private void jBtnReplaceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnReplaceActionPerformed jTglHighlight.setSelected(false); String replacement = jCmbReplace.getSelectedItem() == null ? "" : jCmbReplace.getSelectedItem().toString(); dsd.doReplace(textComponent, replacement); }//GEN-LAST:event_jBtnReplaceActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jBtnNext; private javax.swing.JButton jBtnPrev; private javax.swing.JButton jBtnReplace; private javax.swing.JButton jBtnReplaceAll; private javax.swing.JCheckBox jChkIgnoreCase; private javax.swing.JCheckBox jChkRegex; private javax.swing.JCheckBox jChkWrap; private javax.swing.JComboBox jCmbFind; private javax.swing.JComboBox jCmbReplace; private javax.swing.JLabel jLblFind; private javax.swing.JLabel jLblReplace; private javax.swing.JToggleButton jTglHighlight; // End of variables declaration//GEN-END:variables @Override public void caretUpdate(CaretEvent e) { updateHighlights(); } @Override public void escapePressed() { setVisible(false); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/gui/ComboCompletionDialog.form0000644000175000017500000000652512127321546033533 0ustar sylvestresylvestre
      libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/gui/ReplaceDialog.form0000644000175000017500000003403112127321546032006 0ustar sylvestresylvestre
      libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/gui/ShowAbbsDialog.form0000644000175000017500000001350512127321546032146 0ustar sylvestresylvestre
      libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/gui/GotoLineDialog.form0000644000175000017500000001032412127321546032152 0ustar sylvestresylvestre
      libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/gui/ComboCompletionDialog.java0000644000175000017500000002173112127321546033505 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions.gui; import java.awt.Font; import java.awt.Point; import java.awt.Rectangle; import java.awt.Window; import java.awt.event.KeyEvent; import java.util.List; import java.util.Vector; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.SwingUtilities; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.text.BadLocationException; import javax.swing.text.JTextComponent; import jsyntaxpane.actions.ActionUtils; import jsyntaxpane.util.StringUtils; import jsyntaxpane.util.SwingUtils; /** * * @author Ayman Al-Sairafi */ public class ComboCompletionDialog extends javax.swing.JDialog implements EscapeListener { /** * The result returned to the caller */ private String result = null; /** * Our target component */ private JTextComponent target; public String escapeChars = ";(= \t\n\r"; public List items; /** * Creates new form ComboCompletionDialog * @param target */ public ComboCompletionDialog(JTextComponent target) { super(SwingUtilities.getWindowAncestor(target), ModalityType.APPLICATION_MODAL); initComponents(); jTxtItem.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { refilterList(); } @Override public void removeUpdate(DocumentEvent e) { refilterList(); } @Override public void changedUpdate(DocumentEvent e) { refilterList(); } }); // This will allow the textfield to receive TAB keys jTxtItem.setFocusTraversalKeysEnabled(false); this.target = target; SwingUtils.addEscapeListener(this); } /** * Display the Completion Dialog with initial abbrev and using the given items * The dialog is responsible for showing itself and for updating the target * with the text, depending on user actions. * * The dialog will be aligned to the selectionStart of the target component * and when a selection is made, replaceSelection will be called on dialog * * @param abbrev * @param items */ public void displayFor(String abbrev, List items) { this.items = items; try { Window window = SwingUtilities.getWindowAncestor(target); Rectangle rt = target.modelToView(target.getSelectionStart()); Point loc = new Point(rt.x, rt.y); setLocationRelativeTo(window); // convert the location from Text Componet coordinates to // Frame coordinates... loc = SwingUtilities.convertPoint(target, loc, window); // and then to Screen coordinates SwingUtilities.convertPointToScreen(loc, window); setLocation(loc); } catch (BadLocationException ex) { Logger.getLogger(ComboCompletionDialog.class.getName()).log(Level.SEVERE, null, ex); } finally { Font font = target.getFont(); jTxtItem.setFont(font); jLstItems.setFont(font); doLayout(); jTxtItem.setText(abbrev); refilterList(); setVisible(true); } } private void refilterList() { String prefix = jTxtItem.getText(); Vector filtered = new Vector(); Object selected = jLstItems.getSelectedValue(); for (String s : items) { if (StringUtils.camelCaseMatch(s, prefix)) { filtered.add(s); } } jLstItems.setListData(filtered); if (selected != null && filtered.contains(selected)) { jLstItems.setSelectedValue(selected, true); } else { jLstItems.setSelectedIndex(0); } } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { jTxtItem = new javax.swing.JTextField(); jScrollPane1 = new javax.swing.JScrollPane(); jLstItems = new javax.swing.JList(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setResizable(false); setUndecorated(true); jTxtItem.setBorder(null); jTxtItem.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { jTxtItemKeyPressed(evt); } }); jLstItems.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); jLstItems.setFocusable(false); jLstItems.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jLstItemsMouseClicked(evt); } }); jScrollPane1.setViewportView(jLstItems); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jTxtItem, javax.swing.GroupLayout.DEFAULT_SIZE, 375, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 375, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jTxtItem, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, 0) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE)) ); pack(); }// //GEN-END:initComponents private void jTxtItemKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTxtItemKeyPressed int i = jLstItems.getSelectedIndex(); switch (evt.getKeyCode()) { case KeyEvent.VK_ESCAPE: result = jTxtItem.getText(); target.replaceSelection(result); setVisible(false); return; case KeyEvent.VK_DOWN: if (i < jLstItems.getModel().getSize() - 1) { i++; } jLstItems.setSelectedIndex(i); jLstItems.ensureIndexIsVisible(i); break; case KeyEvent.VK_UP: if (i > 0) { i--; } jLstItems.setSelectedIndex(i); jLstItems.ensureIndexIsVisible(i); break; } if (escapeChars.indexOf(evt.getKeyChar()) >= 0) { if (jLstItems.getSelectedIndex() >= 0) { result = jLstItems.getSelectedValue().toString(); } else { result = jTxtItem.getText(); } char pressed = evt.getKeyChar(); // we need to just accept ENTER, and replace the tab with a single // space if (pressed != '\n') { result += (pressed == '\t') ? ' ' : pressed; } target.replaceSelection(result); setVisible(false); } }//GEN-LAST:event_jTxtItemKeyPressed private void jLstItemsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLstItemsMouseClicked if(evt.getClickCount() == 2) { Object selectedValue = jLstItems.getSelectedValue(); if(selectedValue != null){ String selected = selectedValue.toString(); target.replaceSelection(selected); } setVisible(false); } }//GEN-LAST:event_jLstItemsMouseClicked // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JList jLstItems; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTextField jTxtItem; // End of variables declaration//GEN-END:variables @Override public void escapePressed() { setVisible(false); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/gui/QuickFindDialog.java0000644000175000017500000002733612127321546032300 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions.gui; import java.awt.Color; import java.awt.Container; import java.awt.Dimension; import java.awt.Point; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.lang.ref.WeakReference; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.SwingUtilities; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.text.BadLocationException; import javax.swing.text.JTextComponent; import jsyntaxpane.actions.ActionUtils; import jsyntaxpane.actions.DocumentSearchData; import jsyntaxpane.components.Markers; import jsyntaxpane.components.Markers.SimpleMarker; import jsyntaxpane.util.SwingUtils; /** * QuickFind Dialog. Firefox like dialog shown at bottom of editor. * @author Ayman Al-Sairafi */ public class QuickFindDialog extends javax.swing.JDialog implements DocumentListener, ActionListener, EscapeListener { private SimpleMarker marker = new SimpleMarker(Color.PINK); private WeakReference target; private WeakReference dsd; private int oldCaretPosition; /** * This will be set to true if ESC key is used to quit the form. * In that case, the caret will be restored to its old pos, otherwise * it will remain where the user probably clicked. */ private boolean escaped = false; /** * Creates new form QuickFindDialog * * @param target * @param data search data */ public QuickFindDialog(final JTextComponent target, DocumentSearchData data) { super(SwingUtilities.getWindowAncestor(target), ModalityType.MODELESS.MODELESS); initComponents(); SwingUtils.addEscapeListener(this); dsd = new WeakReference(data); } public void showFor(final JTextComponent target) { oldCaretPosition = target.getCaretPosition(); Container view = target.getParent(); Dimension wd = getSize(); wd.width = target.getVisibleRect().width; Point loc = new Point(0, view.getHeight()); setSize(wd); setLocationRelativeTo(view); SwingUtilities.convertPointToScreen(loc, view); setLocation(loc); jTxtFind.setFont(target.getFont()); jTxtFind.getDocument().addDocumentListener(this); WindowAdapter closeListener = new WindowAdapter() { @Override public void windowDeactivated(WindowEvent e) { target.getDocument().removeDocumentListener(QuickFindDialog.this); Markers.removeMarkers(target, marker); if (escaped) { Rectangle aRect; try { aRect = target.modelToView(oldCaretPosition); target.setCaretPosition(oldCaretPosition); target.scrollRectToVisible(aRect); } catch (BadLocationException ex) { } } dispose(); } }; addWindowListener(closeListener); this.target = new WeakReference(target); Pattern p = dsd.get().getPattern(); if (p != null) { jTxtFind.setText(p.pattern()); } jChkWrap.setSelected(dsd.get().isWrap()); setVisible(true); } /** * This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { jToolBar1 = new javax.swing.JToolBar(); jSeparator1 = new javax.swing.JToolBar.Separator(); jLabel1 = new javax.swing.JLabel(); jSeparator2 = new javax.swing.JToolBar.Separator(); jTxtFind = new javax.swing.JTextField(); jSeparator3 = new javax.swing.JToolBar.Separator(); jBtnPrev = new javax.swing.JButton(); jBtnNext = new javax.swing.JButton(); jChkIgnoreCase = new javax.swing.JCheckBox(); jChkRegExp = new javax.swing.JCheckBox(); jChkWrap = new javax.swing.JCheckBox(); jSeparator4 = new javax.swing.JToolBar.Separator(); jLblStatus = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setBackground(java.awt.Color.darkGray); setName("QuickFindDialog"); // NOI18N setResizable(false); setUndecorated(true); jToolBar1.setBorder(javax.swing.BorderFactory.createEtchedBorder()); jToolBar1.setFloatable(false); jToolBar1.setRollover(true); jToolBar1.add(jSeparator1); jLabel1.setLabelFor(jTxtFind); java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle"); // NOI18N jLabel1.setText(bundle.getString("QuickFindDialog.jLabel1.text")); // NOI18N jToolBar1.add(jLabel1); jToolBar1.add(jSeparator2); jTxtFind.setColumns(30); jTxtFind.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jTxtFind.setMaximumSize(new java.awt.Dimension(200, 24)); jTxtFind.setMinimumSize(new java.awt.Dimension(60, 24)); jToolBar1.add(jTxtFind); jToolBar1.add(jSeparator3); jBtnPrev.setIcon(new javax.swing.ImageIcon(getClass().getResource("/META-INF/images/small-icons/go-up.png"))); // NOI18N jBtnPrev.setFocusable(false); jBtnPrev.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jBtnPrev.setOpaque(false); jBtnPrev.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); jBtnPrev.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBtnPrevActionPerformed(evt); } }); jToolBar1.add(jBtnPrev); jBtnNext.setIcon(new javax.swing.ImageIcon(getClass().getResource("/META-INF/images/small-icons/go-down.png"))); // NOI18N jBtnNext.setFocusable(false); jBtnNext.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jBtnNext.setMargin(new java.awt.Insets(2, 2, 2, 2)); jBtnNext.setOpaque(false); jBtnNext.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); jBtnNext.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBtnNextActionPerformed(evt); } }); jToolBar1.add(jBtnNext); jChkIgnoreCase.setMnemonic('C'); jChkIgnoreCase.setText(bundle.getString("QuickFindDialog.jChkIgnoreCase.text")); // NOI18N jChkIgnoreCase.setFocusable(false); jChkIgnoreCase.setOpaque(false); jChkIgnoreCase.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); jToolBar1.add(jChkIgnoreCase); jChkIgnoreCase.addActionListener(this); jChkRegExp.setMnemonic('R'); jChkRegExp.setText(bundle.getString("QuickFindDialog.jChkRegExp.text")); // NOI18N jChkRegExp.setFocusable(false); jChkRegExp.setOpaque(false); jChkRegExp.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); jToolBar1.add(jChkRegExp); jChkRegExp.addActionListener(this); jChkWrap.setMnemonic('W'); jChkWrap.setText(bundle.getString("QuickFindDialog.jChkWrap.text")); // NOI18N jChkWrap.setFocusable(false); jChkWrap.setOpaque(false); jChkWrap.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); jToolBar1.add(jChkWrap); jChkWrap.addActionListener(this); jToolBar1.add(jSeparator4); jLblStatus.setFont(jLblStatus.getFont().deriveFont(jLblStatus.getFont().getStyle() | java.awt.Font.BOLD, jLblStatus.getFont().getSize()-2)); jLblStatus.setForeground(java.awt.Color.red); jToolBar1.add(jLblStatus); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 684, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) ); pack(); }// //GEN-END:initComponents private void jBtnNextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnNextActionPerformed if (dsd.get().doFindNext(target.get())) { jLblStatus.setText(null); } else { jLblStatus.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("QuickFindDialog.NotFound")); } }//GEN-LAST:event_jBtnNextActionPerformed private void jBtnPrevActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnPrevActionPerformed if (dsd.get().doFindPrev(target.get())) { jLblStatus.setText(null); } else { jLblStatus.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("QuickFindDialog.NotFound")); } }//GEN-LAST:event_jBtnPrevActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jBtnNext; private javax.swing.JButton jBtnPrev; private javax.swing.JCheckBox jChkIgnoreCase; private javax.swing.JCheckBox jChkRegExp; private javax.swing.JCheckBox jChkWrap; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLblStatus; private javax.swing.JToolBar.Separator jSeparator1; private javax.swing.JToolBar.Separator jSeparator2; private javax.swing.JToolBar.Separator jSeparator3; private javax.swing.JToolBar.Separator jSeparator4; private javax.swing.JToolBar jToolBar1; private javax.swing.JTextField jTxtFind; // End of variables declaration//GEN-END:variables @Override public void insertUpdate(DocumentEvent e) { updateFind(); } @Override public void removeUpdate(DocumentEvent e) { updateFind(); } @Override public void changedUpdate(DocumentEvent e) { updateFind(); } private void updateFind() { JTextComponent t = target.get(); DocumentSearchData d = dsd.get(); String toFind = jTxtFind.getText(); if (toFind == null || toFind.isEmpty()) { jLblStatus.setText(null); return; } try { d.setWrap(jChkWrap.isSelected()); d.setPattern(toFind, jChkRegExp.isSelected(), jChkIgnoreCase.isSelected()); // The dsd doFindNext will always find from current pos, // so we need to relocate to our saved pos before we call doFindNext jLblStatus.setText(null); t.setCaretPosition(oldCaretPosition); if (!d.doFindNext(t)) { jLblStatus.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("QuickFindDialog.NotFound")); } else { jLblStatus.setText(null); } } catch (PatternSyntaxException e) { jLblStatus.setText(e.getDescription()); } } @Override public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBox) { updateFind(); } } @Override public void escapePressed() { escaped = true; setVisible(false); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/gui/ReflectCompletionDialog.java0000644000175000017500000002561212127321546034034 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions.gui; import java.awt.Font; import java.awt.Point; import java.awt.Rectangle; import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.KeyEvent; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Member; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; import java.util.Vector; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.SwingUtilities; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.text.BadLocationException; import javax.swing.text.JTextComponent; import jsyntaxpane.actions.ActionUtils; import jsyntaxpane.util.ReflectUtils; import jsyntaxpane.util.StringUtils; import jsyntaxpane.util.SwingUtils; /** * * @author Ayman Al-Sairafi */ public class ReflectCompletionDialog extends javax.swing.JDialog implements EscapeListener { /** * The class we are displaying its members: */ private Class theClass; /** * The current filter, to avoid refiltering the items */ public String escapeChars = ";(= \t\n"; public List items; private final JTextComponent target; /** * Creates new form ReflectCompletionDialog * @param target Text component for this dialog */ public ReflectCompletionDialog(JTextComponent target) { super(SwingUtilities.getWindowAncestor(target), ModalityType.APPLICATION_MODAL); initComponents(); this.target = target; jTxtItem.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { refilterList(); } @Override public void removeUpdate(DocumentEvent e) { refilterList(); } @Override public void changedUpdate(DocumentEvent e) { refilterList(); } }); // This will allow the textfield to receive TAB keys jTxtItem.setFocusTraversalKeysEnabled(false); // Add action so we automatically filter on comboBox Enter Key jCmbClassName.getEditor().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateItems(); } }); SwingUtils.addEscapeListener(this); } public void setFonts(Font font) { jTxtItem.setFont(font); jLstItems.setFont(font); doLayout(); } private String getSelection() { String result; if (jLstItems.getSelectedIndex() >= 0) { Object selected = jLstItems.getSelectedValue(); if (selected instanceof Method) { result = ReflectUtils.getJavaCallString((Method) selected); } else if (selected instanceof Constructor) { result = ReflectUtils.getJavaCallString((Constructor) selected); } else if (selected instanceof Field) { result = ((Field) selected).getName(); } else { result = selected.toString(); } } else { result = jTxtItem.getText(); } return result; } private void refilterList() { String prefix = jTxtItem.getText(); Vector filtered = new Vector(); Object selected = jLstItems.getSelectedValue(); for (Member m : items) { if (StringUtils.camelCaseMatch(m.getName(), prefix)) { filtered.add(m); } } jLstItems.setListData(filtered); if (selected != null && filtered.contains(selected)) { jLstItems.setSelectedValue(selected, true); } else { jLstItems.setSelectedIndex(0); } } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { jTxtItem = new javax.swing.JTextField(); jScrollPane1 = new javax.swing.JScrollPane(); jLstItems = new javax.swing.JList(); jCmbClassName = new javax.swing.JComboBox(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setName("CompletionDialog"); // NOI18N setResizable(false); setUndecorated(true); jTxtItem.setBorder(null); jTxtItem.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { jTxtItemKeyPressed(evt); } }); jLstItems.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); jLstItems.setCellRenderer(new jsyntaxpane.actions.gui.MembersListRenderer(this)); jLstItems.setFocusable(false); jLstItems.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jLstItemsMouseClicked(evt); } }); jScrollPane1.setViewportView(jLstItems); jCmbClassName.setEditable(true); jCmbClassName.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Object", "String" })); jCmbClassName.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { jCmbClassNameItemStateChanged(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jTxtItem, javax.swing.GroupLayout.DEFAULT_SIZE, 437, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 437, Short.MAX_VALUE) .addComponent(jCmbClassName, 0, 437, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jTxtItem, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, 0) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 156, Short.MAX_VALUE) .addGap(0, 0, 0) .addComponent(jCmbClassName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) ); pack(); }// //GEN-END:initComponents private void jTxtItemKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTxtItemKeyPressed int i = jLstItems.getSelectedIndex(); switch (evt.getKeyCode()) { case KeyEvent.VK_ESCAPE: target.setCaretPosition(target.getSelectionEnd()); setVisible(false); return; case KeyEvent.VK_DOWN: i++; break; case KeyEvent.VK_UP: i--; break; case KeyEvent.VK_HOME: i = 0; break; case KeyEvent.VK_END: i = jLstItems.getModel().getSize() - 1; break; case KeyEvent.VK_PAGE_DOWN: i += jLstItems.getVisibleRowCount(); break; case KeyEvent.VK_PAGE_UP: i -= jLstItems.getVisibleRowCount(); break; } if (escapeChars.indexOf(evt.getKeyChar()) >= 0) { String result = getSelection(); char pressed = evt.getKeyChar(); // we need to just accept ENTER, and replace the tab with a single // space if (pressed != '\n') { result += (pressed == '\t') ? ' ' : pressed; } target.replaceSelection(result); setVisible(false); } else { // perform bounds checks for i if (i >= jLstItems.getModel().getSize()) { i = jLstItems.getModel().getSize() - 1; } if (i < 0) { i = 0; } jLstItems.setSelectedIndex(i); jLstItems.ensureIndexIsVisible(i); } }//GEN-LAST:event_jTxtItemKeyPressed private void jCmbClassNameItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jCmbClassNameItemStateChanged if (evt.getStateChange() == ItemEvent.SELECTED) { updateItems(); } }//GEN-LAST:event_jCmbClassNameItemStateChanged private void jLstItemsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLstItemsMouseClicked if (evt.getClickCount() == 2) { String selected = getSelection(); target.replaceSelection(selected); setVisible(false); } }//GEN-LAST:event_jLstItemsMouseClicked private void updateItems() { String className = jCmbClassName.getEditor().getItem().toString(); if (items == null) { items = new ArrayList(); } else { items.clear(); } // we must have the class in the Combo: Class aClass = ReflectUtils.findClass(className, ReflectUtils.DEFAULT_PACKAGES); if (aClass != null) { // for now, add everything: theClass = aClass; ReflectUtils.addConstrcutors(aClass, items); ReflectUtils.addMethods(aClass, items); ReflectUtils.addFields(aClass, items); ActionUtils.insertIntoCombo(jCmbClassName, className); jTxtItem.requestFocusInWindow(); } refilterList(); } public Class getTheClass() { return theClass; } /** * Set the items to display * @param items */ public void setItems(List items) { this.items = items; } /** * Display the dialog. * @param target text component (its Window will be the parent) */ public void displayFor(JTextComponent target) { try { int dot = target.getSelectionStart(); Window window = SwingUtilities.getWindowAncestor(target); Rectangle rt = target.modelToView(dot); Point loc = new Point(rt.x, rt.y); // convert the location from Text Componet coordinates to // Frame coordinates... loc = SwingUtilities.convertPoint(target, loc, window); // and then to Screen coordinates SwingUtilities.convertPointToScreen(loc, window); setLocationRelativeTo(window); setLocation(loc); } catch (BadLocationException ex) { Logger.getLogger(ReflectCompletionDialog.class.getName()).log(Level.SEVERE, null, ex); } finally { setFonts(target.getFont()); updateItems(); jTxtItem.setText(target.getSelectedText()); setVisible(true); } } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JComboBox jCmbClassName; private javax.swing.JList jLstItems; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTextField jTxtItem; // End of variables declaration//GEN-END:variables @Override public void escapePressed() { target.setCaretPosition(target.getSelectionEnd()); setVisible(false); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/gui/HTMLPreviewFrame.form0000644000175000017500000000610112127321546032371 0ustar sylvestresylvestre
      libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/gui/EscapeListener.java0000644000175000017500000000177712127321546032212 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions.gui; import javax.swing.RootPaneContainer; /** * This interface is used by dialogs that will need to listen to ESC key. * When the ESC key is pressed, escapePressed is called. * @author Ayman Al-Sairafi */ public interface EscapeListener extends RootPaneContainer { /** * This method will be called when ESC key is pressed. */ public void escapePressed(); } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/gui/HTMLPreviewFrame.java0000644000175000017500000000756412127321546032365 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions.gui; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.text.BadLocationException; import javax.swing.text.Document; import jsyntaxpane.actions.HTMLPreviewAction; /** * * @author Ayman Al-Sairafi */ public class HTMLPreviewFrame extends javax.swing.JFrame implements DocumentListener { Document doc; /** * Creates new form HTMLPreviewFrame * @param doc */ public HTMLPreviewFrame(Document doc) { initComponents(); this.doc = doc; doc.addDocumentListener(this); updateHTML(); } private void updateHTML() { try { jEdtHtml.setText(doc.getText(0, doc.getLength())); } catch (BadLocationException ex) { Logger.getLogger(HTMLPreviewFrame.class.getName()).log(Level.SEVERE, null, ex); } } /** * This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane(); jEdtHtml = new javax.swing.JEditorPane(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle"); // NOI18N setTitle(bundle.getString("HTMLPreviewFrame.title")); // NOI18N addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosed(java.awt.event.WindowEvent evt) { onWindowClosed(evt); } }); jEdtHtml.setContentType(bundle.getString("HTMLPreviewFrame.jEdtHtml.contentType")); // NOI18N jEdtHtml.setEditable(false); jScrollPane1.setViewportView(jEdtHtml); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 688, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 449, Short.MAX_VALUE) ); pack(); }// //GEN-END:initComponents private void onWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_onWindowClosed doc.removeDocumentListener(this); doc.putProperty(HTMLPreviewAction.HTML_PREVIEW_WINDOW, null); doc = null; }//GEN-LAST:event_onWindowClosed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JEditorPane jEdtHtml; private javax.swing.JScrollPane jScrollPane1; // End of variables declaration//GEN-END:variables @Override public void insertUpdate(DocumentEvent e) { updateHTML(); } @Override public void removeUpdate(DocumentEvent e) { updateHTML(); } @Override public void changedUpdate(DocumentEvent e) { updateHTML(); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/gui/ShowAbbsDialog.java0000644000175000017500000001176412127321546032131 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions.gui; import java.util.Arrays; import java.util.Map; import javax.swing.JEditorPane; import javax.swing.SwingUtilities; import jsyntaxpane.util.SwingUtils; /** * Show abbreviations for a JEditorPane. * * @author Ayman Al-Sairafi */ public class ShowAbbsDialog extends javax.swing.JDialog implements EscapeListener { /** * Creates new form ShowAbbsDialog * @param parent * @param abbs */ public ShowAbbsDialog(JEditorPane parent, Map abbs) { super(SwingUtilities.getWindowAncestor(parent), ModalityType.APPLICATION_MODAL); initComponents(); Object[] abbsList = abbs.keySet().toArray(); Arrays.sort(abbsList); jLstAbbs.setListData(abbsList); this.abbs = abbs; jEdtAbbr.setEditorKit(parent.getEditorKit()); jLstAbbs.setSelectedIndex(0); SwingUtils.addEscapeListener(this); setVisible(true); } /** * This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { jSplitPane1 = new javax.swing.JSplitPane(); jScrollPane1 = new javax.swing.JScrollPane(); jLstAbbs = new javax.swing.JList(); jScrollPane2 = new javax.swing.JScrollPane(); jEdtAbbr = new javax.swing.JEditorPane(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle"); // NOI18N setTitle(bundle.getString("ShowAbbsDialog.title")); // NOI18N setLocationByPlatform(true); setMinimumSize(new java.awt.Dimension(600, 300)); setModal(true); setName("dlgShowAbbs"); // NOI18N jSplitPane1.setDividerLocation(150); jSplitPane1.setDividerSize(3); jScrollPane1.setPreferredSize(new java.awt.Dimension(258, 400)); jLstAbbs.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); jLstAbbs.addListSelectionListener(new javax.swing.event.ListSelectionListener() { public void valueChanged(javax.swing.event.ListSelectionEvent evt) { jLstAbbsValueChanged(evt); } }); jScrollPane1.setViewportView(jLstAbbs); jSplitPane1.setLeftComponent(jScrollPane1); jEdtAbbr.setEditable(false); jEdtAbbr.setMinimumSize(new java.awt.Dimension(106, 400)); jScrollPane2.setViewportView(jEdtAbbr); jSplitPane1.setRightComponent(jScrollPane2); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 580, Short.MAX_VALUE) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jSplitPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 337, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); pack(); }// //GEN-END:initComponents private void jLstAbbsValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jLstAbbsValueChanged if (evt.getValueIsAdjusting() == false) { Object selected = jLstAbbs.getSelectedValue(); if (selected != null) { jEdtAbbr.setText(abbs.get(selected.toString())); } } }//GEN-LAST:event_jLstAbbsValueChanged // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JEditorPane jEdtAbbr; private javax.swing.JList jLstAbbs; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JSplitPane jSplitPane1; // End of variables declaration//GEN-END:variables Map abbs; @Override public void escapePressed() { setVisible(false); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/gui/ReflectCompletionDialog.form0000644000175000017500000001141412127321546034051 0ustar sylvestresylvestre
      libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/gui/MembersListRenderer.java0000644000175000017500000000412112127321546033203 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions.gui; import java.awt.Color; import java.awt.Component; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; import javax.swing.DefaultListCellRenderer; import javax.swing.JList; class MembersListRenderer extends DefaultListCellRenderer { static final Color evensColor = new Color(0xeeffee); private ReflectCompletionDialog dlg; public MembersListRenderer(ReflectCompletionDialog dlg) { this.dlg = dlg; } @Override public Component getListCellRendererComponent(final JList list, Object value, final int index, final boolean isSelected, boolean cellHasFocus) { Color back = (index % 2 == 1) ? list.getBackground() : evensColor; if (value instanceof Method) { final Method method = (Method) value; return new MethodCell(list, isSelected, back, method, dlg.getTheClass()); } else if (value instanceof Field) { Field field = (Field) value; return new FieldCell(list, isSelected, back, field, dlg.getTheClass()); } else if (value instanceof Constructor) { Constructor cons = (Constructor) value; return new ConstructorCell(list, isSelected, back, cons, dlg.getTheClass()); } else { Component comp = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); comp.setBackground(back); return comp; } } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/UnindentAction.java0000644000175000017500000000347412127321546031436 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; /** * This is usually mapped to Shift-TAB to unindent the selection. The * current line, or the selected lines are un-indented by the tabstop of the * document. */ public class UnindentAction extends DefaultSyntaxAction { public UnindentAction() { super("UNINDENT"); } @Override public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) { String indent = ActionUtils.getTab(target); String[] lines = ActionUtils.getSelectedLines(target); int start = target.getSelectionStart(); StringBuilder sb = new StringBuilder(); for (String line : lines) { if (line.startsWith(indent)) { sb.append(line.substring(indent.length())); } else if (line.startsWith("\t")) { sb.append(line.substring(1)); } else { sb.append(line); } sb.append('\n'); } target.replaceSelection(sb.toString()); target.select(start, start + sb.length()); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/ReflectCompletionAction.java0000644000175000017500000000307012127321546033260 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import jsyntaxpane.actions.gui.ReflectCompletionDialog; import java.awt.event.ActionEvent; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; import jsyntaxpane.Token; /** * ComboBox like Completion Action: * This will display a list of items to choose from, its can be used similar to * IntelliSense * * @author Ayman Al-Sairafi */ public class ReflectCompletionAction extends DefaultSyntaxAction { ReflectCompletionDialog dlg; public ReflectCompletionAction() { super("REFLECT_COMPLETION"); } @Override public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) { Token t = sDoc.getTokenAt(dot); if(t != null) { target.select(t.start, t.end()); } if (dlg == null) { dlg = new ReflectCompletionDialog(target); } dlg.displayFor(target); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/JumpToPairAction.java0000644000175000017500000000257412127321546031704 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import java.util.Arrays; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; import jsyntaxpane.Token; /** * This actions Jumps to the pair of the token at the cursor. */ public class JumpToPairAction extends DefaultSyntaxAction { public JumpToPairAction() { super("JUMP_TO_PAIR"); } @Override public void actionPerformed(JTextComponent target, SyntaxDocument sdoc, int dot, ActionEvent e) { Token current = sdoc.getTokenAt(dot); if (current == null) { return; } Token pair = sdoc.getPairFor(current); if (pair != null) { target.setCaretPosition(pair.start); } } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/DocumentSearchData.java0000644000175000017500000001707212127321546032211 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.Component; import java.text.MessageFormat; import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import javax.swing.text.BadLocationException; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; import jsyntaxpane.actions.gui.QuickFindDialog; import jsyntaxpane.actions.gui.ReplaceDialog; /** * Data that is shared by Find / Replace and Find Next actions for a Document * The data here will be added as a property of the Document using the key * PROPERTY_KEY. Only through the getFtmEditor can you crate a new instance. * * The class is responsible for handling the doFind and doReplace all actions. * * The class is also responsible for displaying the Find / Replace dialog * * @author Ayman Al-Sairafi */ public class DocumentSearchData { private static final String PROPERTY_KEY = "SearchData"; private Pattern pattern = null; private boolean wrap = true; private ReplaceDialog replaceDlg; private QuickFindDialog quickFindDlg; /** * This prevent creating a new instance. You must call the getFromEditor * to crate a new instance attached to a Document * */ private DocumentSearchData() { } public Pattern getPattern() { return pattern; } /** * Set the pattern to the given compiled pattern. * @see this#setPattern(String, boolean, boolean) * @param pattern */ public void setPattern(Pattern pattern) { this.pattern = pattern; } /** * Sets the pattern from a string and flags * @param pat String of pattern * @param regex true if the pattern should be a regexp * @param ignoreCase true to ignore case * @throws java.util.regex.PatternSyntaxException */ public void setPattern(String pat, boolean regex, boolean ignoreCase) throws PatternSyntaxException { if (pat != null && pat.length() > 0) { int flag = (regex) ? 0 : Pattern.LITERAL; flag |= (ignoreCase) ? Pattern.CASE_INSENSITIVE : 0; setPattern(Pattern.compile(pat, flag)); } else { setPattern(null); } } public boolean isWrap() { return wrap; } public void setWrap(boolean wrap) { this.wrap = wrap; } /** * Get the Search data from a Document. If document does not have any * search data, then a new instance is added, put and reurned. * @param target JTextCOmponent we are attaching to * @return */ public static DocumentSearchData getFromEditor(JTextComponent target) { if (target == null) { return null; } Object o = target.getDocument().getProperty(PROPERTY_KEY); if (o instanceof DocumentSearchData) { DocumentSearchData documentSearchData = (DocumentSearchData) o; return documentSearchData; } else { DocumentSearchData newDSD = new DocumentSearchData(); target.getDocument().putProperty(PROPERTY_KEY, newDSD); return newDSD; } } /** * Perform a replace all operation on the given component. * Note that this create a new duplicate String big as the entire * document and then assign it to the target text component * @param target * @param replacement */ public void doReplaceAll(JTextComponent target, String replacement) { if (replacement == null) { replacement = ""; } SyntaxDocument sDoc = ActionUtils.getSyntaxDocument(target); if (sDoc == null) { return; } if (getPattern() == null) { return; } Matcher matcher = sDoc.getMatcher(getPattern()); String newText = matcher.replaceAll(replacement); try { sDoc.replace(0, sDoc.getLength(), newText, null); } catch (BadLocationException ex) { Logger.getLogger(DocumentSearchData.class.getName()).log(Level.SEVERE, null, ex); } } /** * Replace single occurrence of match with the replacement. * @param target * @param replacement */ public void doReplace(JTextComponent target, String replacement) { if (target.getSelectedText() != null) { target.replaceSelection(replacement == null ? "" : replacement); doFindNext(target); } } /** * FInd the previous match * @param target * @return */ public boolean doFindPrev(JTextComponent target) { if (getPattern() == null) { return false; } SyntaxDocument sDoc = ActionUtils.getSyntaxDocument(target); if (sDoc == null) { return false; } int dot = target.getSelectionStart(); Matcher matcher = sDoc.getMatcher(getPattern()); if (matcher == null) { return false; } // we have no way of jumping to last match, so we need to // go throw all matches, and stop when we reach current pos int start = -1; int end = -1; while (matcher.find()) { if (matcher.end() >= dot) { break; } start = matcher.start(); end = matcher.end(); } if (end > 0) { target.select(start, end); return true; } else { return false; } } /** * Perform a FindNext operation on the given text component. Position * the caret at the start of the next found pattern. * @param target * @return true if pattern is found, false otherwise */ public boolean doFindNext(JTextComponent target) { if (getPattern() == null) { return false; } SyntaxDocument sDoc = ActionUtils.getSyntaxDocument(target); if (sDoc == null) { return false; } int start = target.getSelectionEnd(); if (target.getSelectionEnd() == target.getSelectionStart()) { // we must advance the position by one, otherwise we will find // the same text again start++; } if (start >= sDoc.getLength()) { start = sDoc.getLength(); } Matcher matcher = sDoc.getMatcher(getPattern(), start); if (matcher != null && matcher.find()) { // since we used an offset in the matcher, the matcher location // MUST be offset by that location target.select(matcher.start() + start, matcher.end() + start); return true; } else { if (isWrap()) { matcher = sDoc.getMatcher(getPattern()); if (matcher != null && matcher.find()) { target.select(matcher.start(), matcher.end()); return true; } else { return false; } } else { return false; } } } /** * Display an OptionPane dialog that the search string is not found * @param target */ public void msgNotFound(Component target) { JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(target), MessageFormat.format(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("DocumentSearchData.SearchStringNotFound"), getPattern()), java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("DocumentSearchData.Find"), JOptionPane.INFORMATION_MESSAGE); } /** * Show the Find and Replace dialog for the given frame * @param target */ public void showReplaceDialog(JTextComponent target) { if (replaceDlg == null) { replaceDlg = new ReplaceDialog(target, this); } replaceDlg.setVisible(true); } public void showQuickFindDialog(JTextComponent target) { if (quickFindDlg == null) { quickFindDlg = new QuickFindDialog(target, this); } quickFindDlg.showFor(target); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/JIndentAction.java0000644000175000017500000000531612127321546031202 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.text.BadLocationException; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; import jsyntaxpane.Token; import jsyntaxpane.TokenType; /** * This class should be mapped to VK_ENTER. It performs proper indentation * for Java Type languages and automatically inserts "*" in multi-line comments * Initial Code contributed by ser... AT mail.ru * * @author Ayman Al-Sairafi */ public class JIndentAction extends DefaultSyntaxAction { public JIndentAction() { super("JINDENT"); } /** * {@inheritDoc} * @param e */ @Override public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) { int pos = target.getCaretPosition(); int start = sDoc.getParagraphElement(pos).getStartOffset(); String line = ActionUtils.getLine(target); String lineToPos = line.substring(0, pos - start); String prefix = ActionUtils.getIndent(line); Token t = sDoc.getTokenAt(pos); if (TokenType.isComment(t)) { String trimmed = line.trim(); if (trimmed.startsWith("/*") && trimmed.endsWith("*/")) { // it's a single line comment, do not do anything special } else if (trimmed.endsWith("*/")) { try { // the prefix should be the line where the comment started String commentStartLine = sDoc.getLineAt(t.start); prefix = ActionUtils.getIndent(commentStartLine); } catch (BadLocationException ex) { Logger.getLogger(JIndentAction.class.getName()).log(Level.SEVERE, null, ex); } } else if (trimmed.startsWith("*")) { prefix += "* "; } else if (trimmed.startsWith("/**")) { prefix += " * "; } else if (trimmed.startsWith("/*")) { prefix += " "; } } else if (lineToPos.trim().endsWith("{")) { prefix += ActionUtils.getTab(target); } else { String noComment = sDoc.getUncommentedText(start, pos); // skip EOL comments if (noComment.trim().endsWith("{")) { prefix += ActionUtils.getTab(target); } } target.replaceSelection("\n" + prefix); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/ShowAbbsAction.java0000644000175000017500000000346512127321546031362 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import java.util.Map; import javax.swing.JEditorPane; import javax.swing.JOptionPane; import javax.swing.text.JTextComponent; import jsyntaxpane.DefaultSyntaxKit; import jsyntaxpane.SyntaxDocument; import jsyntaxpane.actions.gui.ShowAbbsDialog; /** * Display all abbreviations for a JTextComponent., if it has any. * Abbreviations are obtained from the IndentAction, so if the target does not * have an instance of that actions, nothing is displayed. * @author Ayman Al-Sairafi */ public class ShowAbbsAction extends DefaultSyntaxAction { public ShowAbbsAction() { super("show-abbreviations"); } @Override public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) { // find the abbreviations actions: DefaultSyntaxKit kit = ActionUtils.getSyntaxKit(target); if (kit != null) { Map abbs = kit.getAbbreviations(); if (abbs == null || abbs.isEmpty()) { JOptionPane.showMessageDialog(target, java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("ShowAbbsAction.NoAbbsForType")); } else { new ShowAbbsDialog((JEditorPane) target, abbs); } } } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/GotoLineAction.java0000644000175000017500000000223412127321546031363 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import jsyntaxpane.actions.gui.GotoLineDialog; import java.awt.event.ActionEvent; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; /** * This actions displays the GotoLine dialog */ public class GotoLineAction extends DefaultSyntaxAction { public GotoLineAction() { super("GOTO_LINE"); } @Override public void actionPerformed(JTextComponent target, SyntaxDocument sdoc, int dot, ActionEvent e) { GotoLineDialog.showForEditor(target); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/SmartHomeSelectAction.java0000644000175000017500000000265512127321546032711 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.text.BadLocationException; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; /** * * @author Ayman Al-Sairafi */ public class SmartHomeSelectAction extends DefaultSyntaxAction { public SmartHomeSelectAction() { super("smart-home-select"); } @Override public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) { try { target.moveCaretPosition(SmartHomeAction.getSmartHomeOffset(target, sDoc, dot)); } catch (BadLocationException ex) { Logger.getLogger(SmartHomeSelectAction.class.getName()).log(Level.SEVERE, null, ex); } } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/HTMLPreviewAction.java0000644000175000017500000000320712127321546031752 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; import jsyntaxpane.actions.gui.HTMLPreviewFrame; /** * Show an HTML Preview window. * This will automatically update on changes to the underlying document. * */ public class HTMLPreviewAction extends DefaultSyntaxAction { public static final String HTML_PREVIEW_WINDOW = "html-preview-window"; public HTMLPreviewAction() { super("HTML_PREVIEW"); } @Override public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) { // have the document property Object obj = sDoc.getProperty(HTML_PREVIEW_WINDOW); if(obj == null) { HTMLPreviewFrame dlg = new HTMLPreviewFrame(sDoc); sDoc.putProperty( HTML_PREVIEW_WINDOW,dlg); dlg.setVisible(true); } else { HTMLPreviewFrame dlg = (HTMLPreviewFrame) obj; dlg.setVisible(enabled); } } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/DuplicateLinesAction.java0000644000175000017500000000321612127321546032551 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.text.BadLocationException; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; /** * This Action duplicates the current line, or all the highlighted lines. * @author Ayman Al-Sairafi */ public class DuplicateLinesAction extends DefaultSyntaxAction { public DuplicateLinesAction() { super("DUPLICATE_LINES"); } @Override public void actionPerformed(JTextComponent target, SyntaxDocument sdoc, int dot, ActionEvent e) { try { int st = sdoc.getLineStartOffset(target.getSelectionStart()); int en = sdoc.getLineEndOffset(target.getSelectionEnd()); String dupLines = sdoc.getText(st, en - st); sdoc.insertString(st, dupLines, null); } catch (BadLocationException ex) { Logger.getLogger(DuplicateLinesAction.class.getName()).log(Level.SEVERE, null, ex); } } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/UndoAction.java0000644000175000017500000000214112127321546030545 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import javax.swing.text.JTextComponent; import javax.swing.text.TextAction; import jsyntaxpane.SyntaxDocument; import jsyntaxpane.util.Configuration; /** * Undo action */ public class UndoAction extends DefaultSyntaxAction { public UndoAction() { super("UNDO"); } @Override public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) { if (sDoc != null) { sDoc.doUndo(); } } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/MapCompletionAction.java0000644000175000017500000000401012127321546032404 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import java.util.Map; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; import jsyntaxpane.Token; import jsyntaxpane.util.JarServiceProvider; /** * Completion Actions: * All completions are based on a simple String to String Map. */ public class MapCompletionAction extends DefaultSyntaxAction { Map completions; public MapCompletionAction() { super("MAP_COMPLETION"); } @Override public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) { Token token = sDoc.getTokenAt(dot); if (token != null) { String abbriv = ActionUtils.getTokenStringAt(sDoc, dot); if (completions.containsKey(abbriv)) { String completed = completions.get(abbriv); if (completed.indexOf('|') >= 0) { int ofst = completed.length() - completed.indexOf('|') - 1; sDoc.replaceToken(token, completed.replace("|", "")); target.setCaretPosition(target.getCaretPosition() - ofst); } else { sDoc.replaceToken(token, completed); } } } } public void setCompletionsFile(String value) { completions = JarServiceProvider.readStringsMap(value); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/RedoAction.java0000644000175000017500000000214112127321546030531 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import javax.swing.text.JTextComponent; import javax.swing.text.TextAction; import jsyntaxpane.SyntaxDocument; import jsyntaxpane.util.Configuration; /** * Redo action */ public class RedoAction extends DefaultSyntaxAction { public RedoAction() { super("REDO"); } @Override public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) { if (sDoc != null) { sDoc.doRedo(); } } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/FindNextAction.java0000644000175000017500000000123712127321546031364 0ustar sylvestresylvestrepackage jsyntaxpane.actions; import java.awt.event.ActionEvent; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; /** * This class performs a Find Next operation by using the current pattern */ public class FindNextAction extends DefaultSyntaxAction { public FindNextAction() { super("find-next"); } @Override public void actionPerformed(JTextComponent target, SyntaxDocument sdoc, int dot, ActionEvent e) { DocumentSearchData dsd = DocumentSearchData.getFromEditor(target); if (dsd != null) { if(!dsd.doFindNext(target)) { dsd.msgNotFound(target); } } } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/PythonIndentAction.java0000644000175000017500000000411212127321546032263 0ustar sylvestresylvestre/* * Copyright 2009 Stefan Bechtold (stefan.bechtold@googlemail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import javax.swing.text.JTextComponent; import javax.swing.text.TextAction; import jsyntaxpane.SyntaxDocument; import jsyntaxpane.util.Configuration; public class PythonIndentAction extends DefaultSyntaxAction { /** * creates new PythonIndentAction. */ public PythonIndentAction() { super("PYTHONINDENT"); } /** * {@inheritDoc} * @param e */ @Override public void actionPerformed(ActionEvent e) { JTextComponent target = getTextComponent(e); if (target != null) { SyntaxDocument sDoc = ActionUtils.getSyntaxDocument(target); int pos = target.getCaretPosition(); int start = sDoc.getParagraphElement(pos).getStartOffset(); String line = ActionUtils.getLine(target); String lineToPos = line.substring(0, pos - start); String prefix = ActionUtils.getIndent(line); int tabSize = ActionUtils.getTabSize(target); if (lineToPos.trim().endsWith(":")) { prefix += ActionUtils.SPACES.substring(0, tabSize); } else { String noComment = sDoc.getUncommentedText(start, pos); // skip EOL comments if (noComment.trim().endsWith(":")) { prefix += ActionUtils.SPACES.substring(0, tabSize); } } target.replaceSelection("\n" + prefix); } } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/QuickFindAction.java0000644000175000017500000000212212127321546031514 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; /** * * @author Ayman Al-Sairafi */ public class QuickFindAction extends DefaultSyntaxAction { public QuickFindAction() { super("quick-find"); } @Override public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) { DocumentSearchData.getFromEditor(target).showQuickFindDialog(target); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/ScriptAction.java0000644000175000017500000000741412127321546031114 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.util.regex.Pattern; import javax.script.Invocable; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; import javax.swing.JOptionPane; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; import jsyntaxpane.util.Configuration; import jsyntaxpane.util.JarServiceProvider; /** * This class executes a script every time it is called. * Anything can be done using any script. * * @author Ayman Al-Sairafi */ public class ScriptAction extends DefaultSyntaxAction { public ScriptAction() { super("scripted-action"); } @Override public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) { if (getValue(SCRIPT_FUNCTION) != null) { String f = getValue(SCRIPT_FUNCTION).toString(); try { engine.put("TARGET", target); engine.put("SDOC", sDoc); engine.put("DOT", dot); engine.put("EVENT", e); engine.put("ACTION", this); engine.put("AU", ActionUtils.getInstance()); invocable.invokeFunction(f); } catch (ScriptException ex) { showScriptError(target, ex); } catch (NoSuchMethodException ex) { showScriptError(target, ex); } } else { JOptionPane.showMessageDialog(target, java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("ScriptAction.NoScriptConfigured"), java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("ScriptAction.ErrorInScript"), JOptionPane.WARNING_MESSAGE); } } public void setFunction(String name) { putValue(SCRIPT_FUNCTION, name); } @Override public void config(Configuration config, String name) { super.config(config, name); // now read and store all of our scripts. for (Configuration.StringKeyMatcher m : config.getKeys(Pattern.compile("Script\\.((\\w|-)+)\\.URL"))) { getScriptFromURL(m.value); } } /** * * @param url */ public void getScriptFromURL(String url) { InputStream is = JarServiceProvider.findResource(url, this.getClass().getClassLoader()); if (is != null) { Reader reader = new InputStreamReader(is); try { engine.eval(reader); } catch (ScriptException ex) { showScriptError(null, ex); } } else { JOptionPane.showMessageDialog(null, java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("ScriptAction.NoScriptFoundIn") + url, java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("ScriptAction.ErrorInScript"), JOptionPane.WARNING_MESSAGE); } } private void showScriptError(JTextComponent target, Exception ex) { JOptionPane.showMessageDialog(target, ex.getMessage(), java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("ScriptAction.ErrorInScript"), JOptionPane.WARNING_MESSAGE); } /** * The key used to store the Script Name for the this action */ static final String SCRIPT_FUNCTION = "SCRIPT_FUNCTION"; static final ScriptEngine engine; static final Invocable invocable; static { engine = new ScriptEngineManager().getEngineByExtension("js"); invocable = (Invocable) engine; } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/DeleteLinesAction.java0000644000175000017500000000307112127321546032040 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.text.BadLocationException; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; /** * This Action deletes the current line, or all the highlighted lines. * @author Ayman Al-Sairafi */ public class DeleteLinesAction extends DefaultSyntaxAction { public DeleteLinesAction() { super("DELETE_LINES"); } @Override public void actionPerformed(JTextComponent target, SyntaxDocument sdoc, int dot, ActionEvent e) { try { int st = sdoc.getLineStartOffset(target.getSelectionStart()); int en = sdoc.getLineEndOffset(target.getSelectionEnd()); sdoc.remove(st, en - st); } catch (BadLocationException ex) { Logger.getLogger(DeleteLinesAction.class.getName()).log(Level.SEVERE, null, ex); } } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/ToggleCommentsAction.java0000644000175000017500000000445412127321546032600 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; /** * This action will toggle comments on or off on selected whole lines. * * @author Ayman Al-Sairafi */ public class ToggleCommentsAction extends DefaultSyntaxAction { protected String lineCommentStart = "// "; protected Pattern lineCommentPattern = null; /** * creates new JIndentAction. * Initial Code contributed by ser... AT mail.ru */ public ToggleCommentsAction() { super("toggle-comment"); } /** * {@inheritDoc} * @param e */ @Override public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) { if (lineCommentPattern == null) { lineCommentPattern = Pattern.compile("(^" + lineCommentStart + ")(.*)"); } String[] lines = ActionUtils.getSelectedLines(target); int start = target.getSelectionStart(); StringBuffer toggled = new StringBuffer(); for (int i = 0; i < lines.length; i++) { Matcher m = lineCommentPattern.matcher(lines[i]); if (m.find()) { toggled.append(m.replaceFirst("$2")); } else { toggled.append(lineCommentStart); toggled.append(lines[i]); } toggled.append('\n'); } target.replaceSelection(toggled.toString()); target.select(start, start + toggled.length()); } public void setLineComments(String value) { lineCommentStart = value.replace("\"", ""); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/ScriptRunnerAction.java0000644000175000017500000000652212127321546032305 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import java.text.MessageFormat; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import javax.swing.text.JTextComponent; import jsyntaxpane.SyntaxDocument; /** * Executes the script in the component's text using a ScriptEngine * The Configuration must contain the key [prefix.]ACTION_NAME.ScriptExtension * and its value is the ScriptExtension that getEngineByExtension returns * If no engine is found, then an option is given to the user to disable the action * * @author Ayman Al-Sairafi */ public class ScriptRunnerAction extends DefaultSyntaxAction { public ScriptRunnerAction() { super("SCRIPT_EXECUTE"); } @Override public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) { try { ScriptEngine eng = getEngine(target); if (eng != null) { getEngine(target).eval(target.getText()); } } catch (ScriptException ex) { JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(target), java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("ScriptRunnerAction.ErrorExecutingScript") + ex.getMessage(), java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("ScriptRunnerAction.ScriptError"), JOptionPane.ERROR_MESSAGE); ActionUtils.setCaretPosition(target, ex.getLineNumber(), ex.getColumnNumber()); } } private ScriptEngine getEngine(JTextComponent target) { if (engine == null) { if (sem == null) { sem = new ScriptEngineManager(); } engine = sem.getEngineByExtension(scriptExtension); } if (engine == null) { int result = JOptionPane.showOptionDialog(target, MessageFormat.format(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("ScriptRunnerAction.ScriptEngineNotFound"), scriptExtension), "jsyntaxpane", JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, null, null); if (result == JOptionPane.YES_OPTION) { setEnabled(false); } } return engine; } public void setScriptExtension(String value) { scriptExtension = value; } static ScriptEngineManager sem; private ScriptEngine engine; private String scriptExtension; } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/ToggleComponentAction.java0000644000175000017500000000373012127321546032751 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.event.ActionEvent; import javax.swing.JEditorPane; import javax.swing.text.JTextComponent; import jsyntaxpane.DefaultSyntaxKit; /** * This Action will Toggle any SyntaxComponents on the EditorPane * You need the configuration Key prefix.ACTION_NAME.Component = componentclassname * Where: * ACTION_NAME is the name given to the action (prefix.Action.ACTION_NAME) * componentclassname is the fully qualified class name of the component * @author Ayman Al-Sairafi */ public class ToggleComponentAction extends DefaultSyntaxAction { private String componentName; public ToggleComponentAction() { super("toggle-component"); putValue(SELECTED_KEY, Boolean.TRUE); } public void setComponent(String name) { componentName = name; } @Override public String toString() { return super.toString() + "(" + componentName + ")"; } @Override public void actionPerformed(ActionEvent e) { JTextComponent target = getTextComponent(e); if (target instanceof JEditorPane) { JEditorPane jEditorPane = (JEditorPane) target; DefaultSyntaxKit kit = (DefaultSyntaxKit) jEditorPane.getEditorKit(); boolean status = kit.toggleComponent(jEditorPane, componentName); putValue(SELECTED_KEY, status); } } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/actions/ActionUtils.java0000644000175000017500000004646512127321546030761 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.actions; import java.awt.Component; import java.awt.Frame; import java.awt.Point; import java.awt.Rectangle; import java.awt.Window; import java.awt.event.KeyEvent; import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.swing.Action; import javax.swing.JComboBox; import javax.swing.JEditorPane; import javax.swing.MutableComboBoxModel; import javax.swing.SwingUtilities; import javax.swing.text.BadLocationException; import javax.swing.text.Document; import javax.swing.text.EditorKit; import javax.swing.text.Element; import javax.swing.text.JTextComponent; import javax.swing.text.PlainDocument; import jsyntaxpane.DefaultSyntaxKit; import jsyntaxpane.SyntaxDocument; import jsyntaxpane.Token; /** * Various utility methods to work on JEditorPane and its SyntaxDocument * for use by Actions * * @author Ayman Al-Sairafi */ public class ActionUtils { private ActionUtils() { } private static ActionUtils instance = null; /** * Get the Singleton instance. Will be created lazily. * @return */ public static synchronized ActionUtils getInstance() { if(instance == null) { instance = new ActionUtils(); } return instance; } /** * Get the indentation of a line of text. This is the subString from * beginning of line to the first non-space char * @param line the line of text * @return indentation of line. */ public static String getIndent(String line) { if (line == null || line.length() == 0) { return ""; } int i = 0; while (i < line.length() && line.charAt(i) == ' ') { i++; } return line.substring(0, i); } /** * Return the lines that span the selection (split as an array of Strings) * if there is no selection then current line is returned. * * Note that the strings returned will not contain the terminating line feeds * If the document is empty, then an empty string array is returned. So * you can always iterate over the returned array without a null check * * The text component will then have the full lines set as selection * @param target * @return String[] of lines spanning selection / or line containing dot */ public static String[] getSelectedLines(JTextComponent target) { String[] lines = null; try { PlainDocument pDoc = (PlainDocument) target.getDocument(); int start = pDoc.getParagraphElement(target.getSelectionStart()).getStartOffset(); int end; if (target.getSelectionStart() == target.getSelectionEnd()) { end = pDoc.getParagraphElement(target.getSelectionEnd()).getEndOffset(); } else { // if more than one line is selected, we need to subtract one from the end // so that we do not select the line with the caret and no selection in it end = pDoc.getParagraphElement(target.getSelectionEnd() - 1).getEndOffset(); } target.select(start, end); lines = pDoc.getText(start, end - start).split("\n"); target.select(start, end); } catch (BadLocationException ex) { Logger.getLogger(ActionUtils.class.getName()).log(Level.SEVERE, null, ex); lines = EMPTY_STRING_ARRAY; } return lines; } /** * Return the line of text at the TextComponent's current position * @param target * @return */ public static String getLine(JTextComponent target) { return getLineAt(target, target.getCaretPosition()); } /** * Return the line of text at the given position. The returned value may * be null. It will not contain the trailing new-line character. * @param target the text component * @param pos char position * @return */ public static String getLineAt(JTextComponent target, int pos) { String line = null; Document doc = target.getDocument(); if (doc instanceof PlainDocument) { PlainDocument pDoc = (PlainDocument) doc; int start = pDoc.getParagraphElement(pos).getStartOffset(); int end = pDoc.getParagraphElement(pos).getEndOffset(); try { line = doc.getText(start, end - start); if (line != null && line.endsWith("\n")) { line = line.substring(0, line.length() - 1); } } catch (BadLocationException ex) { Logger.getLogger(ActionUtils.class.getName()).log(Level.SEVERE, null, ex); } } return line; } /** * Returns the Frame that contains this component or null if the component * is not within a Window or the containing window is not a frame * @param comp * @return */ public static Frame getFrameFor(Component comp) { Window w = SwingUtilities.getWindowAncestor(comp); if (w != null && w instanceof Frame) { Frame frame = (Frame) w; return frame; } return null; } /** * Returns the the Token at pos as a String * @param doc * @param pos * @return */ public static String getTokenStringAt( SyntaxDocument doc, int pos) { String word = ""; Token t = doc.getTokenAt(pos); if (t != null) { try { word = doc.getText(t.start, t.length); } catch (BadLocationException ex) { Logger.getLogger(ActionUtils.class.getName()).log(Level.SEVERE, null, ex); } } return word; } /** * A helper function that will return the SyntaxDocument attached to the * given text component. Return null if the document is not a * SyntaxDocument, or if the text component is null * @param component * @return */ public static SyntaxDocument getSyntaxDocument(JTextComponent component) { if (component == null) { return null; } Document doc = component.getDocument(); if (doc instanceof SyntaxDocument) { return (SyntaxDocument) doc; } else { return null; } } /** * Gets the Line Number at the give position of the editor component. * The first line number is ZERO * @param editor * @param pos * @return line number * @throws javax.swing.text.BadLocationException */ public static int getLineNumber(JTextComponent editor, int pos) throws BadLocationException { if (getSyntaxDocument(editor) != null) { SyntaxDocument sdoc = getSyntaxDocument(editor); return sdoc.getLineNumberAt(pos); } else { Document doc = editor.getDocument(); return doc.getDefaultRootElement().getElementIndex(pos); } } /** * Gets the column number at given position of editor. The first column is * ZERO * @param editor * @param pos * @return the 0 based column number * @throws javax.swing.text.BadLocationException */ public static int getColumnNumber(JTextComponent editor, int pos) throws BadLocationException { // speedup if the pos is 0 if(pos == 0) { return 0; } Rectangle r = editor.modelToView(pos); int start = editor.viewToModel(new Point(0, r.y)); int column = pos - start; return column; } /** * Get the closest position within the document of the component that * has given line and column. * @param editor * @param line the first being 1 * @param column the first being 1 * @return the closest positon for the text component at given line and * column */ public static int getDocumentPosition(JTextComponent editor, int line, int column) { int lineHeight = editor.getFontMetrics(editor.getFont()).getHeight(); int charWidth = editor.getFontMetrics(editor.getFont()).charWidth('m'); int y = line * lineHeight; int x = column * charWidth; Point pt = new Point(x, y); int pos = editor.viewToModel(pt); return pos; } public static int getLineCount(JTextComponent pane) { SyntaxDocument sdoc = getSyntaxDocument(pane); if (sdoc != null) { return sdoc.getLineCount(); } int count = 0; try { int p = pane.getDocument().getLength() - 1; if (p > 0) { count = getLineNumber(pane, p); } } catch (BadLocationException ex) { Logger.getLogger(ActionUtils.class.getName()).log(Level.SEVERE, null, ex); } return count; } /** * Insert the given item into the combo box, and set it as first selected * item. If the item already exists, it is removed, so there are no * duplicates. * @param combo * @param item the item to insert. if it's null, then nothing is inserted */ public static void insertIntoCombo(JComboBox combo, Object item) { if(item == null) { return; } MutableComboBoxModel model = (MutableComboBoxModel) combo.getModel(); if (model.getSize() == 0) { model.insertElementAt(item, 0); return; } Object o = model.getElementAt(0); if (o.equals(item)) { return; } model.removeElement(item); model.insertElementAt(item, 0); combo.setSelectedIndex(0); } public static void insertMagicString(JTextComponent target, String result) { try { insertMagicString(target, target.getCaretPosition(), result); } catch (BadLocationException ex) { Logger.getLogger(ActionUtils.class.getName()).log(Level.SEVERE, null, ex); } } /** * Repeat the string source repeat times. * If repeats == 0 then empty String is returned * if source is null, then empty string is returned * @param source * @param repeat * @return source String repeated repeat times. */ public static String repeatString(String source, int repeat) { if (repeat < 0) { throw new IllegalArgumentException("Cannot repeat " + repeat + " times."); } if (repeat == 0 || source == null || source.length() == 0) { return ""; } StringBuffer buffer = new StringBuffer(); for (int i = 0; i < repeat; i++) { buffer.append(source); } return buffer.toString(); } /** * Checks if the given string is null, empty or contains whitespace only * @param string * @return true if string is null, empty or contains whitespace only, false * otherwise. */ public static boolean isEmptyOrBlanks(String string) { if (string == null || string.length() == 0) { return true; } for (int i = 0; i < string.length(); i++) { char c = string.charAt(i); if (!Character.isWhitespace(c)) { return false; } } return true; } /** * Return the TabStop property for the given text component, or 0 if not * used * @param text * @return */ public static int getTabSize(JTextComponent text) { Integer tabs = (Integer) text.getDocument().getProperty(PlainDocument.tabSizeAttribute); return (null == tabs) ? 0 : tabs.intValue(); } /** * Insert the given String into the textcomponent. If the string contains * the | vertical BAr char, then it will not be inserted, and the cursor will * be set to its location. * If there are TWO vertical bars, then the text between them will be selected * If the toInsert String is multiLine, then indentation of all following lines * will be the same as the first line. TAB characters will be replaced by * the number of spaces in the document's TAB property. * @param target * @param dot * @param toInsert * @throws javax.swing.text.BadLocationException */ public static void insertMagicString(JTextComponent target, int dot, String toInsert) throws BadLocationException { Document doc = target.getDocument(); String[] lines = toInsert.split("\n"); if (lines.length > 1) { // multi line strings will need to be indented String tabToSpaces = getTab(target); String currentLine = getLineAt(target, dot); String currentIndent = getIndent(currentLine); StringBuilder sb = new StringBuilder(toInsert.length()); boolean firstLine = true; for (String l : lines) { if (!firstLine) { sb.append(currentIndent); } firstLine = false; // replace tabs with spaces. sb.append(l.replace("\t", tabToSpaces)); sb.append("\n"); } toInsert = sb.toString(); } if (toInsert.indexOf('|') >= 0) { int ofst = toInsert.indexOf('|'); int ofst2 = toInsert.indexOf('|', ofst + 1); toInsert = toInsert.replace("|", ""); doc.insertString(dot, toInsert, null); dot = target.getCaretPosition(); int strLength = toInsert.length(); if (ofst2 > 0) { // note that we already removed the first |, so end offset is now // one less than what it was. target.select(dot + ofst - strLength, dot + ofst2 - strLength - 1); } else { target.setCaretPosition(dot + ofst - strLength); } } else { doc.insertString(dot, toInsert, null); } } /** * Expand the string template and replaces the selection with the expansion * of the template. The template String may contain any of the following * special tags. * *
    • {@code #{selection}} replaced with the selection, if any. If there is * no selection, then the {@code #{selection}} tag will be removed. *
    • {@code #{p:any text}} will be replaced by {@code any text} and then * set selection to {@code any text} * * This method properly handles indentation as follows: * The indentation of the whole block will match the indentation of the caret * line, or the line with the beginning of the selection, if the selection is * in whole line, i.e.e one or more lines of selected text. {@see selectLines()} * * @param target JEditorCOmponent to be affected * @param templateLines template split as a String array of lines. * * @see insertLinesTemplate */ public static void insertLinesTemplate(JTextComponent target, String[] templateLines) { // get some stuff we'll need: String thisIndent = getIndent(getLineAt(target, target.getSelectionStart())); String[] selLines = getSelectedLines(target); int selStart = -1, selEnd = -1; StringBuffer sb = new StringBuffer(); for (String tLine : templateLines) { int selNdx = tLine.indexOf("#{selection}"); if (selNdx >= 0) { // for each of the selected lines: for (String selLine : selLines) { sb.append(tLine.subSequence(0, selNdx)); sb.append(selLine); sb.append('\n'); } } else { sb.append(thisIndent); // now check for any ptags Matcher pm = PTAGS_PATTERN.matcher(tLine); int lineStart = sb.length(); while (pm.find()) { selStart = pm.start() + lineStart; pm.appendReplacement(sb, pm.group(1)); selEnd = sb.length(); } pm.appendTail(sb); sb.append('\n'); } } int ofst = target.getSelectionStart(); target.replaceSelection(sb.toString()); if (selStart >= 0) { // target.setCaretPosition(selStart); target.select(ofst + selStart, ofst + selEnd); } } /** * Expand the string template and replaces the selection with the expansion * of the template. The template String may contain any of the following * special tags. * *
    • {@code #{selection}} replaced with the selection, if any. If there is * no selection, then the {@code #{selection}} tag will be removed. *
    • {@code #{p:AnyText}} will be replaced by {@code any text} and then * set the text selection to {@code AnyText} * * This methood does NOT perform any indentation and the template should * generally span one line only * * @param target * @param template */ public static void insertSimpleTemplate(JTextComponent target, String template) { String selected = target.getSelectedText(); selected = (selected == null) ? "" : selected; StringBuffer sb = new StringBuffer(template.length()); Matcher pm = PTAGS_PATTERN.matcher(template.replace(TEMPLATE_SELECTION, selected)); int selStart = -1, selEnd = -1; int lineStart = 0; while (pm.find()) { selStart = pm.start() + lineStart; pm.appendReplacement(sb, pm.group(1)); selEnd = sb.length(); } pm.appendTail(sb); // String expanded = template.replace(TEMPLATE_SELECTION, selected); if (selStart >= 0) { selStart += target.getSelectionStart(); selEnd += target.getSelectionStart(); } target.replaceSelection(sb.toString()); if (selStart >= 0) { // target.setCaretPosition(selStart); target.select(selStart, selEnd); } } /** * If the selection is multi lined, then the full lines are selected, * otherwise, nothing is done. * @param target * @return true if the selection is multi-line, or a whole line */ public static boolean selectLines(JTextComponent target) { if (target.getSelectionStart() == target.getSelectionEnd()) { return false; } PlainDocument pDoc = (PlainDocument) target.getDocument(); Element es = pDoc.getParagraphElement(target.getSelectionStart()); // if more than one line is selected, we need to subtract one from the end // so that we do not select the line with the caret and no selection in it Element ee = pDoc.getParagraphElement(target.getSelectionEnd() - 1); if (es.equals(ee) && ee.getEndOffset() != target.getSelectionEnd()) { return false; } int start = es.getStartOffset(); int end = ee.getEndOffset(); target.select(start, end - 1); return true; } /** * Sets the caret position of the given target to the given line and column * @param target * @param line the first being 1 * @param column the first being 1 */ public static void setCaretPosition(JTextComponent target, int line, int column) { int p = getDocumentPosition(target, line, column); target.setCaretPosition(p); } /** * Return a string with number of spaces equal to the tab-stop of the TextComponent * @param target * @return */ public static String getTab(JTextComponent target) { return SPACES.substring(0, getTabSize(target)); } /** * Searches all actions of a JTextComponent for ab action of the given class and returns * the first one that matches that class, or null if no Action is found * @param * @param target * @param aClass * @return Action object of that class or null */ public static T getAction(JTextComponent target, Class aClass) { for (Object k : target.getActionMap().allKeys()) { Action a = target.getActionMap().get(k); if (aClass.isInstance(a)) { @SuppressWarnings("unchecked") T t = (T) a; return t; } } return null; } /** * Return the DefaultSyntaxKit of this target, or null if the target does not * have a DefaultSyntaxKit * @param target * @return kit or null */ public static DefaultSyntaxKit getSyntaxKit(JTextComponent target) { DefaultSyntaxKit kit = null; if (target instanceof JEditorPane) { JEditorPane jEditorPane = (JEditorPane) target; EditorKit k = jEditorPane.getEditorKit(); if (k instanceof DefaultSyntaxKit) { kit = (DefaultSyntaxKit) k; } } return kit; } /** * Create and send a KeyPress KeyEvent to the component given * @param target Editor to get the action * @param v_key from KeyEvent.V_ constants * @param modifiers from KeyEvent.*MASK constants */ public static void sendKeyPress(JTextComponent target, int v_key, int modifiers) { KeyEvent ke = new KeyEvent(target, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), modifiers, v_key, KeyEvent.CHAR_UNDEFINED); target.dispatchEvent(ke); } // This is used internally to avoid NPE if we have no Strings final static String[] EMPTY_STRING_ARRAY = new String[0]; // This is used to quickly create Strings of at most 16 spaces (using substring) final static String SPACES = " "; /** * The Pattern to use for PTags in insertSimpleTemplate */ public static final Pattern PTAGS_PATTERN = Pattern.compile("\\#\\{p:([^}]*)\\}"); public static final String TEMPLATE_SELECTION = "#{selection}"; } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/SyntaxStyle.java0000644000175000017500000001017712127321546027361 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane; import java.awt.Color; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import javax.swing.text.Segment; import javax.swing.text.TabExpander; import javax.swing.text.Utilities; /** * This class represents the Style for a TokenType. This class is responsible * for actually drawing a Token on the View. * * @author Ayman Al-Sairafi */ public final class SyntaxStyle { private Color color; private int fontStyle; public SyntaxStyle() { super(); } public SyntaxStyle(Color color, boolean bold, boolean italic) { super(); this.color = color; setBold(bold); setItalic(italic); } public SyntaxStyle(Color color, int fontStyle) { super(); this.color = color; this.fontStyle = fontStyle; } public SyntaxStyle(String str) { String[] parts = str.split("\\s*,\\s*"); if (parts.length != 2) { throw new IllegalArgumentException("style not correct format: " + str); } this.color = new Color(Integer.decode(parts[0])); this.fontStyle = Integer.decode(parts[1]); } public boolean isBold() { return (fontStyle & Font.BOLD) != 0; } public void setBold(Boolean bold) { if (bold) { fontStyle |= Font.BOLD; } else { int mask = -1 ^ Font.BOLD; fontStyle = (fontStyle & (mask)); } } public String getColorString() { return String.format("0x%06x", color.getRGB() & 0x00ffffff); } public void setColorString(String color) { this.color = Color.decode(color); } public Boolean isItalic() { return (fontStyle & Font.ITALIC) != 0; } public void setItalic(Boolean italic) { if (italic) { fontStyle |= Font.ITALIC; } else { fontStyle = (fontStyle & (-1 ^ Font.ITALIC)); } } public int getFontStyle() { return fontStyle; } public Color getColor() { return color; } /** * Draw text. This can directly call the Utilities.drawTabbedText. * Sub-classes can override this method to provide any other decorations. * @param segment - the source of the text * @param x - the X origin >= 0 * @param y - the Y origin >= 0 * @param graphics - the graphics context * @param e - how to expand the tabs. If this value is null, tabs will be * expanded as a space character. * @param startOffset - starting offset of the text in the document >= 0 * @return */ public int drawText(Segment segment, int x, int y, Graphics graphics, TabExpander e, int startOffset) { graphics.setFont(graphics.getFont().deriveFont(getFontStyle())); FontMetrics fontMetrics = graphics.getFontMetrics(); int a = fontMetrics.getAscent(); int h = a + fontMetrics.getDescent(); int w = Utilities.getTabbedTextWidth(segment, fontMetrics, 0, e, startOffset); int rX = x - 1; int rY = y - a; int rW = w + 2; int rH = h; if ((getFontStyle() & 0x10) != 0) { graphics.setColor(Color.decode("#EEEEEE")); graphics.fillRect(rX, rY, rW, rH); } graphics.setColor(getColor()); x = Utilities.drawTabbedText(segment, x, y, graphics, e, startOffset); if ((getFontStyle() & 0x8) != 0) { graphics.setColor(Color.RED); graphics.drawRect(rX, rY, rW, rH); } return x; } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/SyntaxTester.java0000644000175000017500000002070712127321546027527 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane; import java.awt.event.ItemEvent; import java.io.IOException; import java.io.StringReader; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.DefaultComboBoxModel; import javax.swing.text.EditorKit; import jsyntaxpane.actions.ActionUtils; import jsyntaxpane.actions.CaretMonitor; public class SyntaxTester extends javax.swing.JFrame { /** Creates new form Tester */ public SyntaxTester() { // this is a test for adding regex lexer. It wont work unless the // JavaRegex.properties is found in the classpath // DefaultSyntaxKit.registerContentType("text/aa_regex", "jsyntaxpane.JavaRegexKit"); initComponents(); jCmbLangs.setModel(new DefaultComboBoxModel(DefaultSyntaxKit.getContentTypes())); // jEdtTest.setContentType(jCmbLangs.getItemAt(0).toString()); jCmbLangs.setSelectedItem("text/java"); new CaretMonitor(jEdtTest, lblCaretPos); } /** * This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // //GEN-BEGIN:initComponents private void initComponents() { lblCaretPos = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); jEdtTest = new javax.swing.JEditorPane(); lblToken = new javax.swing.JLabel(); jCmbLangs = new javax.swing.JComboBox(); jToolBar1 = new javax.swing.JToolBar(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle"); // NOI18N setTitle(bundle.getString("SyntaxTester.title")); // NOI18N lblCaretPos.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); lblCaretPos.setText(bundle.getString("SyntaxTester.lblCaretPos.text")); // NOI18N jEdtTest.setContentType(bundle.getString("SyntaxTester.jEdtTest.contentType")); // NOI18N jEdtTest.setFont(new java.awt.Font("Monospaced", 0, 13)); jEdtTest.setCaretColor(new java.awt.Color(153, 204, 255)); jEdtTest.addCaretListener(new javax.swing.event.CaretListener() { public void caretUpdate(javax.swing.event.CaretEvent evt) { jEdtTestCaretUpdate(evt); } }); jScrollPane1.setViewportView(jEdtTest); lblToken.setFont(new java.awt.Font("Courier New", 0, 12)); lblToken.setText(bundle.getString("SyntaxTester.lblToken.text")); // NOI18N jCmbLangs.setMaximumRowCount(20); jCmbLangs.setFocusable(false); jCmbLangs.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { jCmbLangsItemStateChanged(evt); } }); jToolBar1.setRollover(true); jToolBar1.setFocusable(false); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addComponent(jCmbLangs, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 441, Short.MAX_VALUE) .addComponent(lblCaretPos, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(lblToken, javax.swing.GroupLayout.DEFAULT_SIZE, 221, Short.MAX_VALUE) .addGap(484, 484, 484)) .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 715, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 715, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, 0) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(lblToken, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblCaretPos, javax.swing.GroupLayout.DEFAULT_SIZE, 21, Short.MAX_VALUE) .addComponent(jCmbLangs, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap()) ); pack(); }// //GEN-END:initComponents private void jEdtTestCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_jEdtTestCaretUpdate SyntaxDocument sDoc = ActionUtils.getSyntaxDocument(jEdtTest); if (sDoc != null) { Token t = sDoc.getTokenAt(evt.getDot()); if (t != null) { CharSequence tData = t.getText(sDoc); if (t.length > 40) { tData = tData.subSequence(0, 40); } lblToken.setText(t.toString() + ": " + tData); } else { // null token, remove the status lblToken.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("NO_TOKEN_AT_CURSOR")); } } }//GEN-LAST:event_jEdtTestCaretUpdate private void jCmbLangsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jCmbLangsItemStateChanged if (evt.getStateChange() == ItemEvent.SELECTED) { String lang = jCmbLangs.getSelectedItem().toString(); // save the state of the current JEditorPane, as it's Document is about // to be replaced. String oldText = jEdtTest.getText(); // install a new DefaultSyntaxKit on the JEditorPane for the requested language. jEdtTest.setContentType(lang); // Recreate the Toolbar jToolBar1.removeAll(); EditorKit kit = jEdtTest.getEditorKit(); if (kit instanceof DefaultSyntaxKit) { DefaultSyntaxKit defaultSyntaxKit = (DefaultSyntaxKit) kit; defaultSyntaxKit.addToolBarActions(jEdtTest, jToolBar1); } jToolBar1.validate(); try { // setText should not be called (read the JavaDocs). Better use the read // method and create a new document. jEdtTest.read(new StringReader(oldText), lang); } catch (IOException ex) { Logger.getLogger(SyntaxTester.class.getName()).log(Level.SEVERE, null, ex); } } jEdtTest.requestFocusInWindow(); }//GEN-LAST:event_jCmbLangsItemStateChanged /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { try { DefaultSyntaxKit.initKit(); new SyntaxTester().setVisible(true); } catch (Exception e) { e.printStackTrace(); System.exit(2); } } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JComboBox jCmbLangs; private javax.swing.JEditorPane jEdtTest; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JToolBar jToolBar1; private javax.swing.JLabel lblCaretPos; private javax.swing.JLabel lblToken; // End of variables declaration//GEN-END:variables } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/TokenConstants.java0000644000175000017500000001403212127321546030021 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane; /** * Constants used by Tokens. * @author Ayman Al-Sairafi */ public class TokenConstants { /** * Token Kinds */ // Operators and separators - Suitable for Java Type Languages public static final short EQ = 1; // = public static final short GT = 2; // > public static final short LT = 3; // < public static final short NOT = 4; // ! public static final short COMP = 5; // ~ public static final short QUESTION = 6; // ? public static final short COLON = 7; // : public static final short EQEQ = 8; // == public static final short LTEQ = 9; // <= public static final short GTEQ = 10; // >= public static final short NOTEQ = 11; // != public static final short ANDAND = 12; // && public static final short OROR = 13; // || public static final short PLUSPLUS = 14; // ++ public static final short MINUSMINUS = 15; // -- public static final short PLUS = 16; // + public static final short MINUS = 17; // - public static final short MULT = 18; // * public static final short DIV = 19; // / public static final short AND = 20; // & public static final short OR = 21; // | public static final short XOR = 22; // ^ public static final short MOD = 23; // % public static final short LSHIFT = 24; // << public static final short RSHIFT = 25; // >> public static final short URSHIFT = 26; // >>> public static final short PLUSEQ = 27; // += public static final short MINUSEQ = 28; // -= public static final short MULTEQ = 29; // *= public static final short DIVEQ = 30; // /= public static final short ANDEQ = 31; // &= public static final short OREQ = 32; // |= public static final short XOREQ = 33; // ^= public static final short MODEQ = 34; // %= public static final short LSHIFTEQ = 35; // <<= public static final short RSHIFTEQ = 36; // >>= public static final short URSHIFTEQ = 37; // >>>= public static final short LPAREN = 38; // ( public static final short RPAREN = 39; // ) public static final short LBRACE = 40; // { public static final short RBRACE = 41; // } public static final short LBRACK = 42; // [ public static final short RBRACK = 43; // ] public static final short SEMICOLON = 44; // ; public static final short COMMA = 46; // , public static final short DOT = 47; // . // Keywords for Java Type Languages public static final short KW_START = 255; public static final short KW_abstract = KW_START + 0; public static final short KW_assert = KW_START + 1; public static final short KW_boolean = KW_START + 2; public static final short KW_break = KW_START + 3; public static final short KW_byte = KW_START + 4; public static final short KW_case = KW_START + 5; public static final short KW_catch = KW_START + 6; public static final short KW_char = KW_START + 7; public static final short KW_class = KW_START + 8; public static final short KW_const = KW_START + 9; public static final short KW_continue = KW_START + 10; public static final short KW_do = KW_START + 11; public static final short KW_double = KW_START + 12; public static final short KW_else = KW_START + 13; public static final short KW_extends = KW_START + 14; public static final short KW_final = KW_START + 15; public static final short KW_finally = KW_START + 16; public static final short KW_float = KW_START + 17; public static final short KW_for = KW_START + 18; public static final short KW_default = KW_START + 19; public static final short KW_implements = KW_START + 20; public static final short KW_import = KW_START + 21; public static final short KW_instanceof = KW_START + 22; public static final short KW_int = KW_START + 23; public static final short KW_interface = KW_START + 24; public static final short KW_long = KW_START + 25; public static final short KW_native = KW_START + 26; public static final short KW_new = KW_START + 27; public static final short KW_goto = KW_START + 28; public static final short KW_if = KW_START + 29; public static final short KW_public = KW_START + 30; public static final short KW_short = KW_START + 31; public static final short KW_super = KW_START + 32; public static final short KW_switch = KW_START + 33; public static final short KW_synchronized = KW_START + 34; public static final short KW_package = KW_START + 35; public static final short KW_private = KW_START + 36; public static final short KW_protected = KW_START + 37; public static final short KW_transient = KW_START + 38; public static final short KW_return = KW_START + 39; public static final short KW_void = KW_START + 40; public static final short KW_static = KW_START + 41; public static final short KW_while = KW_START + 42; public static final short KW_this = KW_START + 43; public static final short KW_throw = KW_START + 44; public static final short KW_throws = KW_START + 45; public static final short KW_try = KW_START + 46; public static final short KW_volatile = KW_START + 47; public static final short KW_strictfp = KW_START + 48; } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/syntaxkits/0000755000175000017500000000000012127321546026422 5ustar sylvestresylvestrelibjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/syntaxkits/JavaSyntaxKit.java0000644000175000017500000000174012127321546032027 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.syntaxkits; import jsyntaxpane.DefaultSyntaxKit; import jsyntaxpane.Lexer; import jsyntaxpane.lexers.JavaLexer; /** * * @author Ayman Al-Sairafi */ public class JavaSyntaxKit extends DefaultSyntaxKit { public JavaSyntaxKit() { super(new JavaLexer()); } JavaSyntaxKit(Lexer lexer) { super(lexer); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/syntaxkits/LuaSyntaxKit.java0000644000175000017500000000163512127321546031672 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.syntaxkits; import jsyntaxpane.DefaultSyntaxKit; import jsyntaxpane.lexers.LuaLexer; /** * * @author Michael Leung */ public class LuaSyntaxKit extends DefaultSyntaxKit { public LuaSyntaxKit() { super(new LuaLexer()); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/syntaxkits/TALSyntaxKit.java0000644000175000017500000000160412127321546031565 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.syntaxkits; import jsyntaxpane.DefaultSyntaxKit; import jsyntaxpane.lexers.TALLexer; /** * * @author Ayman Al-Sairafi */ public class TALSyntaxKit extends DefaultSyntaxKit { public TALSyntaxKit() { super(new TALLexer()); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/syntaxkits/DOSBatchSyntaxKit.java0000644000175000017500000000163012127321546032533 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.syntaxkits; import jsyntaxpane.DefaultSyntaxKit; import jsyntaxpane.lexers.DOSBatchLexer; /** * * @author Ayman Al-Sairafi */ public class DOSBatchSyntaxKit extends DefaultSyntaxKit { public DOSBatchSyntaxKit() { super(new DOSBatchLexer()); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/syntaxkits/CppSyntaxKit.java0000644000175000017500000000153112127321546031666 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.syntaxkits; import jsyntaxpane.lexers.CppLexer; /** * * @author Ayman Al-Sairafi */ public class CppSyntaxKit extends CSyntaxKit { public CppSyntaxKit() { super(new CppLexer()); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/syntaxkits/ClojureSyntaxKit.java0000644000175000017500000000176612127321546032561 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.syntaxkits; import jsyntaxpane.DefaultSyntaxKit; import jsyntaxpane.Lexer; import jsyntaxpane.lexers.ClojureLexer; /** * * @author Ayman Al-Sairafi */ public class ClojureSyntaxKit extends DefaultSyntaxKit { public ClojureSyntaxKit() { super(new ClojureLexer()); } public ClojureSyntaxKit(Lexer lexer) { super(lexer); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/syntaxkits/PropertiesSyntaxKit.java0000644000175000017500000000164012127321546033301 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.syntaxkits; import jsyntaxpane.DefaultSyntaxKit; import jsyntaxpane.lexers.PropertiesLexer; /** * * @author Ayman Al-Sairafi */ public class PropertiesSyntaxKit extends DefaultSyntaxKit { public PropertiesSyntaxKit() { super(new PropertiesLexer()); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/syntaxkits/BashSyntaxKit.java0000644000175000017500000000161012127321546032017 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.syntaxkits; import jsyntaxpane.DefaultSyntaxKit; import jsyntaxpane.lexers.BashLexer; /** * * @author Ayman Al-Sairafi */ public class BashSyntaxKit extends DefaultSyntaxKit { public BashSyntaxKit() { super(new BashLexer()); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/syntaxkits/SqlSyntaxKit.java0000644000175000017500000000160412127321546031704 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.syntaxkits; import jsyntaxpane.DefaultSyntaxKit; import jsyntaxpane.lexers.SqlLexer; /** * * @author Ayman Al-Sairafi */ public class SqlSyntaxKit extends DefaultSyntaxKit { public SqlSyntaxKit() { super(new SqlLexer()); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/syntaxkits/GroovySyntaxKit.java0000644000175000017500000000155012127321546032432 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.syntaxkits; import jsyntaxpane.lexers.GroovyLexer; /** * * @author Ayman Al-Sairafi */ public class GroovySyntaxKit extends JavaSyntaxKit { public GroovySyntaxKit() { super(new GroovyLexer()); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/syntaxkits/JFlexSyntaxKit.java0000644000175000017500000000156112127321546032157 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.syntaxkits; import jsyntaxpane.lexers.JFlexLexer; /** * JFlex lexer * @author Ayman Al-Sairafi */ public class JFlexSyntaxKit extends JavaSyntaxKit { public JFlexSyntaxKit() { super(new JFlexLexer()); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/syntaxkits/CSyntaxKit.java0000644000175000017500000000217612127321546031334 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.syntaxkits; import jsyntaxpane.DefaultSyntaxKit; import jsyntaxpane.Lexer; import jsyntaxpane.lexers.CLexer; /** * * @author Ayman Al-Sairafi */ public class CSyntaxKit extends DefaultSyntaxKit { public CSyntaxKit() { super(new CLexer()); } /** * Construct a JavaSyntaxKit user the supplied lexer. This is protected so * only subclasses may extend this with a new lexer. * @param lexer */ CSyntaxKit(Lexer lexer) { super(lexer); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/syntaxkits/RubySyntaxKit.java0000644000175000017500000000161012127321546032063 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.syntaxkits; import jsyntaxpane.DefaultSyntaxKit; import jsyntaxpane.lexers.RubyLexer; /** * * @author Ayman Al-Sairafi */ public class RubySyntaxKit extends DefaultSyntaxKit { public RubySyntaxKit() { super(new RubyLexer()); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/syntaxkits/XHTMLSyntaxKit.java0000644000175000017500000000161412127321546032042 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.syntaxkits; import jsyntaxpane.DefaultSyntaxKit; import jsyntaxpane.lexers.XHTMLLexer; /** * * @author Ayman Al-Sairafi */ public class XHTMLSyntaxKit extends DefaultSyntaxKit { public XHTMLSyntaxKit() { super(new XHTMLLexer()); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/syntaxkits/PlainSyntaxKit.java0000644000175000017500000000161412127321546032211 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.syntaxkits; import jsyntaxpane.DefaultSyntaxKit; import jsyntaxpane.lexers.EmptyLexer; /** * * @author Ayman Al-Sairafi */ public class PlainSyntaxKit extends DefaultSyntaxKit { public PlainSyntaxKit() { super(new EmptyLexer()); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/syntaxkits/JavaScriptSyntaxKit.java0000644000175000017500000000164012127321546033213 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.syntaxkits; import jsyntaxpane.DefaultSyntaxKit; import jsyntaxpane.lexers.JavaScriptLexer; /** * * @author Ayman Al-Sairafi */ public class JavaScriptSyntaxKit extends DefaultSyntaxKit { public JavaScriptSyntaxKit() { super(new JavaScriptLexer()); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/syntaxkits/PythonSyntaxKit.java0000644000175000017500000000162112127321546032425 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.syntaxkits; import jsyntaxpane.DefaultSyntaxKit; import jsyntaxpane.lexers.PythonLexer; /** * * @author Ayman Al-Sairafi */ public class PythonSyntaxKit extends DefaultSyntaxKit { public PythonSyntaxKit() { super(new PythonLexer()); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/syntaxkits/XmlSyntaxKit.java0000644000175000017500000000160512127321546031706 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.syntaxkits; import jsyntaxpane.DefaultSyntaxKit; import jsyntaxpane.lexers.XmlLexer; /** * * @author Ayman Al-Sairafi */ public class XmlSyntaxKit extends DefaultSyntaxKit { public XmlSyntaxKit() { super(new XmlLexer()); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/syntaxkits/XPathSyntaxKit.java0000644000175000017500000000161412127321546032172 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.syntaxkits; import jsyntaxpane.DefaultSyntaxKit; import jsyntaxpane.lexers.XPathLexer; /** * * @author Ayman Al-Sairafi */ public class XPathSyntaxKit extends DefaultSyntaxKit { public XPathSyntaxKit() { super(new XPathLexer()); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/syntaxkits/ScalaSyntaxKit.java0000644000175000017500000000175412127321546032176 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.syntaxkits; import jsyntaxpane.DefaultSyntaxKit; import jsyntaxpane.Lexer; import jsyntaxpane.lexers.ScalaLexer; /** * * @author Ayman Al-Sairafi */ public class ScalaSyntaxKit extends DefaultSyntaxKit { public ScalaSyntaxKit() { super(new ScalaLexer()); } public ScalaSyntaxKit(Lexer lexer) { super(lexer); } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/lexers/0000755000175000017500000000000012127321546025503 5ustar sylvestresylvestrelibjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/lexers/EmptyLexer.java0000644000175000017500000000167712127321546030457 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.lexers; import jsyntaxpane.*; import java.util.List; import javax.swing.text.Segment; /** * A lexer that does nothing. Used for plain document editing. * @author Ayman Al-Sairafi */ public class EmptyLexer implements Lexer { @Override public void parse(Segment segment, int ofst, List tokens) { } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/lexers/SimpleRegexLexer.java0000644000175000017500000000676112127321546031604 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.lexers; import java.io.FileReader; import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.TreeSet; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.swing.text.Segment; import jsyntaxpane.Lexer; import jsyntaxpane.Token; import jsyntaxpane.TokenComparators; import jsyntaxpane.TokenType; /** * This is a "dynamic" Lexer that will use Regex patterns to parse any document, * It is NOT as fast as other JFLex generated lexers. * * The current implementation is about 20x slower than a JFLex lexer * (5000 lines in 100ms, vs 5ms for JFlex lexer) * * This is still usable for a few 100 lines. 500 lines parse in about 10ms. * * It also depends on how complex the Regexp and how many of them will actually * provide a match. * * Since KEYWORD TokenType is by order less than IDENTIFIER, the higher * precedence of KEYWORD token will be used, even if the same regex matches * an IDENTIFIER. This is a neat side-effect of the ordering of the TokenTypes. * We now just need to add any non-overlapping matches. And since longer matches * are found first, we will properly match the longer identifiers which start with * a keyword. * * This behaviour can easily be modified by overriding the {@link compareTo} method * * @author Ayman Al-Sairafi */ public class SimpleRegexLexer implements Lexer { public SimpleRegexLexer(Map props) { putPatterns(props); } public SimpleRegexLexer(String propsLocation) throws IOException { Properties props = new Properties(); props.load(new FileReader(propsLocation)); putPatterns(props); } @Override public void parse(Segment segment, int ofst, List tokens) { TreeSet allMatches = new TreeSet(TokenComparators.LONGEST_FIRST); // add to ourset all the matches by all our regexes for (Map.Entry e : patterns.entrySet()) { Matcher m = e.getValue().matcher(segment); while (m.find()) { Token t = new Token(e.getKey(), m.start() + ofst, m.end() - m.start()); allMatches.add(t); } } int end = -1; for (Token t : allMatches) { if (t.start > end) { tokens.add(t); end = t.end(); } } } Map patterns = new HashMap(); public SimpleRegexLexer putPattern(TokenType type, String regex) { patterns.put(type, Pattern.compile(regex)); return this; } public SimpleRegexLexer putPatterns(Map props) { for (Object key : props.keySet()) { TokenType t = TokenType.valueOf(key.toString()); patterns.put(t, Pattern.compile(props.get(key).toString())); } return this; } } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/lexers/DefaultJFlexLexer.java0000644000175000017500000001150112127321546031661 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane.lexers; import java.io.CharArrayReader; import jsyntaxpane.*; import java.io.IOException; import java.io.Reader; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.text.Segment; /** * This is a default, and abstract implemenatation of a Lexer using JFLex * with some utility methods that Lexers can implement. * * @author Ayman Al-Sairafi */ public abstract class DefaultJFlexLexer implements Lexer { protected int tokenStart; protected int tokenLength; protected int offset; /** * Helper method to create and return a new Token from of TokenType * tokenStart and tokenLength will be modified to the newStart and * newLength params * @param type * @param tStart * @param tLength * @param newStart * @param newLength * @return */ protected Token token(TokenType type, int tStart, int tLength, int newStart, int newLength) { tokenStart = newStart; tokenLength = newLength; return new Token(type, tStart + offset, tLength); } /** * Create and return a Token of given type from start with length * offset is added to start * @param type * @param start * @param length * @return */ protected Token token(TokenType type, int start, int length) { return new Token(type, start + offset, length); } /** * Create and return a Token of given type. start is obtained from {@link yychar()} * and length from {@link yylength()} * offset is added to start * @param type * @return */ protected Token token(TokenType type) { return new Token(type, yychar() + offset, yylength()); } /** * Create and return a Token of given type and pairValue. * start is obtained from {@link yychar()} * and length from {@link yylength()} * offset is added to start * * @param type * @param pairValue * @return */ protected Token token(TokenType type, int pairValue) { return new Token(type, yychar() + offset, yylength(), (byte) pairValue); } /** * The DefaultJFlexLexer simply calls the yylex method of a JFLex compatible * Lexer and adds the tokens obtained to an ArrayList. */ @Override public void parse(Segment segment, int ofst, List tokens) { try { CharArrayReader reader = new CharArrayReader(segment.array, segment.offset, segment.count); yyreset(reader); this.offset = ofst; for (Token t = yylex(); t != null; t = yylex()) { tokens.add(t); } } catch (IOException ex) { Logger.getLogger(DefaultJFlexLexer.class.getName()).log(Level.SEVERE, null, ex); } } /** * This will be called to reset the the lexer. * This is created automatically by JFlex. * @param reader */ public abstract void yyreset(Reader reader); /** * This is called to return the next Token from the Input Reader * @return next token, or null if no more tokens. * @throws java.io.IOException */ public abstract Token yylex() throws java.io.IOException; /** * Returns the character at position pos from the * matched text. * * It is equivalent to yytext().charAt(pos), but faster * * @param pos the position of the character to fetch. * A value from 0 to yylength()-1. * * @return the character at position pos */ public abstract char yycharat(int pos); /** * Returns the length of the matched text region. * This method is automatically implemented by JFlex lexers * @return */ public abstract int yylength(); /** * Returns the text matched by the current regular expression. * This method is automatically implemented by JFlex lexers * @return */ public abstract String yytext(); /** * Return the char number from beginning of input stream. * This is NOT implemented by JFLex, so the code must be * added to create this and return the private yychar field * @return */ public abstract int yychar(); } libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/TokenType.java0000644000175000017500000000503512127321546026771 0ustar sylvestresylvestre/* * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License * at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsyntaxpane; /** * These are the various token types supported by JSyntaxPane. * * @author ayman */ public enum TokenType { OPERATOR, // Language operators DELIMITER, // Delimiters. Constructs that are not necessarily operators for a language KEYWORD, // language reserved keywords KEYWORD2, // Other language reserved keywords, like C #defines IDENTIFIER, // identifiers, variable names, class names NUMBER, // numbers in various formats STRING, // String STRING2, // For highlighting meta chars within a String COMMENT, // comments COMMENT2, // special stuff within comments REGEX, // regular expressions REGEX2, // special chars within regular expressions TYPE, // Types, usually not keywords, but supported by the language TYPE2, // Types from standard libraries TYPE3, // Types for users DEFAULT, // any other text WARNING, // Text that should be highlighted as a warning ERROR; // Text that signals an error /** * Tests if the given token is a Comment Token. * @param t * @return */ public static boolean isComment(Token t) { if (t != null && (t.type == COMMENT || t.type == COMMENT2)) { return true; } else { return false; } } /** * Tests if the given token is a Keyword Token. * @param t * @return */ public static boolean isKeyword(Token t) { if (t != null && (t.type == KEYWORD || t.type == KEYWORD2)) { return true; } else { return false; } } /** * Tests if the given token is a String Token. * @param t * @return */ public static boolean isString(Token t) { if (t != null && (t.type == STRING || t.type == STRING2)) { return true; } else { return false; } } } libjsyntaxpane-java-0.9.6~r156/src/main/resources/0000755000175000017500000000000012127321547022727 5ustar sylvestresylvestrelibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/0000755000175000017500000000000012127321547024067 5ustar sylvestresylvestrelibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/0000755000175000017500000000000012127321547025334 5ustar sylvestresylvestrelibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/0000755000175000017500000000000012127321547027555 5ustar sylvestresylvestrelibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/comment.png0000644000175000017500000000115412127321547031726 0ustar sylvestresylvestrePNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxb? X[Ǽb|\|l P83T3Wư d>abb>w w3lJDVf?792_՛!.+{@ v@ PcNXӢR5,"<` @l:@l   %~ ^w20O}s@k@=@`e2_.`6t <ā6 .=xI>5dt3 o`ᕔ `&Ƨ 50#d+  s5 @GX57]@`  bP:Nπ @9z8 \=} pm6"bAX x'#9$ r%;v @C$K<e@. l. ļ@YF {V~IENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/undo.png0000644000175000017500000000121212127321547031224 0ustar sylvestresylvestrePNG  IHDRabKGD pHYs B(xtIME #!IDAT8˕Ohaǿ҈ABCxbDP];<Aui%+$IENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/goto-line.png0000644000175000017500000000040712127321547032161 0ustar sylvestresylvestrePNG  IHDRagAMA7tEXtSoftwarePaint.NET v3.36%IDAT8Oc` H\dgn9HnƤ bPE4\hĞ,L #3=A!9AaNFț8 @P5dT` @N&bU9IENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/play.png0000644000175000017500000000122412127321547031227 0ustar sylvestresylvestrePNG  IHDRabKGD pHYs  tIME $!٭^!IDAT8˝Kk<2$M&1ibZI0#JHRlgt'XB\H/r . BMXlJФ3M23.Ħb)wus9@wx`]: z`0,>0LDz/nZϵZMB4>7ԤʥOSL4-kuhpf.^x06 Îx""@0Sx}LQ*̝d t 6x=>褃bxuhEFo͎0,kf,BoZ;5e>Y& x' FȉIENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/html-preview.png0000644000175000017500000000164012127321547032707 0ustar sylvestresylvestrePNG  IHDRabKGD pHYs  tIME,ޏ5tEXtComment(c) 2004 Jakub Steiner Created with The GIMPًoIDAT8˭]h[ec4i棍mТ,uī)0o)Ee8oR]GAL70v+\?,Mrs {.~8)-] , Xtދ4uljdȁ4c(ˢ\oiɍe!ɹ`W'M d(=ؤQV9?r!'hɊ'2yGDpZmHC6y.KOho~GxhnChCJLC$h/C 죤i- <R.r އR+@hc\_$b) kN;Np@f"lR,BRlޡl2Z^G,-Roa<K6BBEzːR5hi!iQh R4L:]Vdz8þTB(HC򷶊ÇƓdF&M/ȧ^]~Zk77 ;sK[x =ءw vǶm*X]|/|xBHРeq弢pk9.žVίs3S/RPpl71IENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/surround-if.png0000644000175000017500000000116412127321547032542 0ustar sylvestresylvestrePNG  IHDRa;IDATxڅMhAjФJ/Ki RBJ0CKڢ =AB%co6S^644q?IHξ7&E}lDDy@R9>iEv۠VeX+m=8t:gHHbκwp8dTp8wa+;_#C0'á &$IMO;Vց7Q1Zer,\.Lmo %o1==I^-o 5.nc!ӛo 6Y-\cfث'JAd}EKka=ɤf>nbOj?({Qϭwd2: J Y3ZWYoF( LNъ "D"!lo*Vu-҈Gk( :  Oz~ T>Q* qT*D%̉wz\w> B*y@AE}K*!7+%EQ)v9;љ}IENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/jump-to-pair.png0000644000175000017500000000077212127321547032615 0ustar sylvestresylvestrePNG  IHDRaIDATxڭS+a~ÜrSh#0ƅ%&RHB JrF{qܸ$KF!&,!abNMHZz=|' X}$^ gE|w&} h |-&d~lu:2TjQ$3M๡*M`* @1;x DZ^¾&N`;!Ӝ nuhǢ50 vp ,m d .%=Thhڅh/[^{|Ю؀C]c9/F PfV.2&:%rg?4jbHm9LϘ,ۤz ӧA٧S͡l:s }$3x'_G9YQ"r8)Z%JIENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/surround-debug.png0000644000175000017500000000116212127321547033230 0ustar sylvestresylvestrePNG  IHDRa9IDATxڅAhAHU0$jKDoVSjZLiBQB,Z%1$$DH! xݓ⹦ [Zl7Ύ7}|>܇H$j+ZOoF2H l$@ =FA2=Lҿëk`f,)!7Ạ$Yb+a5,H$^0]üFVFEjw\t646?nq8︈/=F3[~'$ƴ eI|rm6YaMӘRRC (3E:&݀(o6f&^"k!t|zHOh&Fl|nl .y\.,7$&ߢfX A7FP4oqVi-eY|j&wfRH&}~į=}zJ X~ɽcl( n;z E"ݿ{Iw UfI=x:0@t\1))k~%#3=%IENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/edit-find-replace.png0000644000175000017500000000141012127321547033533 0ustar sylvestresylvestrePNG  IHDRabKGD pHYs  tIMEvhIDAT8˭Ml a3H,VЉࠉ4q RIcKZAD"qD6уK}DHEb[nwg?];;i/Nɓ<y7Wbh4MhTz-?$kKe]KVԈS%U_w?j,a aYd+ԉ˥(cRU5o:H|J[]$t3l`}'ǎ6;{s;ǼlA6W uh 8^o%osy,\j!pp$Cm9XM(O=*|%~2]M:'7yeP*̙Sbr|N JgYtkikypO;o?E[v pXVcnyJ6>~O3ZTϑ{Inn>! /h2 0䛼YĂw;3ɐ ?xHa ? |`U}rb<.v>he~gj6fyc9$Ir<21Hz ɐH$f(`O(rB˹B SKiry νYIENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/surround-with.png0000644000175000017500000000070212127321547033114 0ustar sylvestresylvestrePNG  IHDRaIDATxڥKAgt~ JTXjE :_AC:u'):TTbV}f㩛 |{|g7sp]9a@7P~"<6 =\ !p(C b_wM%v tE`t0.^k2['1)O!M,r2MIߛDi j2Λ *N|:J|&9tǤWNk)NoPU(*F,_rjVc6o‰x(r+tv\;vkTis1 2މf7\}++=x!pI\XI^h?2B5IENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/select-all.png0000644000175000017500000000067112127321547032314 0ustar sylvestresylvestrePNG  IHDRasBIT|dtEXtSoftwarewww.inkscape.org<KIDAT8=N@X  .   @I.A ډ)wQ52ͬ3߼7 I<> FZKlo hi1ZkjRY12i4MX,0p/ DdqvXD"$IJžc:KVi" wxS8*9Q18m6*N7qRlFId2ٰEkWZh%{x.>+ml6[0."A%AP[dQQUl$Z-<@!`fqF2t IENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/go-up.png0000644000175000017500000000121412127321547031310 0ustar sylvestresylvestrePNG  IHDRasBIT|dtEXtSoftwarewww.inkscape.org<IDAT8OhAƿ73ٍzhLт@*ՊhDbE-rkJIbREOBM*^DPC)*4&Q!|ߛ!5ɛ|fvn<IuL:.O <WLFfG ฼ʼns֖ǖ% Ep74HK: ]"GJ a2Wk =<؎Ql*eh :}6.N_ +XR"K(u@AVqE؟~ԋ+U?cjJZۆ25|I=/b1 lܺ?n%&Fs'0۶К"IENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/highlight.png0000644000175000017500000000074212127321547032235 0ustar sylvestresylvestrePNG  IHDRasRGBgAMA a cHRMz&u0`:pQ< pHYs  ~tIME $!٭^tEXtSoftwarePaint.NET v3.5.5IIDAT8O͑QKO/DAB E H1̍m9:|CEFĺV=;iP%ٌ,DŽay}L܇TVm5MCQJ@v`;@{̜֥*B>^A0nk{%e~BiWڂ$XwޚBRx>ԥ/3Pz*Q5dIENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/show-abbs.png0000644000175000017500000000063212127321547032151 0ustar sylvestresylvestrePNG  IHDRaaIDATxcd0\5\|k8@)04 Nb- f_bQ ~3YQ4`5CPp"{;{]&:lժm޺eH2WWvwkV9;dI`cll ^WW3cvvGXX^jalϷ< 4 (6o0@_wI p%/TsblA y7P5(a 5\@3\IENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/reflect.png0000644000175000017500000000124112127321547031705 0ustar sylvestresylvestrePNG  IHDRahIDATxmMlA|Zdimlx1F1ZcQ6AKF ԊUDXmLcԋ&$^q#7",řمlw^2o~t ꮃtZDAڪjdS~۔ɷN #3&u@>*A JͦH.֙(}^  I2 =Kk_(Bw}ٙ(`0+]¾Okkkzܙ¯Nbc^tzX1@$o۠) x8RU}fK[Bj` Bt=Rx4$3(QqbbQit]~I_(BT02G\VA(u|.RHh+`?+8xjn7\>\8g|fG_OI6ã \.q'̱8`9=7ܳbbF& ҾS>9`021@uW'G)g٪Ա7T:DdVeLwu拨F$jTdӨ:R5NJ<o ]IENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/Thumbs.db0000644000175000017500000012100012127321547031320 0ustar sylvestresylvestreࡱ>    &1 !"#$%'-()*+,.6/02E3457?89:;<=>@HABCDFGIJKLMNORoot Entry  q1Catalog2 JFIF``C   %# , #&')*)-0-(0%()(C   (((((((((((((((((((((((((((((((((((((((((((((((((((``" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ??\#w yHz 29=do[->(ιJTyiT&=+k_SWxteN*tN7a53H?Oٲ?Zza`?. 6H!=: >>F?e,>6.ηeQsF[Z?5kkHDgdNUO?Pxw&o 㵯a{e~ Ɏ){ӭn4RtQ[BqҢk1bɿ* <tk*O#5VK]c~Rx'j`7:g']oMtkhOMVv`JGr 7]#"6}*SǽE/:'4;|ȩ <iiZʱ6rBnx9 3 g8qc6i6iAYڄH5@Cne?}hu*C4[wvsrKi'}nSsN# p=K[DE^wH+A(泎!ר= V&0_GEgEc ~`OqŴu>pMmgon"P;{rawg$zW<)[~?_U3^_K'dxø@ϝsVQ3?'Vۿa\U+9=CN+c<NT[I4 Ւ嶆يSSû{׈o'T!h##9_^i$ޢ,p%6B1{_ z9<㎬k#ᾃx<9W^8|T*MrCRQ6Y\8q}Ko#Fǽizu[/ ~Knв:ǜpSZ?z_$[tyVO Zri#T\==NkUEߧ\#сj]sG$lJY?%u]JBڄ Q]ğ7`Kk%UEVUzW^ +Xw*{=/)o|u YufϘqywĿ÷V1\#B$۞ý{Gφ@dF3a}k]Jt/ Oo쿛جxúO=Qܫe3ǫzLgNtwg_ Uyb\Qe+^~Jlk(/ȅy$0hjEwiW+;Z:q܌Þ>({1U$eIaZ =?L$ˡOD>Zn/n$//dS?ڶnoM(=2wFN=Z[5+/.vjEe(FpA֪kw CusBq$Pv> ?¦țݗgdJh0HΧhY+dUQз/Fyb=s^m+]7Ķ[mZ#w3:+cX׼=Q O-G!EaUӣf6\);oY\њY"F(Y$l[:A$x2WD>V]jz6_]i| ۦ]?Or̈́33pr{f}u⏉_u V.T(Հݍ8j?h:{ |R3B`ҽ~SHW1|GmMnhZHe'wE^;)u]X]Ep]q٤A=\ MK/[o!M!Փle f;W+p?K K`w;?$JE)B:U9+w*xLz׳Wx-$Wf^mZF96C8@C%-?^6*]4ƭrIW~sã?Zﵫ,z@> W:Վ%Sg9oV_XC԰āfX `u&#w2W|KQ9Z5iê˻_1s^ ]2W=ujxuTg5':}].oN"h]`U$*vv?J½m뛛{YRe1ȋ".ӹ9N#WN"WFժu"kݓO_$Њ[wK8v(w~N;-+~a⩦U~aC}/ŖQ>3|}_RH-aQiUNΫ"DTǯu,ry0mʿÁt~U#W?o?|ߵvߎrjBr7)\3sx:mZSoϮ`jLr77\j45cp[X<#aֺOiͪCoScȚc6@~?v^%'] kBunxw JGN:gξ-|ivE$_ia;2 $eG)=K9¹M&֬{Xm&Ie,8q6Œee$-.oNSw]O7  !"#$%&'(*+,-./012345789:;<=>?@ABDEFGHIJKLMNPQRSTUVWXYZ[]^_`abcdefghjklmnopqrstuwxyz{|}~"```ꇟ9{A42CD7B6-E9B9-4D02-B7A6-288B71AD28BA}4]4" JFIF``C   %# , #&')*)-0-(0%()(C   (((((((((((((((((((((((((((((((((((((((((((((((((((" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ? Ե-_hxԦTfBvW|+gbE}" R{1wqz i<s}]:H $-9v\4~d%y鞇37ךz-Vfi%ɕ$c2I  JFIF``C   345) 66%# , #&')*)-0-(0%()(C   (((((((((((((((((((((((((((((((((((((((((((((((((((" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?u!ӤKq$ۙTʘ 2pBqCյEӎ ٠K{L"s|uW)9l F&+Yket)DnXkwQ5wKo. 3TXwx|ȕKYk JFIF``C   %# , #&')*)-0-(0%()(C   (((((((((((((((((((((((((((((((((((((((((((((((((((" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?x5ֶ%eVewe f9rz1WGZ^,AdgI]cf.Yq:M2'Qi<: ds{M5 _TW!$Msk Bnr:n2rn? JFIF``C   %# , #&')*)-0-(0%()(C   (((((((((((((((((((((((((((((((((((((((((((((((((((" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ??Z[I3o^([=܇zdZ;YGXTr=WMb? 'TX⸔q(U©I{U趞!#d,#5dϵ@DX^PK79k JFIF``C   %# , #&')*)-0-(0%()(C   (((((((((((((((((((((((((((((((((((((((((((((((((((" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?/o6G4p@S;pKc9>ة_؅W mYUvA~ KJӛLӞt^D!qr#sV-k:iϭ, M4Ͽr`:`uIrɾk[S JFIF``C   %# , #&')*)-0-(0%()(C   (((((((((((((((((((((((((((((((((((((((((((((((((((" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz51617181 w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?4KRԠ^%pn"&цndvSt*T]&T=3`NsX^1mu]#P궖Kvm$HU~f(խ5i%HnCa4d@{r<` JFIF``C   %# , #&')*)-0-(0%()(C   (((((((((((((((((((((((((((((((((((((((((((((((((((" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ??_|L@,4L,@X؞:`[RhK U|"5YV^k4&P d`$ 1ue'~+/[#yk r:Sכ  JFIF``C   %# , #&')*)-0-(0%()(C   (((((((((((((((((((((((((((((((((((((((((((((((((((" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?!ŚY5if7; ;4i=_ jV[<1Bʹ<;]+^"lZVSz5\Ny zUo#Omx;8<,,WQS^:T5z֠M JFIF``C   %# , #&')*)-0-(0%()(C   (((((((((((((((((((((((((((((((((((((((((((((((((((" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?F]iok5)3}ӈ}֏[Lb1ix/kp\QCu$U 3Qw3#CFPu?H^iNeacϰ{P JFIF``C   %# , #&')*)-0-(0%()(C   ((((((((((((((((((((((((((((((((((((((((((((((((((("910212 22!+ }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?\A#fydo##{ď%meyER'x ;|5;ÿ$#֍,G#FtrH8S>ǥww %X2WiOAO(f񪤣ޝr5%$ӱ  JFIF``C   %# , #&')*)-0-(0%()(C   (((((((((((((((((((((((((((((((((((((((((((((((((((" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ? N$>6p뫭ɷ mcp?V$Hrw$b` έ5/S܋h5(~iC\W i^!NѬiY#opK H|<*uYMY4 I= JFIF``C         !"#$%&'()+,-./012345689:;<=>?@ABCDEFGHpJKLMNOPQRSTUWXYZ[\]^_`abdefghijklmnoqrtuvwxyz{|}~%# , #&')*)-0-(0%()(C   (((((((((((((((((((((((((((((((((((((((((((((((((((" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?%km>$qq" *yLgO&QX]IGZI.Y>h![.n$as 5O3xl-ƥ5ƥ.\adt10\EG봋Q7n Rs? JFIF``C   %# , #&')*)-0-(0%()(C   (((((((((((((((((((((((((((((((((((((((((((((((((((" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?[멧AꗑȬ$bE;;WmC1E`:g ῈQiC>wyJ!ߔ}đ.ݸIJ?CXfoQɎ) 1`C9 2 / T&f9}8m 89@'8yJ.W]G4*2? JFIF``C   %# , #&')*)-0-(0%()(C   (((((((((((((((((((((((((((((((((((((((((((((((((((" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz 32"42#52*62Iw!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?>gwgiq# n4!%Vdueelf#QkKm&L<&k+H =Y毩hȚ6mٚYghveOw:5 JFIF``C   %# , #&')*)-0-(0%()(C   (((((((((((((((((((((((((((((((((((((((((((((((((((" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?}j-ܑ5ΧutVjә"K1DfcP]M#UsI: ܒG"8eVv PASK []֛ܽD̙I_,r2l}YVzjCX 3DխT{˘ wD( 0,qp+6k JFIF``C   %# , #&')*)-0-(0%()(C   (((((((((((((((((((((((((((((((((((((((((((((((((((" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?S{(-Uյ ]F[h`B"8S:-'V]BK++iP5\)b.h=8"x^:w:k(ZGs yW1ʠm6bt 'U [n.V9lrK4dYsurround-try.png2lsurround-if.png*XGcomment.png6XGcomplete-word.png2$Gcompletions.png>$Gcopy-to-clipboard.png<UGcut-to-clipboard.png$ ߆Gfind.png. UGfind-next.png* f5go-down.png. ߆Ggoto-line.png& 5go-up.png4 Ghtml-preview.png( Gindent.png49Gjump-to-pair.pngD9Gpaste-from-clipboard.png$fGplay.png$fGredo.png*(nreflect.png0KGselect-all.png.(`show-abbs.png,|Gsurround.png<o_msurround-comment.png8ؠ"surround-debug.png> JFIF``C   %# , #&')*)-0-(0%()(C   (((((((((((((((((((((((((((((((((((((((((((((((((((" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?m^CW՟T5[+#8bFs,0;kvulTڛm۹3vDK{}0Owqk4?t1pzO'/ZƓssk4QF)77Σs%$㓜Τ5o2F)M JFIF``C   %# , #&')*)-0-(0%()(C   (((((((((72V82c92s03((((((((((((((((((((((((((((((((((((((((((" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?[Ųx ( |q_&C1.x@9O#ok^p{Oa Nq~ s:j>td9Q_cq#smxO±Q# yܪ{G?쏔yK䋫f JFIF``C   %# , #&')*)-0-(0%()(C   (((((((((((((((((((((((((((((((((((((((((((((((((((" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?x4/iʹ^=c?9h/,u9սE>%rgަ3'?k||EM!FȠz+KrI?~$-edit-find-replace.png*5go-next.png25go-previous.png6KGsurround-with.pn JFIF``C   %# , #&')*)-0-(0%()(C   (((((((((((((((((((((((((((((((((((((((((((((((((((" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?oڍwkLƳXǣá#.{}ndL6~@ Dz5 _Q:ms,1!O#MGu4%$LzB܎"Bی@JN?+7\ժi  JFIF``C   %# , #&')*)-0-(0%()(C   (((((((((((((((((((((((((((((((((((((((((((((((((((" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?gWңQ{\#[XbY\ɀyb&>{sHK"pd*6ߪ4۫[M{mHXIz^.@hl 8;P<;Kkk{-ޣv A+:M9U@P9mg8("surround-while.pngB JFIF``C   %# , #&')*)-0-(0%()(C   (((((((((13233343((((((((((((((((((((((((((((((((((((((((((" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ? __[^y/ao-U.8/ >;YF>σs{MxV7rCp\o0A"of ܎+CIܓjwRͽy̅@T` ׂ:U_Rӡ~U JFIF``C   %# , #&')*)-0-(0%()(C   (((((((((((((((((((((((((((((((((((((((((((((((((((" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ??^$ԓOK"k{HC"+3;VKx[yuaxV$kTR/.mMV/ Ez% !y&lt]illߵ8(dgKr{>/_>ʊ85d_ JFIF``C   %# , #&')*)-0-(0%()(C   (((((((((((((((((((((((((((((((((((((((((((((((((((" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?}oSkŽ}W0̎\dgt4VV A'Njα ɖkgdgO?62:b3/dXK:I!BȭԒpB^,ne(zZ8(S JFIF``C   %# , #&')*)-0-(0%()(C   (((((((((((((((((((((((((((((((((((((((((((((((((((" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?F-:GoI#3Oyd'f9Qa.}ilj]<Qic0+Ԃ2{kZOg&mg]Is\RL c#٤Ubtoggle-token-marker.png4 Eatoggle-lines.png$!|Gundo.png,"Gunindent.pnglibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/go-next.png0000644000175000017500000000124412127321547031645 0ustar sylvestresylvestrePNG  IHDRasBIT|dtEXtSoftwarewww.inkscape.org<6IDAT8KHTaFR^D hFh"[FBr6B+7(rEb>p-f)7",3x_3ԁ1|tSSRƣqwp5Xb55ː|E7%Z[2.d I( xp_=IIENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/surround.png0000644000175000017500000000070012127321547032141 0ustar sylvestresylvestrePNG  IHDRaIDATxڅKADzI_g|8H+R)8#,<}}}/[Iyݞ _vv3s9E-P;;]q`>Kfi0@ d2.@ .Ft]?_ G( eba'h "ҀrlAR9F (JY8rXu$jz$:]kMVSt7F*ߡ^VE2A4Mh4HJ]45nZFnوunضM w}_4MR|n,RtYA\.{bN|v~ώx =Iyb2alBfDqIENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/go-down.png0000644000175000017500000000125312127321547031636 0ustar sylvestresylvestrePNG  IHDRasBIT|dtEXtSoftwarewww.inkscape.org<=IDAT8MhAߙk`C"I"/*AU*mك١E&MADEt>S8zVO޼)c>. Q51Qw&zgO/Dk00(nCȽ{[a~5鈴@bLQ= &$dY[AOXZloxz.Ҽ6?_h8|E7sJ*hIENDB`././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/paste-from-clipboard.pnglibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/paste-from-clipboard.p0000644000175000017500000000106112127321547033746 0ustar sylvestresylvestrePNG  IHDRa pHYs  tIME IDAT8˕kSQ4$1Ԕ "\\jbpv!8EmA84K.8)RHB^olF91/m ~=?T*{ϝ~I\.konΚ+*+v< |`_)h/Y2g .9.Ҵ0f LD9̤γ׫VTS yf,y_ϲxAPTB"Jqm.f!1 ނD"03sl08[y=j(߼ )>\qKa{UEEȝ<9DAU21 (mnh>A_4!5纀VҨ)onP^CDz\Z14I3XpcZ7l/D#팦$1fSU;`\13TKOxiIENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/completions.png0000644000175000017500000000153712127321547032625 0ustar sylvestresylvestrePNG  IHDRabKGDC pHYs  tIME 2:P5tEXtComment(c) 2004 Jakub Steiner Created with The GIMPًoIDAT8˕KHTqƿ;:G&YjfR>E"ġ%ԤlbpaE1EM%It&JJ͊4Lqtwo5~s~s8T\L)%) 1ek^v}STޔ0bmeZqU7S{z?\!&,zIW׈%ooߓc,RFg}ZUYEӣm%Y{[n=v_0kEI珖D N Jhs;u&%srm'$=Wn/@ ,C-f PPn(.*rraB+YWUH43 sW߽%::6ilZN̾24PU}z YXXx(7VL6^|IENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/complete-word.png0000644000175000017500000000103612127321547033044 0ustar sylvestresylvestrePNG  IHDRaIDATxcd0R̀1 k`dO@@Y A 4NAX9r?@C2d`KJ ]&R~ H?d8p$=癛?n bI(΁aǎW!!'O0]|  /B!4`*@m{}}ӧOlH'9 ?1Y8J?1<f1 Ā666M)xSNZB )1{ dȩ@us sKP#…K3 '_L{d @ f C`<4v{|Roӧ&&OA. yQPtB l@ b\ '/x]p7R"T# 4%R_hJߠxGO([~ /(΍mbD=IENDB`././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/toggle-token-marker.pnglibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/toggle-token-marker.pn0000644000175000017500000000105112127321547033767 0ustar sylvestresylvestrePNG  IHDRagAMA7tEXtSoftwarePaint.NET v3.36%IDAT8OS=KA|hhE+E1HD4EARXJAXAky}@w;3>fu`KB'}5zA*r#w`"4D-ʠ fJHE|g%T1/Ⱐ-y 2PN8g`>|CAC~CeeyKIqlV~oYmu3g:Ym:0XR-"{ʉ8~97d\ "[@A/lz\ߒfH X&B]Z@NDBV{d.żYzWU#YAkZf~J/ȺLaTvViU+J#5ϭb3(lX^)JЋ @Lp%cXG$ʖKŁ@H4as\֑k#A8S. DZPl?WW?IENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/unindent.png0000644000175000017500000000066412127321547032115 0ustar sylvestresylvestrePNG  IHDRabKGDG pHYs  tIME  . AIDAT8˕NPkqn,I+ u>!#n,1h%,SaVs5d2d ,w[}ֶk :2 A$@"MUGr]dF˱ArgVr4!D|,κIB i&`M ်MHHQlm I&v>,QmON7(IpT0NSOPv~vf;2( =k;DuSCH! =SP[ ]L`YVw6fvjg:qIENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/surround-comment.png0000644000175000017500000000116712127321547033611 0ustar sylvestresylvestrePNG  IHDRa>IDATxڅ_hRQǿS7blq_z1a |.2 XnQF\bhiJ*B 6ŠEz*b hιux~.z&!5DS,zQVӬ= ݣ^صX,#7d0I흝q'?)v:Լw }4 {,v)`@]t #ܔQ~4YRBAZ{f͗5f BV r`]aAJ:.C1<Օ58'ƔD"Z}d}TNWp)tF,.W2x9X HR1JN׸2Ӕ &o{e0&o>G2l0ᲓU1h:jY8bdG0"t:DQkp a|I_ƇՏ#JYd6  w]Ǵ 3K^Pg[”zM-Hʁ>oo޹nP;^Aul[oS7۔[4=gN6ѴIENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/surround-while.png0000644000175000017500000000117112127321547033252 0ustar sylvestresylvestrePNG  IHDRa@IDATxڅSQhRQf6bM zKQ//5F0]PQ LZh>,}} a/bDOYCq>1it?945?B$uh\sU$t:{*l6A˄&&c~)U Ɖ`g`0y(,RR &@4Mflooat\Ozed(B ~2R$vRUe]%Lh$YeEFO`P(MPTVf,n0z ˉ.-a1mjVsR52^ L 2̳R'AxǼZ %\2{w#N R-j;Nܨ5>d:bnG6$ [, zfgY~՟sk |Oש0w^ \.*b᰸]l@x0[=Fz'j0j?M zapDamQW;\BEIENDB`././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/edit-find-replace-all.pnglibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/edit-find-replace-all.0000644000175000017500000000137212127321547033603 0ustar sylvestresylvestrePNG  IHDRasRGBgAMA a cHRMz&u0`:pQ< pHYs  ~tIMEvhtEXtSoftwarePaint.NET v3.5.5I+IDAT8O]OAD=z-AkΐvK?حBI%HTЦEOL..bLʾf$';3y眙il0[{(ʱ;}Yӷ\ͤ5mM$O0YeE2umd?j(86 a8|ikH 0u9zXY2/Xb-%ECIyReK}VPe_WZ)$F̼OHC:g.2hk9ƋsPUNNÖ~X:n{:D"L&BM06MPP.X,BesG,waNK N#$- }JIENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/find.png0000644000175000017500000000115112127321547031201 0ustar sylvestresylvestrePNG  IHDRabKGD4g pHYs  tIME %/IDAT8˝MkQ;$MfJR ]hE Uw&o$ADtYwUM;AT(VP5G'M23EHIBRgw=GvM;N!#Lv B]wf2f_Kдkw߾J9zjmŋi+dk&nߌĢ5(4]#Ns ^R>q>sƕ]$ ORpsӶQ %#6Kot Kz Xd4,U~_e% EJvK0n \$[5ܪ-]pi-Nlc5ߣ-F}=kr+Bt4M¹|'+7*|\YT[z,?",+| 0p8TNVdT앬/dߧ>xtXtk뗧d3 ;e+D, XIԏz ?YD>T#$œ~-+{ϙsw X, owσrUKB`Hq'TpuXMUa?)}[PNeڧt5ɹ={V7c3Xu,O# : 6ĥ,-(靳㓱tw$Z 4nUxEG:=x{ `@fM{Uv"3C0c\@nFȂTbTZL\>{tWwvYk-0U4lQ4l69n7J]HaN3E.En ͽZ65$ݖ/܏nխϯ;v?$#P6$E/K^5IENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/small-icons/toggle-lines.png0000644000175000017500000000107512127321547032657 0ustar sylvestresylvestrePNG  IHDRagAMA7tEXtSoftwarePaint.NET v3.36%IDAT8OuS-HCa=aa` 0 `X̤Ad2((+26&IA;g7|pw{wy5 (`8Qbȹ湏qm:<&G$d F`Jiym7TDb$[ccvY Db(.KK+w8A abH.MsJc@1 ?ee|@A-\"͵5p߬<   Pxzd7WV342ae(.cƫuBb ##_((𓕏x @1@C? `5K1/ X` && M r:fx]B7P֝{͠4x  &] - >m.Ƞl h> r@]pp^ zY ¿@|gA6  &Bp* Fp@QyYL6BV K Hq@S*^`4VtIENDB`././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/completions/constructor_protected.pnglibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/completions/constructor_protected.0000644000175000017500000000124312127321547034327 0ustar sylvestresylvestrePNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<5IDATxb?CYecڧ?g2200b>vY Db(.KK+w8A abH.MsJc@1 ?ee|@ A-Q>x@>Hf˦ݕ A4 dw@mxBk7^ qub~?  )B1/\D UU"|y[+4@L @ƻ~3Dǽ-Nz ?f)AKʄAz e-CEIÍw^~>8A⌟߭[ @~f 4`= -u f2`AE_@pR_7Lr'^p1g@1¢((d!sbK6՝_'v0\xVh߯;20Dڱ3|A|8H sk?! ćia"Y@X2UV{5id @0#P{d9 @, C33-)lׯ6lrd| &Sgσ5N`XF8;a##-͆ݏ r|;xo8#\q6,//RyaOwvak%[c| gt*>ytj@70? >?f)v%e P_XXX=?A ?'30~~nnP8@1=.Pro?2V0 ĕ-A. ,Z b1%=uM̌M$E0w^ 8@, H|6,j JQ4Ϟp%[}$ v, ?c$ (ĚbaA e!L@@Y3#,;M@J տG0s54'GIENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/completions/field_private.png0000644000175000017500000000113112127321547033207 0ustar sylvestresylvestrePNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxb?MիI P6]KI;@ KҚڻ_z{\<> @, C33-)lׯ6lrd| &Sgσ5N`XF8;a##-͆MkNc©8  ㊎Tϊ&\ԅ kK%c| c5?  (0^h?? O \B eL0|l/@" L[4g6cVobxi_o,Ϸv6m n#(*X`Ag\"E%Ej$b o 6i >H$V6k.SbQ73GA y:j_Xd$>GA y:d`S*T@X  ;/P1)r:L} /_?~ T $R@X Ռ;;$ɃV/<+kی޿gF;}ù;w  ̡g?|"4`r_wR@3N %6+:L,mjP04 ѭ@IENDB`././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/completions/method_static_protected.pnglibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/completions/method_static_protecte0000644000175000017500000000140012127321547034342 0ustar sylvestresylvestrePNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxb?CYecڧ?g2200b>vY Db(.KK+w8A abH.MsJc@ ?e|vd|o }@A-\"͵5pߴK,r8#a]w+(l&yLs 6[9uU ?6ϟT90~A& F$53) &?lߺa*ɿ~;ǃ3U-XQ.ې @L A!}MPK.~)IQ K)(| `e-CEIÊw>`dd@ /Ѐ;0lݱ!@Ū`g@]ӇZo6|yNo_!@>wz* ~ f&L@?˗W W@|+^q>c``gG5A[Xy.V֪ό,w9sw=yaH@a5p΋WZA0UG;}w Fpp)Yѡ`biKW+)w0ČIENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/completions/class.png0000644000175000017500000000142112127321547031501 0ustar sylvestresylvestrePNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxb?6A<|w%K N<e@4πD63Vi$"``Ip wKv3~s.*˰Ǖ;PPL s 9~_T.e7eX]0"y»0q+V1|z$C6 gl5 i(6ŭ bïޱ1MJM:@1L_G0Sΐ_ R ?c$K6320߿}AP?ɪaJw;;Ã?X >}   ߀6ÁA$ r  o^a<ÍhA0 .`bw@L ~mDL " ?;1@ `ff| .߽ɁA/>~@,a`ccĚy,]Oo`/û7o_pC{oߝ @N哿39KӋIϿO}m{3|u @V3[ ~/@Ktr-IENDB`././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/completions/field_static_private.pnglibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/completions/field_static_private.p0000644000175000017500000000122012127321547034230 0ustar sylvestresylvestrePNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<"IDATxb?MիI P6]KI;@ KҚڻ_z{\<> @, C33-)lׯ6lrd| ߾a8uz)ab~pbT'O2A||]@L Ԭ?ۏ ,4L qf<~f f5|kgzr1'00: 0J>/*-(b?0 t@1@|yE4pF1U:b&_%S:|eu8YQN1g`}KM IENDB`././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/completions/method_static_private.pnglibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/completions/method_static_private.0000644000175000017500000000141312127321547034251 0ustar sylvestresylvestrePNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxb?MիI P6]KI;@ KҚڻ_z{\<> @, C33-)lׯ6lrd| ߾a8uvY Db(.KK+w8A abH.MsJc@1 ?ee|@A-\"͵5pߴK,r8+/IS\ Pxzd7WV342||ʃK=UՙRں,b  _{Ǜ[7L9ׯ?`xPSQq9ϟ`.ې @L g yo߿0krG_rHI20||AR ,. ?g{[[&X8OBP0o@ðunU9`}i ;? &ӇZo6|yNWg ?~@pܿHΞ> b`f_0e;@Uʵf\10H$R@,L_y.V֪Ϭ + ,"[3s{@!%QFFA'%#`9jssOw =@4j'b! ybwHTZIENDB`././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/completions/field_static_protected.pnglibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/completions/field_static_protected0000644000175000017500000000117112127321547034316 0ustar sylvestresylvestrePNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe< IDATxb?CYecڧ?g2200b>vY Db(.KK+w8A abH.MsJc@ ?e|f|7> ƀ.A`]s oVqEXef,CCLvN.   OH :8k_g>N@L@پuTv:#OV>12 $4?~]ctÏ@/2bI %U ;-!l7o?;0lݱAĖ,@p|ۇM~B3& RWE-0ÿ)Y/w0 _YPL&V?DT@,$˰dJ'/g#@1s`dd4F;-7A0z$IENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/completions/method_private.png0000644000175000017500000000141312127321547033407 0ustar sylvestresylvestrePNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxb?MիI P6]KI;@ KҚڻ_z{\<> @, C33-)lׯ6lrd| &Sgσ5N`XF8;a##-͆M=Q6q 8 ^ ē<ι   ㊎aQCXa~ I/3}}x=}jb`K5@" B@O0-hfrȡeӯ@㣗2 &3||e$X]@,? %]?Y4 o@ cxMBP@" L[4R r3 X6b 1X#W }@ %da1?##g/_ez:bo, ׏Ύ?}p^@,~GXY~f=,07o<~pݿ'= FXnHN*J.F2|@>'PO?n?}wNp)1h? ~į@>SSMWIENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/completions/field.png0000644000175000017500000000052612127321547031464 0ustar sylvestresylvestrePNG  IHDRa pHYs  gAMA|Q cHRMz%u0`:o_FIDATxb?% (DDĂM0a&@X CuvPHli&?tWU5e)Sg߾vgpϟ  @,dTA A!xYF P\@pp?=w '?~48zE X~|z[&F ˗.ghlesCKSC`pC$ϟ??(. F-bYyŞf-63>top|| uu %/N&򯐶ua0  n\ UW/E7 ),iUHnfFv{7/.}n@1r#Pb` {-)# @@~0[kٯIENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/images/completions/method.png0000644000175000017500000000105412127321547031656 0ustar sylvestresylvestrePNG  IHDRa pHYs  gAMA|Q cHRMz%u0`:o_FIDATxb?% (DDĂOrGv6h @'yLs q̤P.eRں,b  _{Հ i\lXd40\pȡ?>~0 a"))I10H$R@X  E:j?9؁A y:j߿}S `u5 ^} L81H pū?{3vv ɃV/<+kی޿gVefx-ÃǏݹ佇U u3!122 :(HF{@?ܓ+ݹ@3Hb!h@2  iƸ<IENDB`libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/0000755000175000017500000000000012127321547025712 5ustar sylvestresylvestrelibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/0000755000175000017500000000000012127321547030256 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/kitsfortypes.propertieslibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/kitsfortypes.propert0000644000175000017500000000242312127321547034442 0ustar sylvestresylvestre# This file contains the default content types and the SyntaxKit class names # that will be used for them. # The keys are content types, and the values are the fully qualified class # names text/c=jsyntaxpane.syntaxkits.CSyntaxKit text/cpp=jsyntaxpane.syntaxkits.CppSyntaxKit text/java=jsyntaxpane.syntaxkits.JavaSyntaxKit text/groovy=jsyntaxpane.syntaxkits.GroovySyntaxKit text/javascript=jsyntaxpane.syntaxkits.JavaScriptSyntaxKit text/js=jsyntaxpane.syntaxkits.JavaScriptSyntaxKit text/json=jsyntaxpane.syntaxkits.JavaScriptSyntaxKit text/xml=jsyntaxpane.syntaxkits.XmlSyntaxKit text/sql=jsyntaxpane.syntaxkits.SqlSyntaxKit text/properties=jsyntaxpane.syntaxkits.PropertiesSyntaxKit text/python=jsyntaxpane.syntaxkits.PythonSyntaxKit text/tal=jsyntaxpane.syntaxkits.TALSyntaxKit text/jflex=jsyntaxpane.syntaxkits.JFlexSyntaxKit text/ruby=jsyntaxpane.syntaxkits.RubySyntaxKit text/scala=jsyntaxpane.syntaxkits.ScalaSyntaxKit text/clojure=jsyntaxpane.syntaxkits.ClojureSyntaxKit text/dosbatch=jsyntaxpane.syntaxkits.DOSBatchSyntaxKit text/bash=jsyntaxpane.syntaxkits.BashSyntaxKit text/xpath=jsyntaxpane.syntaxkits.XPathSyntaxKit text/xhtml=jsyntaxpane.syntaxkits.XHTMLSyntaxKit text/lua=jsyntaxpane.syntaxkits.LuaSyntaxKit text/plain=jsyntaxpane.syntaxkits.PlainSyntaxKitlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/defaultsyntaxkit/0000755000175000017500000000000012127321547033661 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/defaultsyntaxkit/config_de.propertieslibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/defaultsyntaxkit/con0000644000175000017500000000242512127321547034366 0ustar sylvestresylvestre# # German localization ovverrides for # Main Configuration of JSyntaxPane # # Actions: Action.find.MenuText = Suchen Action.find.ToolTip= Suchen und Ersetzen Dialog anzeigen Action.find-next.MenuText = Weitersuchen Action.find-next.ToolTip = Letzte Suche erneut ausführen Action.goto-line.MenuText = Gehe zu Zeilennummer Action.goto-line.ToolTip = Gehe zu Zeilennummer Action.indent.MenuText = Einrücken Action.unindent.MenuText = Ausrücken Action.undo.MenuText = Rückgängig Action.redo.MenuText = Wiederherstellen Action.delete-lines.MenuText = Zeile(n) löschen Action.dup-lines-up.MenuText = Zeilen oben verdoppeln Action.dup-lines-down.MenuText = Zeilen unten verdoppeln Action.toggle-lines.MenuText = Zeilennummern an-/abschalten Action.toggle-comments.MenuText = Kommentare umschalten Action.jump-to-pair.MenuText = Zum Paar springen Action.complete-word.MenuText = Wort vervollständigen Action.show-abbs.MenuText = Abkürzungen anzeigen Action.show-abbs.ToolTip = Abkürzungen anzeigen # # These configure the Default Actions provided by DefaultEditorKit for popup menus DefaultAction.copy-to-clipboard.MenuText = Kopieren DefaultAction.cut-to-clipboard.MenuText = Ausschneiden DefaultAction.paste-from-clipboard.MenuText = Einfügen DefaultAction.select-all.MenuText = Alles auswählen ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/defaultsyntaxkit/config.propertieslibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/defaultsyntaxkit/con0000644000175000017500000001437612127321547034376 0ustar sylvestresylvestre# # Main Configuration of JSyntaxPane # # ----------------------------------------------------------------------------- # # These will be used by all kits, unless the same key is used for a specific # kit, in which case the specific will be used: # # These are the componets that will be installed be default for any kit, # unless specified otherwise Components = jsyntaxpane.components.PairsMarker, \ jsyntaxpane.components.LineNumbersRuler # This is the color to highlight tokens whenever the cursor is on them TokenMarker.Color = 0xffeeaa # Colors for PairMarkers PairMarker.Color = 0xffbb77 # # Right Margin for LineNumbers border in pixels, Default = 5 LineNumbers.RightMargin = 7 # Foreground for line numbers, Default = Black LineNumbers.Foreground = 0x333300 # Background for line numbers, Default = White LineNumbers.Background = 0xeeeeff # Color to use for highlighting current line background LineNumbers.CurrentBack = 0xccccee # Default color for the Caret, Black CaretColor = 0x000000 # # Actions: # The key is of the format: # Actions.NAME = class [, key]* # where NAME is the name to be given to the Action. Any String [alpha or -] is valid. # class is the fully qualified class name of the SyntaxAction class. # Starting from 0.9.5, each Action will instantiate a new class. If you need # to share some data between the Actions, then add a Property to the Document # Key is the keyboard key to map it to as specified by # KeyStroke.getKeyStroge(String key). You may have zero or more key bindings # to an Action. The last Key bound will be shown in the popup menu if enabled. # You can also specify the "menu" modifier, and it will be mapped to the proper menu # key depending on the running platform (CTRL on Windows and ALT on Mac) # # Each fully qualified key can also be used as a prefix for configuring the Action # Action.NAME.MenuText = The description to use in menus (This sets the Action NAME property) # Action.NAME.SmallIcon = the smallicon to use. The default is to look for an icon # with the same name as the action + ".png". This sets the Actions SMALL_ICON property # Action.NAME.Tooltip = Tooltip displayed for menu. This sets the # Actions SHORT_DESCRIPTION property Action.quick-find = jsyntaxpane.actions.QuickFindAction, control F Action.find = jsyntaxpane.actions.FindReplaceAction, control H Action.find.MenuText = Find Action.find.ToolTip= Display Find And Replace Dialog Action.find-next = jsyntaxpane.actions.FindNextAction, F3 Action.find-next.MenuText = Find Next Action.find-next.ToolTip = Repeat Last Find Action.goto-line = jsyntaxpane.actions.GotoLineAction, control G Action.goto-line.MenuText = Goto Line Number Action.goto-line.ToolTip = Goto Line Number Action.indent = jsyntaxpane.actions.IndentAction, TAB Action.indent.MenuText = Indent Action.indent.Abbreviations = ${class_path}/abbreviations.properties Action.unindent = jsyntaxpane.actions.UnindentAction, shift TAB Action.unindent.MenuText = Un-Indent Action.jindent = jsyntaxpane.actions.JIndentAction, ENTER Action.undo = jsyntaxpane.actions.UndoAction, menu Z Action.undo.MenuText = Undo Action.redo = jsyntaxpane.actions.RedoAction, menu Y Action.redo.MenuText = Redo Action.delete-lines = jsyntaxpane.actions.DeleteLinesAction, control E Action.delete-lines.MenuText = Delete Line(s) Action.dup-lines-up = jsyntaxpane.actions.DuplicateLinesAction, shift control UP Action.dup-lines-up.MenuText = DUplicate Lines Above Action.dup-lines-down = jsyntaxpane.actions.DuplicateLinesAction, shift control DOWN Action.dup-lines-down.MenuText = Duplicate Lines Below Action.toggle-lines = jsyntaxpane.actions.ToggleComponentAction, control F2 Action.toggle-lines.Component = jsyntaxpane.components.LineNumbersRuler Action.toggle-lines.MenuText = Toggle Line Numbers Action.toggle-comments = jsyntaxpane.actions.ToggleCommentsAction, control SLASH Action.toggle-comments.MenuText = Toggle Comments Action.toggle-comments.SmallIcon = comment.png Action.jump-to-pair = jsyntaxpane.actions.JumpToPairAction, control OPEN_BRACKET Action.jump-to-pair.MenuText = Jump to Pair Action.complete-word = jsyntaxpane.actions.CompleteWordAction, control K Action.complete-word.MenuText = Complete Word Action.smart-home = jsyntaxpane.actions.SmartHomeAction, HOME Action.smart-home-select = jsyntaxpane.actions.SmartHomeSelectAction, shift HOME Action.show-abbs = jsyntaxpane.actions.ShowAbbsAction, F8 Action.show-abbs.MenuText = Show abbreviations Action.show-abbs.ToolTip = Show abbreviations # # These configure the Default Actions provided by DefaultEditorKit for popup menus DefaultAction.copy-to-clipboard.MenuText = Copy DefaultAction.cut-to-clipboard.MenuText = Cut DefaultAction.paste-from-clipboard.MenuText = Paste DefaultAction.select-all.MenuText = Select All # # View configuration: # This controls how text is anti-aliased on the editor control: # see the RenderingHints.VALUE_TEXT_ANTIALIAS.... for details # DEFAULT: use the JRE default (default value) # ON: set to on, let the JRE determine best method for the display # OFF: no AA # GASP: used on GTK # HBGR: # HRGB: # VBGR: # VRGM TextAA = ON DEFAULT_EDIT_MENU= \ cut-to-clipboard , \ copy-to-clipboard , \ paste-from-clipboard , \ - , \ select-all , \ - , \ undo , \ redo , \ - , \ find , \ find-next , \ goto-line , \ jump-to-pair , \ - , \ complete-word , \ show-abbs # Default Popup Menu PopupMenu = \ ${DEFAULT_EDIT_MENU} , \ - , \ goto-line , \ toggle-comments # # These are the various Attributes for each TokenType. # The keys of this map are the TokenType Strings, and the values are: # color (hex, or integer), Font.Style attribute # Style is one of: 0 = plain, 1=bold, 2=italic, 3=bold/italic Style.OPERATOR = 0x000000, 0 Style.DELIMITER = 0x000000, 1 Style.KEYWORD = 0x3333ee, 0 Style.KEYWORD2 = 0x3333ee, 3 Style.TYPE = 0x000000, 2 Style.TYPE2 = 0x000000, 1 Style.TYPE3 = 0x000000, 3 Style.STRING = 0xcc6600, 0 Style.STRING2 = 0xcc6600, 1 Style.NUMBER = 0x999933, 1 Style.REGEX = 0xcc6600, 0 Style.IDENTIFIER = 0x000000, 0 Style.COMMENT = 0x339933, 2 Style.COMMENT2 = 0x339933, 3 Style.DEFAULT = 0x000000, 0 Style.WARNING = 0xCC0000, 0 Style.ERROR = 0xCC0000, 3libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/scripts/0000755000175000017500000000000012127321547031745 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/scripts/insertdate.jslibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/scripts/insertdate.j0000644000175000017500000000047012127321547034263 0ustar sylvestresylvestre// Import the needed java packages and classes importPackage(java.util); importClass(javax.swing.JOptionPane) function putDate() { TARGET.replaceSelection("This is a dummy proc that inserts the Current Date:\n" + new Date()); TARGET.replaceSelection("\nTab Size of doc = " + AU.getTabSize(TARGET)); }libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/0000755000175000017500000000000012127321547032477 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/sqlsyntaxkit/libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/sqlsyntax0000755000175000017500000000000012127321547034466 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/sqlsyntaxkit/config.propertieslibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/sqlsyntax0000644000175000017500000000017412127321547034472 0ustar sylvestresylvestreAction.toggle-comments = jsyntaxpane.actions.ToggleCommentsAction, control SLASH Action.toggle-comments.LineComments = "-- "././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/clojuresyntaxkit/libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/clojuresy0000755000175000017500000000000012127321547034437 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/clojuresyntaxkit/config.propertieslibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/clojuresy0000644000175000017500000000022212127321547034435 0ustar sylvestresylvestre# # ClojureSyntaxKit # Action.toggle-comments = jsyntaxpane.actions.ToggleCommentsAction, control SLASH Action.toggle-comments.LineComments = "; "././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/luasyntaxkit/libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/luasyntax0000755000175000017500000000000012127321547034450 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/luasyntaxkit/combocompletions.txtlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/luasyntax0000644000175000017500000000075012127321547034454 0ustar sylvestresylvestreand break do else else \n\t#{p:block} elseif elseif (#{p:exp}) then \n\t#{p:block} end false for for #{p:var}=#{p:num},#{p:max} do \n\t|block \nend for #{p:namelist} in #{p:explist} do \n\t#{p:block} \nend function function #{p:name} () \n\nend if if (#{p:exp}) then \n\t#{p:block} \nend in local local function #{p:name} () \n\nend nil not or repeat repeat \n\t#{p:block} \nuntil #{p:exp} return then true until while while (#{p:exp}) do \n\t#{p:block} \nend././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/luasyntaxkit/config.propertieslibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/luasyntax0000644000175000017500000000156212127321547034456 0ustar sylvestresylvestre# # Lua Properties: # # For completions, you have to define the Action (key to trigger completions): Action.combo-completion = jsyntaxpane.actions.ComboCompletionAction, control SPACE Action.combo-completion.MenuText = Completions Action.combo-completion.ItemsURL=${class_path}/combocompletions.txt # auto fill-in actions Action.parenthesis = jsyntaxpane.actions.PairAction, typed ( Action.brackets = jsyntaxpane.actions.PairAction, typed [ Action.quotes = jsyntaxpane.actions.PairAction, typed ' Action.double-quotes = jsyntaxpane.actions.PairAction, typed " Action.close-curly = jsyntaxpane.actions.JUnindentAction, typed } # Style is one of: 0 = plain, 1=bold, 2=italic, 3=bold/italic Style.OPERATOR = 0x000000, 0 Style.KEYWORD = 0x3333ee, 0 Style.STRING = 0xcc6600, 0 Style.NUMBER = 0x999933, 1 Style.IDENTIFIER = 0x000000, 0 Style.COMMENT = 0x339933, 2././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/propertiessyntaxkit/libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/propertie0000755000175000017500000000000012127321547034431 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/propertiessyntaxkit/config.propertieslibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/propertie0000644000175000017500000000017312127321547034434 0ustar sylvestresylvestreAction.toggle-comments = jsyntaxpane.actions.ToggleCommentsAction, control SLASH Action.toggle-comments.LineComments = "# "././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/scalasyntaxkit/libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/scalasynt0000755000175000017500000000000012127321547034421 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/scalasyntaxkit/config.propertieslibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/scalasynt0000644000175000017500000000017312127321547034424 0ustar sylvestresylvestreAction.toggle-comments = jsyntaxpane.actions.ToggleCommentsAction, control SLASH Action.toggle-comments.LineComments = "# "././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/xhtmlsyntaxkit/libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/xhtmlsynt0000755000175000017500000000000012127321547034472 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/xhtmlsyntaxkit/config.propertieslibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/xhtmlsynt0000644000175000017500000000121412127321547034472 0ustar sylvestresylvestre# # XHTMLSyntaxKit # Action.html-preview = jsyntaxpane.actions.HTMLPreviewAction, F1 Action.html-preview.MenuText = Preview HTML Action.html-preview.ToolTip = Preview in Java Swing internal Viewer, with auto update Action.toggle-comments = jsyntaxpane.actions.TemplateAction, control SLASH Action.toggle-comments.MenuText = Comment Block Action.toggle-comments.SmallIcon = comment.png Action.toggle-comments.MustHaveSelection = true Action.toggle-comments.Template = PopupMenu = \ ${DEFAULT_EDIT_MENU} , \ - , \ toggle-comments , \ html-preview , \ - , \ toggle-lines././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/talsyntaxkit/libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/talsyntax0000755000175000017500000000000012127321547034447 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/talsyntaxkit/config.propertieslibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/talsyntax0000644000175000017500000000017412127321547034453 0ustar sylvestresylvestreAction.toggle-comments = jsyntaxpane.actions.ToggleCommentsAction, control SLASH Action.toggle-comments.LineComments = "-- "././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/plainsyntaxkit/libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/plainsynt0000755000175000017500000000000012127321547034441 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/plainsyntaxkit/config.propertieslibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/plainsynt0000644000175000017500000000071712127321547034450 0ustar sylvestresylvestre# # Plain / Empty Document # Components = jsyntaxpane.components.LineNumbersRuler PopupMenu = \ cut-to-clipboard , \ copy-to-clipboard , \ paste-from-clipboard , \ - , \ select-all , \ - , \ undo , \ redo , \ - , \ find , \ find-next , \ goto-line , \ - , \ complete-word ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/pythonsyntaxkit/libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/pythonsyn0000755000175000017500000000000012127321547034473 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/pythonsyntaxkit/config.propertieslibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/pythonsyn0000644000175000017500000000075312127321547034502 0ustar sylvestresylvestreAction.toggle-comments = jsyntaxpane.actions.ToggleCommentsAction, control NUMBER_SIGN Action.toggle-comments.LineComments = "# " Action.indent.WordRegex=\\w+|\\/(\\*)+ Action.jindent = jsyntaxpane.actions.PythonIndentAction, ENTER # Action.unindent = jsyntaxpane.actions.PythonUnindentAction, shift TAB Action.unindent.MenuText = Un-Indent Action.unindent.Tooltip = Un-Indent block PopupMenu = \ ${DEFAULT_EDIT_MENU} , \ - , \ indent , \ unindent ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/bashsyntaxkit/libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/bashsynta0000755000175000017500000000000012127321547034414 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/bashsyntaxkit/config.propertieslibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/bashsynta0000644000175000017500000000023712127321547034420 0ustar sylvestresylvestre# # BashSyntaxKit Specifics # Action.toggle-comments = jsyntaxpane.actions.ToggleCommentsAction, control NUMBER_SIGN Action.toggle-comments.LineComments = "# "././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/groovysyntaxkit/libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/groovysyn0000755000175000017500000000000012127321547034477 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/groovysyntaxkit/abbreviations.propertieslibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/groovysyn0000644000175000017500000000237512127321547034510 0ustar sylvestresylvestre# This file contains the code templates that will be used by the Java Syntax # editor kit. # The keys are the completion strings, and the values are the full expansion # of the text. The #{p:TEXT} will be replaced pu=public pr=private st=static cl=class #{p:TheClass} {\n} St=String In=Integer Bo=Boolean bo=boolean fl=float ch=char wh=while ex=extends im=implements Ex=Exception en=enum #{p:TheEnum} {\n} re=return df=default: cs=case #{p:value}:\n break; sw=switch(#{p:expr}){\n case 1:\n break;\n} iof=instanceof trc=try {\n #{p:statements;}\n} catch (Exception e) {\n} th=throw thn=throw new ths=throws fori=for(int i=0; i<#{p:max}; i++) {\n // statement\n} fore=for(#{p:Object} o: items) {\n // statement\n} ife=if(#{p:condition}) {\n // When true\n} else {\n // when false\n} iff=if(#{p:condition}) {\n // When true\n} sout=System.out.println("#{p:text}"); serr=System.err.println("#{p:Error text}"); psvm=public static void main(String[] args) {\n #{p:}\n} psfs=public static final String #{p:CONST} = ""; psfi=public static final int #{p:CONST} = 0; psfb=public static final boolean #{p:CONST} = true; Psfs=private static final String #{p:CONST} = ""; Psfi=private static final int #{p:CONST} = 0; IAE=IllegalArgumentException././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/groovysyntaxkit/config.propertieslibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/groovysyn0000644000175000017500000000015412127321547034501 0ustar sylvestresylvestre# # Other Java type actions for other languages: # Style.COMMENT = 0x666666, 2 Style.COMMENT2 = 0x666666, 3././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/javascriptsyntaxkit/libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/javascrip0000755000175000017500000000000012127321547034402 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/javascriptsyntaxkit/config.propertieslibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/javascrip0000644000175000017500000000163112127321547034405 0ustar sylvestresylvestre# # JavaScript # Action.execute-script = jsyntaxpane.actions.ScriptRunnerAction, control R Action.execute-script.ScriptExtension = js Action.execute-script.MenuText = Execute Script Action.execute-script.ToolTip = Execute JavaScript in internal JRE Action.execute-script.SmallIcon = play.png Action.indent.WordRegex=\\w+|\\/(\\*)+ Action.parenthesis = jsyntaxpane.actions.PairAction, typed ( Action.brackets = jsyntaxpane.actions.PairAction, typed [ Action.quotes = jsyntaxpane.actions.PairAction, typed ' Action.double-quotes = jsyntaxpane.actions.PairAction, typed " Action.close-curly = jsyntaxpane.actions.JUnindentAction, typed } PopupMenu = \ ${DEFAULT_EDIT_MENU} , \ - , \ indent , \ unindent , \ - , \ toggle-comments , \ - , \ toggle-lines , \ - , \ execute-script ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/javasyntaxkit/libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/javasynta0000755000175000017500000000000012127321547034420 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/javasyntaxkit/config_de_ch.propertieslibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/javasynta0000644000175000017500000000017412127321547034424 0ustar sylvestresylvestre# # Swiss German localization overrides for # JavaSyntaxKit Specific properties. (no 'ß') # SURROUND_WITH=Umschliessen mit././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/javasyntaxkit/config_de.propertieslibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/javasynta0000644000175000017500000000154212127321547034424 0ustar sylvestresylvestre# # German localization overrides for # JavaSyntaxKit Specific properties. # Action.toggle-token-marker.MenuText = Token-Markierung an-/abschalten Action.combo-completion.MenuText = Vervollständigungen Action.reflect.MenuText = Reflektionen Action.surround-try.MenuText = Try-Catch-Block Action.surround-try.ToolTip = Auswahl mit einem Try-Catch-Block umgeben Action.surround-while.MenuText = While-Schleife Action.surround-while.ToolTip = Auswahl mit einer While-Schleife umgeben Action.surround-debug.MenuText = Ausdruck debuggen Action.surround-debug.ToolTip = Ausdruck nach System.out ausgeben Action.surround-if.MenuText = Mit If-Anweisung umgeben Action.surround-if.ToolTip = Ausdruck mit If-Anweisung umgeben Action.surround-comment.MenuText = Blockkommentar Action.surround-comment.ToolTip = Zeilen mit Blockkommentar umgeben SURROUND_WITH=Umschließen mit././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/javasyntaxkit/combocompletions.txtlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/javasynta0000644000175000017500000000040112127321547034415 0ustar sylvestresylvestrepublic protected private class static toString() equals(|) hashCode() JTextField JEditorPane JTextPane JComboBox JList JTree jsyntaxpane setContentType("text/|lang|") setProperty("|key|") for(int i=0; i < |max|; i++) {\n\t// loop body \n} ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/javasyntaxkit/abbreviations.propertieslibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/javasynta0000644000175000017500000000244312127321547034425 0ustar sylvestresylvestre# This file contains the code templates that will be used by the Java Syntax # editor kit. # The keys are the completion strings, and the values are the full expansion # of the text. The #{p:TEXT} will be replaced pu=public pr=private st=static cl=class #{p:TheClass} {\n} St=String In=Integer Bo=Boolean bo=boolean fl=float ch=char wh=while ex=extends im=implements Ex=Exception en=enum #{p:TheEnum} {\n} re=return df=default: cs=case #{p:value}:\n break; sw=switch(#{p:expr}){\n case 1:\n break;\n} iof=instanceof trc=try {\n #{p:statements;}\n} catch (Exception e) {\n} th=throw thn=throw new ths=throws fori=for(int i=0; i<#{p:max}; i++) {\n // statement\n} fore=for(#{p:Object} o: items) {\n // statement\n} ife=if(#{p:condition}) {\n // When true\n} else {\n // when false\n} iff=if(#{p:condition}) {\n // When true\n} sout=System.out.println("#{p:text}"); serr=System.err.println("#{p:Error text}"); psvm=public static void main(String[] args) {\n #{p:}\n} psfs=public static final String #{p:CONST} = ""; psfi=public static final int #{p:CONST} = 0; psfb=public static final boolean #{p:CONST} = true; Psfs=private static final String #{p:CONST} = ""; Psfi=private static final int #{p:CONST} = 0; IAE=IllegalArgumentException /*=/* #{p:} */ /**=/**\n * #{p:}\n */././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/javasyntaxkit/config.propertieslibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/javasynta0000644000175000017500000000771012127321547034427 0ustar sylvestresylvestre# # JavaSyntaxKit Specific properties. # Components = jsyntaxpane.components.PairsMarker, \ jsyntaxpane.components.LineNumbersRuler, \ jsyntaxpane.components.TokenMarker TokenMarker.TokenTypes = IDENTIFIER, TYPE, TYPE2, TYPE3 # # Performs single color selection (Default = false) # SingleColorSelect = true RightMarginColumn = 80 RightMarginColor = 0xdddddd # # Java Actions Action.indent.WordRegex=\\w+|\\/(\\*)+ Action.parenthesis = jsyntaxpane.actions.PairAction, typed ( Action.toggle-token-marker = jsyntaxpane.actions.ToggleComponentAction, control F3 Action.toggle-token-marker.MenuText = Toggle Token Marker Action.toggle-token-marker.Component = jsyntaxpane.components.TokenMarker Action.brackets = jsyntaxpane.actions.PairAction, typed [ Action.quotes = jsyntaxpane.actions.PairAction, typed ' Action.double-quotes = jsyntaxpane.actions.PairAction, typed " Action.close-curly = jsyntaxpane.actions.JUnindentAction, typed } Action.toggle-comments = jsyntaxpane.actions.ToggleCommentsAction, control SLASH # For completions, you have to define the Action (key to trigger completions): Action.combo-completion = jsyntaxpane.actions.ComboCompletionAction, control SPACE Action.combo-completion.MenuText = Completions Action.combo-completion.ItemsURL=${class_path}/combocompletions.txt Action.reflect = jsyntaxpane.actions.ReflectCompletionAction, control I, shift F1 Action.reflect.MenuText = Reflections # Enclose selection: Try Catch Action.surround-try = jsyntaxpane.actions.TemplateAction, control T Action.surround-try.MenuText = try catch block Action.surround-try.ToolTip = Surround selection with a try catch block Action.surround-try.Template = try {\n #{selection}\n} catch (#{p:Exception} ex) {\n} finally {\n} Action.surround-try.WholeLines= true Action.surround-while = jsyntaxpane.actions.TemplateAction, control W Action.surround-while.MenuText = while loop Action.surround-while.ToolTip = Surround selection in while loop Action.surround-while.Template = while(#{p:condition}) {\n #{selection}\n} Action.surround-while.WholeLines = true Action.surround-debug = jsyntaxpane.actions.TemplateAction, control D Action.surround-debug.MenuText = Debug Expression Action.surround-debug.ToolTip = Output expression to System.out Action.surround-debug.Template = System.out.println("The value of #{selection} = " + (#{selection})); Action.surround-debug.WholeLines = false Action.surround-debug.MustHaveSelection = true Action.surround-if = jsyntaxpane.actions.TemplateAction, control I Action.surround-if.MenuText = Surround with If Action.surround-if.ToolTip = Surround expression with If condition Action.surround-if.Template = if(#{p:condition}) {\n #{selection}\n}\n Action.surround-if.WholeLines = true Action.surround-if.MustHaveSelection = true Action.surround-comment = jsyntaxpane.actions.TemplateAction Action.surround-comment.MenuText = Block comment Action.surround-comment.ToolTip = Surround lines with block comments Action.surround-comment.Template = /*\n#{selection}\n*/ Action.surround-comment.WholeLines = true Action.surround-comment.MustHaveSelection = true Action.insert-date = jsyntaxpane.actions.ScriptAction, F12 Action.insert-date.Function = putDate Script.insert-date.URL = jsyntaxpane/scripts/insertdate.js # Localizable menu entry for "Surround with" menu item SURROUND_WITH=Surround with # # These are the completions to be in the IntelliSense completion dialog # comma separated values. # Vertical bars: if there is one, it will position the cursor. If there are # two, they will be start and end of selection PopupMenu = \ ${DEFAULT_EDIT_MENU} , \ - , \ indent , \ unindent , \ - , \ toggle-comments , \ - , \ reflect , \ >${SURROUND_WITH} , \ surround-try , \ surround-while , \ surround-debug , \ surround-if , \ surround-comment , \ < , \ toggle-lines , \ toggle-token-marker././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/dosbatchsyntaxkit/libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/dosbatchs0000755000175000017500000000000012127321547034372 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/dosbatchsyntaxkit/config.propertieslibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/dosbatchs0000644000175000017500000000023612127321547034375 0ustar sylvestresylvestre# # DOS Batch Specifics # Action.toggle-comments = jsyntaxpane.actions.ToggleCommentsAction, control NUMBER_SIGN Action.toggle-comments.LineComments = "rem " ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/rubysyntaxkit/libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/rubysynta0000755000175000017500000000000012127321547034460 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/rubysyntaxkit/config.propertieslibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/rubysynta0000644000175000017500000000027212127321547034463 0ustar sylvestresylvestre# # Ruby # Action.toggle-comments = jsyntaxpane.actions.ToggleCommentsAction, control NUMBER_SIGN Action.toggle-comments.LineComments = "# " Action.complete-word.WordsRegexp = \\w+(\\?)?././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/xpathsyntaxkit/libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/xpathsynt0000755000175000017500000000000012127321547034462 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/xpathsyntaxkit/config.propertieslibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/xpathsynt0000644000175000017500000000023712127321547034466 0ustar sylvestresylvestrePopupMenu = \ ${DEFAULT_EDIT_MENU} , \ - , \ Toggle Line Numbers = toggle-lines ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/xmlsyntaxkit/libjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/xmlsyntax0000755000175000017500000000000012127321547034467 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/xmlsyntaxkit/config.propertieslibjsyntaxpane-java-0.9.6~r156/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/xmlsyntax0000644000175000017500000000212112127321547034465 0ustar sylvestresylvestreComponents = jsyntaxpane.components.PairsMarker, \ jsyntaxpane.components.LineNumbersRuler PairMarker.Color = 0xffeeaa Action.toggle-comments = jsyntaxpane.actions.TemplateAction, control SLASH Action.toggle-comments.MenuText = Comment Block Action.toggle-comments.SmallIcon = comment.png Action.toggle-comments.MustHaveSelection = true Action.toggle-comments.Template = Action.prettify = jsyntaxpane.actions.XmlPrettifyAction, control P Action.prettify.MenuText = Reformat XML Action.prettify.ToolTip = Reformat XML # The XmlPrettifyAction takes these config parameters: # IndentAmount = int (amount of spaces for indentation, default = 4) # StandAlone = yes/no, default = yes. see OutputKeys.STANDALONE # OmitDeclaration = yes/no, default = yes. see OutputKeys.OMIT_XML_DECLARATION # Indent = yes/no, default = yes. see OutputKeys.INDENT Action.prettify.IndentAmount = 2 Action.tag-close = jsyntaxpane.actions.XmlTagCompleteAction, typed > PopupMenu = \ ${DEFAULT_EDIT_MENU} , \ - , \ toggle-comments , \ prettify , \ toggle-lineslibjsyntaxpane-java-0.9.6~r156/src/main/resources/jsyntaxpane/0000755000175000017500000000000012127321547025273 5ustar sylvestresylvestrelibjsyntaxpane-java-0.9.6~r156/src/main/resources/jsyntaxpane/Bundle.properties0000644000175000017500000000352512127321547030627 0ustar sylvestresylvestre# To change this template, choose Tools | Templates # and open the template in the editor. SyntaxTester.title=JSyntaxPane Tester SyntaxTester.lblCaretPos.text=Caret Position SyntaxTester.lblToken.text=Token under cursor SyntaxTester.jEdtTest.contentType= NO_TOKEN_AT_CURSOR=NO Token at cursor HTMLPreviewFrame.title=HTML Preview HTMLPreviewFrame.jEdtHtml.contentType=text/html QuickFindDialog.jChkWrap.text=Wrap QuickFindDialog.jChkRegExp.text=Reg Exp QuickFindDialog.jChkIgnoreCase.text=Ignore Case QuickFindDialog.jLabel1.text=Quick Find QuickFindDialog.NotFound=not found ReplaceDialog.jChkRegex.text=Regular Expression ReplaceDialog.jChkIgnoreCase.text=Ignore Case ReplaceDialog.jLblReplace.text=Replace ReplaceDialog.jTglHighlight.text=Highlight ReplaceDialog.jBtnReplaceAll.text=Replace All ReplaceDialog.jBtnPrev.text=Previous ReplaceDialog.jChkWrap.toolTipText=Wrap to beginning when end is reached ReplaceDialog.jChkWrap.text=Wrap around ReplaceDialog.title=Find and Replace ReplaceDialog.jBtnNext.text=Next ReplaceDialog.jLblFind.text=Find ReplaceDialog.jBtnReplace.text=Replace ShowAbbsDialog.title=Abbreviations # To change this template, choose Tools | Templates # and open the template in the editor. GotoLineDialog.title=Goto Line GotoLineDialog.jBtnOk.text=Go DocumentSearchData.SearchStringNotFound=Search String {0} not found DocumentSearchData.Find=Find ScriptAction.NoScriptConfigured=Action does not have script function configured ScriptAction.ErrorInScript=Error in Script ScriptAction.NoScriptFoundIn=No script is found in: ScriptRunnerAction.ErrorExecutingScript=Error executing script:\\n ScriptRunnerAction.ScriptError=Script Error ScriptRunnerAction.ScriptEngineNotFound=Script Engine for [{0}] not found. Disable this Action? ShowAbbsAction.NoAbbsForType=No Abbreviations exist for this content type libjsyntaxpane-java-0.9.6~r156/src/main/resources/jsyntaxpane/Bundle_de.properties0000644000175000017500000000344612127321547031301 0ustar sylvestresylvestre# To change this template, choose Tools | Templates # and open the template in the editor. SyntaxTester.title=JSyntaxPane Tester SyntaxTester.lblCaretPos.text=Caret-Position SyntaxTester.lblToken.text=Token unter dem Cursor SyntaxTester.jEdtTest.contentType= NO_TOKEN_AT_CURSOR=Kein Token am Cursor GotoLineDialog.title=Gehe zu Zeile GotoLineDialog.jBtnOk.text=Ok HTMLPreviewFrame.title=HTML-Vorschau HTMLPreviewFrame.jEdtHtml.contentType=text/html QuickFindDialog.jChkWrap.text=Ganzes Dokument QuickFindDialog.jChkRegExp.text=Regex QuickFindDialog.jChkIgnoreCase.text=Gro/Klein ignorieren QuickFindDialog.jLabel1.text=Schnellsuche QuickFindDialog.NotFound=nicht gefunden ReplaceDialog.jChkRegex.text=Regulrer Ausdruck ReplaceDialog.jChkIgnoreCase.text=Gro/Klein ignorieren ReplaceDialog.jLblReplace.text=Ersetzen ReplaceDialog.jTglHighlight.text=Hervorheben ReplaceDialog.jBtnReplaceAll.text=Alle Ersetzen ReplaceDialog.jBtnPrev.text=Zurck ReplaceDialog.jChkWrap.toolTipText=Von vorne weitersuchen wenn das Ende erreicht ist ReplaceDialog.jChkWrap.text=Ganzes Dokument ReplaceDialog.title=Suchen und Ersetzen ReplaceDialog.jBtnNext.text=Weiter ReplaceDialog.jLblFind.text=Suchen ReplaceDialog.jBtnReplace.text=Ersetzen DocumentSearchData.SearchStringNotFound=Suchbegriff {0} nicht gefunden DocumentSearchData.Find=Suchen ScriptAction.NoScriptConfigured=Aktion hat kein Skript zugeordnet ScriptAction.ErrorInScript=Fehler im Skript ScriptAction.NoScriptFoundIn=Kein Skript gefunden in: ScriptRunnerAction.ErrorExecutingScript=Fehler bei Skriptausfhrung:\\n ScriptRunnerAction.ScriptError=Skript-Fehler ScriptRunnerAction.ScriptEngineNotFound=Skript-Engine fr [{0}] nicht gefunden. Aktion deaktivieren? ShowAbbsAction.NoAbbsForType=Es gibt keine Abkrzungen fr diesen Content-Type