 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.textedit.textarea.tokenmarker;
22 import java.util.ArrayList;
23 import java.util.Collection;
24 import java.util.HashMap;
25 import java.util.Iterator;
27 import java.util.Map.Entry;
28 import java.util.regex.Pattern;
29 import javax.swing.text.Segment;
32 import org.jetbrains.annotations.NotNull;
33 import org.jetbrains.annotations.Nullable;
46 private static final Map<String, Spec>
FIXED_SPECS =
new HashMap<>();
53 private static final Map<Pattern, Spec>
REGEX_SPECS =
new HashMap<>();
62 FIXED_SPECS.put(
"friendship",
new Spec(
Token.
KEYWORD1,
new Parameter(
"group",
Token.
KEYWORD2,
ParameterType.
STRING_INTEGER),
new Parameter(
"name",
Token.
KEYWORD2,
ParameterType.
STRING_INTEGER),
new Parameter(
"player",
Token.
KEYWORD2,
ParameterType.
INTEGER),
new Parameter(
"race",
Token.
KEYWORD2,
ParameterType.
STRING_INTEGER)));
82 final char[] array = line.array;
83 int offset = line.offset;
84 final int end = line.count + offset;
87 }
else if (array[offset] ==
'#') {
90 }
else if (array[offset] ==
' ') {
100 final Collection<Integer> segments =
new ArrayList<>();
102 while (offset < end) {
103 final int commandStart = offset;
104 while (offset < end && array[offset] !=
' ') {
107 segments.add(offset - commandStart);
109 final int spacesStart = offset;
110 while (offset < end && array[offset] ==
' ') {
113 segments.add(offset - spacesStart);
117 final Iterator<Integer>
it = segments.iterator();
118 int offset2 = line.offset;
120 final int commandLength =
it.next();
121 final String command =
new String(array, offset2, commandLength);
124 offset2 += commandLength;
126 final int spacesLength1 =
it.next();
128 offset2 += spacesLength1;
130 while (
it.hasNext()) {
131 final int parameterLength =
it.next();
133 if (tmp.length == 2) {
134 final String parameterString = tmp[0];
135 final String valueString = tmp[1];
138 final boolean parameterValid = parameter !=
null;
147 offset2 += parameterLength;
149 final int spacesLength2 =
it.next();
151 offset2 += spacesLength2;
167 if (fixedSpec !=
null) {
171 for (
final Entry<Pattern, Spec> entry :
REGEX_SPECS.entrySet()) {
172 if (entry.getKey().matcher(command).matches()) {
173 return entry.getValue();
This package contains the other part of the script editor.
byte getId()
Returns the token id used to highlight this command.
Base package of all Gridarta classes.
A TokenMarker for the message field of Daimonin AI objects.
void addToken(final int length, final byte id)
Adds a token to the token list.
static final byte NULL
Normal text token id.
INTEGER
Integer parameter.
byte markTokensImpl(final byte token, @NotNull final Segment line)
An abstract method that splits a line up into tokens.
static final byte OPERATOR
Operator token id.
static final byte LABEL
Label token id.
STRING_INTEGER
String/Integer list parameter.
static final byte INVALID
Invalid token id.
static final byte KEYWORD2
Keyword 2 token id.
ParameterType getParameterType()
Returns the parameter type for the value of this parameter.
byte getId()
Returns the token id used to highlight the parameter name.
static final byte KEYWORD1
Keyword 1 token id.
Utility class for string manipulation.
Parameter getParameter(final String name)
Returns the parameter specification for a parameter name.
Describes a command (excluding the command name).
static final Map< String, Spec > FIXED_SPECS
Commands having a fixed command name.
static Spec getSpec(@NotNull final String command)
Returns the command specification from a command name.
Pattern getPattern()
Returns the pattern matching valid parameter values.
A token marker that splits lines of text into tokens.
static final Map< Pattern, Spec > REGEX_SPECS
Commands having variable command names.
Describes a parameter type.
static final byte COMMENT1
Comment 1 token id.
This document describes some hints and requirements for general development on the CrossfireEditor If you plan to make changes to the editor code or setup please read the following and keep it in derived from a basic editor application called Gridder by Pasi Ker�nen so please communicate with best through the cf devel mailing before considering any fundamental changes About code DO NOT USE TABS No matter what Java development platform you are please configure insert indent Tabs are displayed totally different in every editor and there are millions of different editors out there The insertion of tabs in the source code is messing up the syntax formatting in a way that is UNREPAIRABLE Apart from please keep code indentation accurate This is not just good it helps to keep code readable and in that way dramatically decreases the chance for overlooked bugs Everyone is welcomed to correct indentation errors wherever they are spotted Before you start to do this please double check that your editor is really configured to insert spaces Line feeds may be checked in either in windows or in unix linux style All reasonable text and java editors can deal with both linefeed formats Converting line feeds is but in this case please make sure that only linefeed characters are changed and nothing else is affected Due to the platform independent nature of the editor has the potential to run on almost any given operating system the build process differs greatly between systems as well as java environments In the several people have attempted to add build scripts along with structural changes to optimize the setup on one particular system environment which has led to conflict Please do *not *attempt to change the structure or any directories for the mere purpose of improving a build process or performance in a java environment Build scripts may be placed in the root it would be especially fine if it is just one or two files but the latter is not required Please excuse me for placing such restriction I and many users of the editor greatly appreciate build scripts We just had some real troubles over this issue in the past and I don t want to have them repeated the editor has relatively high performance requirements I ve spent a lot of extra work to keep everything as fast and memory efficient as possible when you add new data fields or calculations in the archetype please make sure they are as efficient as possible and worth both the time and space they consume Now don t be afraid too much No development would be possible without adding calculations and data at all Just bear in mind unlike for many other open source performance does make a difference for the CrossfireEditor The for as many systems as possible In case you are unexperienced with java and note that the graphics look different on every and with every font They also have different sizes proportions and behave different A seemingly trivial and effectless change can wreck havoc for the same GUI run on another system please don t be totally afraid of it
static final Pattern PATTERN_EQUAL
The pattern that matches a single equal sign ("=").