use of me.itay.idemodthingy.programs.bluej.api.Problem in project IDEProgram by Itay2805.
the class BlueJCodeEditor method render.
@Override
protected void render(Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) {
if (!visible)
return;
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
Gui.drawRect(xPosition, yPosition, xPosition + width, yPosition + height, backgroundColor);
FontRenderer font = Minecraft.getMinecraft().fontRendererObj;
// render text
if (highlighter == null) {
// no highlighter
IDEModProgramThingy.LOGGER.info("No highlighter attached! Using default highlighting!");
for (int i = from; i < from + maxLines; i++) {
if (i >= lines.size()) {
break;
}
int Y = i * font.FONT_HEIGHT;
font.drawString(lines.get(i).replace("\t", " "), 2 + xPosition, 2 + yPosition + Y, Color.WHITE.getRGB());
}
} else {
// with highlight
IDEModProgramThingy.LOGGER.info("Using highlighter for: " + highlighter.getName());
for (int i = from; i < from + maxLines; i++) {
if (i >= lines.size()) {
break;
}
int Y = i * font.FONT_HEIGHT;
int X = 0;
for (Token token : tokens) {
String text = "";
if (token instanceof StaticToken) {
text = ((StaticToken) token).getToken().replace("\t", " ");
} else if (token instanceof DynamicToken) {
text = ((DynamicToken) token).getToken().replace("\t", " ");
}
font.drawString(text, 2 + xPosition + X, 2 + yPosition + Y, token.getColor());
X += font.getStringWidth(text);
}
}
for (Problem problem : problems) {
if (from >= problem.getLine() || from + maxLines < problem.getLine()) {
continue;
}
int X = font.getStringWidth(lines.get(problem.getLine()).substring(0, problem.getColumn()));
int Y = problem.getLine() * font.FONT_HEIGHT * 2;
int length = problem.getLength();
while ((length--) > 0) {
font.drawString("~", 2 + xPosition + X, 2 + yPosition + Y, problem.getColor());
X += errorLength;
}
}
}
if (editable) {
// render cursor
if (cursorState) {
int X = font.getStringWidth(getCurrentLine().substring(0, cursorX).replace("\t", " "));
int Y = (cursorY - from) * font.FONT_HEIGHT;
font.drawString("|", 2 + xPosition + X, 2 + yPosition + Y, cursorColor);
}
}
}
Aggregations