Use underscores instead of spaces for all internal names. And renamed some script functions at the same time.

* cannocial_name_form now outputs "_", where it used to use " "
* this simplifies reflectio and scripting code, because now C++ names are also MSE internal names
* added 'caption' property to fields. This is used instead of the name in NativeLookEditor, since the latter will now contain underscores.
* renamed text related script functions for consistency, since we were touching that part of the code anyway.
This commit is contained in:
Twan van Laarhoven
2020-04-22 23:33:06 +02:00
parent be4bb8d8ed
commit 713a9e4a40
33 changed files with 240 additions and 197 deletions
+45 -45
View File
@@ -516,7 +516,7 @@ ScriptValueP sort_script(Context& ctx, const ScriptValueP& list, ScriptValue& or
SCRIPT_FUNCTION_WITH_DEP(position_of) {
ScriptValueP of = ctx.getVariable(_("of"));
ScriptValueP in = ctx.getVariable(_("in"));
ScriptValueP order_by = ctx.getVariableOpt(_("order by"));
ScriptValueP order_by = ctx.getVariableOpt(_("order_by"));
ScriptValueP filter = ctx.getVariableOpt(_("filter"));
if (filter == script_nil) filter = ScriptValueP();
SCRIPT_RETURN(position_in_vector(of, in, order_by, filter));
@@ -524,7 +524,7 @@ SCRIPT_FUNCTION_WITH_DEP(position_of) {
SCRIPT_FUNCTION_DEPENDENCIES(position_of) {
ScriptValueP of = ctx.getVariable(_("of"));
ScriptValueP in = ctx.getVariable(_("in"));
ScriptValueP order_by = ctx.getVariableOpt(_("order by"));
ScriptValueP order_by = ctx.getVariableOpt(_("order_by"));
ScriptValueP filter = ctx.getVariableOpt(_("filter"));
ScriptObject<Set*>* s = dynamic_cast<ScriptObject<Set*>* >(in.get());
ScriptObject<CardP>* c = dynamic_cast<ScriptObject<CardP>*>(of.get());
@@ -581,8 +581,8 @@ SCRIPT_FUNCTION(filter_list) {
SCRIPT_FUNCTION(sort_list) {
SCRIPT_PARAM_C(ScriptValueP, input);
SCRIPT_PARAM_DEFAULT_N(ScriptValueP, _("order by"), order_by, script_nil);
SCRIPT_PARAM_DEFAULT_N(bool, _("remove duplicates"), remove_duplicates, false);
SCRIPT_PARAM_DEFAULT(ScriptValueP, order_by, script_nil);
SCRIPT_PARAM_DEFAULT(bool, remove_duplicates, false);
return sort_script(ctx, input, *order_by, remove_duplicates);
}
@@ -648,8 +648,8 @@ SCRIPT_FUNCTION_WITH_DEP(expand_keywords) {
SCRIPT_PARAM_C(String, input);
SCRIPT_PARAM_C(Set*, set);
SCRIPT_OPTIONAL_PARAM_N_(ScriptValueP, _("condition"), match_condition);
SCRIPT_OPTIONAL_PARAM_N_(ScriptValueP, _("default expand"), default_expand);
SCRIPT_PARAM_N(ScriptValueP, _("combine"), combine);
SCRIPT_OPTIONAL_PARAM_(ScriptValueP, default_expand);
SCRIPT_PARAM(ScriptValueP, combine);
KeywordDatabase& db = set->keyword_db;
if (db.empty()) {
db.prepare_parameters(set->game->keyword_parameter_types, set->keywords);
@@ -668,8 +668,8 @@ SCRIPT_FUNCTION_WITH_DEP(expand_keywords) {
SCRIPT_FUNCTION_DEPENDENCIES(expand_keywords) {
SCRIPT_PARAM_C(Set*, set);
SCRIPT_OPTIONAL_PARAM_N_(ScriptValueP, _("condition"), match_condition);
SCRIPT_OPTIONAL_PARAM_N_(ScriptValueP, _("default expand"), default_expand);
SCRIPT_PARAM_N(ScriptValueP, _("combine"), combine);
SCRIPT_OPTIONAL_PARAM_(ScriptValueP, default_expand);
SCRIPT_PARAM(ScriptValueP, combine);
if (match_condition) match_condition->dependencies(ctx,dep);
default_expand ->dependencies(ctx,dep);
combine ->dependencies(ctx,dep);
@@ -715,62 +715,62 @@ void init_script_basic_functions(Context& ctx) {
// debugging
ctx.setVariable(_("trace"), script_trace);
// conversion
ctx.setVariable(_("to string"), script_to_string);
ctx.setVariable(_("to int"), script_to_int);
ctx.setVariable(_("to real"), script_to_real);
ctx.setVariable(_("to number"), script_to_number);
ctx.setVariable(_("to boolean"), script_to_boolean);
ctx.setVariable(_("to color"), script_to_color);
ctx.setVariable(_("to date"), script_to_date);
ctx.setVariable(_("to code"), script_to_code);
ctx.setVariable(_("type name"), script_type_name);
ctx.setVariable(_("to_string"), script_to_string);
ctx.setVariable(_("to_int"), script_to_int);
ctx.setVariable(_("to_real"), script_to_real);
ctx.setVariable(_("to_number"), script_to_number);
ctx.setVariable(_("to_boolean"), script_to_boolean);
ctx.setVariable(_("to_color"), script_to_color);
ctx.setVariable(_("to_date"), script_to_date);
ctx.setVariable(_("to_code"), script_to_code);
ctx.setVariable(_("type_name"), script_type_name);
// math
ctx.setVariable(_("abs"), script_abs);
ctx.setVariable(_("random real"), script_random_real);
ctx.setVariable(_("random int"), script_random_int);
ctx.setVariable(_("random boolean"), script_random_boolean);
ctx.setVariable(_("random_real"), script_random_real);
ctx.setVariable(_("random_int"), script_random_int);
ctx.setVariable(_("random_boolean"), script_random_boolean);
ctx.setVariable(_("sin"), script_sin);
ctx.setVariable(_("cos"), script_cos);
ctx.setVariable(_("tan"), script_tan);
ctx.setVariable(_("sin deg"), script_sin_deg);
ctx.setVariable(_("cos deg"), script_cos_deg);
ctx.setVariable(_("tan deg"), script_tan_deg);
ctx.setVariable(_("sin_deg"), script_sin_deg);
ctx.setVariable(_("cos_deg"), script_cos_deg);
ctx.setVariable(_("tan_deg"), script_tan_deg);
ctx.setVariable(_("exp"), script_exp);
ctx.setVariable(_("log"), script_log);
ctx.setVariable(_("log10"), script_log10);
ctx.setVariable(_("sqrt"), script_sqrt);
ctx.setVariable(_("pow"), script_pow);
// string
ctx.setVariable(_("to upper"), script_to_upper);
ctx.setVariable(_("to lower"), script_to_lower);
ctx.setVariable(_("to title"), script_to_title);
ctx.setVariable(_("to_upper"), script_to_upper);
ctx.setVariable(_("to_lower"), script_to_lower);
ctx.setVariable(_("to_title"), script_to_title);
ctx.setVariable(_("reverse"), script_reverse);
ctx.setVariable(_("trim"), script_trim);
ctx.setVariable(_("substring"), script_substring);
ctx.setVariable(_("contains"), script_contains);
ctx.setVariable(_("format"), script_format);
ctx.setVariable(_("format rule"), intrusive(new ScriptRule(script_format)));
ctx.setVariable(_("curly quotes"), script_curly_quotes);
ctx.setVariable(_("regex escape"), script_regex_escape);
ctx.setVariable(_("sort text"), script_sort_text);
ctx.setVariable(_("sort rule"), intrusive(new ScriptRule(script_sort_text)));
ctx.setVariable(_("format_rule"), intrusive(new ScriptRule(script_format)));
ctx.setVariable(_("curly_quotes"), script_curly_quotes);
ctx.setVariable(_("regex_escape"), script_regex_escape);
ctx.setVariable(_("sort_text"), script_sort_text);
ctx.setVariable(_("sort_rule"), intrusive(new ScriptRule(script_sort_text)));
// tagged string
ctx.setVariable(_("tag contents"), script_tag_contents);
ctx.setVariable(_("remove tag"), script_remove_tag);
ctx.setVariable(_("remove tags"), script_remove_tags);
ctx.setVariable(_("tag contents rule"), intrusive(new ScriptRule(script_tag_contents)));
ctx.setVariable(_("tag remove rule"), intrusive(new ScriptRule(script_remove_tag)));
ctx.setVariable(_("tag_contents"), script_tag_contents);
ctx.setVariable(_("remove_tag"), script_remove_tag);
ctx.setVariable(_("remove_tags"), script_remove_tags);
ctx.setVariable(_("tag_contents_rule"), intrusive(new ScriptRule(script_tag_contents)));
ctx.setVariable(_("tag_remove_rule"), intrusive(new ScriptRule(script_remove_tag)));
// collection
ctx.setVariable(_("position"), script_position_of);
ctx.setVariable(_("length"), script_length);
ctx.setVariable(_("number of items"), script_number_of_items);
ctx.setVariable(_("filter list"), script_filter_list);
ctx.setVariable(_("sort list"), script_sort_list);
ctx.setVariable(_("random shuffle"), script_random_shuffle);
ctx.setVariable(_("random select"), script_random_select);
ctx.setVariable(_("random select many"), script_random_select_many);
ctx.setVariable(_("number_of_items"), script_number_of_items); // deprecated
ctx.setVariable(_("filter_list"), script_filter_list);
ctx.setVariable(_("sort_list"), script_sort_list);
ctx.setVariable(_("random_shuffle"), script_random_shuffle);
ctx.setVariable(_("random_select"), script_random_select);
ctx.setVariable(_("random_select_many"), script_random_select_many);
// keyword
ctx.setVariable(_("expand keywords"), script_expand_keywords);
ctx.setVariable(_("expand keywords rule"), intrusive(new ScriptRule(script_expand_keywords)));
ctx.setVariable(_("keyword usage"), script_keyword_usage);
ctx.setVariable(_("expand_keywords"), script_expand_keywords);
ctx.setVariable(_("expand_keywords_rule"), intrusive(new ScriptRule(script_expand_keywords)));
ctx.setVariable(_("keyword_usage"), script_keyword_usage);
}
+1 -1
View File
@@ -55,5 +55,5 @@ SCRIPT_FUNCTION(new_card) {
// ----------------------------------------------------------------------------- : Init
void init_script_construction_functions(Context& ctx) {
ctx.setVariable(_("new card"), script_new_card);
ctx.setVariable(_("new_card"), script_new_card);
}
+13 -13
View File
@@ -99,8 +99,8 @@ SCRIPT_FUNCTION_WITH_DEP(combined_editor) {
nv.second = index_to_untagged(nv.first, nv.first.size()) == 0;
}
// options
SCRIPT_PARAM_DEFAULT_N(bool, _("hide when empty"), hide_when_empty, false);
SCRIPT_PARAM_DEFAULT_N(bool, _("soft before empty"), soft_before_empty, false);
SCRIPT_PARAM_DEFAULT(bool, hide_when_empty, false);
SCRIPT_PARAM_DEFAULT(bool, soft_before_empty, false);
// recombine the parts
String new_value = value_parts.front().first;
bool new_value_empty = value_parts.front().second;
@@ -336,7 +336,7 @@ void read_choices_param(Context& ctx, vector<String>& choices_out) {
// add the given choice if it is not already active
SCRIPT_FUNCTION(require_choice) {
SCRIPT_PARAM_C(String,input);
SCRIPT_OPTIONAL_PARAM_N_(String,_("last change"),last_change);
SCRIPT_OPTIONAL_PARAM_(String, last_change);
vector<String> choices;
read_choices_param(ctx, choices);
SCRIPT_RETURN(filter_choices(input, choices, 1, (int)choices.size(), last_change));
@@ -345,7 +345,7 @@ SCRIPT_FUNCTION(require_choice) {
// make sure at most one of the choices is active
SCRIPT_FUNCTION(exclusive_choice) {
SCRIPT_PARAM_C(String,input);
SCRIPT_OPTIONAL_PARAM_N_(String,_("last change"),last_change);
SCRIPT_OPTIONAL_PARAM_(String, last_change);
vector<String> choices;
read_choices_param(ctx, choices);
SCRIPT_RETURN(filter_choices(input, choices, 0, 1, last_change));
@@ -354,7 +354,7 @@ SCRIPT_FUNCTION(exclusive_choice) {
// make sure exactly one of the choices is active
SCRIPT_FUNCTION(require_exclusive_choice) {
SCRIPT_PARAM_C(String,input);
SCRIPT_OPTIONAL_PARAM_N_(String,_("last change"),last_change);
SCRIPT_OPTIONAL_PARAM_(String, last_change);
vector<String> choices;
read_choices_param(ctx, choices);
SCRIPT_RETURN(filter_choices(input, choices, 1, 1, last_change));
@@ -393,13 +393,13 @@ SCRIPT_FUNCTION(count_chosen) {
// ----------------------------------------------------------------------------- : Init
void init_script_editor_functions(Context& ctx) {
ctx.setVariable(_("forward editor"), script_combined_editor); // compatability
ctx.setVariable(_("combined editor"), script_combined_editor);
ctx.setVariable(_("primary choice"), script_primary_choice);
ctx.setVariable(_("forward_editor"), script_combined_editor); // compatability
ctx.setVariable(_("combined_editor"), script_combined_editor);
ctx.setVariable(_("primary_choice"), script_primary_choice);
ctx.setVariable(_("chosen"), script_chosen);
ctx.setVariable(_("count chosen"), script_count_chosen);
ctx.setVariable(_("require choice"), script_require_choice);
ctx.setVariable(_("exclusive choice"), script_exclusive_choice);
ctx.setVariable(_("require exclusive choice"), script_require_exclusive_choice);
ctx.setVariable(_("remove choice"), script_remove_choice);
ctx.setVariable(_("count_chosen"), script_count_chosen);
ctx.setVariable(_("require_choice"), script_require_choice);
ctx.setVariable(_("exclusive_choice"), script_exclusive_choice);
ctx.setVariable(_("require_exclusive_choice"), script_require_exclusive_choice);
ctx.setVariable(_("remove_choice"), script_remove_choice);
}
+7 -7
View File
@@ -334,11 +334,11 @@ SCRIPT_FUNCTION(process_english_hints) {
// ----------------------------------------------------------------------------- : Init
void init_script_english_functions(Context& ctx) {
ctx.setVariable(_("english number"), script_english_number);
ctx.setVariable(_("english number a"), script_english_number_a);
ctx.setVariable(_("english number multiple"), script_english_number_multiple);
ctx.setVariable(_("english number ordinal"), script_english_number_ordinal);
ctx.setVariable(_("english singular"), script_english_singular);
ctx.setVariable(_("english plural"), script_english_plural);
ctx.setVariable(_("process english hints"), script_process_english_hints);
ctx.setVariable(_("english_number"), script_english_number);
ctx.setVariable(_("english_number_a"), script_english_number_a);
ctx.setVariable(_("english_number_multiple"), script_english_number_multiple);
ctx.setVariable(_("english_number_ordinal"), script_english_number_ordinal);
ctx.setVariable(_("english_singular"), script_english_singular);
ctx.setVariable(_("english_plural"), script_english_plural);
ctx.setVariable(_("process_english_hints"), script_process_english_hints);
}
+11 -11
View File
@@ -278,11 +278,11 @@ SCRIPT_FUNCTION(to_html) {
SCRIPT_PARAM_C(String, input);
// symbol font?
SymbolFontP symbol_font;
SCRIPT_OPTIONAL_PARAM_N(String, _("symbol font"), font_name) {
SCRIPT_OPTIONAL_PARAM_N(String, _("symbol_font"), font_name) {
symbol_font = SymbolFont::byName(font_name);
symbol_font->update(ctx);
}
SCRIPT_OPTIONAL_PARAM_N_(double, _("symbol font size"), symbol_font_size);
SCRIPT_OPTIONAL_PARAM_(double, symbol_font_size);
if (symbol_font_size <= 0) symbol_font_size = 12; // a default
SCRIPT_RETURN(to_html(input, symbol_font, symbol_font_size));
}
@@ -290,8 +290,8 @@ SCRIPT_FUNCTION(to_html) {
// convert a symbol string to html
SCRIPT_FUNCTION(symbols_to_html) {
SCRIPT_PARAM_C(String, input);
SCRIPT_PARAM_N(String, _("symbol font"), font_name);
SCRIPT_OPTIONAL_PARAM_N_(double, _("symbol font size"), symbol_font_size);
SCRIPT_PARAM_N(String, _("symbol_font"), font_name);
SCRIPT_OPTIONAL_PARAM_(double, symbol_font_size);
SymbolFontP symbol_font = SymbolFont::byName(font_name);
symbol_font->update(ctx);
if (symbol_font_size <= 0) symbol_font_size = 12; // a default
@@ -451,12 +451,12 @@ SCRIPT_FUNCTION(sanitize) {
// ----------------------------------------------------------------------------- : Init
void init_script_export_functions(Context& ctx) {
ctx.setVariable(_("to html"), script_to_html);
ctx.setVariable(_("symbols to html"), script_symbols_to_html);
ctx.setVariable(_("to text"), script_to_text);
ctx.setVariable(_("copy file"), script_copy_file);
ctx.setVariable(_("write text file"), script_write_text_file);
ctx.setVariable(_("write image file"), script_write_image_file);
ctx.setVariable(_("write set file"), script_write_set_file);
ctx.setVariable(_("to_html"), script_to_html);
ctx.setVariable(_("symbols_to_html"), script_symbols_to_html);
ctx.setVariable(_("to_text"), script_to_text);
ctx.setVariable(_("copy_file"), script_copy_file);
ctx.setVariable(_("write_text_file"), script_write_text_file);
ctx.setVariable(_("write_image_file"), script_write_image_file);
ctx.setVariable(_("write_set_file"), script_write_set_file);
ctx.setVariable(_("sanitize"), script_sanitize);
}
+41 -41
View File
@@ -106,16 +106,16 @@ SCRIPT_FUNCTION(recolor_image) {
SCRIPT_FUNCTION(enlarge) {
SCRIPT_PARAM_C(GeneratedImageP, input);
SCRIPT_PARAM_N(double, _("border size"), border_size);
SCRIPT_PARAM(double, border_size);
return intrusive(new EnlargeImage(input, border_size));
}
SCRIPT_FUNCTION(crop) {
SCRIPT_PARAM_C(GeneratedImageP, input);
SCRIPT_PARAM_N(int, _("width"), width);
SCRIPT_PARAM_N(int, _("height"), height);
SCRIPT_PARAM_N(double, _("offset x"), offset_x);
SCRIPT_PARAM_N(double, _("offset y"), offset_y);
SCRIPT_PARAM(int, width);
SCRIPT_PARAM(int, height);
SCRIPT_PARAM(double, offset_x);
SCRIPT_PARAM(double, offset_y);
return intrusive(new CropImage(input, width, height, offset_x, offset_y));
}
@@ -131,17 +131,17 @@ SCRIPT_FUNCTION(flip_vertical) {
SCRIPT_FUNCTION(rotate) {
SCRIPT_PARAM_C(GeneratedImageP, input);
SCRIPT_PARAM_N(Degrees, _("angle"), angle);
SCRIPT_PARAM(Degrees, angle);
return intrusive(new RotateImage(input,deg_to_rad(angle)));
}
SCRIPT_FUNCTION(drop_shadow) {
SCRIPT_PARAM_C(GeneratedImageP, input);
SCRIPT_OPTIONAL_PARAM_N_(double, _("offset x"), offset_x);
SCRIPT_OPTIONAL_PARAM_N_(double, _("offset y"), offset_y);
SCRIPT_OPTIONAL_PARAM_N_(double, _("alpha"), alpha);
SCRIPT_OPTIONAL_PARAM_N_(double, _("blur radius"), blur_radius);
SCRIPT_OPTIONAL_PARAM_N_(Color, _("color"), color);
SCRIPT_OPTIONAL_PARAM_(double, offset_x);
SCRIPT_OPTIONAL_PARAM_(double, offset_y);
SCRIPT_OPTIONAL_PARAM_(double, alpha);
SCRIPT_OPTIONAL_PARAM_(double, blur_radius);
SCRIPT_OPTIONAL_PARAM_(Color, color);
return intrusive(new DropShadowImage(input, offset_x, offset_y, alpha, blur_radius, color));
}
@@ -176,30 +176,30 @@ SCRIPT_FUNCTION(symbol_variation) {
throw ScriptError(_("Variation of symbol not found ('") + variation + _("')"));
} else {
// custom variation
SCRIPT_PARAM_N(double, _("border radius"), border_radius);
SCRIPT_OPTIONAL_PARAM_N_(String, _("fill type"), fill_type);
SCRIPT_PARAM(double, border_radius);
SCRIPT_OPTIONAL_PARAM_(String, fill_type);
SymbolVariationP var(new SymbolVariation);
var->border_radius = border_radius;
if (fill_type == _("solid") || fill_type.empty()) {
SCRIPT_PARAM_N(Color, _("fill color"), fill_color);
SCRIPT_PARAM_N(Color, _("border color"), border_color);
SCRIPT_PARAM(Color, fill_color);
SCRIPT_PARAM(Color, border_color);
var->filter = intrusive(new SolidFillSymbolFilter(fill_color, border_color));
} else if (fill_type == _("linear gradient")) {
SCRIPT_PARAM_N(Color, _("fill color 1"), fill_color_1);
SCRIPT_PARAM_N(Color, _("border color 1"), border_color_1);
SCRIPT_PARAM_N(Color, _("fill color 2"), fill_color_2);
SCRIPT_PARAM_N(Color, _("border color 2"), border_color_2);
SCRIPT_PARAM_N(double, _("center x"), center_x);
SCRIPT_PARAM_N(double, _("center y"), center_y);
SCRIPT_PARAM_N(double, _("end x"), end_x);
SCRIPT_PARAM_N(double, _("end y"), end_y);
SCRIPT_PARAM(Color, fill_color_1);
SCRIPT_PARAM(Color, border_color_1);
SCRIPT_PARAM(Color, fill_color_2);
SCRIPT_PARAM(Color, border_color_2);
SCRIPT_PARAM(double, center_x);
SCRIPT_PARAM(double, center_y);
SCRIPT_PARAM(double, end_x);
SCRIPT_PARAM(double, end_y);
var->filter = intrusive(new LinearGradientSymbolFilter(fill_color_1, border_color_1, fill_color_2, border_color_2
,center_x, center_y, end_x, end_y));
} else if (fill_type == _("radial gradient")) {
SCRIPT_PARAM_N(Color, _("fill color 1"), fill_color_1);
SCRIPT_PARAM_N(Color, _("border color 1"), border_color_1);
SCRIPT_PARAM_N(Color, _("fill color 2"), fill_color_2);
SCRIPT_PARAM_N(Color, _("border color 2"), border_color_2);
SCRIPT_PARAM(Color, fill_color_1);
SCRIPT_PARAM(Color, border_color_1);
SCRIPT_PARAM(Color, fill_color_2);
SCRIPT_PARAM(Color, border_color_2);
var->filter = intrusive(new RadialGradientSymbolFilter(fill_color_1, border_color_1, fill_color_2, border_color_2));
} else {
throw ScriptError(_("Unknown fill type for symbol_variation: ") + fill_type);
@@ -216,22 +216,22 @@ SCRIPT_FUNCTION(built_in_image) {
// ----------------------------------------------------------------------------- : Init
void init_script_image_functions(Context& ctx) {
ctx.setVariable(_("to image"), script_to_image);
ctx.setVariable(_("linear blend"), script_linear_blend);
ctx.setVariable(_("masked blend"), script_masked_blend);
ctx.setVariable(_("combine blend"), script_combine_blend);
ctx.setVariable(_("set mask"), script_set_mask);
ctx.setVariable(_("set alpha"), script_set_alpha);
ctx.setVariable(_("set combine"), script_set_combine);
ctx.setVariable(_("to_image"), script_to_image);
ctx.setVariable(_("linear_blend"), script_linear_blend);
ctx.setVariable(_("masked_blend"), script_masked_blend);
ctx.setVariable(_("combine_blend"), script_combine_blend);
ctx.setVariable(_("set_mask"), script_set_mask);
ctx.setVariable(_("set_alpha"), script_set_alpha);
ctx.setVariable(_("set_combine"), script_set_combine);
ctx.setVariable(_("saturate"), script_saturate);
ctx.setVariable(_("invert image"), script_invert_image);
ctx.setVariable(_("recolor image"), script_recolor_image);
ctx.setVariable(_("invert_image"), script_invert_image);
ctx.setVariable(_("recolor_image"), script_recolor_image);
ctx.setVariable(_("enlarge"), script_enlarge);
ctx.setVariable(_("crop"), script_crop);
ctx.setVariable(_("flip horizontal"), script_flip_horizontal);
ctx.setVariable(_("flip vertical"), script_flip_vertical);
ctx.setVariable(_("flip_horizontal"), script_flip_horizontal);
ctx.setVariable(_("flip_vertical"), script_flip_vertical);
ctx.setVariable(_("rotate"), script_rotate);
ctx.setVariable(_("drop shadow"), script_drop_shadow);
ctx.setVariable(_("symbol variation"), script_symbol_variation);
ctx.setVariable(_("built in image"), script_built_in_image);
ctx.setVariable(_("drop_shadow"), script_drop_shadow);
ctx.setVariable(_("symbol_variation"), script_symbol_variation);
ctx.setVariable(_("built_in_image"), script_built_in_image);
}
+16 -14
View File
@@ -105,7 +105,7 @@ struct RegexReplacer {
}
};
SCRIPT_FUNCTION_WITH_SIMPLIFY(replace) {
SCRIPT_FUNCTION_WITH_SIMPLIFY(replace_text) {
// construct replacer
RegexReplacer replacer;
replacer.match = from_script<ScriptRegexP>(ctx.getVariable(SCRIPT_VAR_match), SCRIPT_VAR_match);
@@ -131,7 +131,7 @@ SCRIPT_FUNCTION_WITH_SIMPLIFY(replace) {
SCRIPT_RETURN(replacer.match->replace_all(input, replacer.replacement_string));
}
}
SCRIPT_FUNCTION_SIMPLIFY_CLOSURE(replace) {
SCRIPT_FUNCTION_SIMPLIFY_CLOSURE(replace_text) {
FOR_EACH(b, closure.bindings) {
if (b.first == SCRIPT_VAR_match || b.first == SCRIPT_VAR_in_context) {
b.second = regex_from_script(b.second); // pre-compile
@@ -198,7 +198,7 @@ SCRIPT_FUNCTION_SIMPLIFY_CLOSURE(break_text) {
SCRIPT_FUNCTION_WITH_SIMPLIFY(split_text) {
SCRIPT_PARAM_C(String, input);
SCRIPT_PARAM_C(ScriptRegexP, match);
SCRIPT_PARAM_DEFAULT_N(bool, _("include empty"), include_empty, true);
SCRIPT_PARAM_DEFAULT(bool, include_empty, true);
ScriptCustomCollectionP ret(new ScriptCustomCollection);
// find all matches
String::const_iterator start = input.begin();
@@ -227,12 +227,12 @@ SCRIPT_FUNCTION_SIMPLIFY_CLOSURE(split_text) {
// ----------------------------------------------------------------------------- : Rules : regex match
SCRIPT_FUNCTION_WITH_SIMPLIFY(match) {
SCRIPT_FUNCTION_WITH_SIMPLIFY(match_text) {
SCRIPT_PARAM_C(String, input);
SCRIPT_PARAM_C(ScriptRegexP, match);
SCRIPT_RETURN(match->matches(input));
}
SCRIPT_FUNCTION_SIMPLIFY_CLOSURE(match) {
SCRIPT_FUNCTION_SIMPLIFY_CLOSURE(match_text) {
FOR_EACH(b, closure.bindings) {
if (b.first == SCRIPT_VAR_match) {
b.second = regex_from_script(b.second); // pre-compile
@@ -244,13 +244,15 @@ SCRIPT_FUNCTION_SIMPLIFY_CLOSURE(match) {
// ----------------------------------------------------------------------------- : Init
void init_script_regex_functions(Context& ctx) {
ctx.setVariable(_("replace"), script_replace);
ctx.setVariable(_("filter text"), script_filter_text);
ctx.setVariable(_("break text"), script_break_text);
ctx.setVariable(_("split text"), script_split_text);
ctx.setVariable(_("match"), script_match);
ctx.setVariable(_("replace rule"), intrusive(new ScriptRule(script_replace)));
ctx.setVariable(_("filter rule"), intrusive(new ScriptRule(script_filter_text)));
ctx.setVariable(_("break rule"), intrusive(new ScriptRule(script_break_text)));
ctx.setVariable(_("match rule"), intrusive(new ScriptRule(script_match)));
ctx.setVariable(_("replace_text"), script_replace_text);
ctx.setVariable(_("replace"), script_replace_text); // old name
ctx.setVariable(_("filter_text"), script_filter_text);
ctx.setVariable(_("break_text"), script_break_text);
ctx.setVariable(_("split_text"), script_split_text);
ctx.setVariable(_("match_text"), script_match_text);
ctx.setVariable(_("match"), script_match_text); // old name
ctx.setVariable(_("replace_rule"), intrusive(new ScriptRule(script_replace_text)));
ctx.setVariable(_("filter_rule"), intrusive(new ScriptRule(script_filter_text)));
ctx.setVariable(_("break_rule"), intrusive(new ScriptRule(script_break_text)));
ctx.setVariable(_("match_rule"), intrusive(new ScriptRule(script_match_text)));
}
+4 -4
View File
@@ -96,8 +96,8 @@ SCRIPT_FUNCTION(check_spelling) {
assert_tagged(input);
if (!settings.stylesheetSettingsFor(*stylesheet).card_spellcheck_enabled)
SCRIPT_RETURN(input);
SCRIPT_OPTIONAL_PARAM_N_(String,_("extra dictionary"),extra_dictionary);
SCRIPT_OPTIONAL_PARAM_N_(ScriptValueP,_("extra match"),extra_match);
SCRIPT_OPTIONAL_PARAM_(String, extra_dictionary);
SCRIPT_OPTIONAL_PARAM_(ScriptValueP, extra_match);
// remove old spelling error tags
input = remove_tag(input, _("<error-spelling"));
// no language -> spelling checking
@@ -176,6 +176,6 @@ SCRIPT_FUNCTION(check_spelling_word) {
// ----------------------------------------------------------------------------- : Init
void init_script_spelling_functions(Context& ctx) {
ctx.setVariable(_("check spelling"), script_check_spelling);
ctx.setVariable(_("check spelling word"), script_check_spelling_word);
ctx.setVariable(_("check_spelling"), script_check_spelling);
ctx.setVariable(_("check_spelling_word"), script_check_spelling_word);
}