📄 help.c
字号:
XmNlabelString, st1=XmStringCreateSimple("<< Browse"), XmNmnemonic, 'o', XmNbottomAttachment, XmATTACH_WIDGET, XmNbottomWidget, dismissBtn, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 51, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, 73, NULL); XtAddCallback(btn, XmNactivateCallback, prevTopicCB, appShell); XmStringFree(st1); btn = XtVaCreateManagedWidget("nextTopic", xmPushButtonWidgetClass, form, XmNlabelString, st1=XmStringCreateSimple("Browse >>"), XmNmnemonic, 'e', XmNbottomAttachment, XmATTACH_WIDGET, XmNbottomWidget, dismissBtn, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 75, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, 97, NULL); XtAddCallback(btn, XmNactivateCallback, nextTopicCB, appShell); XmStringFree(st1); btn = XtVaCreateManagedWidget("histBack", xmPushButtonWidgetClass, form, XmNlabelString, st1=XmStringCreateSimple("Back"), XmNmnemonic, 'B', XmNbottomAttachment, XmATTACH_WIDGET, XmNbottomWidget, dismissBtn, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 3, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, 25, NULL); XtAddCallback(btn, XmNactivateCallback, bwHistoryCB, appShell); XmStringFree(st1); btnFW = XtVaCreateManagedWidget("histForw", xmPushButtonWidgetClass, form, XmNlabelString, st1=XmStringCreateSimple("Forward"), XmNmnemonic, 'w', XmNbottomAttachment, XmATTACH_WIDGET, XmNbottomWidget, dismissBtn, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 27, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, 49, NULL); XtAddCallback(btnFW, XmNactivateCallback, fwHistoryCB, appShell); XmStringFree(st1); /* Create a text widget inside of a scrolled window widget */ sw = XtVaCreateManagedWidget("sw", xmScrolledWindowWidgetClass, form, XmNshadowThickness, 2, XmNtopAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_WIDGET, XmNbottomWidget, btnFW, NULL); hScrollBar = XtVaCreateManagedWidget("hScrollBar", xmScrollBarWidgetClass, sw, XmNorientation, XmHORIZONTAL, XmNrepeatDelay, 10, NULL); vScrollBar = XtVaCreateManagedWidget("vScrollBar", xmScrollBarWidgetClass, sw, XmNorientation, XmVERTICAL, XmNrepeatDelay, 10, NULL); HelpTextPanes[topic] = XtVaCreateManagedWidget("helpText", textWidgetClass, sw, textNrows, 30, textNcolumns, 65, textNbacklightCharTypes, NULL, textNhScrollBar, hScrollBar, textNvScrollBar, vScrollBar, textNreadOnly, True, textNcontinuousWrap, True, textNautoShowInsertPos, True, NULL); XtVaSetValues(sw, XmNworkWindow, HelpTextPanes[topic], XmNhorizontalScrollBar, hScrollBar, XmNverticalScrollBar, vScrollBar, NULL); /* Initialize help style information, if it hasn't already been init'd */ initHelpStyles (HelpTextPanes[topic]); /* Put together the text to display and separate it into parallel text and style data for display by the widget */ helpText = stitch (HelpTextPanes[topic], HelpText[topic], &styleData); /* Stuff the text into the widget's text buffer */ BufSetAll (TextGetBuffer (HelpTextPanes[topic]) , helpText); XtFree (helpText); /* Create a style buffer for the text widget and fill it with the style data which was generated along with the text content */ HelpStyleBuffers[topic] = BufCreate(); BufSetAll(HelpStyleBuffers[topic], styleData); XtFree (styleData); TextDAttachHighlightData(((TextWidget)HelpTextPanes[topic])->text.textD, HelpStyleBuffers[topic], HelpStyleInfo, N_STYLES, '\0', NULL, NULL); /* This shouldn't be necessary (what's wrong in text.c?) */ HandleXSelections(HelpTextPanes[topic]); /* Process dialog mnemonic keys */ AddDialogMnemonicHandler(form, FALSE); /* Set the default button */ XtVaSetValues(form, XmNdefaultButton, dismissBtn, NULL); XtVaSetValues(form, XmNcancelButton, dismissBtn, NULL); /* realize all of the widgets in the new window */ RealizeWithoutForcingPosition(appShell); /* Give the text pane the initial focus */ XmProcessTraversal(HelpTextPanes[topic], XmTRAVERSE_CURRENT); /* Make close command in window menu gracefully prompt for close */ AddMotifCloseCallback(appShell, (XtCallbackProc)dismissCB, appShell); /* Initialize navigation information, if it hasn't already been init'd */ initNavigationHistory(); /* Set the window title */ setHelpWinTitle(appShell, topic); #ifdef EDITRES XtAddEventHandler (appShell, (EventMask)0, True, (XtEventHandler)_XEditResCheckMessages, NULL);#endif /* EDITRES */ return appShell;}static void changeTopicOrRaise(int existingTopic, int newTopic) { if(HelpWindows[newTopic] == NULL) { changeWindowTopic(existingTopic, newTopic); adaptNavigationButtons(newTopic); } else { RaiseShellWindow(HelpWindows[newTopic]); adaptNavigationButtons(existingTopic); adaptNavigationButtons(newTopic); }}/*** Callbacks for window controls*/static void dismissCB(Widget w, XtPointer clientData, XtPointer callData){ int topic; if ((topic = findTopicFromShellWidget((Widget)clientData)) == -1) return; /* I don't understand the mechanism by which this can be called with HelpWindows[topic] as NULL, but it has happened */ XtDestroyWidget(HelpWindows[topic]); HelpWindows[topic] = NULL; if (HelpStyleBuffers[topic] != NULL) { BufFree(HelpStyleBuffers[topic]); HelpStyleBuffers[topic] = NULL; } }static void prevTopicCB(Widget w, XtPointer clientData, XtPointer callData) { int topic; if ((topic = findTopicFromShellWidget((Widget)clientData)) == -1) return; /* shouldn't happen */ topic--; if(topic >= 0) changeTopicOrRaise(topic+1, topic);}static void nextTopicCB(Widget w, XtPointer clientData, XtPointer callData) { int topic; if ((topic = findTopicFromShellWidget((Widget)clientData)) == -1) return; /* shouldn't happen */ topic++; if(topic < NUM_TOPICS) changeTopicOrRaise(topic-1, topic);}static void bwHistoryCB(Widget w, XtPointer clientData, XtPointer callData) { int topic, goTo; if ((topic = findTopicFromShellWidget((Widget)clientData)) == -1) return; /* shouldn't happen */ goTo=navHistBack[topic]; if(goTo >= 0 && goTo < NUM_TOPICS) { navHistForw[goTo]=topic; changeTopicOrRaise(topic, goTo); }}static void fwHistoryCB(Widget w, XtPointer clientData, XtPointer callData){ int topic, goTo; if ((topic = findTopicFromShellWidget((Widget)clientData)) == -1) return; /* shouldn't happen */ goTo=navHistForw[topic]; if(goTo >= 0 && goTo < NUM_TOPICS) { navHistBack[goTo]=topic; changeTopicOrRaise(topic, goTo); }}static void searchHelpCB(Widget w, XtPointer clientData, XtPointer callData){ char promptText[DF_MAX_PROMPT_LENGTH]; int response, topic; static char **searchHistory = NULL; static int nHistoryStrings = 0; if ((topic = findTopicFromShellWidget((Widget)clientData)) == -1) return; /* shouldn't happen */ SetDialogFPromptHistory(searchHistory, nHistoryStrings); response = DialogF(DF_PROMPT, HelpWindows[topic], 3, "Find", "Search for: (use up arrow key to recall previous)", promptText, "This Section", "All Sections", "Cancel"); if (response == 3) return; AddToHistoryList(promptText, &searchHistory, &nHistoryStrings); searchHelpText(HelpWindows[topic], topic, promptText, response == 2, 0, 0);}static void searchHelpAgainCB(Widget w, XtPointer clientData, XtPointer callData){ int topic; if ((topic = findTopicFromShellWidget((Widget)clientData)) == -1) return; /* shouldn't happen */ searchHelpText(HelpWindows[topic], topic, LastSearchString, LastSearchWasAllTopics, LastSearchPos, LastSearchTopic);}static void printCB(Widget w, XtPointer clientData, XtPointer callData){ int topic, helpStringLen; char *helpString; if ((topic = findTopicFromShellWidget((Widget)clientData)) == -1) return; /* shouldn't happen */ helpString = TextGetWrapped(HelpTextPanes[topic], 0, TextGetBuffer(HelpTextPanes[topic])->length, &helpStringLen); PrintString(helpString, helpStringLen, HelpWindows[topic], HelpTitles[topic]); XtFree(helpString);}/*** Find the topic and text position within that topic targeted by a hyperlink** with name "link_name". Returns true if the link was successfully interpreted.*/static int is_known_link(char *link_name, int *topic, int *textPosition){ Href * hypertext; /*------------------------------ * Direct topic links found here. *------------------------------*/ for (*topic=0; HelpTitles[*topic] != NULL; (*topic)++) { if (strcmp (link_name, HelpTitles[*topic]) == 0) { *textPosition = 0; return 1; } } /*------------------------------------ * Links internal to topics found here. *------------------------------------*/ for (hypertext = &H_R[0]; hypertext != NULL; hypertext = hypertext->next) { if (strcmp (link_name, hypertext->source) == 0) { *topic = hypertext->topic; *textPosition = hypertext->location; return 1; } } return 0;}/*** Find the text of a hyperlink from a clicked character position somewhere** within the hyperlink text, and display the help that it links to.*/static void follow_hyperlink(int topic, int charPosition, int newWindow){ textDisp *textD = ((TextWidget)HelpTextPanes[topic])->text.textD; char * link_text; int link_topic; int link_pos; int end = charPosition; int begin = charPosition; char whatStyle = BufGetCharacter(textD->styleBuffer, end); /*-------------------------------------------------- * Locate beginning and ending of current text style. *--------------------------------------------------*/ while (whatStyle == BufGetCharacter(textD->styleBuffer, ++end));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -