mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Added <prefix> and <suffix> tags;
Added prefix and suffix support to combined_editor; 'always symbol' now checks if the symbols are available in the symbol font; Fixed parser bug in spec_sort; A first information field is no longer used as set identification git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@653 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -239,7 +239,14 @@ void in_place_sort(const String& spec, String& input, String& ret) {
|
||||
String spec_sort(const String& spec, String& input, String& ret) {
|
||||
SpecIterator it(spec);
|
||||
while(it.nextUntil(0)) {
|
||||
if (it.value == _('<')) { // keep only a single copy
|
||||
if (it.escaped) { // single character, escaped
|
||||
FOR_EACH(d, input) {
|
||||
if (d == it.value) {
|
||||
ret += d;
|
||||
d = REMOVED;
|
||||
}
|
||||
}
|
||||
} else if (it.value == _('<')) { // keep only a single copy
|
||||
while (it.nextUntil(_('>'))) {
|
||||
size_t pos = input.find_first_of(it.value);
|
||||
if (pos != String::npos) {
|
||||
|
||||
@@ -249,6 +249,13 @@ size_t index_to_cursor(const String& str, size_t index, Movement dir) {
|
||||
}
|
||||
}
|
||||
i = after;
|
||||
} else if (i == 0 && is_substr(str, i, _("<prefix"))) {
|
||||
// prefix at start of string, skip contents
|
||||
i = match_close_tag_end(str, i);
|
||||
has_width = false;
|
||||
} else if (is_substr(str, i, _("<suffix")) && match_close_tag_end(str,i) >= str.size()) {
|
||||
// suffix at end of string
|
||||
break;
|
||||
} else {
|
||||
i = skip_tag(str, i);
|
||||
has_width = false;
|
||||
@@ -268,7 +275,8 @@ void cursor_to_index_range(const String& str, size_t cursor, size_t& start, size
|
||||
start = end = 0;
|
||||
size_t cur = 0;
|
||||
size_t i = 0;
|
||||
while (cur <= cursor && i < str.size()) {
|
||||
size_t size = str.size(); // can be changed by <suffix> tags
|
||||
while (cur <= cursor && i < size) {
|
||||
Char c = str.GetChar(i);
|
||||
bool has_width = true;
|
||||
if (c == _('<')) {
|
||||
@@ -278,6 +286,14 @@ void cursor_to_index_range(const String& str, size_t cursor, size_t& start, size
|
||||
if (cur >= cursor) { ++i; break; }
|
||||
// skip tag contents, tag counts as a single 'character'
|
||||
i = match_close_tag_end(str, i);
|
||||
} else if (i == 0 && is_substr(str, i, _("<prefix"))) {
|
||||
// prefix at start of string, skip contents, index never before
|
||||
start = i = match_close_tag_end(str,i);
|
||||
has_width = false;
|
||||
} else if (is_substr(str, i, _("<suffix")) && match_close_tag_end(str,i) >= str.size()) {
|
||||
// suffix at start of string, skip contents
|
||||
size = i;
|
||||
has_width = false;
|
||||
} else {
|
||||
i = skip_tag(str, i);
|
||||
has_width = false;
|
||||
@@ -290,8 +306,8 @@ void cursor_to_index_range(const String& str, size_t cursor, size_t& start, size
|
||||
if (cur == cursor) start = i;
|
||||
}
|
||||
}
|
||||
end = min(i, str.size());
|
||||
if (cur < cursor) start = end = str.size();
|
||||
end = min(i, size);
|
||||
if (cur < cursor) start = end = size;
|
||||
if (end <= start) end = start + 1;
|
||||
}
|
||||
|
||||
@@ -336,6 +352,12 @@ String untag_for_cursor(const String& str) {
|
||||
} else if (is_substr(str, i, _("<sep"))) {
|
||||
i = match_close_tag_end(str, i);
|
||||
ret += _('\3'); // use a random character here
|
||||
} else if (i == 0 && is_substr(str, i, _("<prefix"))) {
|
||||
// prefix at start of string, skip contents, index never before
|
||||
i = match_close_tag_end(str,i);
|
||||
} else if (is_substr(str, i, _("<suffix")) && match_close_tag_end(str,i) >= str.size()) {
|
||||
// suffix at start of string, skip contents
|
||||
i = str.size();
|
||||
} else {
|
||||
i = skip_tag(str, i);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user