From f21f11ac87d6a0b8b47e0af6ee3a60c51297372c Mon Sep 17 00:00:00 2001 From: twanvl Date: Mon, 14 May 2007 18:24:01 +0000 Subject: [PATCH] Support for automatic curly quotes git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@375 0fc631ac-6414-0410-93d0-97cfa31319b6 --- data/magic.mse-game/game | 18 ++++++++++++++---- src/script/functions/basic.cpp | 21 +++++++++++++++++++++ src/util/string.hpp | 8 ++++++++ 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/data/magic.mse-game/game b/data/magic.mse-game/game index 3e297dd2..cd32d07a 100644 --- a/data/magic.mse-game/game +++ b/data/magic.mse-game/game @@ -265,7 +265,8 @@ init script: replace_rule( match: "[a-z]", in_context: "[(]()?|[ ]*: |—| — ", - replace: { to_upper() }) + replace: { to_upper() }) + + curly_quotes #character filter for title line name_filter := @@ -309,7 +310,9 @@ init script: # step 1 : remove italic tags tag_remove_rule(tag: "") + # step 2 : surround by tags - { "" + input + "" } + { "" + input + "" } + + # curly quotes + curly_quotes # Used in FPM and Future Sight brush_context := "(?ix) # case insensitive, ignore whitespace @@ -1210,6 +1213,9 @@ keyword mode: keyword mode: name: pseudo description: Pseudo keyword / named ability (Hellbent, Threshold, etc.) +keyword mode: + name: inline + description: Inline keyword, reminder text at end of line (Scry, Regenerate, etc.) keyword mode: is default: true name: custom @@ -1643,8 +1649,12 @@ keyword: keyword: keyword: Fateseal match: Fateseal number - mode: expert - reminder: Look at the top {english_number_multiple(param1)} card(s) of an opponent's library, then put any number of them on the bottom of that player's library and the rest on top in any order. + mode: inline + reminder: + Look at the top { + if param1.value==1 then "card of an opponent's library, then you may put it on the bottom of that player's library." + else "{english_number(param1)} cards of an opponent's library, then put any number of them on the bottom of that player's library and the rest on top in any order." + } keyword: keyword: Transfigure match: Transfigure cost diff --git a/src/script/functions/basic.cpp b/src/script/functions/basic.cpp index efe667da..712d0c34 100644 --- a/src/script/functions/basic.cpp +++ b/src/script/functions/basic.cpp @@ -75,6 +75,26 @@ SCRIPT_RULE_1(format, String, format) { } } +SCRIPT_FUNCTION(curly_quotes) { + SCRIPT_PARAM(String, input); + bool open = true, in_tag = false; + FOR_EACH(c, input) { + if (c == _('\'') || c == LEFT_SINGLE_QUOTE || c == RIGHT_SINGLE_QUOTE) { + c = open ? LEFT_SINGLE_QUOTE : RIGHT_SINGLE_QUOTE; + } else if (c == _('\"') || c == LEFT_DOUBLE_QUOTE || c == RIGHT_DOUBLE_QUOTE) { + c = open ? LEFT_DOUBLE_QUOTE : RIGHT_DOUBLE_QUOTE; + } + if (c == _('<')) { + in_tag = true; + } else if (c == _('>')) { + in_tag = false; + } else if (!in_tag) { + open = isSpace(c); + } + } + SCRIPT_RETURN(input); +} + // ----------------------------------------------------------------------------- : Tagged string @@ -576,6 +596,7 @@ void init_script_basic_functions(Context& ctx) { ctx.setVariable(_("contains"), script_contains); ctx.setVariable(_("format"), script_format); ctx.setVariable(_("format rule"), script_format_rule); + ctx.setVariable(_("curly quotes"), script_curly_quotes); // tagged string ctx.setVariable(_("tag contents"), script_tag_contents); ctx.setVariable(_("remove tag"), script_tag_remove); diff --git a/src/util/string.hpp b/src/util/string.hpp index 3a4a40fb..73668d1a 100644 --- a/src/util/string.hpp +++ b/src/util/string.hpp @@ -64,9 +64,17 @@ void writeUTF8(wxTextOutputStream& stream, const String& str); #ifdef UNICODE #define LEFT_ANGLE_BRACKET _("\x2039") #define RIGHT_ANGLE_BRACKET _("\x203A") + #define LEFT_SINGLE_QUOTE _('\x2018') + #define RIGHT_SINGLE_QUOTE _('\x2019') + #define LEFT_DOUBLE_QUOTE _('\x201C') + #define RIGHT_DOUBLE_QUOTE _('\x201D') #else #define LEFT_ANGLE_BRACKET _("<") #define RIGHT_ANGLE_BRACKET _(">") + #define LEFT_SINGLE_QUOTE _('\'') + #define RIGHT_SINGLE_QUOTE _('\'') + #define LEFT_DOUBLE_QUOTE _('\"') + #define RIGHT_DOUBLE_QUOTE _('\"') #endif // ----------------------------------------------------------------------------- : Char functions