mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 05:07:00 -04:00
formating works, cursor position now prefers to be inside tags
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@171 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -229,12 +229,12 @@ void cursor_to_index_range(const String& str, size_t cursor, size_t& start, size
|
||||
if (cur < cursor) start = end = str.size();
|
||||
}
|
||||
|
||||
size_t cursor_to_index(const String& str, size_t cursor) {
|
||||
size_t cursor_to_index(const String& str, size_t cursor, Movement dir) {
|
||||
size_t start, end;
|
||||
cursor_to_index_range(str, cursor, start, end);
|
||||
// TODO: If at i there is <tag></tag> return a position inside the tags
|
||||
// This allows formating to be enabled without a selection
|
||||
return start;
|
||||
return dir == MOVE_RIGHT ? end - 1 : start;
|
||||
}
|
||||
|
||||
|
||||
@@ -373,12 +373,12 @@ String simplify_tagged_overlap(const String& str) {
|
||||
add_or_cancel_tag(tag, open_tags);
|
||||
if (open_tags.find(anti_tag(tag)) != String::npos) {
|
||||
// still not canceled out
|
||||
i += tag.size() + 2;
|
||||
i += tag.size() + 1;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
// skip this tag, doubling it has no effect
|
||||
i += tag.size() + 2;
|
||||
i += tag.size() + 1;
|
||||
add_or_cancel_tag(tag, open_tags);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ size_t index_to_cursor(const String& str, size_t index, Movement dir = MOVE_MID)
|
||||
void cursor_to_index_range(const String& str, size_t cursor, size_t& begin, size_t& end);
|
||||
|
||||
/// Find the character index corresponding to the given cursor position
|
||||
size_t cursor_to_index(const String& str, size_t cursor);
|
||||
size_t cursor_to_index(const String& str, size_t cursor, Movement dir = MOVE_MID);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Global operations
|
||||
|
||||
|
||||
Reference in New Issue
Block a user