bool KateApp::openInput (const QString &text) { activeMainWindow()->viewManager()->openUrl( KUrl(), "", true ); if (!activeMainWindow()->viewManager()->activeView ()) return false; KTextEditor::Document *doc = activeMainWindow()->viewManager()->activeView ()->document(); if (!doc) return false; return doc->setText (text); }
void ModelTest::testCompletionRangeSecondLine() { KTextEditor::Document* doc = KTextEditor::Editor::instance()->createDocument(0); doc->setText("body{color:red;}\nbody{font-w:normal;}"); // 01234567890123456789 KTextEditor::View* view = doc->createView(0); CodeCompletionModel* model = new CodeCompletionModel(doc); KTextEditor::Cursor position(1, 9); KTextEditor::Range range = model->completionRange(view, position); kDebug() << range << doc->text(range); QCOMPARE(range, KTextEditor::Range(1, 5, 1, 11)); QCOMPARE(doc->text(range), QString("font-w")); delete doc; }