Advertisement
Guest User

Untitled

a guest
Feb 16th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.89 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  
  3. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <style type="text/css">
  6. html,
  7. body {
  8. width: 100%;
  9. height: 100%;
  10. margin: 0;
  11. padding: 0;
  12. overflow: hidden;
  13. background-repeat: no-repeat;
  14. background-attachment: scroll;
  15. background-image: url("https://i.vgy.me/aIFPIP.jpg");
  16. }
  17. </style>
  18.  
  19. <title></title>
  20. </head>
  21. <body>
  22. <div id="container" style="width:100%;height:100%;opacity:0.5;"></div>
  23. <script src="vs/loader.js"></script>
  24. <script type="text/javascript">
  25. require.config({ paths: { 'vs': 'vs' } });
  26. // API
  27. var GetText;
  28. var SetText;
  29. var SetTheme;
  30. var SetScroll;
  31. var ShowErr;
  32. var Refresh;
  33.  
  34. // Enablers
  35. var SwitchMinimap;
  36. var SwitchReadonly;
  37. var SwitchRenderWhitespace;
  38. var SwitchLinks;
  39. var SwitchLineHeight;
  40. var SwitchFontSize;
  41. var SwitchFolding;
  42. var SwitchAutoIndent;
  43. var SwitchFontFamily;
  44. var SwitchFontLigatures;
  45. var AddIntellisense;
  46.  
  47. // Variables
  48. var editor;
  49. var Proposals = [];
  50.  
  51. require(['vs/editor/editor.main'], function () {
  52. function getDependencyProposals() {
  53. return Proposals;
  54. }
  55.  
  56. monaco.languages.registerCompletionItemProvider('lua', {
  57. provideCompletionItems: function(model, position) {
  58. return getDependencyProposals();
  59. }
  60. });
  61.  
  62. monaco.editor.defineTheme('net-theme-light', {
  63. base: 'vs',
  64. inherit: true,
  65. rules: [
  66. { token: 'global', foreground: '000000' },
  67. { token: 'keyword', foreground: 'ff6a00' },
  68. { token: 'comment', foreground: '666666' },
  69. { token: 'number', foreground: 'ffc600' },
  70. { token: 'string', foreground: 'ff8c3a' },
  71. ]
  72. });
  73.  
  74. monaco.editor.defineTheme('net-theme-dark', {
  75. base: 'vs-dark',
  76. inherit: true,
  77. rules: [
  78. { token: 'global', foreground: 'adadad', fontStyle: "bold" },
  79. { token: 'keyword', foreground: '7c2689', fontStyle: "bold" },
  80. { token: 'comment', foreground: '9b9b9b' },
  81. { token: 'number', foreground: '485784' },
  82. { token: 'string', foreground: 'cecece' },
  83. ]
  84. });
  85.  
  86. editor = monaco.editor.create(document.getElementById('container'), {
  87. value: [
  88. "--[[",
  89. " Lua Script",
  90. "--]]",
  91. ].join('\n'),
  92. language: 'lua',
  93. theme: "net-theme-light",
  94. folding: true,
  95. scrollbar: {
  96. verticalHasArrows: true,
  97. },
  98. dragAndDrop: true,
  99. links: false,
  100. minimap: {
  101. enabled: false,
  102. },
  103. showFoldingControls: "always",
  104. smoothScrolling: true,
  105. });
  106.  
  107. window.onresize = function() {
  108. editor.layout();
  109. };
  110.  
  111. GetText = function() {
  112. return editor.getValue();
  113. }
  114.  
  115. SetText = function(x) {
  116. editor.setValue(x);
  117. }
  118.  
  119. SetTheme = function(themeName) {
  120. if (themeName == "Dark") {
  121. monaco.editor.setTheme("net-theme-dark");
  122. }
  123. if (themeName == "Light") {
  124. monaco.editor.setTheme("net-theme-light");
  125. }
  126. }
  127.  
  128. SwitchMinimap = function(flag) {
  129. editor.updateOptions({
  130. minimap: {
  131. enabled: flag,
  132. }
  133. });
  134. }
  135.  
  136. SwitchReadonly = function(flag) {
  137. editor.updateOptions({
  138. readOnly: flag,
  139. });
  140. }
  141.  
  142. SwitchRenderWhitespace = function(op) {
  143. editor.updateOptions({
  144. renderWhitespace: op,
  145. });
  146. }
  147.  
  148. SwitchLinks = function(flag) {
  149. editor.updateOptions({
  150. links: flag,
  151. });
  152. }
  153.  
  154. SwitchLineHeight = function(num) {
  155. editor.updateOptions({
  156. lineHeight: num,
  157. });
  158. }
  159.  
  160. SwitchFontSize = function(num) {
  161. editor.updateOptions({
  162. fontSize: num,
  163. });
  164. }
  165.  
  166. SwitchFolding = function(flag) {
  167. editor.updateOptions({
  168. folding: flag,
  169. });
  170. }
  171.  
  172. SwitchAutoIndent = function(flag) {
  173. editor.updateOptions({
  174. autoIndent: flag,
  175. });
  176. }
  177.  
  178. SwitchFontFamily = function(name) {
  179. editor.updateOptions({
  180. fontFamily: name,
  181. });
  182. }
  183.  
  184. SwitchFontLigatures = function(flag) {
  185. editor.updateOptions({
  186. fontLigatures: flag,
  187. });
  188. }
  189.  
  190.  
  191. ShowErr = function(line, column, endline, endcolumn, errMessage) {
  192. editor.revealPositionInCenter({ lineNumber: line, column: column});
  193. editor.deltaDecorations([], [
  194. {
  195. range: new monaco.Range(line, column, endline, endcolumn),
  196. options: {
  197. inlineClassName: 'squiggly-error',
  198. hoverMessage: {
  199. value: errMessage,
  200. }
  201. },
  202. },
  203. ]);
  204. }
  205.  
  206. AddIntellisense = function(l, k, d, i) {
  207. var t;
  208. switch(k)
  209. {
  210. case "Class":
  211. t = monaco.languages.CompletionItemKind.Class;
  212. break;
  213. case "Color":
  214. t = monaco.languages.CompletionItemKind.Color;
  215. break;
  216. case "Constructor":
  217. t = monaco.languages.CompletionItemKind.Constructor;
  218. break;
  219. case "Enum":
  220. t = monaco.languages.CompletionItemKind.Enum;
  221. break;
  222. case "Field":
  223. t = monaco.languages.CompletionItemKind.Field;
  224. break;
  225. case "File":
  226. t = monaco.languages.CompletionItemKind.File;
  227. break;
  228. case "Folder":
  229. t = monaco.languages.CompletionItemKind.Folder;
  230. break;
  231. case "Function":
  232. t = monaco.languages.CompletionItemKind.Function;
  233. break;
  234. case "Interface":
  235. t = monaco.languages.CompletionItemKind.Interface;
  236. break;
  237. case "Keyword":
  238. t = monaco.languages.CompletionItemKind.Keyword;
  239. break;
  240. case "Method":
  241. t = monaco.languages.CompletionItemKind.Method;
  242. break;
  243. case "Module":
  244. t = monaco.languages.CompletionItemKind.Module;
  245. break;
  246. case "Property":
  247. t = monaco.languages.CompletionItemKind.Property;
  248. break;
  249. case "Reference":
  250. t = monaco.languages.CompletionItemKind.Reference;
  251. break;
  252. case "Snippet":
  253. t = monaco.languages.CompletionItemKind.Snippet;
  254. break;
  255. case "Text":
  256. t = monaco.languages.CompletionItemKind.Text;
  257. break;
  258. case "Unit":
  259. t = monaco.languages.CompletionItemKind.Unit;
  260. break;
  261. case "Value":
  262. t = monaco.languages.CompletionItemKind.Value;
  263. break;
  264. case "Variable":
  265. t = monaco.languages.CompletionItemKind.Variable;
  266. break;
  267. }
  268.  
  269. Proposals.push({
  270. label: l,
  271. kind: t,
  272. detail: d,
  273. insertText: i
  274. });
  275. }
  276.  
  277. SetScroll = function(line) {
  278. editor.revealLineInCenter({ lineNumber: line});
  279. }
  280.  
  281. Refresh = function() {
  282. var text = getText();
  283. setText("");
  284. editor.trigger('keyboard', 'type', {text: text});
  285. }
  286. });
  287. </script>
  288. </body>
  289. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement