MCPcopy Create free account
hub / github.com/baldurk/renderdoc / interactive_keypress

Method interactive_keypress

qrenderdoc/Windows/PythonShell.cpp:1385–1493  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1383}
1384
1385void PythonShell::interactive_keypress(QKeyEvent *event)
1386{
1387 if(event->key() == Qt::Key_Tab)
1388 {
1389 QString base = ui->lineInput->text();
1390 if(!base.isEmpty() && !base.rbegin()->isSpace())
1391 {
1392 // search backwards from the end for the first non dotted identifier first, and extract that
1393 // substring. This is just ASCII, not unicode
1394 for(int i = base.count() - 1; i >= 0; i--)
1395 {
1396 if(!base[i].isLetterOrNumber() && base[i] != QLatin1Char('.') && base[i] != QLatin1Char('_'))
1397 {
1398 base = base.right(base.count() - 1 - i);
1399 break;
1400 }
1401 }
1402
1403 // skip any initial digits that got included in the coarse search above
1404 while(!base.isEmpty() && base[0].isDigit())
1405 base.remove(0, 1);
1406
1407 QStringList options = interactiveContext->completionOptions(base);
1408
1409 QString line = ui->lineInput->text();
1410
1411 if(!options.isEmpty())
1412 {
1413 QString commonSubstring = options[0];
1414
1415 for(int i = 1; i < options.count(); i++)
1416 {
1417 const QString &opt = options[i];
1418 if(opt.count() < commonSubstring.count())
1419 commonSubstring.truncate(opt.count());
1420
1421 for(int j = 0; j < commonSubstring.count(); j++)
1422 {
1423 if(commonSubstring[j] != opt[j])
1424 {
1425 commonSubstring.truncate(j);
1426 break;
1427 }
1428 }
1429 }
1430
1431 if(commonSubstring.length() > base.length())
1432 {
1433 line.chop(base.length());
1434 line += commonSubstring;
1435 ui->lineInput->setText(line);
1436 }
1437
1438 if(options.count() > 1)
1439 {
1440 QString text;
1441 text += line;
1442 text += lit("\n");

Callers

nothing calls this directly

Calls 14

QLatin1CharClass · 0.85
completionOptionsMethod · 0.80
chopMethod · 0.80
keyMethod · 0.45
textMethod · 0.45
isEmptyMethod · 0.45
rbeginMethod · 0.45
countMethod · 0.45
rightMethod · 0.45
removeMethod · 0.45
truncateMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected