regExp.indexIn(leftOfCursor); auto rexExpCapturedTexts = regExp.capturedTexts(); auto memberOf = rexExpCapturedTexts[MODULE_INDEX]; completionPrefix = rexExpCapturedTexts[PROPERTY_INDEX]; bool switchedModule = false; if (memberOf != _completerModule) { _completerModule = memberOf; auto autoCompleteModel = getAutoCompleteModel(memberOf); if (autoCompleteModel == nullptr) { _completer->popup()->hide(); return false; } _completer->setModel(autoCompleteModel); _completer->popup()->installEventFilter(this); switchedModule = true; } if (switchedModule || completionPrefix != _completer->completionPrefix()) { _completer->setCompletionPrefix(completionPrefix); _completer->popup()->setCurrentIndex(_completer->completionModel()->index(0, 0)); } auto cursorRect = _ui->promptTextEdit->cursorRect(); cursorRect.setWidth(_completer->popup()->sizeHintForColumn(0) + _completer->popup()->verticalScrollBar()->sizeHint().width()); _completer->complete(cursorRect); highlightedCompletion(_completer->popup()->currentIndex()); return false; } } return false;} void JSConsole::setToNextCommandInHistory() { if (_currentCommandInHistory >= 0) { _currentCommandInHistory--; if (_currentCommandInHistory == NO_CURRENT_HISTORY_COMMAND) { setAndSelectCommand(_rootCommand); } else { setAndSelectCommand(_commandHistory[_currentCommandInHistory]); } }} void JSConsole::setToPreviousCommandInHistory() { if (_currentCommandInHistory < (_commandHistory.length() - 1)) { if (_currentCommandInHistory == NO_CURRENT_HISTORY_COMMAND) { _rootCommand = _ui->promptTextEdit->toPlainText(); } _currentCommandInHistory++; setAndSelectCommand(_commandHistory[_currentCommandInHistory]); }} void JSConsole::resetCurrentCommandHistory() { _currentCommandInHistory = NO_CURRENT_HISTORY_COMMAND;} void JSConsole::resizeTextInput() { _ui->promptTextEdit->setFixedHeight(_ui->promptTextEdit->document()->size().height()); _ui->promptTextEdit->updateGeometry();} void JSConsole::setAndSelectCommand(const QString& text) { QTextCursor cursor = _ui->promptTextEdit->textCursor(); cursor.select(QTextCursor::Document); cursor.deleteChar(); cursor.insertText(text); cursor.movePosition(QTextCursor::End);} void JSConsole::scrollToBottom() { QScrollBar* scrollBar = _ui->scrollArea->verticalScrollBar(); scrollBar->setValue(scrollBar->maximum());} void JSConsole::appendMessage(const QString& gutter, const QString& message) { QWidget* logLine = new QWidget(_ui->logArea); QHBoxLayout* layout = new QHBoxLayout(logLine); layout->setMargin(0); layout->setSpacing(4); QLabel* gutterLabel = new QLabel(logLine); QLabel* messageLabel = new QLabel(logLine); gutterLabel->setFixedWidth(16); gutterLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); messageLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); gutterLabel->setStyleSheet("font-size: 14px; font-family: Inconsolata, Lucida Console, Andale Mono, Monaco;"); messageLabel->setStyleSheet("font-size: 14px; font-family: Inconsolata, Lucida Console, Andale Mono, Monaco;"); gutterLabel->setText(gutter); messageLabel->setText(message); layout->addWidget(gutterLabel); layout->addWidget(messageLabel); logLine->setLayout(layout); layout->setAlignment(gutterLabel, Qt::AlignTop); layout->setStretch(0, 0); layout->setStretch(1, 1); _ui->logArea->layout()->addWidget(logLine); _ui->logArea->updateGeometry(); scrollToBottom();} void JSConsole::clear() { QLayoutItem* item; while ((item = _ui->logArea->layout()->takeAt(0)) != nullptr) { delete item->widget(); delete item; } _ui->logArea->updateGeometry(); scrollToBottom();}Lines 501–618 of 618. Previous lines
regExp.indexIn(leftOfCursor); auto rexExpCapturedTexts = regExp.capturedTexts(); auto memberOf = rexExpCapturedTexts[MODULE_INDEX]; completionPrefix = rexExpCapturedTexts[PROPERTY_INDEX]; bool switchedModule = false; if (memberOf != _completerModule) { _completerModule = memberOf; auto autoCompleteModel = getAutoCompleteModel(memberOf); if (autoCompleteModel == nullptr) { _completer->popup()->hide(); return false; } _completer->setModel(autoCompleteModel); _completer->popup()->installEventFilter(this); switchedModule = true; } if (switchedModule || completionPrefix != _completer->completionPrefix()) { _completer->setCompletionPrefix(completionPrefix); _completer->popup()->setCurrentIndex(_completer->completionModel()->index(0, 0)); } auto cursorRect = _ui->promptTextEdit->cursorRect(); cursorRect.setWidth(_completer->popup()->sizeHintForColumn(0) + _completer->popup()->verticalScrollBar()->sizeHint().width()); _completer->complete(cursorRect); highlightedCompletion(_completer->popup()->currentIndex()); return false; } } return false; } void JSConsole::setToNextCommandInHistory() { if (_currentCommandInHistory >= 0) { _currentCommandInHistory--; if (_currentCommandInHistory == NO_CURRENT_HISTORY_COMMAND) { setAndSelectCommand(_rootCommand); } else { setAndSelectCommand(_commandHistory[_currentCommandInHistory]); } } } void JSConsole::setToPreviousCommandInHistory() { if (_currentCommandInHistory < (_commandHistory.length() - 1)) { if (_currentCommandInHistory == NO_CURRENT_HISTORY_COMMAND) { _rootCommand = _ui->promptTextEdit->toPlainText(); } _currentCommandInHistory++; setAndSelectCommand(_commandHistory[_currentCommandInHistory]); } } void JSConsole::resetCurrentCommandHistory() { _currentCommandInHistory = NO_CURRENT_HISTORY_COMMAND; } void JSConsole::resizeTextInput() { _ui->promptTextEdit->setFixedHeight(_ui->promptTextEdit->document()->size().height()); _ui->promptTextEdit->updateGeometry(); } void JSConsole::setAndSelectCommand(const QString& text) { QTextCursor cursor = _ui->promptTextEdit->textCursor(); cursor.select(QTextCursor::Document); cursor.deleteChar(); cursor.insertText(text); cursor.movePosition(QTextCursor::End); } void JSConsole::scrollToBottom() { QScrollBar* scrollBar = _ui->scrollArea->verticalScrollBar(); scrollBar->setValue(scrollBar->maximum()); } void JSConsole::appendMessage(const QString& gutter, const QString& message) { QWidget* logLine = new QWidget(_ui->logArea); QHBoxLayout* layout = new QHBoxLayout(logLine); layout->setMargin(0); layout->setSpacing(4); QLabel* gutterLabel = new QLabel(logLine); QLabel* messageLabel = new QLabel(logLine); gutterLabel->setFixedWidth(16); gutterLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); messageLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); gutterLabel->setStyleSheet("font-size: 14px; font-family: Inconsolata, Lucida Console, Andale Mono, Monaco;"); messageLabel->setStyleSheet("font-size: 14px; font-family: Inconsolata, Lucida Console, Andale Mono, Monaco;"); gutterLabel->setText(gutter); messageLabel->setText(message); layout->addWidget(gutterLabel); layout->addWidget(messageLabel); logLine->setLayout(layout); layout->setAlignment(gutterLabel, Qt::AlignTop); layout->setStretch(0, 0); layout->setStretch(1, 1); _ui->logArea->layout()->addWidget(logLine); _ui->logArea->updateGeometry(); scrollToBottom(); } void JSConsole::clear() { QLayoutItem* item; while ((item = _ui->logArea->layout()->takeAt(0)) != nullptr) { delete item->widget(); delete item; } _ui->logArea->updateGeometry(); scrollToBottom(); }