AcePerl
view release on metacpan or search on metacpan
acelib/texthelp.c view on Meta::CPAN
#include "help_.h"
#include "freeout.h"
/********************************************************************/
static void htmlPagePrint (HtmlPage *page);
static void printTextSection (HtmlNode *node);
/********************************************************************/
static char buf[10000] ; /* text-buffer for wordwrapping */
/********************************************************************/
static float xPos ;
static int indent ;
static int WINX ;
/* dumps out help-page without images and markups */
UTIL_FUNC_DEF BOOL helpPrint (char *helpFilename)
/* returns TRUE if a help page could successfully be displayed
for the given subject, returns FALSE if no such page found */
{
HtmlPage *page ;
Array dirList;
char *cp;
int i,n,x;
if ((page = htmlPageCreate (helpFilename)))
{
/* found a page */
htmlPagePrint (page);
htmlPageDestroy (page);
return TRUE;
}
if (!helpFilename)
freeOut ("Help subject not found\n");
else
freeOut ("Help subject is ambiguous\n");
freeOut ("Try:\n help\n");
/* now show a list of possible files */
if(!(dirList = filDirectoryCreate
(helpGetDir(), HELP_FILE_EXTENSION, "r")) )
{
messout ("Can't open help directory %s\n"
"(%s)",
helpGetDir(), messSysErrorText()) ;
return FALSE ;
}
for (i = 0, x = 0 ; i < arrayMax(dirList) ; i++)
{
cp = arr(dirList,i,char*) ;
if (!cp || !*cp || !strlen(cp))
continue ;
if (helpFilename)
{
if (strncasecmp(filGetFilename(helpFilename),cp,
strlen(filGetFilename(helpFilename))) != 0)
continue;
}
n = strlen(cp) ;
if (n > 5 && !strcmp("."HELP_FILE_EXTENSION,cp + n - 5))
*(cp + n - 5) = 0 ;
x += n + 1 ;
if (x > 50) { x = n + 1 ; freeOut("\n") ;}
freeOutf("%s ", cp) ;
}
freeOut("\n") ;
filDirectoryDestroy (dirList);
return FALSE;
} /* helpPrint */
/************************************************************/
/* counter-part to graphWebBrowser(), which remote-controls
netscape using the -remote command line option. Useful
for textual applications running in an X11 environment,
where x-apps can be called from within the application,
but the Xtoolkit (used to drive netscape via X-atoms)
shouldn't be linked in, because it is a textual app. */
/************************************************************/
UTIL_FUNC_DEF BOOL helpWebBrowser(char *link)
{
/* currently impossible, because it is hard to find out whether
a netscape process is already running.
Stupidly enough 'netscape -remote...' doesn't exit
with code 1, if it can't connect to an existing process
*/
return FALSE;
} /* helpWebBrowser */
/************************************************************/
/****************** ***********************/
/****************** static functions ***********************/
/****************** ***********************/
/************************************************************/
static void htmlPagePrint (HtmlPage *page)
{
/* init screen-position parameters */
WINX = 80 ;
indent = 2 ;
xPos = indent ;
/* start recursivle printing nodes */
printTextSection (page->root) ;
( run in 0.875 second using v1.01-cache-2.11-cpan-39bf76dae61 )