Advertisement
vipejames

monaco

Nov 15th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.71 KB | None | 0 0
  1. {Remove this text before pasting. Go to synapse folder then bin folder then right click Monaco Open with notepad and paste below there then save it. Remove this text before pasting.}
  2.  
  3.  
  4. <!DOCTYPE html>
  5.  
  6. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  7. <head>
  8. <style type="text/css">
  9. html,
  10. body {
  11. width: 100%;
  12. height: 100%;
  13. margin: 0;
  14. padding: 0;
  15. overflow: hidden;
  16. }
  17. </style>
  18. <meta charset="utf-8" />
  19. <title></title>
  20. </head>
  21. <body>
  22. <div id="container" style="width:100%;height:100%;"></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: 'FFFFFF', fontStyle: "bold" },
  79. { token: 'keyword', foreground: 'ff6a00', fontStyle: "bold" },
  80. { token: 'comment', foreground: '666666' },
  81. { token: 'number', foreground: 'ffc600' },
  82. { token: 'string', foreground: 'ff8c3a' },
  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. document.getElementsByClassName("lines-content monaco-editor-background")[0].style.backgroundImage="url(https://cdn.discordapp.com/attachments/512377999052505109/512743506155143188/unknown.png)"
  278. document.getElementsByClassName("margin")[0].style.backgroundImage="url(https://cdn.discordapp.com/attachments/512377999052505109/512743506155143188/unknown.png)"
  279. document.getElementsByClassName("lines-content monaco-editor-background")[0].style.backgroundAttachment="fixed"
  280. document.getElementsByClassName("margin")[0].style.backgroundAttachment="fixed"
  281. document.getElementsByClassName("lines-content monaco-editor-background")[0].style.repeat="no-repeat"
  282. document.getElementsByClassName("margin")[0].style.repeat="no-repeat"
  283.  
  284. SetScroll = function(line) {
  285. editor.revealLineInCenter({ lineNumber: line});
  286. }
  287.  
  288. Refresh = function() {
  289. var text = getText();
  290. setText("");
  291. editor.trigger('keyboard', 'type', {text: text});
  292. }
  293. });
  294. </script>
  295. </body>
  296. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement