Commit 89de0488 authored by twanvl's avatar twanvl

cleaned up magic keywords; correct drawing of placeholders

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