// ==UserScript== // @name AceInstead // @namespace https://github.com/Som1Lse/AceInstead // @description Changes the text editor to be Ace (https://ace.c9.io) instead of CodeMirror // @include http://d.godbolt.org/* // @include http://go.godbolt.org/* // @include http://gcc.godbolt.org/* // @include http://rust.godbolt.org/* // @include https://d.godbolt.org/* // @include https://go.godbolt.org/* // @include https://gcc.godbolt.org/* // @include https://rust.godbolt.org/* // @resource require_js http://requirejs.org/docs/release/2.3.2/comments/require.js // @resource ace_js https://raw.githubusercontent.com/ajaxorg/ace-builds/master/src-noconflict/ace.js // @resource ext_searchbox_js https://raw.githubusercontent.com/ajaxorg/ace-builds/master/src-noconflict/ext-searchbox.js // @resource theme_monokai_js https://raw.githubusercontent.com/ajaxorg/ace-builds/master/src-noconflict/theme-monokai.js // @resource mode_d_js https://raw.githubusercontent.com/ajaxorg/ace-builds/master/src-noconflict/mode-d.js // @resource mode_rust_js https://raw.githubusercontent.com/ajaxorg/ace-builds/master/src-noconflict/mode-rust.js // @resource mode_c_cpp_js https://raw.githubusercontent.com/ajaxorg/ace-builds/master/src-noconflict/mode-c_cpp.js // @resource mode_golang_js https://raw.githubusercontent.com/ajaxorg/ace-builds/master/src-noconflict/mode-golang.js // @version 2.0.1 // @grant unsafeWindow // @grant GM_getResourceText // @grant GM_addStyle // @run-at document-start // ==/UserScript== (function(){ 'use strict'; function RemoteExecute(code){ if(typeof(code) === 'function') code = '('+code.toString()+')()'; new unsafeWindow.Function(code).call(unsafeWindow); } GM_addStyle( '.ace_editor {'+ 'margin-bottom: 0px;'+ '}'+ '.ace_gutter-layer .ace_gutter-cell>div {'+ 'display: inline-block;'+ '}'+ '.ace_search {'+ 'color: #000000;'+ 'font-family: sans-serif;'+ '}'+ '.address, .opcodes {'+ 'vertical-align: top !important;'+ 'font-size: 12px !important;'+ 'display: inline-block;'+ 'width: initial !important;'+ '}'+ //fix the markers for the monokai-theme so they are properly transparent '.ace-monokai .ace_marker-layer .ace_active-line {'+ 'background: rgba(0,0,0,0.2) !important;'+ '}'+ '.ace-monokai .ace_marker-layer .ace_selection {'+ 'background: rgba(209, 200, 174, 0.2) !important;'+ '}'+ '.rainbow-0, .rainbow-1, .rainbow-2, .rainbow-3, .rainbow-4, .rainbow-5,'+ '.rainbow-6, .rainbow-7, .rainbow-8, .rainbow-9, .rainbow-10,.rainbow-11 {'+ 'position: absolute;'+ 'opacity: 0.3;'+ '}' ); RemoteExecute(GM_getResourceText('require_js')+ 'window.define = define;'+ 'window.require = require;'+ 'window.requirejs = requirejs;'); var scripts = [ 'ace_js', 'ext_searchbox_js', 'theme_monokai_js', 'mode_d_js', 'mode_rust_js', 'mode_c_cpp_js', 'mode_golang_js', ]; for(var i = 0;i')){ tokens = [{'type': 'keyword','value': eat()}]; } var match = /^\S[^#]*:/i.exec(str); if(match === null){ match = /^\s+[a-z_]\w*/i.exec(str); if(match !== null){ tokens.push({'type': 'keyword','value': eat(match[0])}); }else{ match = /^\s+\.\w+/i.exec(str); if(match !== null){ tokens.push({'type': 'storage.type','value': eat(match[0])}); } } }else{ tokens.push({'type': 'variable.parameter','value': eat(match[0])}); } while(str.length>0){ match = /^\s+/i.exec(str); if(match !== null){ tokens.push({'type': 'spacing','value': eat(match[0])}); continue; } match = /^\$?-?\d\w*/i.exec(str); if(match !== null){ tokens.push({'type': 'constant.numeric','value': eat(match[0])}); continue; } match = /^%?\w+/i.exec(str); if(match !== null && (match[0].search(/^%?[xy]mm\d+$/i) === 0 || match[0].search(/^%?[re]?([a-d]x|di|si|bp|sp)$/i) === 0 || match[0].search(/^%?[re]ip$/i) === 0 || match[0].search(/^%?(di|si|bp|sp)l$/i) === 0 || match[0].search(/^%?[a-d][hl]$/i) === 0 || match[0].search(/^%?[c-fs]s$/i) === 0)){ console.log(match); tokens.push({'type': 'variable','value': eat(match[0])}); continue; } match = /^(ptr|offset|flat|byte|(d|w|xmm|ymm)?word)/i.exec(str); if(match !== null){ tokens.push({'type': 'storage.type','value': eat(match[0])}); continue; } match = /^[a-z_.\-$@][\w.\-$@]*/i.exec(str); if(match !== null){ tokens.push({'type': 'identifier','value': eat(match[0])}); continue; } if(str[0] === '<' || str[0] === '(' || str[0] === '[' || str[0] === '{'){ tokens.push({'type': 'paren.lparen','value': eat(1)}); }else if(str[0] === '>' || str[0] === ')' || str[0] === ']' || str[0] === '}'){ tokens.push({'type': 'paren.lparen','value': eat(1)}); }else if(str[0] === ',' || str[0] === '$' || str[0] === '%' || str[0] === '+' || str[0] === '*' || str[0] === ':' || str[0] === '!' || str[0] === '-' || str[0] === '&'){ tokens.push({'type': 'punctuation.operator','value': eat(1)}); }else if(str[0] === '\"'){ var i; for(i = 1;i0) tokens.push({'type': 'invalid','value': eat(i)}); } }else if(str[0] === '#'){ tokens.push({'type': 'comment','value': eat()}); }else{ tokens.push({'type': 'invalid','value': eat(1)}); } } return {'state': 'start','tokens': tokens}; }, }; this.getTokenizer = function(){ return this._tokenizer; }; this.createWorker = function(){ return null; }; }; oop.inherits(Mode,require('./text').Mode); }); require(['editor'],function(editor){ function DiagTypeAsInt(type){ switch(type){ case 'error': return 2; case 'warning': return 1; default: return 0; } } function MaxDiagType(type1,type2){ if(DiagTypeAsInt(type2) >= DiagTypeAsInt(type1)){ return type2; }else{ return type1; } } function UpdateAnnotations(editor){ var temp_annotations = {}; var a,x; for(a in editor.widgetsByCompiler){ var compiler = editor.widgetsByCompiler[a].compiler; x = editor.widgetsByCompiler[a].widgets; for(var i = 0;i