Merge remote-tracking branch 'artemutin/scriptSearchRedirect'

openmw-37
Marc Zinnschlag 9 years ago
commit 3b39572274

@ -198,26 +198,41 @@ void CSVWorld::ScriptSubView::useHint (const std::string& hint)
if (hint.empty()) if (hint.empty())
return; return;
if (hint[0]=='l') unsigned line = 0, column = 0;
{ char c;
std::istringstream stream (hint.c_str()+1); std::istringstream stream (hint.c_str()+1);
switch(hint[0]){
char ignore; case 'R':
int line; case 'r':
int column;
if (stream >> ignore >> line >> column)
{ {
QTextCursor cursor = mEditor->textCursor(); QModelIndex index = mModel->getModelIndex (getUniversalId().getId(), mColumn);
QString source = mModel->data (index).toString();
cursor.movePosition (QTextCursor::Start); unsigned pos, dummy;
if (cursor.movePosition (QTextCursor::Down, QTextCursor::MoveAnchor, line)) if (!(stream >> c >> dummy >> pos) )
cursor.movePosition (QTextCursor::Right, QTextCursor::MoveAnchor, column); return;
mEditor->setFocus(); for (unsigned i = 0; i <= pos; ++i){
mEditor->setTextCursor (cursor); if (source[i] == '\n'){
++line;
column = i+1;
}
}
column = pos - column;
break;
} }
case 'l':
if (!(stream >> c >> line >> column))
return;
} }
QTextCursor cursor = mEditor->textCursor();
cursor.movePosition (QTextCursor::Start);
if (cursor.movePosition (QTextCursor::Down, QTextCursor::MoveAnchor, line))
cursor.movePosition (QTextCursor::Right, QTextCursor::MoveAnchor, column);
mEditor->setFocus();
mEditor->setTextCursor (cursor);
} }
void CSVWorld::ScriptSubView::textChanged() void CSVWorld::ScriptSubView::textChanged()

Loading…
Cancel
Save