Commit 89de0488 authored by twanvl's avatar twanvl

cleaned up magic keywords; correct drawing of placeholders

parent fe606b03
......@@ -308,7 +308,14 @@ tooltip:
############################################################## Labels in the GUI
label:
# Cards tab
card notes: Card notes:
# Keywords tab
keyword: Keyword
match: Matches
mode: Mode
uses: Uses
reminder: Reminder text
# Open dialogs
all files All files
......
This diff is collapsed.
......@@ -27,7 +27,7 @@ void Font::initDependencies(Context& ctx, const Dependency& dep) const {
shadow_color.initDependencies(ctx, dep);
}
FontP Font::make(bool bold, bool italic) const {
FontP Font::make(bool bold, bool italic, bool placeholder_color) const {
FontP f(new Font(*this));
if (bold) f->font.SetWeight(wxBOLD);
if (italic) {
......@@ -37,6 +37,10 @@ FontP Font::make(bool bold, bool italic) const {
f->font.SetWeight(wxBOLD);
}
}
if (placeholder_color) {
f->color = f->separator_color;
f->shadow_displacement = RealSize(0,0); // no shadow
}
return f;
}
......
......@@ -40,8 +40,8 @@ class Font {
/// Does this font have a shadow?
inline bool hasShadow() { return shadow_displacement.width != 0 || shadow_displacement.height != 0; }
/// Make a bold/italic version of this font
FontP make(bool bold, bool italic) const;
/// Make a bold/italic/placeholder version of this font
FontP make(bool bold, bool italic, bool placeholder_color) const;
private:
DECLARE_REFLECTION();
......
......@@ -360,14 +360,15 @@ String KeywordDatabase::expand(const String& text,
// j = even -> parameter #(j/2)
size_t start_u, len_u;
kw->matchRe.GetMatch(&start_u, &len_u, j);
size_t part_end = untagged_to_index(s, start_u + len_u, true);
// note: start_u can be (uint)-1 when len_u == 0
size_t part_end = len_u > 0 ? untagged_to_index(s, start_u + len_u, true) : start;
String part = s.substr(start, part_end - start);
if ((j % 2) == 0) {
// parameter
String param = untagged.substr(start_u, len_u); // untagged version
if (param.empty()) {
// placeholder
param = _("<atom-kwpph>") + kw->parameters[j/2-1]->name + _("</atom-kwpph>");
param = _("<atom-kwpph>") + kw->parameters[j/2-1]->name + _("</atom-kwpph>");
part = part + param; // keep tags
} else if (kw->parameters[j/2-1]->script) {
// apply parameter script
......
......@@ -27,7 +27,7 @@ KeywordList::KeywordList(Window* parent, int id, long additional_style)
// Add columns
InsertColumn(0, _LABEL_("keyword"), wxLIST_FORMAT_LEFT, 0);
InsertColumn(1, _LABEL_("match"), wxLIST_FORMAT_LEFT, 200);
InsertColumn(2, _LABEL_("mode"), wxLIST_FORMAT_LEFT, 100);
InsertColumn(2, _LABEL_("mode"), wxLIST_FORMAT_LEFT, 60);
InsertColumn(3, _LABEL_("uses"), wxLIST_FORMAT_RIGHT, 80);
InsertColumn(4, _LABEL_("reminder"), wxLIST_FORMAT_LEFT, 300);
}
......
......@@ -108,7 +108,7 @@ struct TextElementsFromString {
te.elements.push_back(new_shared5<SymbolTextElement>(text, pos, pos + 1, style.symbol_font, &ctx));
} else {
te.elements.push_back(new_shared6<FontTextElement> (text, pos, pos + 1,
style.font.make(bold > 0, italic > 0),
style.font.make(bold > 0, italic > 0, soft > 0 || kwpph > 0),
soft > 0 ? DRAW_ACTIVE : DRAW_NORMAL,
line > 0 ? BREAK_LINE : BREAK_HARD));
}
......
......@@ -15,21 +15,14 @@ void FontTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, co
if ((what & draw_as) != draw_as) return; // don't draw
dc.SetFont(font->font, font->size * scale);
if (end != start && text.substr(end-1, 1) == _("\n")) end -= 1; // don't draw the newline character at the end
if (draw_as == DRAW_ACTIVE) {
// we are drawing a separator
dc.SetTextForeground(font->separator_color);
dc.DrawText(text.substr(start, end-start), rect.position());
} else {
// draw normally
// draw shadow
if (font->hasShadow()) {
dc.SetTextForeground(font->shadow_color);
dc.DrawText(text.substr(start, end - start), rect.position() + font->shadow_displacement);
}
// draw
dc.SetTextForeground(font->color);
dc.DrawText(text.substr(start, end - start), rect.position());
// draw shadow
if (font->hasShadow()) {
dc.SetTextForeground(font->shadow_color);
dc.DrawText(text.substr(start, end - start), rect.position() + font->shadow_displacement);
}
// draw
dc.SetTextForeground(font->color);
dc.DrawText(text.substr(start, end - start), rect.position());
}
void FontTextElement::getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const {
......
......@@ -9,6 +9,7 @@
#include <script/functions/functions.hpp>
#include <script/functions/util.hpp>
#include <util/tagged_string.hpp>
#include <util/error.hpp>
// ----------------------------------------------------------------------------- : Numbers
......@@ -71,6 +72,14 @@ SCRIPT_FUNCTION(english_number_a) {
// ----------------------------------------------------------------------------- : Singular/plural
SCRIPT_FUNCTION(english_singular) {
throw InternalError(_("TODO"));
}
SCRIPT_FUNCTION(english_plural) {
throw InternalError(_("TODO"));
}
// ----------------------------------------------------------------------------- : Hints
// insert a hint, <hint-1> for singular, <hint-2> otherwise
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment