mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
improved error reporting for the keyword editor
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@260 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -33,3 +33,23 @@ void AtomTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, co
|
||||
}
|
||||
CompoundTextElement::draw(dc, scale, rect, xs, what, start, end);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : ErrorTextElement
|
||||
|
||||
void ErrorTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const {
|
||||
// Draw wavy underline
|
||||
dc.SetPen(*wxRED_PEN);
|
||||
RealPoint pos = rect.bottomLeft() - dc.trInvS(RealSize(0,2));
|
||||
RealSize dx(dc.trInvS(2), 0), dy(0, dc.trInvS(1));
|
||||
while (pos.x + 1 < rect.right()) {
|
||||
dc.DrawLine(pos - dy, pos + dx + dy);
|
||||
pos += dx;
|
||||
dy = -dy;
|
||||
}
|
||||
if (pos.x < rect.right()) {
|
||||
// final piece
|
||||
dc.DrawLine(pos - dy, pos + dx / 2);
|
||||
}
|
||||
// Draw the contents
|
||||
CompoundTextElement::draw(dc, scale, rect, xs, what, start, end);
|
||||
}
|
||||
@@ -73,18 +73,19 @@ struct TextElementsFromString {
|
||||
// What formatting is enabled?
|
||||
int bold, italic, symbol;
|
||||
int soft, kwpph, param, line;
|
||||
int code, code_kw, code_string, param_ref;
|
||||
int code, code_kw, code_string, param_ref, error;
|
||||
int param_id;
|
||||
bool bracket;
|
||||
|
||||
TextElementsFromString()
|
||||
: bold(0), italic(0), symbol(0), soft(0), kwpph(0), param(0), line(0)
|
||||
, code(0), code_kw(0), code_string(0), param_ref(0)
|
||||
, code(0), code_kw(0), code_string(0), param_ref(0), error(0)
|
||||
, param_id(0), bracket(false) {}
|
||||
|
||||
// read TextElements from a string
|
||||
void fromString(TextElements& te, const String& text, size_t start, size_t end, const TextStyle& style, Context& ctx) {
|
||||
te.elements.clear();
|
||||
end = min(end, text.size());
|
||||
// for each character...
|
||||
for (size_t pos = start ; pos < end ; ) {
|
||||
Char c = text.GetChar(pos);
|
||||
@@ -126,11 +127,18 @@ struct TextElementsFromString {
|
||||
else if (is_substr(text, tag_start, _("</line"))) line -= 1;
|
||||
else if (is_substr(text, tag_start, _("<atom"))) {
|
||||
// 'atomic' indicator
|
||||
size_t end = match_close_tag(text, tag_start);
|
||||
shared_ptr<AtomTextElement> e(new AtomTextElement(text, pos, end));
|
||||
fromString(e->elements, text, pos, end, style, ctx);
|
||||
size_t end_tag = min(end, match_close_tag(text, tag_start));
|
||||
shared_ptr<AtomTextElement> e(new AtomTextElement(text, pos, end_tag));
|
||||
fromString(e->elements, text, pos, end_tag, style, ctx);
|
||||
te.elements.push_back(e);
|
||||
pos = skip_tag(text, end);
|
||||
pos = skip_tag(text, end_tag);
|
||||
} else if (is_substr(text, tag_start, _( "<error"))) {
|
||||
// error indicator
|
||||
size_t end_tag = min(end, match_close_tag(text, tag_start));
|
||||
shared_ptr<ErrorTextElement> e(new ErrorTextElement(text, pos, end_tag));
|
||||
fromString(e->elements, text, pos, end_tag, style, ctx);
|
||||
te.elements.push_back(e);
|
||||
pos = skip_tag(text, end_tag);
|
||||
} else {
|
||||
// ignore other tags
|
||||
}
|
||||
|
||||
@@ -164,6 +164,13 @@ class AtomTextElement : public CompoundTextElement {
|
||||
virtual void draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const;
|
||||
};
|
||||
|
||||
/// A TextElement drawn using a red wavy underline
|
||||
class ErrorTextElement : public CompoundTextElement {
|
||||
public:
|
||||
ErrorTextElement(const String& text, size_t start ,size_t end) : CompoundTextElement(text, start, end) {}
|
||||
|
||||
virtual void draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : Other text elements
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user