Changeset 5711

Show
Ignore:
Timestamp:
05/01/09 19:56:36 (3 years ago)
Author:
westram
Message:
  • can show *.pdf from ARB help (done same way as *ps)
  • arb.ps -> arb.pdf
  • help history
    • wrap around
    • dont add pages twice
    • get_full_qualified_help_file_name now returns "" if helpfilename is "" (previously return help directory, which was added to help history then)
    • do not delete help-history when a 'HELP' button is pressed
Location:
trunk
Files:
1 added
2 removed
13 modified

Legend:

Unmodified
Added
Removed
  • trunk/ARBDB/ad_prot.h

    r5708 r5711  
    291291GB_CSTR GB_getenvPATH P_((void)); 
    292292GB_CSTR GB_getenvARB_GS P_((void)); 
     293GB_CSTR GB_getenvARB_PDFVIEW P_((void)); 
    293294GB_CSTR GB_getenvARB_TEXTEDIT P_((void)); 
    294295GB_CSTR GB_getenvDOCPATH P_((void)); 
  • trunk/ARBDB/adsocket.c

    r5708 r5711  
    10481048} 
    10491049 
     1050GB_CSTR GB_getenvARB_PDFVIEW(void) { 
     1051    static const char *pdfview = 0; 
     1052    if (!pdfview) { 
     1053        pdfview = getenv_executable("ARB_PDFVIEW"); // doc in arb_envar.hlp 
     1054        if (!pdfview) pdfview = GB_find_executable("PDF viewer", "epdfview", "xpdf", "kpdf", "acroread", "gv", NULL); 
     1055    } 
     1056    return pdfview; 
     1057} 
     1058 
    10501059GB_CSTR GB_getenvARB_TEXTEDIT(void) { 
    10511060    static const char *editor = 0; 
     
    10871096        if (strcmp(env, "ARBHOME")      == 0) return GB_getenvARBHOME(); 
    10881097        if (strcmp(env, "ARB_GS")       == 0) return GB_getenvARB_GS(); 
     1098        if (strcmp(env, "ARB_PDFVIEW")  == 0) return GB_getenvARB_PDFVIEW(); 
    10891099        if (strcmp(env, "ARB_DOC")      == 0) return GB_getenvDOCPATH(); 
    10901100        if (strcmp(env, "ARB_TEXTEDIT") == 0) return GB_getenvARB_TEXTEDIT(); 
  • trunk/HELP_SOURCE/arb_help2xml.cxx

    r5708 r5711  
    373373    // cuts off the '.hlp' 
    374374    size_t pos   = s.find(".hlp"); 
    375     if ((pos+4) != s.length()) { 
    376         pos          = s.find(".ps"); 
    377         if ((pos+3) == s.length()) return s; // accept .ps 
    378         throw string("Expected extension .hlp"); 
    379     } 
    380     return string(s, 0, s.length()-4); 
     375    if ((pos+4) == s.length()) { 
     376        return string(s, 0, s.length()-4); 
     377    } 
     378 
     379    pos = s.find(".ps"); 
     380    if ((pos+3) == s.length()) { 
     381        return s; // accept .ps 
     382    } 
     383 
     384    pos = s.find(".pdf"); 
     385    if ((pos+4) == s.length()) { 
     386        return s; // accept .pdf 
     387    } 
     388     
     389    throw string("Expected extension .hlp"); 
    381390} 
    382391inline void check_duplicates(const string& link, const char */*where*/, const Links& existing, bool add_warnings) { 
  • trunk/HELP_SOURCE/oldhelp/arb.hlp

    r5260 r5711  
    66UP      arb_commands.hlp 
    77UP      copyright.hlp 
    8 UP      arb.ps 
     8UP      arb.pdf 
    99UP      changes.hlp 
    1010 
  • trunk/HELP_SOURCE/oldhelp/arb_envar.hlp

    r2986 r5711  
    6464                            (default: 'gv' or 'ghostview') 
    6565 
     66                    ARB_PDFVIEW 
     67 
     68                            name of pdf viewer used by ARB 
     69                            (default: 'epdfview' or 'acroread' or 'gv') 
     70 
    6671                    ARB_WORKDIR 
    6772 
     
    7176                    ARB_DOC 
    7277 
    73                             directory where ARB searches for *.ps or *.ps.gz 
    74                             (default: $ARBHOME/lib/help) 
     78                            directory where ARB searches for *.ps, *.ps.gz, *.pdf 
     79                            and *.pdf.gz (default: $ARBHOME/lib/help) 
    7580 
    7681NOTES           Short description of how to set an environment variable: 
  • trunk/HELP_SOURCE/oldhelp/consensus.ps.gz

    • Property svn:mime-type changed from application/octet-stream to application/x-gzip
  • trunk/HELP_SOURCE/oldhelp/pos_variability.ps.gz

    • Property svn:mime-type changed from application/octet-stream to application/x-gzip
  • trunk/HELP_SOURCE/oldhelp/rna3d_general.hlp

    r4186 r5711  
    22UP      arb.hlp 
    33UP      glossary.hlp 
    4 UP  rna3d_manual.ps 
     4UP      rna3d_manual.pdf 
    55 
    66#Please insert subtopic references  (line starts with keyword SUB) 
    77#SUB    subtopic.hlp 
    8 SUB rna3d_dispMolecule.hlp 
    9 SUB rna3d_dispBases.hlp 
    10 SUB rna3d_dispHelices.hlp 
    11 SUB rna3d_mapSeqData.hlp 
     8SUB     rna3d_dispMolecule.hlp 
     9SUB     rna3d_dispBases.hlp 
     10SUB     rna3d_dispHelices.hlp 
     11SUB     rna3d_mapSeqData.hlp 
    1212 
    1313# Hypertext links in helptext can be added like this: LINK{ref.hlp|http://add|bla@domain} 
  • trunk/HELP_SOURCE/oldhelp/rna3d_manual.pdf.gz

    • Property svn:mime-type changed from application/octet-stream to application/x-gzip
  • trunk/HELP_SOURCE/to_help.xsl

    r3414 r5711  
    9696    <xsl:choose> 
    9797      <xsl:when test="string-length(substring-before($doc,'.ps'))&gt;0"> <!--it's a postscript link--> 
    98         <value-of select="{concat($postscriptpath,$doc,'.gz')}"/> 
     98        <xsl:text>Postscript: </xsl:text> 
     99        <xsl:value-of select="$doc"/> 
     100      </xsl:when> 
     101      <xsl:when test="string-length(substring-before($doc,'.pdf'))&gt;0"> <!--it's a PDF link--> 
     102        <xsl:text>PDF: </xsl:text> 
     103        <xsl:value-of select="$doc"/> 
    99104      </xsl:when> 
    100105      <xsl:otherwise> 
     
    121126 
    122127    <xsl:value-of select="$dest"/> 
    123     <xsl:if test="substring-before($dest,'.ps')=''"> <!-- not postscript: add .hlp --> 
    124       <xsl:text>.hlp</xsl:text> 
     128    <xsl:if test="substring-before($dest,'.ps')=''"> <!-- not postscript .. --> 
     129      <xsl:if test="substring-before($dest,'.pdf')=''"> <!-- .. or pdf .. --> 
     130        <xsl:text>.hlp</xsl:text> <!-- .. -> add .hlp --> 
     131      </xsl:if> 
    125132    </xsl:if> 
    126133    <xsl:text>&br;</xsl:text> 
  • trunk/HELP_SOURCE/to_html.xsl

    r5504 r5711  
    3737    <xsl:value-of select="$rootpath"/><xsl:text>../help/</xsl:text> 
    3838  </xsl:variable> 
     39  <xsl:variable name="pdfpath"><xsl:value-of select="$postscriptpath"/></xsl:variable> 
    3940 
    4041  <xsl:variable name="tableBorder">0</xsl:variable> 
     
    147148        <A href="{concat($postscriptpath,$doc,'.gz')}"> 
    148149          <xsl:value-of select="$doc"/> (Postscript) 
     150        </A> 
     151      </xsl:when> 
     152      <xsl:when test="string-length(substring-before($doc,'.pdf'))&gt;0"> <!--it's a pdf link--> 
     153        <A href="{concat($pdfpath,$doc,'.gz')}"> 
     154          <xsl:value-of select="$doc"/> (PDF) 
    149155        </A> 
    150156      </xsl:when> 
  • trunk/WINDOW/AW_status.cxx

    r5710 r5711  
    15191519        if (!rel_path) rel_path = helpfile; 
    15201520 
    1521         if (path_for_edit) { 
     1521        if (rel_path[0]) { 
     1522            if (path_for_edit) { 
    15221523#if defined(DEBUG) 
    1523             char *gen_doc_path = GB_strdup(GB_path_in_ARBHOME("HELP_SOURCE/genhelp", NULL)); 
    1524  
    1525             char *devel_source = GBS_global_string_copy("%s/%s", devel_doc_path, rel_path); 
    1526             char *gen_source   = GBS_global_string_copy("%s/%s", gen_doc_path, rel_path); 
    1527  
    1528             int devel_size = GB_size_of_file(devel_source); 
    1529             int gen_size   = GB_size_of_file(gen_source); 
    1530  
    1531             gb_assert(devel_size <= 0 || gen_size <= 0); // only one of them shall exist 
    1532  
    1533             if (gen_size>0) { 
    1534                 result = GBS_global_string("%s", gen_source); // edit generated doc 
     1524                char *gen_doc_path = GB_strdup(GB_path_in_ARBHOME("HELP_SOURCE/genhelp", NULL)); 
     1525 
     1526                char *devel_source = GBS_global_string_copy("%s/%s", devel_doc_path, rel_path); 
     1527                char *gen_source   = GBS_global_string_copy("%s/%s", gen_doc_path, rel_path); 
     1528 
     1529                int devel_size = GB_size_of_file(devel_source); 
     1530                int gen_size   = GB_size_of_file(gen_source); 
     1531 
     1532                gb_assert(devel_size <= 0 || gen_size <= 0); // only one of them shall exist 
     1533 
     1534                if (gen_size>0) { 
     1535                    result = GBS_global_string("%s", gen_source); // edit generated doc 
     1536                } 
     1537                else { 
     1538                    result = GBS_global_string("%s", devel_source); // use normal help source (may be non-existing) 
     1539                } 
     1540 
     1541                free(gen_source); 
     1542                free(devel_source); 
     1543                free(gen_doc_path); 
     1544#else             
     1545                result = GBS_global_string("%s/%s", GB_getenvDOCPATH(), rel_path); // use real help file in RELEASE 
     1546#endif // DEBUG 
    15351547            } 
    15361548            else { 
    1537                 result = GBS_global_string("%s", devel_source); // use normal help source (may be non-existing) 
    1538             } 
    1539  
    1540             free(gen_source); 
    1541             free(devel_source); 
    1542             free(gen_doc_path); 
    1543 #else             
    1544             result = GBS_global_string("%s/%s", GB_getenvDOCPATH(), rel_path); // use real help file in RELEASE 
    1545 #endif // DEBUG 
     1549                result = GBS_global_string("%s/%s", GB_getenvDOCPATH(), rel_path); 
     1550            } 
    15461551        } 
    15471552        else { 
    1548             result = GBS_global_string("%s/%s", GB_getenvDOCPATH(), rel_path); 
    1549         } 
    1550     } 
    1551  
    1552 #if defined(DEBUG) 
    1553     printf("Helpfile='%s'\n", result); 
    1554 #endif // DEBUG 
     1553            result = ""; 
     1554        } 
     1555    } 
    15551556 
    15561557    free(devel_doc_path); 
     
    16511652} 
    16521653 
    1653 static void aw_help_new_helpfile(AW_root *awr) { 
     1654static void aw_help_select_newest_in_history(AW_root *aw_root) { 
     1655    char *history = aw_help_global.history; 
     1656    if (history) { 
     1657        const char *sep      = strchr(history, '#'); 
     1658        char       *lastHelp = sep ? GB_strpartdup(history, sep-1) : strdup(history); 
     1659 
     1660        aw_root->awar("tmp/aw_window/helpfile")->write_string(lastHelp); 
     1661        free(lastHelp); 
     1662    } 
     1663} 
     1664 
     1665static void aw_help_back(AW_root *aw_root) { 
     1666    char *history = aw_help_global.history; 
     1667    if (history) { 
     1668        const char *sep = strchr(history, '#'); 
     1669        if (sep) { 
     1670            char *first   = GB_strpartdup(history, sep-1); 
     1671            char *newhist = GBS_global_string_copy("%s#%s", sep+1, first); // wrap first to end 
     1672 
     1673            free(aw_help_global.history); 
     1674            aw_help_global.history = newhist; 
     1675 
     1676            free(first); 
     1677             
     1678            aw_help_select_newest_in_history(aw_root); 
     1679        } 
     1680    } 
     1681} 
     1682static void aw_help_back(AW_window *aww) { aw_help_back(aww->get_root()); } 
     1683 
     1684static GB_ERROR aw_help_show_external_format(const char *help_file, const char *viewer) { 
     1685    // Called to show *.ps or *.pdf in external viewer. 
     1686    // Can as well show *.suffix.gz (decompresses to temporary *.suffix) 
     1687     
     1688    struct stat st; 
     1689    GB_ERROR    error = NULL; 
     1690    char        sys[1024]; 
     1691 
     1692    sys[0] = 0; 
     1693 
     1694    if (stat(help_file, &st) == 0) { // *.ps exists 
     1695        GBS_global_string_to_buffer(sys, sizeof(sys), "%s %s &", viewer, help_file); 
     1696    } 
     1697    else { 
     1698        char *compressed = GBS_global_string_copy("%s.gz", help_file); 
     1699 
     1700        if (stat(compressed, &st) == 0) { // *.ps.gz exists 
     1701            char *name_ext; 
     1702            GB_split_full_path(compressed, NULL, NULL, &name_ext, NULL); 
     1703            // 'name_ext' contains xxx.ps or xxx.pdf 
     1704            char *name, *suffix; 
     1705            GB_split_full_path(name_ext, NULL, NULL, &name, &suffix); 
     1706 
     1707            char *tempname     = GB_unique_filename(name, suffix); 
     1708            char *uncompressed = GB_create_tempfile(tempname); 
     1709                 
     1710            GBS_global_string_to_buffer(sys, sizeof(sys), 
     1711                                        "(gunzip <%s >%s ; %s %s ; rm %s) &", 
     1712                                        compressed, uncompressed, 
     1713                                        viewer, uncompressed, 
     1714                                        uncompressed); 
     1715 
     1716            free(uncompressed); 
     1717            free(tempname); 
     1718            free(name); 
     1719            free(suffix); 
     1720            free(name_ext); 
     1721        } 
     1722        else { 
     1723            error = GBS_global_string("Neither %s nor %s exists", help_file, compressed); 
     1724        } 
     1725        free(compressed); 
     1726    } 
     1727 
     1728    if (sys[0] && !error) error = GB_system(sys); 
     1729 
     1730    return error; 
     1731} 
     1732 
     1733static void aw_help_helpfile_changed_cb(AW_root *awr) { 
    16541734    char *help_file = get_full_qualified_help_file_name(awr); 
    16551735 
     
    16581738    } 
    16591739    else if (GBS_string_matches(help_file,"*.ps",GB_IGNORE_CASE) ){ // Postscript file 
    1660         struct stat st; 
    1661         GB_ERROR    error = 0; 
    1662         char        sys[1024]; 
    1663          
    1664         sys[0] = 0; 
    1665  
    1666         if (stat(help_file, &st) == 0) { // *.ps exists 
    1667             GBS_global_string_to_buffer(sys, sizeof(sys), "%s %s &", GB_getenvARB_GS(), help_file); 
    1668         } 
    1669         else { 
    1670             char *compressed = GBS_global_string_copy("%s.gz", help_file); 
    1671  
    1672             if (stat(compressed, &st) == 0) { // *.ps.gz exists 
    1673                 char *name_ps; 
    1674                 GB_split_full_path(compressed, NULL, NULL, &name_ps, NULL); 
    1675                 // 'name_ps' contains xxx.ps 
    1676                 char *name, *suffix; 
    1677                 GB_split_full_path(name_ps, NULL, NULL, &name, &suffix); 
    1678  
    1679                 char *tempname     = GB_unique_filename(name, suffix); 
    1680                 char *uncompressed = GB_create_tempfile(tempname); 
    1681                  
    1682                 GBS_global_string_to_buffer(sys, sizeof(sys), 
    1683                                             "(gunzip <%s >%s ; %s %s ; rm %s) &", 
    1684                                             compressed, uncompressed, 
    1685                                             GB_getenvARB_GS(), uncompressed, 
    1686                                             uncompressed); 
    1687  
    1688                 free(uncompressed); 
    1689                 free(tempname); 
    1690                 free(name); 
    1691                 free(suffix); 
    1692                 free(name_ps); 
    1693             } 
    1694             else { 
    1695                 sprintf(AW_ERROR_BUFFER, "Neither %s nor %s where found", help_file, compressed); 
    1696                 aw_message(); 
    1697             } 
    1698             free(compressed); 
    1699         } 
    1700  
    1701         if (sys[0] && !error) error = GB_system(sys); 
     1740        GB_ERROR error = aw_help_show_external_format(help_file, GB_getenvARB_GS()); 
    17021741        if (error) aw_message(error); 
     1742        aw_help_select_newest_in_history(awr); 
     1743    } 
     1744    else if (GBS_string_matches(help_file,"*.pdf",GB_IGNORE_CASE) ){ // PDF file 
     1745        GB_ERROR error = aw_help_show_external_format(help_file, GB_getenvARB_PDFVIEW()); 
     1746        if (error) aw_message(error); 
     1747        aw_help_select_newest_in_history(awr); 
    17031748    } 
    17041749    else{ 
    17051750        if (aw_help_global.history){ 
    1706             if (strncmp(help_file,aw_help_global.history,strlen(help_file))){ 
    1707                 char comm[1024]; 
    1708                 char *h; 
    1709                 sprintf(comm,"*=%s#*1",help_file); 
    1710                 h = GBS_string_eval(aw_help_global.history,comm,0); 
     1751            if (strncmp(help_file,aw_help_global.history,strlen(help_file)) != 0) { 
     1752                // remove current help from history (if present) and prefix it to history 
     1753                char *comm = GBS_global_string_copy("*#%s*=*1*2:*=%s#*1", help_file, help_file); 
     1754                char *h    = GBS_string_eval(aw_help_global.history,comm,0); 
     1755 
     1756                aw_assert(h); 
     1757 
    17111758                free(aw_help_global.history); 
    17121759                aw_help_global.history = h; 
     1760 
     1761                free(comm); 
    17131762            } 
    17141763        } 
     
    17661815    } 
    17671816    free(help_file); 
    1768 } 
    1769  
    1770 static void aw_help_back(AW_window *aww) { 
    1771     if (!aw_help_global.history) return; 
    1772     if (!strchr(aw_help_global.history,'#') ) return; 
    1773     char *newhist = GBS_string_eval(aw_help_global.history,"*#*=*2",0); // delete first 
    1774     free(aw_help_global.history); 
    1775     aw_help_global.history = newhist; 
    1776     char *helpfile = GBS_string_eval(aw_help_global.history,"*#*=*1",0);    // first word 
    1777     aww->get_root()->awar("tmp/aw_window/helpfile")->write_string(helpfile); 
    1778     free(helpfile); 
    17791817} 
    17801818 
     
    18881926} 
    18891927 
    1890 void AW_POPUP_HELP(AW_window *aw,AW_CL /*char */ helpcd) 
    1891 { 
    1892     AW_root *awr=aw->get_root(); 
    1893     static AW_window_simple *helpwindow=0; 
    1894  
    1895  
    1896     char *help_file= (char*)helpcd; 
    1897  
    1898  
    1899     if(!helpwindow) { 
     1928void AW_POPUP_HELP(AW_window *aw,AW_CL /*char */ helpcd) { 
     1929    static AW_window_simple *helpwindow = 0; 
     1930 
     1931    AW_root *awr       = aw->get_root(); 
     1932    char    *help_file = (char*)helpcd; 
     1933 
     1934    if (!helpwindow) { 
    19001935        awr->awar_string( "tmp/aw_window/helptext", "" , AW_ROOT_DEFAULT); 
    19011936        awr->awar_string( "tmp/aw_window/search_expression", "" , AW_ROOT_DEFAULT); 
    19021937        awr->awar_string( "tmp/aw_window/helpfile", "" , AW_ROOT_DEFAULT); 
    1903         awr->awar("tmp/aw_window/helpfile")->add_callback(aw_help_new_helpfile); 
    1904  
    1905         helpwindow=new AW_window_simple; 
     1938        awr->awar("tmp/aw_window/helpfile")->add_callback(aw_help_helpfile_changed_cb); 
     1939 
     1940        helpwindow = new AW_window_simple; 
    19061941        helpwindow->init(awr,"HELP","HELP WINDOW"); 
    19071942        helpwindow->load_xfig("help.fig"); 
     
    19491984 
    19501985    } 
    1951     free(aw_help_global.history); 
    1952     aw_help_global.history = 0; 
    1953  
    1954     awr->awar("tmp/aw_window/helpfile")->write_string(""); 
    1955     if(help_file) awr->awar("tmp/aw_window/helpfile")->write_string(help_file); 
    1956     if (GBS_string_matches(help_file,"*.ps",GB_IGNORE_CASE)) return;// dont open help if postscript file 
    1957     helpwindow->show(); 
     1986 
     1987    aw_assert(help_file); 
     1988 
     1989    awr->awar("tmp/aw_window/helpfile")->write_string(help_file); 
     1990     
     1991    if (!GBS_string_matches(help_file,"*.ps",GB_IGNORE_CASE) && 
     1992        !GBS_string_matches(help_file,"*.pdf",GB_IGNORE_CASE)) 
     1993    { // dont open help if postscript or pdf file 
     1994        helpwindow->show(); 
     1995    } 
    19581996} 
    19591997 
  • trunk/WINDOW/aw_window.hxx

    r5625 r5711  
    278278    // -------------------------------- 
    279279     
    280     AW_root *get_root(void) { return root; }; 
     280    AW_root *get_root(void) { return root; } 
    281281 
    282282    //******************* Global layout functions **********************