⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 help.c

📁 nedit 是一款linux下的开发源码的功能强大的编辑器
💻 C
📖 第 1 页 / 共 4 页
字号:
    while (whatStyle == BufGetCharacter(textD->styleBuffer, begin-1))  begin--;    link_text = BufGetRange (textD->buffer, begin, end);        if (is_known_link (link_text, &link_topic, &link_pos) )     {        if (HelpWindows[link_topic] != NULL)        {            RaiseShellWindow(HelpWindows[link_topic]);        } else        {            if (newWindow)            {                HelpWindows[link_topic] = createHelpPanel(link_topic);            } else            {                changeWindowTopic(topic, link_topic);            }        }        navHistBack[link_topic] = topic;        navHistForw[topic] = link_topic;        TextSetCursorPos(HelpTextPanes[link_topic], link_pos);        adaptNavigationButtons(link_topic);        adaptNavigationButtons(topic);    }    XtFree (link_text);}static void helpFocusButtonsAP(Widget w, XEvent *event, String *args,        Cardinal *nArgs){       XmProcessTraversal(w, XmTRAVERSE_NEXT_TAB_GROUP);}/*  * handler for help-button-action(<button-name>) * Calls the activate callback for the named button widget of the help text win. */static void helpButtonActionAP(Widget w, XEvent *event, String *args,        Cardinal *nArgs){    char buf[80];    int topic;    Widget btn;        if(*nArgs != 1)    {        fprintf(stderr, "help-button-action: requires exactly one argument.\n");        return;    }        /* Find the topic being displayed by this widget */    for (topic = 0; topic < NUM_TOPICS; topic++)        if (HelpTextPanes[topic] == w)            break;        if(topic == NUM_TOPICS || HelpWindows[topic] == NULL)        return; /* Shouldn't happen */    /* Compose the button widget name */        strcpy(&buf[0], "helpForm.");    if (strlen(args[0]) <= 70)    {        strcat(&buf[0], args[0]);    } else    {        fprintf(stderr, "help-button-action: argument too long");        return;    }        btn=XtNameToWidget(HelpWindows[topic], buf);    if (btn)    {        XtCallCallbacks(btn, XmNactivateCallback, HelpWindows[topic]);    } else    {        fprintf(stderr, "help-button-action: invalid argument: %s\n", args[0]);    }}/*  * Handler for action help-hyperlink() * Arguments: none - init: record event position  *            "current": if clicked on a link, follow link in same window *            "new":     if clicked on a link, follow link in new window * * With the 1st argument "current" or "new" this action can have two additional * arguments. These arguments must be valid names of XmText actions.  * In this case, the action named in argument #2 is called if the action * help-hyperlink is about to follow the hyperlink. The Action in argument #3 * is called if no hyperlink has been recognized at the current event position. */static void helpHyperlinkAP(Widget w, XEvent *event, String *args,        Cardinal *nArgs){    XButtonEvent *e = (XButtonEvent *)event;    int topic;    textDisp *textD = ((TextWidget)w)->text.textD;    int clickedPos, newWin;    static int pressX=0, pressY=0;        /* called without arguments we just record coordinates */    if (*nArgs == 0)    {        pressX = e->x;        pressY = e->y;        return;    }        newWin = !strcmp(args[0], "new");        if(!newWin && strcmp(args[0], "current")) {        fprintf(stderr, "help-hyperlink: Unrecognized argument %s\n", args[0]);        return;    }        /*      * If for any reason (pointer moved - drag!, no hyperlink found)      * this action can't follow a hyperlink then execute the the action      * named in arg #3 (if provided)     */    if (abs(pressX - e->x) > CLICK_THRESHOLD            || abs(pressY - e->y) > CLICK_THRESHOLD)    {        if (*nArgs == 3)            XtCallActionProc(w, args[2], event, NULL, 0);        return;    }        clickedPos = TextDXYToCharPos(textD, e->x, e->y);    /* Beware of possible EBCDIC coding! Use the mapping table. */    if (BufGetCharacter(textD->styleBuffer, clickedPos) !=            (char)AlphabetToAsciiTable[(unsigned char)STL_NM_LINK])    {        if (*nArgs == 3)            XtCallActionProc(w, args[2], event, NULL, 0);        return;    }    /* Find the topic being displayed by this widget */    for (topic = 0; topic < NUM_TOPICS; topic++)        if (HelpTextPanes[topic] == w)            break;        if (topic == NUM_TOPICS)    {        /* If we get here someone must have bound help-hyperlink to a non-help         * text widget (!) Or some other really strange thing happened.         */        if (*nArgs == 3)            XtCallActionProc(w, args[2], event, NULL, 0);        return;    }        /* If the action help-hyperlink had 3 arguments execute the action     * named in arg #2 before really following the link.     */    if (*nArgs == 3)        XtCallActionProc(w, args[1], event, NULL, 0);        follow_hyperlink(topic, clickedPos, newWin);}   /*** Install the action for following hyperlinks in the help window*/void InstallHelpLinkActions(XtAppContext context){       static XtActionsRec Actions[] =    {        {"help-hyperlink", helpHyperlinkAP},        {"help-focus-buttons", helpFocusButtonsAP},        {"help-button-action", helpButtonActionAP}    };    XtAppAddActions(context, Actions, XtNumber(Actions));}/*** Search the help text.  If allSections is true, searches all of the help** text, otherwise searches only in parentTopic.*/static void searchHelpText(Widget parent, int parentTopic,        const char *searchFor, int allSections, int startPos, int startTopic){        int topic, beginMatch, endMatch;    int found = False;    char * helpText  = NULL;        /* Search for the string */    for (topic=startTopic; topic<NUM_TOPICS; topic++)    {        if (!allSections && topic != parentTopic)            continue;        helpText = stitch(parent, HelpText[topic], NULL);        if (SearchString(helpText, searchFor, SEARCH_FORWARD, SEARCH_LITERAL,                False, topic == startTopic ? startPos : 0, &beginMatch,                &endMatch, NULL, NULL, GetPrefDelimiters()))        {            found = True;            XtFree(helpText);            break;        }        XtFree(helpText);    }    if (!found)    {        if (startPos != 0 || (allSections && startTopic != 0))        {            /* Wrap search */            searchHelpText(parent, parentTopic, searchFor, allSections, 0, 0);            return;        }        DialogF(DF_INF, parent, 1, "String Not Found", "String Not Found", "Dismiss");        return;    }        /* update navigation history */      if (parentTopic != topic)    {        navHistForw[parentTopic]= topic;        navHistBack[topic]= parentTopic;    }        /* If the appropriate window is already up, bring it to the top, if not,       make the parent window become this topic */    changeTopicOrRaise(parentTopic, topic);    BufSelect(TextGetBuffer(HelpTextPanes[topic]), beginMatch, endMatch);    TextSetCursorPos(HelpTextPanes[topic], endMatch);        /* Save the search information for search-again */    strcpy(LastSearchString, searchFor);    LastSearchTopic = topic;    LastSearchPos = endMatch;    LastSearchWasAllTopics = allSections;}/*** Change a help window to display a new topic.  (Help window data is stored** and indexed by topic so if a given topic is already displayed or has been** positioned by the user, it can be found and popped back up in the same** place.)  To change the topic displayed, the stored data has to be relocated.*/static void changeWindowTopic(int existingTopic, enum HelpTopic newTopic){    char *helpText, *styleData;        /* Relocate the window/widget/buffer information */    if (newTopic != existingTopic)    {        HelpWindows[newTopic] = HelpWindows[existingTopic];        HelpWindows[existingTopic] = NULL;        HelpStyleBuffers[newTopic] = HelpStyleBuffers[existingTopic];        HelpStyleBuffers[existingTopic] = NULL;        HelpTextPanes[newTopic] = HelpTextPanes[existingTopic];        HelpTextPanes[existingTopic] = NULL;        setHelpWinTitle(HelpWindows[newTopic], newTopic);    }         /* Set the existing text widget to display the new text.  Because it's       highlighted, we have to turn off highlighting before changing the       displayed text to prevent the text widget from trying to apply the       old, mismatched, highlighting to the new text */    helpText = stitch(HelpTextPanes[newTopic], HelpText[newTopic], &styleData);    TextDAttachHighlightData(((TextWidget)HelpTextPanes[newTopic])->text.textD,            NULL, NULL, 0, '\0', NULL, NULL);    BufSetAll(TextGetBuffer(HelpTextPanes[newTopic]), helpText);    XtFree(helpText);    BufSetAll(HelpStyleBuffers[newTopic], styleData);    XtFree(styleData);    TextDAttachHighlightData(((TextWidget)HelpTextPanes[newTopic])->text.textD,            HelpStyleBuffers[newTopic], HelpStyleInfo, N_STYLES, '\0', NULL,            NULL);}static int findTopicFromShellWidget(Widget shellWidget){    int i;        for (i=0; i<NUM_TOPICS; i++)        if (shellWidget == HelpWindows[i])            return i;    return -1;}static void initNavigationHistory(void) {    static int doInitNavigationHistory = True;    int i;        if (doInitNavigationHistory)    {        for (i=0; i<NUM_TOPICS; i++)            navHistBack[i] = navHistForw[i] = -1;        doInitNavigationHistory = False;    }}#if XmVersion == 2000/* amai: This function may be called before the Motif part         is being initialized. The following, public interface         is known to initialize at least xmUseVersion.         That interface is declared in <Xm/Xm.h> in Motif 1.2 only.         As for Motif 2.1 we don't need this call anymore.         This also holds for the Motif 2.1 version of LessTif         releases > 0.93.0. */extern void XmRegisterConverters(void);#endif/* Print version info to stdout */void PrintVersion(void){    const char *text;  #if XmVersion < 2001    XmRegisterConverters();  /* see comment above */#endif    text = getBuildInfo();    puts (text);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -