国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
5.3KB

  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: https://codemirror.net/5/LICENSE
  3. (function() {
  4. var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-c");
  5. function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
  6. MT("indent",
  7. "[type void] [def foo]([type void*] [variable a], [type int] [variable b]) {",
  8. " [type int] [variable c] [operator =] [variable b] [operator +]",
  9. " [number 1];",
  10. " [keyword return] [operator *][variable a];",
  11. "}");
  12. MT("indent_switch",
  13. "[keyword switch] ([variable x]) {",
  14. " [keyword case] [number 10]:",
  15. " [keyword return] [number 20];",
  16. " [keyword default]:",
  17. " [variable printf]([string \"foo %c\"], [variable x]);",
  18. "}");
  19. MT("def",
  20. "[type void] [def foo]() {}",
  21. "[keyword struct] [def bar]{}",
  22. "[keyword enum] [def zot]{}",
  23. "[keyword union] [def ugh]{}",
  24. "[type int] [type *][def baz]() {}");
  25. MT("def_new_line",
  26. "::[variable std]::[variable SomeTerribleType][operator <][variable T][operator >]",
  27. "[def SomeLongMethodNameThatDoesntFitIntoOneLine]([keyword const] [variable MyType][operator &] [variable param]) {}")
  28. MT("double_block",
  29. "[keyword for] (;;)",
  30. " [keyword for] (;;)",
  31. " [variable x][operator ++];",
  32. "[keyword return];");
  33. MT("preprocessor",
  34. "[meta #define FOO 3]",
  35. "[type int] [variable foo];",
  36. "[meta #define BAR\\]",
  37. "[meta 4]",
  38. "[type unsigned] [type int] [variable bar] [operator =] [number 8];",
  39. "[meta #include <baz> ][comment // comment]")
  40. MT("c_underscores",
  41. "[builtin __FOO];",
  42. "[builtin _Complex];",
  43. "[builtin __aName];",
  44. "[variable _aName];");
  45. MT("c_types",
  46. "[type int];",
  47. "[type long];",
  48. "[type char];",
  49. "[type short];",
  50. "[type double];",
  51. "[type float];",
  52. "[type unsigned];",
  53. "[type signed];",
  54. "[type void];",
  55. "[type bool];",
  56. "[type foo_t];",
  57. "[variable foo_T];",
  58. "[variable _t];");
  59. var mode_cpp = CodeMirror.getMode({indentUnit: 2}, "text/x-c++src");
  60. function MTCPP(name) { test.mode(name, mode_cpp, Array.prototype.slice.call(arguments, 1)); }
  61. MTCPP("cpp14_literal",
  62. "[number 10'000];",
  63. "[number 0b10'000];",
  64. "[number 0x10'000];",
  65. "[string '100000'];");
  66. MTCPP("ctor_dtor",
  67. "[def Foo::Foo]() {}",
  68. "[def Foo::~Foo]() {}");
  69. MTCPP("cpp_underscores",
  70. "[builtin __FOO];",
  71. "[builtin _Complex];",
  72. "[builtin __aName];",
  73. "[variable _aName];");
  74. var mode_objc = CodeMirror.getMode({indentUnit: 2}, "text/x-objectivec");
  75. function MTOBJC(name) { test.mode(name, mode_objc, Array.prototype.slice.call(arguments, 1)); }
  76. MTOBJC("objc_underscores",
  77. "[builtin __FOO];",
  78. "[builtin _Complex];",
  79. "[builtin __aName];",
  80. "[variable _aName];");
  81. MTOBJC("objc_interface",
  82. "[keyword @interface] [def foo] {",
  83. " [type int] [variable bar];",
  84. "}",
  85. "[keyword @property] ([keyword atomic], [keyword nullable]) [variable NSString][operator *] [variable a];",
  86. "[keyword @property] ([keyword nonatomic], [keyword assign]) [type int] [variable b];",
  87. "[operator -]([type instancetype])[variable initWithFoo]:([type int])[variable a] " +
  88. "[builtin NS_DESIGNATED_INITIALIZER];",
  89. "[keyword @end]");
  90. MTOBJC("objc_implementation",
  91. "[keyword @implementation] [def foo] {",
  92. " [type int] [variable bar];",
  93. "}",
  94. "[keyword @property] ([keyword readwrite]) [type SEL] [variable a];",
  95. "[operator -]([type instancetype])[variable initWithFoo]:([type int])[variable a] {",
  96. " [keyword if](([keyword self] [operator =] [[[keyword super] [variable init] ]])) {}",
  97. " [keyword return] [keyword self];",
  98. "}",
  99. "[keyword @end]");
  100. MTOBJC("objc_types",
  101. "[type int];",
  102. "[type foo_t];",
  103. "[variable foo_T];",
  104. "[type id];",
  105. "[type SEL];",
  106. "[type instancetype];",
  107. "[type Class];",
  108. "[type Protocol];",
  109. "[type BOOL];"
  110. );
  111. var mode_scala = CodeMirror.getMode({indentUnit: 2}, "text/x-scala");
  112. function MTSCALA(name) { test.mode("scala_" + name, mode_scala, Array.prototype.slice.call(arguments, 1)); }
  113. MTSCALA("nested_comments",
  114. "[comment /*]",
  115. "[comment But wait /* this is a nested comment */ for real]",
  116. "[comment /**** let * me * show * you ****/]",
  117. "[comment ///// let / me / show / you /////]",
  118. "[comment */]");
  119. var mode_java = CodeMirror.getMode({indentUnit: 2}, "text/x-java");
  120. function MTJAVA(name) { test.mode("java_" + name, mode_java, Array.prototype.slice.call(arguments, 1)); }
  121. MTJAVA("types",
  122. "[type byte];",
  123. "[type short];",
  124. "[type int];",
  125. "[type long];",
  126. "[type float];",
  127. "[type double];",
  128. "[type boolean];",
  129. "[type char];",
  130. "[type void];",
  131. "[type Boolean];",
  132. "[type Byte];",
  133. "[type Character];",
  134. "[type Double];",
  135. "[type Float];",
  136. "[type Integer];",
  137. "[type Long];",
  138. "[type Number];",
  139. "[type Object];",
  140. "[type Short];",
  141. "[type String];",
  142. "[type StringBuffer];",
  143. "[type StringBuilder];",
  144. "[type Void];");
  145. })();