Exemplo n.º 1
0
bool MANFrame::SearchManPage(const wxString &dirs, const wxString &keyword)
{
    SetDirs(dirs);

    if (keyword.IsEmpty())
    {
        if (m_dirsVect.empty())
        {
            SetPage(NoSearchDirsSet);
        }

        return false;
    }

    std::vector<wxString> files_found;

    GetMatches(keyword, &files_found);
    m_entry->SetValue(keyword);

    if (files_found.empty())
    {
        SetPage(ManPageNotFound);
        return false;
    }

    if (files_found.size() == 1)
    {
        wxString filename = files_found.front();
        wxString man_page = GetManPage(filename);

        if (man_page.IsEmpty())
        {
            SetPage(ManPageNotFound);
            return false;
        }

        SetPage(cbC2U(man2html_buffer(cbU2C(man_page))));
        return true;
    }

    SetPage(CreateLinksPage(files_found));

    return true;
}
Exemplo n.º 2
0
void MANFrame::OnLinkClicked(wxHtmlLinkEvent &event)
{
    wxString link = event.GetLinkInfo().GetHref();

    if (link.StartsWith(_T("man:"), &link))
    {
        if (link.Last() == _T(')'))
        {
            link.RemoveLast();
            wxString name = link.BeforeLast(_T('('));

            if (name.IsEmpty())
            {
                return;
            }

            wxString section = link.AfterLast(_T('('));

            if (!section.IsEmpty())
            {
                name += _T(".") + section;
            }

            SearchManPage(name);
        }
    }
    else if (link.StartsWith(_T("fman:"), &link))
    {
        wxString man_page = GetManPage(link);

        if (man_page.IsEmpty())
        {
            SetPage(ManPageNotFound);
            return;
        }

        SetPage(cbC2U(man2html_buffer(cbU2C(man_page))));
    }
    else if (wxFileName(link).GetExt().Mid(0, 3).CmpNoCase(_T("htm")) == 0)
    {
    	m_htmlWindow->LoadPage(link);
    }
}