| 1527 | } |
| 1528 | |
| 1529 | void PythonShell::startAutocomplete() |
| 1530 | { |
| 1531 | sptr_t pos = scriptEditor->currentPos(); |
| 1532 | sptr_t line = scriptEditor->lineFromPosition(pos); |
| 1533 | sptr_t lineStart = scriptEditor->positionFromLine(line); |
| 1534 | QByteArray lineText = scriptEditor->getLine(line); |
| 1535 | |
| 1536 | sptr_t end = pos - lineStart - 1; |
| 1537 | sptr_t start; |
| 1538 | for(start = end; start >= 0; start--) |
| 1539 | { |
| 1540 | char c = lineText[(int)start]; |
| 1541 | if(QChar::fromLatin1(c).isLetterOrNumber() || c == '.' || c == '_') |
| 1542 | continue; |
| 1543 | |
| 1544 | start++; |
| 1545 | break; |
| 1546 | } |
| 1547 | |
| 1548 | QString comp = QString::fromUtf8(lineText.mid(start, end - start + 1)); |
| 1549 | |
| 1550 | PythonContext *context = newImportedDummyContext(); |
| 1551 | |
| 1552 | QStringList completions = context->completionOptions(comp); |
| 1553 | |
| 1554 | context->Finish(); |
| 1555 | |
| 1556 | scriptEditor->autoCShow(comp.count(), completions.join(QLatin1Char(' ')).toUtf8().data()); |
| 1557 | } |
| 1558 | |
| 1559 | PythonContext *PythonShell::newImportedDummyContext() |
| 1560 | { |
nothing calls this directly
no test coverage detected