Tweaked cursor movement a bit

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@882 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2008-05-25 16:39:04 +00:00
parent 47e37d8778
commit 9eaebcbcdd
3 changed files with 41 additions and 22 deletions
+6 -3
View File
@@ -347,12 +347,15 @@ String untag_for_cursor(const String& str) {
for (size_t i = 0 ; i < str.size() ; ) {
Char c = str.GetChar(i);
if (c == _('<')) {
if (is_substr(str, i, _("<atom"))) {
if (is_substr(str, i, _("<atom-kwpph"))) {
i = match_close_tag_end(str, i);
ret += _('\2'); // use a random character here
ret += UNTAG_ATOM_KWPPH;
} else if (is_substr(str, i, _("<atom"))) {
i = match_close_tag_end(str, i);
ret += UNTAG_ATOM;
} else if (is_substr(str, i, _("<sep"))) {
i = match_close_tag_end(str, i);
ret += _('\3'); // use a random character here
ret += UNTAG_SEP;
} 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);
+5
View File
@@ -114,6 +114,11 @@ void cursor_to_index_range(const String& str, size_t cursor, size_t& begin, size
/// Find the character index corresponding to the given cursor position
size_t cursor_to_index(const String& str, size_t cursor, Movement dir = MOVE_MID);
const Char UNTAG_ATOM = _('\2');
const Char UNTAG_SEP = _('\3');
const Char UNTAG_ATOM_KWPPH = _('\4');
/// Untag a string for use with cursors, <atom>...</atom> becomes a single character.
/** This string should only be used for cursor position calculations. */
String untag_for_cursor(const String& str);