示例#1
0
void GolangEdit::editorViewGodoc()
{
    LiteApi::ITextLexer *textLexer = LiteApi::getTextLexer(m_editor);
    if (!textLexer) {
        return;
    }
    QTextCursor cursor = m_editor->textCursor();
    bool b = textLexer->isInImport(cursor);
    if (!b) {
        return;
    }
    QString pkg = parser_import(cursor.block().text());
    if (pkg.isEmpty()) {
        return;
    }
    LiteApi::IGolangDoc *doc = LiteApi::getGolangDoc(m_liteApp);
    if (!doc) {
        return;
    }
    QUrl url;
    url.setScheme("pdoc");
    url.setPath(pkg);
    doc->openUrl(url);
    doc->activeBrowser();
}
示例#2
0
void WelcomeBrowser::openUrl(const QUrl &url)
{
    m_liteApp->mainWindow()->statusBar()->clearMessage();

    if (url.scheme() == "http" ||
            url.scheme() == "https" ||
            url.scheme() == "mailto") {
        QDesktopServices::openUrl(url);
    } else if (url.scheme() == "session") {
        m_liteApp->loadSession(url.path());
    } else if (url.scheme() == "proj") {
        m_liteApp->fileManager()->openProject(url.path());
    } else if (url.scheme() == "file") {
        m_liteApp->fileManager()->openEditor(url.path());
    } else if (url.scheme() == "folder") {
        m_liteApp->fileManager()->openFolderProject(url.path());
    }else if (url.scheme() == "doc") {
        LiteApi::ILiteDoc *doc = LiteApi::findExtensionObject<LiteApi::ILiteDoc*>(m_liteApp,"LiteApi.ILiteDoc");
        if (doc) {
            doc->openUrl(url.path());
            doc->activeBrowser();
        }
    } else if (url.scheme() == "godoc") {
        LiteApi::IGolangDoc *doc = LiteApi::findExtensionObject<LiteApi::IGolangDoc*>(m_liteApp,"LiteApi.IGolangDoc");
        if (doc) {
            doc->openUrl(url.path());
            doc->activeBrowser();
        }
    } else if (url.scheme() == "goplay") {
        LiteApi::IEditor *browser = LiteApi::findExtensionObject<LiteApi::IEditor*>(m_liteApp,"LiteApi.Goplay");
        if (browser) {
            m_liteApp->editorManager()->activeBrowser(browser);
        }
    }
}
示例#3
0
void FileBrowser::viewGodoc()
{
    QDir dir = contextDir();
    LiteApi::IGolangDoc *doc = LiteApi::findExtensionObject<LiteApi::IGolangDoc*>(m_liteApp,"LiteApi.IGolangDoc");
    if (doc) {
        QUrl url;
        url.setScheme("pdoc");
        url.setPath(dir.path());
        doc->openUrl(url);
        doc->activeBrowser();
    }
}