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

📄 usercmds.c

📁 nedit 是一款linux下的开发源码的功能强大的编辑器
💻 C
📖 第 1 页 / 共 5 页
字号:
    XtVaCreateManagedWidget("mneLabel", xmLabelGadgetClass, form,    	    XmNlabelString, s1=MKSTRING("Mnemonic"),    	    XmNmnemonic, 'i',    	    XmNuserData, ucd->mneTextW,    	    XmNalignment, XmALIGNMENT_END,    	    XmNmarginTop, 5,    	    XmNleftAttachment, XmATTACH_POSITION,    	    XmNleftPosition, LIST_RIGHT + 22,    	    XmNrightAttachment, XmATTACH_POSITION,    	    XmNrightPosition, RIGHT_MARGIN_POS-21,    	    XmNbottomAttachment, XmATTACH_WIDGET,    	    XmNbottomWidget, ucd->mneTextW, NULL);    XmStringFree(s1);    pasteReplayBtn = XtVaCreateManagedWidget("pasteReplay",    	    xmPushButtonWidgetClass, form,    	    XmNlabelString, s1=MKSTRING("Paste Learn/\nReplay Macro"),    	    XmNmnemonic, 'P',    	    XmNsensitive, GetReplayMacro() != NULL,     	    XmNleftAttachment, XmATTACH_POSITION,   	    XmNleftPosition, RIGHT_MARGIN_POS-20,    	    XmNrightAttachment, XmATTACH_POSITION,    	    XmNrightPosition, RIGHT_MARGIN_POS,	    XmNbottomAttachment, XmATTACH_POSITION,    	    XmNbottomPosition, MACRO_CMD_TOP, NULL);    XtAddCallback(pasteReplayBtn, XmNactivateCallback,    	    pasteReplayCB, ucd);    XmStringFree(s1);        ucd->nameTextW = XtVaCreateManagedWidget("name", xmTextWidgetClass, form,	    XmNleftAttachment, XmATTACH_POSITION,	    XmNleftPosition, LIST_RIGHT,	    XmNrightAttachment, XmATTACH_POSITION,	    XmNrightPosition, RIGHT_MARGIN_POS,	    XmNbottomAttachment, XmATTACH_WIDGET,    	    XmNbottomWidget, accLabel, NULL);    RemapDeleteKey(ucd->nameTextW);     nameLabel = XtVaCreateManagedWidget("nameLabel", xmLabelGadgetClass, form,    	    XmNlabelString, s1=MKSTRING("Menu Entry"),    	    XmNmnemonic, 'y',    	    XmNuserData, ucd->nameTextW,    	    XmNalignment, XmALIGNMENT_BEGINNING,    	    XmNmarginTop, 5,    	    XmNleftAttachment, XmATTACH_POSITION,    	    XmNleftPosition, LIST_RIGHT,    	    XmNbottomAttachment, XmATTACH_WIDGET,    	    XmNbottomWidget, ucd->nameTextW, NULL);    XmStringFree(s1);     XtVaCreateManagedWidget("nameNotes", xmLabelGadgetClass, form,    	    XmNlabelString, s1=MKSTRING("(> for sub-menu, @ language mode)"),    	    XmNalignment, XmALIGNMENT_END,    	    XmNmarginTop, 5,    	    XmNleftAttachment, XmATTACH_WIDGET,    	    XmNleftWidget, nameLabel,    	    XmNrightAttachment, XmATTACH_POSITION,    	    XmNrightPosition, RIGHT_MARGIN_POS,    	    XmNbottomAttachment, XmATTACH_WIDGET,    	    XmNbottomWidget, ucd->nameTextW, NULL);    XmStringFree(s1);    XtVaCreateManagedWidget("topLabel", xmLabelGadgetClass, form,    	    XmNlabelString, s1=MKSTRING("Select a macro menu item from the list at left.\n\Select \"New\" to add a new command to the menu."),	    XmNtopAttachment, XmATTACH_POSITION,	    XmNtopPosition, 2,	    XmNleftAttachment, XmATTACH_POSITION,	    XmNleftPosition, LIST_RIGHT,	    XmNrightAttachment, XmATTACH_POSITION,	    XmNrightPosition, RIGHT_MARGIN_POS,	    XmNbottomAttachment, XmATTACH_WIDGET,    	    XmNbottomWidget, nameLabel, NULL);    XmStringFree(s1);     cmdLabel = XtVaCreateManagedWidget("cmdLabel", xmLabelGadgetClass, form,    	    XmNlabelString, s1=MKSTRING("Macro Command to Execute"),    	    XmNmnemonic, 'x',    	    XmNalignment, XmALIGNMENT_BEGINNING,    	    XmNmarginTop, 5,    	    XmNtopAttachment, XmATTACH_POSITION,    	    XmNtopPosition, MACRO_CMD_TOP,    	    XmNleftAttachment, XmATTACH_POSITION,    	    XmNleftPosition, LEFT_MARGIN_POS, NULL);    XmStringFree(s1);    okBtn = XtVaCreateManagedWidget("ok",xmPushButtonWidgetClass,form,    	    XmNlabelString, s1=MKSTRING("OK"),    	    XmNleftAttachment, XmATTACH_POSITION,    	    XmNleftPosition, 8,    	    XmNrightAttachment, XmATTACH_POSITION,    	    XmNrightPosition, 23,    	    XmNbottomAttachment, XmATTACH_POSITION,    	    XmNbottomPosition, 99, NULL);    XtAddCallback(okBtn, XmNactivateCallback, okCB, ucd);    XmStringFree(s1);    applyBtn = XtVaCreateManagedWidget("apply",xmPushButtonWidgetClass,form,    	    XmNlabelString, s1=MKSTRING("Apply"),    	    XmNmnemonic, 'A',    	    XmNleftAttachment, XmATTACH_POSITION,    	    XmNleftPosition, 31,    	    XmNrightAttachment, XmATTACH_POSITION,    	    XmNrightPosition, 46,    	    XmNbottomAttachment, XmATTACH_POSITION,    	    XmNbottomPosition, 99, NULL);    XtAddCallback(applyBtn, XmNactivateCallback, applyCB, ucd);    XmStringFree(s1);    applyBtn = XtVaCreateManagedWidget("check",xmPushButtonWidgetClass,form,    	    XmNlabelString, s1=MKSTRING("Check"),    	    XmNmnemonic, 'C',    	    XmNleftAttachment, XmATTACH_POSITION,    	    XmNleftPosition, 54,    	    XmNrightAttachment, XmATTACH_POSITION,    	    XmNrightPosition, 69,    	    XmNbottomAttachment, XmATTACH_POSITION,    	    XmNbottomPosition, 99, NULL);    XtAddCallback(applyBtn, XmNactivateCallback, checkCB, ucd);    XmStringFree(s1);    dismissBtn = XtVaCreateManagedWidget("dismiss",xmPushButtonWidgetClass,form,    	    XmNlabelString, s1=MKSTRING("Dismiss"),    	    XmNleftAttachment, XmATTACH_POSITION,    	    XmNleftPosition, 77,    	    XmNrightAttachment, XmATTACH_POSITION,    	    XmNrightPosition, 92,    	    XmNbottomAttachment, XmATTACH_POSITION,    	    XmNbottomPosition, 99, NULL);    XtAddCallback(dismissBtn, XmNactivateCallback, dismissCB, ucd);    XmStringFree(s1);        ac = 0;    XtSetArg(args[ac], XmNeditMode, XmMULTI_LINE_EDIT); ac++;    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;    XtSetArg(args[ac], XmNtopWidget, cmdLabel); ac++;    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_POSITION); ac++;    XtSetArg(args[ac], XmNleftPosition, LEFT_MARGIN_POS); ac++;    XtSetArg(args[ac], XmNrightAttachment, XmATTACH_POSITION); ac++;    XtSetArg(args[ac], XmNrightPosition, RIGHT_MARGIN_POS); ac++;    XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;    XtSetArg(args[ac], XmNbottomWidget, okBtn); ac++;    XtSetArg(args[ac], XmNbottomOffset, 5); ac++;    ucd->cmdTextW = XmCreateScrolledText(form, "name", args, ac);    AddMouseWheelSupport(ucd->cmdTextW);    XtManageChild(ucd->cmdTextW);    RemapDeleteKey(ucd->cmdTextW);    XtVaSetValues(cmdLabel, XmNuserData, ucd->cmdTextW, NULL); /* for mnemonic */       /* Disable text input for the accelerator key widget, let the       event handler manage it instead */    disableTextW(ucd->accTextW);    /* initializs the dialog fields to match "New" list item */    updateDialogFields(NULL, ucd);           /* Set initial default button */    XtVaSetValues(form, XmNdefaultButton, okBtn, NULL);    XtVaSetValues(form, XmNcancelButton, dismissBtn, NULL);        /* Handle mnemonic selection of buttons and focus to dialog */    AddDialogMnemonicHandler(form, FALSE);        /* Make widgets for top level shell and paste-replay buttons available       to other functions */    if (dialogType == MACRO_CMDS) {    	MacroCmdDialog = ucd->dlogShell;	MacroPasteReplayBtn = pasteReplayBtn;    } else {	BGMenuCmdDialog = ucd->dlogShell;    	BGMenuPasteReplayBtn = pasteReplayBtn;    }        /* Realize all of the widgets in the new dialog */    RealizeWithoutForcingPosition(ucd->dlogShell);}/*** Update the Shell, Macro, and window background menus menu of window "window"** from the currently loaded command descriptions.*/void UpdateShellMenu(WindowInfo *window){    updateMenu(window, SHELL_CMDS);}void UpdateMacroMenu(WindowInfo *window){    updateMenu(window, MACRO_CMDS);}void UpdateBGMenu(WindowInfo *window){    updateMenu(window, BG_MENU_CMDS);}/*** Dim/undim buttons for pasting replay macros into macro and bg menu dialogs*/void DimPasteReplayBtns(int sensitive){    if (MacroCmdDialog != NULL)    	XtSetSensitive(MacroPasteReplayBtn, sensitive);    if (BGMenuCmdDialog != NULL)    	XtSetSensitive(BGMenuPasteReplayBtn, sensitive);}/*** Dim/undim user programmable menu items which depend on there being** a selection in their associated window.*/void DimSelectionDepUserMenuItems(WindowInfo *window, int sensitive){#ifndef VMS    dimSelDepItemsInMenu(window->shellMenuPane, ShellMenuItems,	    NShellMenuItems, sensitive);#endif /*VMS*/    dimSelDepItemsInMenu(window->macroMenuPane, MacroMenuItems,	    NMacroMenuItems, sensitive);    dimSelDepItemsInMenu(window->bgMenuPane, BGMenuItems,	    NBGMenuItems, sensitive);}static void dimSelDepItemsInMenu(Widget menuPane, menuItemRec **menuList,	int nMenuItems, int sensitive){    WidgetList items;    Widget subMenu;    XtPointer userData;    int n, index;    Cardinal nItems;        XtVaGetValues(menuPane, XmNchildren, &items, XmNnumChildren, &nItems, NULL);    for (n=0; n<(int)nItems; n++) {	XtVaGetValues(items[n], XmNuserData, &userData, NULL);    	if (userData !=  (XtPointer)PERMANENT_MENU_ITEM) {    	    if (XtClass(items[n]) == xmCascadeButtonWidgetClass) {	    	XtVaGetValues(items[n], XmNsubMenuId, &subMenu, NULL);		dimSelDepItemsInMenu(subMenu, menuList, nMenuItems, sensitive);	    } else {		index = (int)userData - 10;		if (index <0 || index >= nMenuItems)    		    return;		if (menuList[index]->input == FROM_SELECTION)		    XtSetSensitive(items[n], sensitive);	    }    	}    }}/*** Harmless kludge for making undo/redo menu items in background menu properly** sensitive (even though they're programmable) along with real undo item** in the Edit menu*/void SetBGMenuUndoSensitivity(WindowInfo *window, int sensitive){    if (window->bgMenuUndoItem != NULL)    	XtSetSensitive(window->bgMenuUndoItem, sensitive);}void SetBGMenuRedoSensitivity(WindowInfo *window, int sensitive){    if (window->bgMenuRedoItem != NULL)	XtSetSensitive(window->bgMenuRedoItem, sensitive);}/*** Generate a text string for the preferences file describing the contents** of the shell cmd list.  This string is not exactly of the form that it** can be read by LoadShellCmdsString, rather, it is what needs to be written** to a resource file such that it will read back in that form.*/char *WriteShellCmdsString(void){    return writeMenuItemString(ShellMenuItems, NShellMenuItems,    	    SHELL_CMDS);}/*** Generate a text string for the preferences file describing the contents of** the macro menu and background menu commands lists.  These strings are not** exactly of the form that it can be read by LoadMacroCmdsString, rather, it** is what needs to be written to a resource file such that it will read back** in that form.*/char *WriteMacroCmdsString(void){    return writeMenuItemString(MacroMenuItems, NMacroMenuItems, MACRO_CMDS);}char *WriteBGMenuCmdsString(void){    return writeMenuItemString(BGMenuItems, NBGMenuItems, BG_MENU_CMDS);}/*** Read a string representing shell command menu items and add them to the** internal list used for constructing shell menus*/int LoadShellCmdsString(char *inString){    return loadMenuItemString(inString, ShellMenuItems, &NShellMenuItems,    	    SHELL_CMDS);}/*** Read strings representing macro menu or background menu command menu items** and add them to the internal lists used for constructing menus*/int LoadMacroCmdsString(char *inString){    return loadMenuItemString(inString, MacroMenuItems, &NMacroMenuItems,    	    MACRO_CMDS);}int LoadBGMenuCmdsString(char *inString){    return loadMenuItemString(inString, BGMenuItems, &NBGMenuItems,    	    BG_MENU_CMDS);}/*** Search through the shell menu and execute the first command with menu item** name "itemName".  Returns True on successs and False on failure.*/#ifndef VMSint DoNamedShellMenuCmd(WindowInfo *window, const char *itemName, int fromMacro){    int i;        for (i=0; i<NShellMenuItems; i++) {    	if (!strcmp(ShellMenuItems[i]->name, itemName)) {    	    if (ShellMenuItems[i]->output == TO_SAME_WINDOW &&    	    	    CheckReadOnly(window))    	    	return False;    	    DoShellMenuCmd(window, ShellMenuItems[i]->cmd,    		ShellMenuItems[i]->input, ShellMenuItems[i]->output,    		ShellMenuItems[i]->repInput, ShellMenuItems[i]->saveFirst,    		ShellMenuItems[i]->loadAfter, fromMacro);    	    return True;    	}    }    return False;}#endif /*VMS*//*** Search through the Macro or background menu and execute the first command** with menu item name "itemName".  Returns True on successs and False on** failure.*/int DoNamedMacroMenuCmd(WindowInfo *window, const char *itemName){    int i;        for (i=0; i<NMacroMenuItems; i++) {    	if (!strcmp(MacroMenuItems[i]->name, itemName)) {    	    DoMacro(window, MacroMenuItems[i]->cmd, "macro menu command");    	    return True;    	}    }    return False;}

⌨️ 快捷键说明

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