123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557 |
- /*
- Language: NSIS
- Description: Nullsoft Scriptable Install System
- Author: Jan T. Sott <jan.sott@gmail.com>
- Website: https://nsis.sourceforge.io/Main_Page
- Category: scripting
- */
- function nsis(hljs) {
- const regex = hljs.regex;
- const LANGUAGE_CONSTANTS = [
- "ADMINTOOLS",
- "APPDATA",
- "CDBURN_AREA",
- "CMDLINE",
- "COMMONFILES32",
- "COMMONFILES64",
- "COMMONFILES",
- "COOKIES",
- "DESKTOP",
- "DOCUMENTS",
- "EXEDIR",
- "EXEFILE",
- "EXEPATH",
- "FAVORITES",
- "FONTS",
- "HISTORY",
- "HWNDPARENT",
- "INSTDIR",
- "INTERNET_CACHE",
- "LANGUAGE",
- "LOCALAPPDATA",
- "MUSIC",
- "NETHOOD",
- "OUTDIR",
- "PICTURES",
- "PLUGINSDIR",
- "PRINTHOOD",
- "PROFILE",
- "PROGRAMFILES32",
- "PROGRAMFILES64",
- "PROGRAMFILES",
- "QUICKLAUNCH",
- "RECENT",
- "RESOURCES_LOCALIZED",
- "RESOURCES",
- "SENDTO",
- "SMPROGRAMS",
- "SMSTARTUP",
- "STARTMENU",
- "SYSDIR",
- "TEMP",
- "TEMPLATES",
- "VIDEOS",
- "WINDIR"
- ];
- const PARAM_NAMES = [
- "ARCHIVE",
- "FILE_ATTRIBUTE_ARCHIVE",
- "FILE_ATTRIBUTE_NORMAL",
- "FILE_ATTRIBUTE_OFFLINE",
- "FILE_ATTRIBUTE_READONLY",
- "FILE_ATTRIBUTE_SYSTEM",
- "FILE_ATTRIBUTE_TEMPORARY",
- "HKCR",
- "HKCU",
- "HKDD",
- "HKEY_CLASSES_ROOT",
- "HKEY_CURRENT_CONFIG",
- "HKEY_CURRENT_USER",
- "HKEY_DYN_DATA",
- "HKEY_LOCAL_MACHINE",
- "HKEY_PERFORMANCE_DATA",
- "HKEY_USERS",
- "HKLM",
- "HKPD",
- "HKU",
- "IDABORT",
- "IDCANCEL",
- "IDIGNORE",
- "IDNO",
- "IDOK",
- "IDRETRY",
- "IDYES",
- "MB_ABORTRETRYIGNORE",
- "MB_DEFBUTTON1",
- "MB_DEFBUTTON2",
- "MB_DEFBUTTON3",
- "MB_DEFBUTTON4",
- "MB_ICONEXCLAMATION",
- "MB_ICONINFORMATION",
- "MB_ICONQUESTION",
- "MB_ICONSTOP",
- "MB_OK",
- "MB_OKCANCEL",
- "MB_RETRYCANCEL",
- "MB_RIGHT",
- "MB_RTLREADING",
- "MB_SETFOREGROUND",
- "MB_TOPMOST",
- "MB_USERICON",
- "MB_YESNO",
- "NORMAL",
- "OFFLINE",
- "READONLY",
- "SHCTX",
- "SHELL_CONTEXT",
- "SYSTEM|TEMPORARY",
- ];
- const COMPILER_FLAGS = [
- "addincludedir",
- "addplugindir",
- "appendfile",
- "assert",
- "cd",
- "define",
- "delfile",
- "echo",
- "else",
- "endif",
- "error",
- "execute",
- "finalize",
- "getdllversion",
- "gettlbversion",
- "if",
- "ifdef",
- "ifmacrodef",
- "ifmacrondef",
- "ifndef",
- "include",
- "insertmacro",
- "macro",
- "macroend",
- "makensis",
- "packhdr",
- "searchparse",
- "searchreplace",
- "system",
- "tempfile",
- "undef",
- "uninstfinalize",
- "verbose",
- "warning",
- ];
- const CONSTANTS = {
- className: 'variable.constant',
- begin: regex.concat(/\$/, regex.either(...LANGUAGE_CONSTANTS))
- };
- const DEFINES = {
- // ${defines}
- className: 'variable',
- begin: /\$+\{[\!\w.:-]+\}/
- };
- const VARIABLES = {
- // $variables
- className: 'variable',
- begin: /\$+\w[\w\.]*/,
- illegal: /\(\)\{\}/
- };
- const LANGUAGES = {
- // $(language_strings)
- className: 'variable',
- begin: /\$+\([\w^.:!-]+\)/
- };
- const PARAMETERS = {
- // command parameters
- className: 'params',
- begin: regex.either(...PARAM_NAMES)
- };
- const COMPILER = {
- // !compiler_flags
- className: 'keyword',
- begin: regex.concat(
- /!/,
- regex.either(...COMPILER_FLAGS)
- )
- };
- const ESCAPE_CHARS = {
- // $\n, $\r, $\t, $$
- className: 'char.escape',
- begin: /\$(\\[nrt]|\$)/
- };
- const PLUGINS = {
- // plug::ins
- className: 'title.function',
- begin: /\w+::\w+/
- };
- const STRING = {
- className: 'string',
- variants: [
- {
- begin: '"',
- end: '"'
- },
- {
- begin: '\'',
- end: '\''
- },
- {
- begin: '`',
- end: '`'
- }
- ],
- illegal: /\n/,
- contains: [
- ESCAPE_CHARS,
- CONSTANTS,
- DEFINES,
- VARIABLES,
- LANGUAGES
- ]
- };
- const KEYWORDS = [
- "Abort",
- "AddBrandingImage",
- "AddSize",
- "AllowRootDirInstall",
- "AllowSkipFiles",
- "AutoCloseWindow",
- "BGFont",
- "BGGradient",
- "BrandingText",
- "BringToFront",
- "Call",
- "CallInstDLL",
- "Caption",
- "ChangeUI",
- "CheckBitmap",
- "ClearErrors",
- "CompletedText",
- "ComponentText",
- "CopyFiles",
- "CRCCheck",
- "CreateDirectory",
- "CreateFont",
- "CreateShortCut",
- "Delete",
- "DeleteINISec",
- "DeleteINIStr",
- "DeleteRegKey",
- "DeleteRegValue",
- "DetailPrint",
- "DetailsButtonText",
- "DirText",
- "DirVar",
- "DirVerify",
- "EnableWindow",
- "EnumRegKey",
- "EnumRegValue",
- "Exch",
- "Exec",
- "ExecShell",
- "ExecShellWait",
- "ExecWait",
- "ExpandEnvStrings",
- "File",
- "FileBufSize",
- "FileClose",
- "FileErrorText",
- "FileOpen",
- "FileRead",
- "FileReadByte",
- "FileReadUTF16LE",
- "FileReadWord",
- "FileWriteUTF16LE",
- "FileSeek",
- "FileWrite",
- "FileWriteByte",
- "FileWriteWord",
- "FindClose",
- "FindFirst",
- "FindNext",
- "FindWindow",
- "FlushINI",
- "GetCurInstType",
- "GetCurrentAddress",
- "GetDlgItem",
- "GetDLLVersion",
- "GetDLLVersionLocal",
- "GetErrorLevel",
- "GetFileTime",
- "GetFileTimeLocal",
- "GetFullPathName",
- "GetFunctionAddress",
- "GetInstDirError",
- "GetKnownFolderPath",
- "GetLabelAddress",
- "GetTempFileName",
- "GetWinVer",
- "Goto",
- "HideWindow",
- "Icon",
- "IfAbort",
- "IfErrors",
- "IfFileExists",
- "IfRebootFlag",
- "IfRtlLanguage",
- "IfShellVarContextAll",
- "IfSilent",
- "InitPluginsDir",
- "InstallButtonText",
- "InstallColors",
- "InstallDir",
- "InstallDirRegKey",
- "InstProgressFlags",
- "InstType",
- "InstTypeGetText",
- "InstTypeSetText",
- "Int64Cmp",
- "Int64CmpU",
- "Int64Fmt",
- "IntCmp",
- "IntCmpU",
- "IntFmt",
- "IntOp",
- "IntPtrCmp",
- "IntPtrCmpU",
- "IntPtrOp",
- "IsWindow",
- "LangString",
- "LicenseBkColor",
- "LicenseData",
- "LicenseForceSelection",
- "LicenseLangString",
- "LicenseText",
- "LoadAndSetImage",
- "LoadLanguageFile",
- "LockWindow",
- "LogSet",
- "LogText",
- "ManifestDPIAware",
- "ManifestLongPathAware",
- "ManifestMaxVersionTested",
- "ManifestSupportedOS",
- "MessageBox",
- "MiscButtonText",
- "Name|0",
- "Nop",
- "OutFile",
- "Page",
- "PageCallbacks",
- "PEAddResource",
- "PEDllCharacteristics",
- "PERemoveResource",
- "PESubsysVer",
- "Pop",
- "Push",
- "Quit",
- "ReadEnvStr",
- "ReadINIStr",
- "ReadRegDWORD",
- "ReadRegStr",
- "Reboot",
- "RegDLL",
- "Rename",
- "RequestExecutionLevel",
- "ReserveFile",
- "Return",
- "RMDir",
- "SearchPath",
- "SectionGetFlags",
- "SectionGetInstTypes",
- "SectionGetSize",
- "SectionGetText",
- "SectionIn",
- "SectionSetFlags",
- "SectionSetInstTypes",
- "SectionSetSize",
- "SectionSetText",
- "SendMessage",
- "SetAutoClose",
- "SetBrandingImage",
- "SetCompress",
- "SetCompressor",
- "SetCompressorDictSize",
- "SetCtlColors",
- "SetCurInstType",
- "SetDatablockOptimize",
- "SetDateSave",
- "SetDetailsPrint",
- "SetDetailsView",
- "SetErrorLevel",
- "SetErrors",
- "SetFileAttributes",
- "SetFont",
- "SetOutPath",
- "SetOverwrite",
- "SetRebootFlag",
- "SetRegView",
- "SetShellVarContext",
- "SetSilent",
- "ShowInstDetails",
- "ShowUninstDetails",
- "ShowWindow",
- "SilentInstall",
- "SilentUnInstall",
- "Sleep",
- "SpaceTexts",
- "StrCmp",
- "StrCmpS",
- "StrCpy",
- "StrLen",
- "SubCaption",
- "Unicode",
- "UninstallButtonText",
- "UninstallCaption",
- "UninstallIcon",
- "UninstallSubCaption",
- "UninstallText",
- "UninstPage",
- "UnRegDLL",
- "Var",
- "VIAddVersionKey",
- "VIFileVersion",
- "VIProductVersion",
- "WindowIcon",
- "WriteINIStr",
- "WriteRegBin",
- "WriteRegDWORD",
- "WriteRegExpandStr",
- "WriteRegMultiStr",
- "WriteRegNone",
- "WriteRegStr",
- "WriteUninstaller",
- "XPStyle"
- ];
- const LITERALS = [
- "admin",
- "all",
- "auto",
- "both",
- "bottom",
- "bzip2",
- "colored",
- "components",
- "current",
- "custom",
- "directory",
- "false",
- "force",
- "hide",
- "highest",
- "ifdiff",
- "ifnewer",
- "instfiles",
- "lastused",
- "leave",
- "left",
- "license",
- "listonly",
- "lzma",
- "nevershow",
- "none",
- "normal",
- "notset",
- "off",
- "on",
- "open",
- "print",
- "right",
- "show",
- "silent",
- "silentlog",
- "smooth",
- "textonly",
- "top",
- "true",
- "try",
- "un.components",
- "un.custom",
- "un.directory",
- "un.instfiles",
- "un.license",
- "uninstConfirm",
- "user",
- "Win10",
- "Win7",
- "Win8",
- "WinVista",
- "zlib"
- ];
- const FUNCTION_DEFINITION = {
- match: [
- /Function/,
- /\s+/,
- regex.concat(/(\.)?/, hljs.IDENT_RE)
- ],
- scope: {
- 1: "keyword",
- 3: "title.function"
- }
- };
- // Var Custom.Variable.Name.Item
- // Var /GLOBAL Custom.Variable.Name.Item
- const VARIABLE_NAME_RE = /[A-Za-z][\w.]*/;
- const VARIABLE_DEFINITION = {
- match: [
- /Var/,
- /\s+/,
- /(?:\/GLOBAL\s+)?/,
- VARIABLE_NAME_RE
- ],
- scope: {
- 1: "keyword",
- 3: "params",
- 4: "variable"
- }
- };
- return {
- name: 'NSIS',
- case_insensitive: true,
- keywords: {
- keyword: KEYWORDS,
- literal: LITERALS
- },
- contains: [
- hljs.HASH_COMMENT_MODE,
- hljs.C_BLOCK_COMMENT_MODE,
- hljs.COMMENT(
- ';',
- '$',
- { relevance: 0 }
- ),
- VARIABLE_DEFINITION,
- FUNCTION_DEFINITION,
- { beginKeywords: 'Function PageEx Section SectionGroup FunctionEnd SectionEnd', },
- STRING,
- COMPILER,
- DEFINES,
- VARIABLES,
- LANGUAGES,
- PARAMETERS,
- PLUGINS,
- hljs.NUMBER_MODE
- ]
- };
- }
- export { nsis as default };
|