📄 nedit.c
字号:
"*macroMenu.mnemonic: c", "*macroMenu.learnKeystrokes.accelerator: Alt<Key>k", "*macroMenu.learnKeystrokes.acceleratorText: Alt+K", "*macroMenu.finishLearn.accelerator: Alt<Key>k", "*macroMenu.finishLearn.acceleratorText: Alt+K", "*macroMenu.cancelLearn.accelerator: Ctrl<Key>period", "*macroMenu.cancelLearn.acceleratorText: Ctrl+.", "*macroMenu.replayKeystrokes.accelerator: Ctrl<Key>k", "*macroMenu.replayKeystrokes.acceleratorText: Ctrl+K", "*macroMenu.repeat.accelerator: Ctrl<Key>comma", "*macroMenu.repeat.acceleratorText: Ctrl+,", "*windowsMenu.mnemonic: W", "*windowsMenu.splitWindow.accelerator: Ctrl<Key>2", "*windowsMenu.splitWindow.acceleratorText: Ctrl+2", "*windowsMenu.closePane.accelerator: Ctrl<Key>1", "*windowsMenu.closePane.acceleratorText: Ctrl+1", "*helpMenu.mnemonic: H", "nedit.helpForm.sw.helpText*translations: #override\<Key>Tab:help-focus-buttons()\\n\<Key>Return:help-button-action(\"dismiss\")\\n\<KeyPress>osfCancel:help-button-action(\"dismiss\")\\n\~Meta~Ctrl~Shift<Btn1Down>:\ grab-focus() help-hyperlink()\\n\~Meta~Ctrl~Shift<Btn1Up>:\ help-hyperlink(\"current\", \"process-cancel\", \"extend-end\")\\n\~Meta~Ctrl~Shift<Btn2Down>:\ process-bdrag() help-hyperlink()\\n\~Meta~Ctrl~Shift<Btn2Up>:\ help-hyperlink(\"new\", \"process-cancel\", \"copy-to\")", NULL};static const char cmdLineHelp[] =#ifndef VMS"Usage: nedit [-read] [-create] [-line n | +n] [-server] [-do command]\n\ [-tags file] [-tabs n] [-wrap] [-nowrap] [-autowrap]\n\ [-autoindent] [-noautoindent] [-autosave] [-noautosave]\n\ [-lm languagemode] [-rows n] [-columns n] [-font font]\n\ [-geometry geometry] [-iconic] [-noiconic] [-svrname name]\n\ [-display [host]:server[.screen] [-xrm resourcestring]\n\ [-import file] [-background color] [-foreground color]\n\ [-V|-version] [--]\n\ [file...]\n";#else"";#endif /*VMS*/int main(int argc, char **argv){ int i, lineNum, nRead, fileSpecified = FALSE, editFlags = CREATE; int gotoLine = False, macroFileRead = False, opts = True; int iconic = False; char *toDoCommand = NULL, *geometry = NULL, *langMode = NULL; char filename[MAXPATHLEN], pathname[MAXPATHLEN]; XtAppContext context; XrmDatabase prefDB; static const char *protectedKeywords[] = {"-iconic", "-icon", "-geometry", "-g", "-rv", "-reverse", "-bd", "-bordercolor", "-borderwidth", "-bw", "-title", NULL}; /* Save the command which was used to invoke nedit for restart command */ ArgV0 = argv[0]; /* Set locale for C library, X, and Motif input functions. Reverts to "C" if requested locale not available. */ XtSetLanguageProc(NULL, neditLanguageProc, NULL); /* Initialize X toolkit (does not open display yet) */ XtToolkitInitialize(); context = XtCreateApplicationContext(); /* Set up a warning handler to trap obnoxious Xt grab warnings */ SuppressPassiveGrabWarnings(); /* Set up default resources if no app-defaults file is found */ XtAppSetFallbackResources(context, fallbackResources); #if XmVersion >= 1002 /* Allow users to change tear off menus with X resources */ XmRepTypeInstallTearOffModelConverter();#endif #ifdef VMS /* Convert the command line to Unix style (This is not an ideal solution) */ ConvertVMSCommandLine(&argc, &argv);#endif /*VMS*/#ifdef __EMX__ /* expand wildcards if necessary */ _wildcard(&argc, &argv);#endif /* Read the preferences file and command line into a database */ prefDB = CreateNEditPrefDB(&argc, argv); /* Open the display and read X database and remaining command line args. XtOpenDisplay must be allowed to process some of the resource arguments with its inaccessible internal option table, but others, like -geometry and -iconic are per-window and it should not be allowed to consume them, so we temporarily masked them out. */ maskArgvKeywords(argc, argv, protectedKeywords); TheDisplay = XtOpenDisplay (context, NULL, APP_NAME, APP_CLASS, NULL, 0, &argc, argv); unmaskArgvKeywords(argc, argv, protectedKeywords); if (!TheDisplay) { XtWarning ("NEdit: Can't open display\n"); exit(EXIT_FAILURE); } patchResourcesForVisual(); patchResourcesForKDEbug(); /* Initialize global symbols and subroutines used in the macro language */ InitMacroGlobals(); RegisterMacroSubroutines(); /* Store preferences from the command line and .nedit file, and set the appropriate preferences */ RestoreNEditPrefs(prefDB, XtDatabase(TheDisplay)); LoadPrintPreferences(XtDatabase(TheDisplay), APP_NAME, APP_CLASS, True); SetDeleteRemap(GetPrefMapDelete()); SetPointerCenteredDialogs(GetPrefRepositionDialogs()); SetGetEFTextFieldRemoval(!GetPrefStdOpenDialog()); /* Set up action procedures for menu item commands */ InstallMenuActions(context); /* Add Actions for following hyperlinks in the help window */ InstallHelpLinkActions(context); /* Add actions for mouse wheel support in scrolled windows (except text area) */ InstallMouseWheelActions(context); /* Install word delimiters for regular expression matching */ SetREDefaultWordDelimiters(GetPrefDelimiters()); /* Read the nedit dynamic database of files for the Open Previous command (and eventually other information as well) */ ReadNEditDB(); /* Process -import command line argument before others which might open windows (loading preferences doesn't update menu settings, which would then be out of sync with the real preference settings) */ for (i=1; i<argc; i++) { if(!strcmp(argv[i], "--")) { break; /* treat all remaining arguments as filenames */ } else if (!strcmp(argv[i], "-import")) { nextArg(argc, argv, &i); ImportPrefFile(argv[i], False); } else if (!strcmp(argv[i], "-importold")) { nextArg(argc, argv, &i); ImportPrefFile(argv[i], True); } } /* Load the default tags file. Don't complain if it doesn't load, the tag file resource is intended to be set and forgotten. Running nedit in a directory without a tags should not cause it to spew out errors. */ if (*GetPrefTagFile() != '\0') AddTagsFile(GetPrefTagFile(), TAG); /* Process any command line arguments (-tags, -do, -read, -create, +<line_number>, -line, -server, and files to edit) not already processed by RestoreNEditPrefs. */ fileSpecified = FALSE; for (i=1; i<argc; i++) { if (opts && !strcmp(argv[i], "--")) { opts = False; /* treat all remaining arguments as filenames */ continue; } else if (opts && !strcmp(argv[i], "-tags")) { nextArg(argc, argv, &i); if (!AddTagsFile(argv[i], TAG)) fprintf(stderr, "NEdit: Unable to load tags file\n"); } else if (opts && !strcmp(argv[i], "-do")) { nextArg(argc, argv, &i); if (checkDoMacroArg(argv[i])) toDoCommand = argv[i]; } else if (opts && !strcmp(argv[i], "-read")) { editFlags |= PREF_READ_ONLY; } else if (opts && !strcmp(argv[i], "-create")) { editFlags |= SUPPRESS_CREATE_WARN; } else if (opts && !strcmp(argv[i], "-line")) { nextArg(argc, argv, &i); nRead = sscanf(argv[i], "%d", &lineNum); if (nRead != 1) fprintf(stderr, "NEdit: argument to line should be a number\n"); else gotoLine = True; } else if (opts && (*argv[i] == '+')) { nRead = sscanf((argv[i]+1), "%d", &lineNum); if (nRead != 1) fprintf(stderr, "NEdit: argument to + should be a number\n"); else gotoLine = True; } else if (opts && !strcmp(argv[i], "-server")) { IsServer = True; } else if (opts && (!strcmp(argv[i], "-iconic") || !strcmp(argv[i], "-icon"))) { iconic = True; } else if (opts && !strcmp(argv[i], "-noiconic")) { iconic = False; } else if (opts && (!strcmp(argv[i], "-geometry") || !strcmp(argv[i], "-g"))) { nextArg(argc, argv, &i); geometry = argv[i]; } else if (opts && !strcmp(argv[i], "-lm")) { nextArg(argc, argv, &i); langMode = argv[i]; } else if (opts && !strcmp(argv[i], "-import")) { nextArg(argc, argv, &i); /* already processed, skip */ } else if (opts && (!strcmp(argv[i], "-V") || !strcmp(argv[i], "-version"))) { PrintVersion(); exit(EXIT_SUCCESS); } else if (opts && (*argv[i] == '-')) {#ifdef VMS *argv[i] = '/';#endif /*VMS*/ fprintf(stderr, "NEdit: Unrecognized option %s\n%s", argv[i], cmdLineHelp); exit(EXIT_FAILURE); } else {#ifdef VMS int numFiles, j; char **nameList = NULL; /* Use VMS's LIB$FILESCAN for filename in argv[i] to process */ /* wildcards and to obtain a full VMS file specification */ numFiles = VMSFileScan(argv[i], &nameList, NULL, INCLUDE_FNF); /* for each expanded file name do: */ for (j = 0; j < numFiles; ++j) { if (ParseFilename(nameList[j], filename, pathname) == 0) { EditExistingFile(WindowList, filename, pathname, editFlags, geometry, iconic, langMode); fileSpecified = TRUE; if (!macroFileRead) { ReadMacroInitFile(WindowList); macroFileRead = True; } if (toDoCommand != NULL) DoMacro(WindowList, toDoCommand, "-do macro"); if (gotoLine) SelectNumberedLine(WindowList, lineNum); } else { fprintf(stderr, "nedit: file name too long: %s\n", nameList[j]); } free(nameList[j]); } if (nameList != NULL) free(nameList);#else if (ParseFilename(argv[i], filename, pathname) == 0 ) { EditExistingFile(WindowList, filename, pathname, editFlags, geometry, iconic, langMode); fileSpecified = TRUE; if (!macroFileRead) { ReadMacroInitFile(WindowList); macroFileRead = True; } if (toDoCommand != NULL) DoMacro(WindowList, toDoCommand, "-do macro"); if (gotoLine) SelectNumberedLine(WindowList, lineNum); } else { fprintf(stderr, "nedit: file name too long: %s\n", argv[i]); }#endif /*VMS*/ toDoCommand = NULL; } }#ifdef VMS VMSFileScanDone();#endif /*VMS*/ /* If no file to edit was specified, open a window to edit "Untitled" */ if (!fileSpecified) { EditNewFile(geometry, iconic, langMode, NULL); ReadMacroInitFile(WindowList); if (toDoCommand != NULL) DoMacro(WindowList, toDoCommand, "-do macro"); } /* Begin remembering last command invoked for "Repeat" menu item */ AddLastCommandActionHook(context); /* Set up communication port and write ~/.nedit_server_process file */ if (IsServer)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -