!7
sS snippetID;
sS savedText, remoteText;
static EditorFrame e;
import org.fife.ui.rsyntaxtextarea.*;
sclass JavaXTokenizer extends AbstractTokenMaker {
public TokenMap getWordsToHighlight() {
ret new TokenMap;
}
int currentTokenStart, currentTokenType, startTokenType;
/**
* Returns a list of tokens representing the given text.
*
* @param text The text to break into tokens.
* @param startTokenType The token with which to start tokenizing.
* @param startOffset The offset at which the line of tokens begins.
* @return A linked list of tokens representing text
.
*/
public Token getTokenList(Segment text, int initialTokenType, int startOffset) {
resetTokenList();
char[] array = text.array;
int offset = text.offset;
int count = text.count;
int end = offset + count;
// Token starting offsets are always of the form:
// 'startOffset + (currentTokenStart-offset)', but since startOffset and
// offset are constant, tokens' starting positions become:
// 'newStartOffset+currentTokenStart'.
int newStartOffset = startOffset - offset;
currentTokenStart = offset;
currentTokenType = startTokenType;
for (int i=offset; i p = testBracketHygieneExt(text);
S status = "";
if (remoteText != null && neq(remoteText, text))
status = "Changes. ";
if (p == null)
status += "Hygienic";
else {
status += p.b;
//setCaretPosition(ta, p.a);
}
silentStatus(trim(status));
}
svoid status(S s) {
silentStatus(infoBoxAndReturn(s));
}
svoid silentStatus(S s) {
e.setStatus(s);
}
svoid saveSnippetThen(final Runnable next) {
if (empty(snippetID)) ret;
fS text = getText(e.textArea);
status("Saving...");
thread {
fS page = editSnippet(snippetID, text);
remoteText = text; // TODO: check save result
status("Saved snippet: " + page);
awtCallF(next);
}
}
svoid _butterReload() {
time { butterReload(snippetID); }
infoBox("Reloaded in " + lastTiming_format100ms());
}
svoid transpile(final bool medium) {
saveSnippetThen(r { _transpile(medium) });
}
svoid _transpile(final bool medium) {
status("Transpiling...");
//jdisable(btnEleuReload);
thread "Transpiling" {
try {
final Pair p = transpileOnServer(snippetID, medium ? "medium" : "quick");
awt {
if (p.a)
status("Transpiled OK!");
else {
status("Transpilation error. " + p.b);
showText("Transpilation Error", p.b);
}
}
} catch print e {
status("Transpilation problem. " + e);
}
//jenable(btnEleuReload);
}
}
svoid _loadSnippet(S snippetID) {
e.textArea.setText(remoteText = loadSnippet(snippetID));
setAndSave('snippetID, snippetID);
frameTitle(e, snippetID);
}
svoid newText {
setAndSave(snippetID := null);
remoteText = null;
S lastText = e.getText();
if (nempty(lastText)) logQuotedWithDate("saved-texts.log", lastText);
e.setText("");
frameTitle(e, programTitle());
}
svoid cleanMeUp {
setAndSaveIfChanged(savedText := e.getText());
}