mode-nsis.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. ace.define("ace/mode/nsis_highlight_rules",[], function(require, exports, module) {
  2. "use strict";
  3. var oop = require("../lib/oop");
  4. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  5. var NSISHighlightRules = function() {
  6. this.$rules = {
  7. start: [{
  8. token: "keyword.compiler.nsis",
  9. regex: /^\s*!(?:include|addincludedir|addplugindir|appendfile|cd|delfile|echo|error|execute|packhdr|pragma|finalize|getdllversion|gettlbversion|system|tempfile|warning|verbose|define|undef|insertmacro|macro|macroend|makensis|searchparse|searchreplace)\b/,
  10. caseInsensitive: true
  11. }, {
  12. token: "keyword.command.nsis",
  13. regex: /^\s*(?: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|GetLabelAddress|GetTempFileName|Goto|HideWindow|Icon|IfAbort|IfErrors|IfFileExists|IfRebootFlag|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|LoadLanguageFile|LockWindow|LogSet|LogText|ManifestDPIAware|ManifestSupportedOS|MessageBox|MiscButtonText|Name|Nop|OutFile|Page|PageCallbacks|PEDllCharacteristics|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)\b/,
  14. caseInsensitive: true
  15. }, {
  16. token: "keyword.control.nsis",
  17. regex: /^\s*!(?:ifdef|ifndef|if|ifmacrodef|ifmacrondef|else|endif)\b/,
  18. caseInsensitive: true
  19. }, {
  20. token: "keyword.plugin.nsis",
  21. regex: /^\s*\w+::\w+/,
  22. caseInsensitive: true
  23. }, {
  24. token: "keyword.operator.comparison.nsis",
  25. regex: /[!<>]?=|<>|<|>/
  26. }, {
  27. token: "support.function.nsis",
  28. regex: /(?:\b|^\s*)(?:Function|FunctionEnd|Section|SectionEnd|SectionGroup|SectionGroupEnd|PageEx|PageExEnd)\b/,
  29. caseInsensitive: true
  30. }, {
  31. token: "support.library.nsis",
  32. regex: /\${[\w\.:-]+}/
  33. }, {
  34. token: "constant.nsis",
  35. regex: /\b(?:ARCHIVE|FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_NORMAL|FILE_ATTRIBUTE_OFFLINE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_TEMPORARY|HIDDEN|HKCC|HKCR(32|64)?|HKCU(32|64)?|HKDD|HKEY_CLASSES_ROOT|HKEY_CURRENT_CONFIG|HKEY_CURRENT_USER|HKEY_DYN_DATA|HKEY_LOCAL_MACHINE|HKEY_PERFORMANCE_DATA|HKEY_USERS|HKLM(32|64)?|HKPD|HKU|IDABORT|IDCANCEL|IDD_DIR|IDD_INST|IDD_INSTFILES|IDD_LICENSE|IDD_SELCOM|IDD_UNINST|IDD_VERIFY|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|MB_YESNOCANCEL|NORMAL|OFFLINE|READONLY|SHCTX|SHELL_CONTEXT|SW_HIDE|SW_SHOWDEFAULT|SW_SHOWMAXIMIZED|SW_SHOWMINIMIZED|SW_SHOWNORMAL|SYSTEM|TEMPORARY)\b/,
  36. caseInsensitive: true
  37. }, {
  38. token: "constant.library.nsis",
  39. regex: /\${(?:AtLeastServicePack|AtLeastWin7|AtLeastWin8|AtLeastWin10|AtLeastWin95|AtLeastWin98|AtLeastWin2000|AtLeastWin2003|AtLeastWin2008|AtLeastWin2008R2|AtLeastWinME|AtLeastWinNT4|AtLeastWinVista|AtLeastWinXP|AtMostServicePack|AtMostWin7|AtMostWin8|AtMostWin10|AtMostWin95|AtMostWin98|AtMostWin2000|AtMostWin2003|AtMostWin2008|AtMostWin2008R2|AtMostWinME|AtMostWinNT4|AtMostWinVista|AtMostWinXP|IsDomainController|IsNT|IsServer|IsServicePack|IsWin7|IsWin8|IsWin10|IsWin95|IsWin98|IsWin2000|IsWin2003|IsWin2008|IsWin2008R2|IsWinME|IsWinNT4|IsWinVista|IsWinXP)}/
  40. }, {
  41. token: "constant.language.boolean.true.nsis",
  42. regex: /\b(?:true|on)\b/
  43. }, {
  44. token: "constant.language.boolean.false.nsis",
  45. regex: /\b(?:false|off)\b/
  46. }, {
  47. token: "constant.language.option.nsis",
  48. regex: /(?:\b|^\s*)(?:(?:un\.)?components|(?:un\.)?custom|(?:un\.)?directory|(?:un\.)?instfiles|(?:un\.)?license|uninstConfirm|admin|all|auto|both|bottom|bzip2|current|force|hide|highest|ifdiff|ifnewer|lastused|leave|left|listonly|lzma|nevershow|none|normal|notset|right|show|silent|silentlog|textonly|top|try|user|Win10|Win7|Win8|WinVista|zlib)\b/,
  49. caseInsensitive: true
  50. }, {
  51. token: "constant.language.slash-option.nsis",
  52. regex: /\b\/(?:a|BRANDING|CENTER|COMPONENTSONLYONCUSTOM|CUSTOMSTRING=|date|e|ENABLECANCEL|FILESONLY|file|FINAL|GLOBAL|gray|ifempty|ifndef|ignorecase|IMGID=|ITALIC|LANG=|NOCUSTOM|noerrors|NONFATAL|nonfatal|oname=|o|REBOOTOK|redef|RESIZETOFIT|r|SHORT|SILENT|SOLID|STRIKE|TRIM|UNDERLINE|utcdate|windows|x)\b/,
  53. caseInsensitive: true
  54. }, {
  55. token: "constant.numeric.nsis",
  56. regex: /\b(?:0(?:x|X)[0-9a-fA-F]+|[0-9]+(?:\.[0-9]+)?)\b/
  57. }, {
  58. token: "entity.name.function.nsis",
  59. regex: /\$\([\w\.:-]+\)/
  60. }, {
  61. token: "storage.type.function.nsis",
  62. regex: /\$\w+/
  63. }, {
  64. token: "punctuation.definition.string.begin.nsis",
  65. regex: /`/,
  66. push: [{
  67. token: "punctuation.definition.string.end.nsis",
  68. regex: /`/,
  69. next: "pop"
  70. }, {
  71. token: "constant.character.escape.nsis",
  72. regex: /\$\\./
  73. }, {
  74. defaultToken: "string.quoted.back.nsis"
  75. }]
  76. }, {
  77. token: "punctuation.definition.string.begin.nsis",
  78. regex: /"/,
  79. push: [{
  80. token: "punctuation.definition.string.end.nsis",
  81. regex: /"/,
  82. next: "pop"
  83. }, {
  84. token: "constant.character.escape.nsis",
  85. regex: /\$\\./
  86. }, {
  87. defaultToken: "string.quoted.double.nsis"
  88. }]
  89. }, {
  90. token: "punctuation.definition.string.begin.nsis",
  91. regex: /'/,
  92. push: [{
  93. token: "punctuation.definition.string.end.nsis",
  94. regex: /'/,
  95. next: "pop"
  96. }, {
  97. token: "constant.character.escape.nsis",
  98. regex: /\$\\./
  99. }, {
  100. defaultToken: "string.quoted.single.nsis"
  101. }]
  102. }, {
  103. token: [
  104. "punctuation.definition.comment.nsis",
  105. "comment.line.nsis"
  106. ],
  107. regex: /(;|#)(.*$)/
  108. }, {
  109. token: "punctuation.definition.comment.nsis",
  110. regex: /\/\*/,
  111. push: [{
  112. token: "punctuation.definition.comment.nsis",
  113. regex: /\*\//,
  114. next: "pop"
  115. }, {
  116. defaultToken: "comment.block.nsis"
  117. }]
  118. }, {
  119. token: "text",
  120. regex: /(?:!include|!insertmacro)\b/
  121. }]
  122. };
  123. this.normalizeRules();
  124. };
  125. NSISHighlightRules.metaData = {
  126. comment: "\n\ttodo: - highlight functions\n\t",
  127. fileTypes: ["nsi", "nsh"],
  128. name: "NSIS",
  129. scopeName: "source.nsis"
  130. };
  131. oop.inherits(NSISHighlightRules, TextHighlightRules);
  132. exports.NSISHighlightRules = NSISHighlightRules;
  133. });
  134. ace.define("ace/mode/folding/cstyle",[], function(require, exports, module) {
  135. "use strict";
  136. var oop = require("../../lib/oop");
  137. var Range = require("../../range").Range;
  138. var BaseFoldMode = require("./fold_mode").FoldMode;
  139. var FoldMode = exports.FoldMode = function(commentRegex) {
  140. if (commentRegex) {
  141. this.foldingStartMarker = new RegExp(
  142. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  143. );
  144. this.foldingStopMarker = new RegExp(
  145. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  146. );
  147. }
  148. };
  149. oop.inherits(FoldMode, BaseFoldMode);
  150. (function() {
  151. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  152. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  153. this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
  154. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  155. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  156. this._getFoldWidgetBase = this.getFoldWidget;
  157. this.getFoldWidget = function(session, foldStyle, row) {
  158. var line = session.getLine(row);
  159. if (this.singleLineBlockCommentRe.test(line)) {
  160. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  161. return "";
  162. }
  163. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  164. if (!fw && this.startRegionRe.test(line))
  165. return "start"; // lineCommentRegionStart
  166. return fw;
  167. };
  168. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  169. var line = session.getLine(row);
  170. if (this.startRegionRe.test(line))
  171. return this.getCommentRegionBlock(session, line, row);
  172. var match = line.match(this.foldingStartMarker);
  173. if (match) {
  174. var i = match.index;
  175. if (match[1])
  176. return this.openingBracketBlock(session, match[1], row, i);
  177. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  178. if (range && !range.isMultiLine()) {
  179. if (forceMultiline) {
  180. range = this.getSectionRange(session, row);
  181. } else if (foldStyle != "all")
  182. range = null;
  183. }
  184. return range;
  185. }
  186. if (foldStyle === "markbegin")
  187. return;
  188. var match = line.match(this.foldingStopMarker);
  189. if (match) {
  190. var i = match.index + match[0].length;
  191. if (match[1])
  192. return this.closingBracketBlock(session, match[1], row, i);
  193. return session.getCommentFoldRange(row, i, -1);
  194. }
  195. };
  196. this.getSectionRange = function(session, row) {
  197. var line = session.getLine(row);
  198. var startIndent = line.search(/\S/);
  199. var startRow = row;
  200. var startColumn = line.length;
  201. row = row + 1;
  202. var endRow = row;
  203. var maxRow = session.getLength();
  204. while (++row < maxRow) {
  205. line = session.getLine(row);
  206. var indent = line.search(/\S/);
  207. if (indent === -1)
  208. continue;
  209. if (startIndent > indent)
  210. break;
  211. var subRange = this.getFoldWidgetRange(session, "all", row);
  212. if (subRange) {
  213. if (subRange.start.row <= startRow) {
  214. break;
  215. } else if (subRange.isMultiLine()) {
  216. row = subRange.end.row;
  217. } else if (startIndent == indent) {
  218. break;
  219. }
  220. }
  221. endRow = row;
  222. }
  223. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  224. };
  225. this.getCommentRegionBlock = function(session, line, row) {
  226. var startColumn = line.search(/\s*$/);
  227. var maxRow = session.getLength();
  228. var startRow = row;
  229. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  230. var depth = 1;
  231. while (++row < maxRow) {
  232. line = session.getLine(row);
  233. var m = re.exec(line);
  234. if (!m) continue;
  235. if (m[1]) depth--;
  236. else depth++;
  237. if (!depth) break;
  238. }
  239. var endRow = row;
  240. if (endRow > startRow) {
  241. return new Range(startRow, startColumn, endRow, line.length);
  242. }
  243. };
  244. }).call(FoldMode.prototype);
  245. });
  246. ace.define("ace/mode/nsis",[], function(require, exports, module) {
  247. "use strict";
  248. var oop = require("../lib/oop");
  249. var TextMode = require("./text").Mode;
  250. var NSISHighlightRules = require("./nsis_highlight_rules").NSISHighlightRules;
  251. var FoldMode = require("./folding/cstyle").FoldMode;
  252. var Mode = function() {
  253. this.HighlightRules = NSISHighlightRules;
  254. this.foldingRules = new FoldMode();
  255. this.$behaviour = this.$defaultBehaviour;
  256. };
  257. oop.inherits(Mode, TextMode);
  258. (function() {
  259. this.lineCommentStart = [";", "#"];
  260. this.blockComment = {start: "/*", end: "*/"};
  261. this.$id = "ace/mode/nsis";
  262. }).call(Mode.prototype);
  263. exports.Mode = Mode;
  264. });
  265. (function() {
  266. ace.require(["ace/mode/nsis"], function(m) {
  267. if (typeof module == "object" && typeof exports == "object" && module) {
  268. module.exports = m;
  269. }
  270. });
  271. })();