use of pl.asie.charset.module.tablet.format.words.WordText in project Charset by CharsetMC.
the class AbstractTypesetter method write.
@Override
public void write(String text) throws TruthError {
if (Strings.isNullOrEmpty(text))
return;
final Tokenizer tokenizer = new Tokenizer(text);
while (tokenizer.nextToken()) {
final String token = tokenizer.getToken();
if (token.isEmpty())
continue;
switch(tokenizer.getType()) {
default:
throw new TruthError("Unknown tokentype: " + tokenizer.getToken());
case WORD:
write(new WordText(token));
break;
case PARAMETER:
write(token);
break;
case COMMAND:
final String cmdName = token.toLowerCase(Locale.ROOT);
ICommand cmd = TabletAPI.INSTANCE.getCommand(cmdName);
if (cmd == null) {
throw new TruthError("Unknown command: " + cmdName);
}
runCommand(cmd, tokenizer);
break;
}
}
}
use of pl.asie.charset.module.tablet.format.words.WordText in project Charset by CharsetMC.
the class CommandURLMissing method call.
@Override
public void call(ITypesetter typesetter, ITokenizer tokenizer) throws TruthError {
String content = tokenizer.getParameter("\\urlmissing missing parameter: content");
try {
typesetter.pushStyle(new StyleColor(0xFFCC3333), StyleFormat.ITALIC, StyleFormat.UNDERLINE);
typesetter.write(new WordText(content));
typesetter.popStyle(3);
} catch (Exception e) {
e.printStackTrace();
throw new TruthError(e.getMessage());
}
}
Aggregations