mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
correct selection drawing, fixed cursor position around <line>
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@122 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -509,7 +509,7 @@ void TextValueEditor::moveSelection(IndexType t, size_t new_end, bool also_move_
|
||||
// editor.refreshEditor();
|
||||
// } else {
|
||||
// draw new selection
|
||||
v.drawSelection(rdc, style(), selection_start, selection_end);
|
||||
v.drawSelection(rdc, style(), selection_start_i, selection_end_i);
|
||||
// }
|
||||
showCaret();
|
||||
// TODO; DEBUG!!
|
||||
|
||||
@@ -169,22 +169,29 @@ size_t index_to_cursor(const String& str, size_t index, Movement dir) {
|
||||
// after the loop, cursor corresponds to index end
|
||||
for (size_t i = 0 ; i < str.size() ; ) {
|
||||
Char c = str.GetChar(i);
|
||||
bool has_width = true;
|
||||
if (c == _('<')) {
|
||||
// a tag
|
||||
if (is_substr(str, i, _("<atom")) || is_substr(str, i, _("<sep"))) {
|
||||
// skip tag contents, tag counts as a single 'character'
|
||||
i = skip_tag(str, match_close_tag(str, i));
|
||||
cursor++;
|
||||
start = end;
|
||||
end = i;
|
||||
if (end > index) break;
|
||||
} else if (is_substr(str, i, _("<line"))) {
|
||||
// no contents, but has width
|
||||
i = skip_tag(str, i);
|
||||
if (i > index) {
|
||||
// HACK: Don't walk past <line>
|
||||
dir = dir == MOVE_RIGHT ? MOVE_LEFT : MOVE_RIGHT;
|
||||
}
|
||||
} else {
|
||||
i = skip_tag(str, i);
|
||||
end = i;
|
||||
has_width = false;
|
||||
}
|
||||
} else {
|
||||
cursor++;
|
||||
i++;
|
||||
}
|
||||
if (has_width) {
|
||||
cursor++;
|
||||
start = end;
|
||||
end = i;
|
||||
if (end > index) break;
|
||||
@@ -204,19 +211,24 @@ void cursor_to_index_range(const String& str, size_t cursor, size_t& start, size
|
||||
size_t i = 0;
|
||||
while (cur <= cursor && i < str.size()) {
|
||||
Char c = str.GetChar(i);
|
||||
bool has_width = true;
|
||||
if (c == _('<')) {
|
||||
// a tag
|
||||
if (is_substr(str, i, _("<atom")) || is_substr(str, i, _("<sep"))) {
|
||||
// skip tag contents, tag counts as a single 'character'
|
||||
i = skip_tag(str, match_close_tag(str, i));
|
||||
cur++;
|
||||
if (cur == cursor) start = i;
|
||||
} else if (is_substr(str, i, _("<line"))) {
|
||||
// no contents, but has width
|
||||
i = skip_tag(str, i);
|
||||
} else {
|
||||
i = skip_tag(str, i);
|
||||
has_width = false;
|
||||
}
|
||||
} else {
|
||||
cur++;
|
||||
i++;
|
||||
}
|
||||
if (has_width) {
|
||||
cur++;
|
||||
if (cur == cursor) start = i;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user