| 153 | } |
| 154 | |
| 155 | void CodeEditor::initEditorService() |
| 156 | { |
| 157 | auto &ctx = dpfInstance.serviceContext(); |
| 158 | QString errStr; |
| 159 | if (!ctx.load(dpfservice::EditorService::name(), &errStr)) { |
| 160 | qCritical() << errStr; |
| 161 | } |
| 162 | EditorService *editorService = dpfGetService(EditorService); |
| 163 | if (!editorService) |
| 164 | return; |
| 165 | |
| 166 | editorService->getSelectedText = std::bind(&WorkspaceWidget::selectedText, workspaceWidget); |
| 167 | editorService->getCursorBeforeText = std::bind(&WorkspaceWidget::cursorBeforeText, workspaceWidget); |
| 168 | editorService->getCursorBehindText = std::bind(&WorkspaceWidget::cursorBehindText, workspaceWidget); |
| 169 | editorService->replaceSelectedText = std::bind(&WorkspaceWidget::replaceSelectedText, workspaceWidget, _1); |
| 170 | editorService->showTips = std::bind(&WorkspaceWidget::showTips, workspaceWidget, _1); |
| 171 | editorService->insertText = std::bind(&WorkspaceWidget::insertText, workspaceWidget, _1); |
| 172 | editorService->undo = std::bind(&WorkspaceWidget::undo, workspaceWidget); |
| 173 | editorService->modifiedFiles = std::bind(&WorkspaceWidget::modifiedFiles, workspaceWidget); |
| 174 | editorService->saveAll = std::bind(&WorkspaceWidget::saveAll, workspaceWidget); |
| 175 | editorService->currentFile = std::bind(&WorkspaceWidget::currentFile, workspaceWidget); |
| 176 | editorService->setText = std::bind(&WorkspaceWidget::setText, workspaceWidget, _1); |
| 177 | editorService->registerWidget = std::bind(&WorkspaceWidget::registerWidget, workspaceWidget, _1, _2); |
| 178 | editorService->switchWidget = std::bind(&WorkspaceWidget::switchWidget, workspaceWidget, _1); |
| 179 | editorService->switchDefaultWidget = std::bind(&WorkspaceWidget::switchDefaultWidget, workspaceWidget); |
| 180 | editorService->openedFiles = std::bind(&WorkspaceWidget::openedFiles, workspaceWidget); |
| 181 | editorService->fileText = std::bind(&WorkspaceWidget::fileText, workspaceWidget, _1); |
| 182 | editorService->replaceAll = std::bind(&WorkspaceWidget::replaceAll, workspaceWidget, _1, _2, _3, _4, _5); |
| 183 | editorService->replaceText = std::bind(&WorkspaceWidget::replaceText, workspaceWidget, _1, _2, _3, _4, _5); |
| 184 | editorService->replaceRange = std::bind(&WorkspaceWidget::replaceRange, workspaceWidget, _1, _2, _3); |
| 185 | editorService->backgroundMarkerDefine = std::bind(&WorkspaceWidget::backgroundMarkerDefine, workspaceWidget, _1, _2, _3); |
| 186 | editorService->setRangeBackgroundColor = std::bind(&WorkspaceWidget::setRangeBackgroundColor, workspaceWidget, _1, _2, _3, _4); |
| 187 | editorService->getBackgroundRange = std::bind(&WorkspaceWidget::getBackgroundRange, workspaceWidget, _1, _2); |
| 188 | editorService->clearAllBackgroundColor = std::bind(&WorkspaceWidget::clearAllBackgroundColor, workspaceWidget, _1, _2); |
| 189 | editorService->showLineWidget = std::bind(&WorkspaceWidget::showLineWidget, workspaceWidget, _1, _2); |
| 190 | editorService->closeLineWidget = std::bind(&WorkspaceWidget::closeLineWidget, workspaceWidget); |
| 191 | editorService->cursorPosition = std::bind(&WorkspaceWidget::cursorPosition, workspaceWidget); |
| 192 | editorService->registerDiagnosticRepairTool = std::bind(&ResourceManager::registerDiagnosticRepairTool, ResourceManager::instance(), _1, _2); |
| 193 | editorService->getDiagnosticRepairTool = std::bind(&ResourceManager::getDiagnosticRepairTool, ResourceManager::instance()); |
| 194 | editorService->lineText = std::bind(&WorkspaceWidget::lineText, workspaceWidget, _1, _2); |
| 195 | editorService->eOLAnnotate = std::bind(&WorkspaceWidget::eOLAnnotate, workspaceWidget, _1, _2, _3, _4, _5); |
| 196 | editorService->clearEOLAnnotation = std::bind(&WorkspaceWidget::clearEOLAnnotation, workspaceWidget, _1, _2); |
| 197 | editorService->clearAllEOLAnnotation = std::bind(&WorkspaceWidget::clearAllEOLAnnotation, workspaceWidget, _1); |
| 198 | editorService->annotate = std::bind(&WorkspaceWidget::annotate, workspaceWidget, _1, _2, _3, _4, _5); |
| 199 | editorService->clearAnnotation = std::bind(&WorkspaceWidget::clearAnnotation, workspaceWidget, _1, _2); |
| 200 | editorService->clearAllAnnotation = std::bind(&WorkspaceWidget::clearAllAnnotation, workspaceWidget, _1); |
| 201 | editorService->rangeText = std::bind(&WorkspaceWidget::rangeText, workspaceWidget, _1, _2); |
| 202 | editorService->selectionRange = std::bind(&WorkspaceWidget::selectionRange, workspaceWidget, _1); |
| 203 | editorService->codeRange = std::bind(&WorkspaceWidget::codeRange, workspaceWidget, _1, _2); |
| 204 | editorService->registerInlineCompletionProvider = std::bind(&ResourceManager::registerInlineCompletionProvider, ResourceManager::instance(), _1); |
| 205 | |
| 206 | LexerManager::instance()->init(editorService); |
| 207 | } |
| 208 | |
| 209 | void CodeEditor::initWindowService() |
| 210 | { |