forked from qt-creator/qt-creator
TextEditor: Introduce some convenience text accessors in the editor
And adjust users. Change-Id: I9329257cfa5f3298731deb07c2881bc37d9a051d Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
@@ -105,42 +105,41 @@ void CMakeEditor::build()
|
||||
QString CMakeEditor::contextHelpId() const
|
||||
{
|
||||
int pos = position();
|
||||
BaseTextDocument *doc = const_cast<CMakeEditor*>(this)->textDocument();
|
||||
|
||||
QChar chr;
|
||||
do {
|
||||
--pos;
|
||||
if (pos < 0)
|
||||
break;
|
||||
chr = doc->characterAt(pos);
|
||||
chr = characterAt(pos);
|
||||
if (chr == QLatin1Char('('))
|
||||
return QString();
|
||||
} while (chr.unicode() != QChar::ParagraphSeparator);
|
||||
|
||||
++pos;
|
||||
chr = doc->characterAt(pos);
|
||||
chr = characterAt(pos);
|
||||
while (chr.isSpace()) {
|
||||
++pos;
|
||||
chr = doc->characterAt(pos);
|
||||
chr = characterAt(pos);
|
||||
}
|
||||
int begin = pos;
|
||||
|
||||
do {
|
||||
++pos;
|
||||
chr = doc->characterAt(pos);
|
||||
chr = characterAt(pos);
|
||||
} while (chr.isLetterOrNumber() || chr == QLatin1Char('_'));
|
||||
int end = pos;
|
||||
|
||||
while (chr.isSpace()) {
|
||||
++pos;
|
||||
chr = doc->characterAt(pos);
|
||||
chr = characterAt(pos);
|
||||
}
|
||||
|
||||
// Not a command
|
||||
if (chr != QLatin1Char('('))
|
||||
return QString();
|
||||
|
||||
QString command = doc->textAt(begin, end - begin).toLower();
|
||||
QString command = textAt(begin, end - begin).toLower();
|
||||
return QLatin1String("command/") + command;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user