mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +00:00
d618ddc172
- feature: codemirror modules now loaded by default: search.js, comment.js dialog.js, autorefresh.js, searchcursor.js, dialog.css codemirror search & replace is now activated by default. to use this feature now you must only load in fhemweb attribute 'JavaScripts' the codemirror/fhem_codemirror.js file new extraKeys for 'TAB', 'Shift+Tab', 'STRG+Q', 'STRG+UP', and 'STRG+DOWN' are added. codemirror default parameters are now: indentUnit:4, indentWithTabs:false, autoCloseBrackets:false, matchBrackets:true, autofocus:true, theme:"blackboard", lineNumbers:true, autoRefresh:true this can be overwritten with fhemweb attribute 'codemirrorParam' - updated: codemirror version to 5.8 the default codemirror javascript files are now minified git-svn-id: https://svn.fhem.de/fhem/trunk@9668 2b470e98-0d58-463d-a4d8-8e2adae1ed80
5 lines
2.3 KiB
JavaScript
5 lines
2.3 KiB
JavaScript
(function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)})(function(e){function t(a,c,b,e){var d=a.getLineHandle(c.line),h=c.ch-1,d=0<=h&&r[d.text.charAt(h)]||r[d.text.charAt(++h)];if(!d)return null;var g=">"==d.charAt(1)?1:-1;if(b&&0<g!=(h==c.ch))return null;b=a.getTokenTypeAt(l(c.line,h+1));a=u(a,l(c.line,h+(0<g?1:0)),g,b||null,e);return null==a?null:{from:l(c.line,h),
|
|
to:a&&a.pos,match:a&&a.ch==d.charAt(0),forward:0<g}}function u(a,c,b,e,d){var h=d&&d.maxScanLineLength||1E4,g=d&&d.maxScanLines||1E3,f=[];d=d&&d.bracketRegex?d.bracketRegex:/[(){}[\]]/;for(var g=0<b?Math.min(c.line+g,a.lastLine()+1):Math.max(a.firstLine()-1,c.line-g),k=c.line;k!=g;k+=b){var p=a.getLine(k);if(p){var m=0<b?0:p.length-1,n=0<b?p.length:-1;if(!(p.length>h))for(k==c.line&&(m=c.ch-(0>b?1:0));m!=n;m+=b){var q=p.charAt(m);if(d.test(q)&&(void 0===e||a.getTokenTypeAt(l(k,m+1))==e))if(">"==r[q].charAt(1)==
|
|
0<b)f.push(q);else if(f.length)f.pop();else return{pos:l(k,m),ch:q}}}}return k-b==(0<b?a.lastLine():a.firstLine())?!1:null}function v(a,c,b){for(var e=a.state.matchBrackets.maxHighlightLineLength||1E3,d=[],h=a.listSelections(),g=0;g<h.length;g++){var f=h[g].empty()&&t(a,h[g].head,!1,b);if(f&&a.getLine(f.from.line).length<=e){var k=f.match?"CodeMirror-matchingbracket":"CodeMirror-nonmatchingbracket";d.push(a.markText(f.from,l(f.from.line,f.from.ch+1),{className:k}));f.to&&a.getLine(f.to.line).length<=
|
|
e&&d.push(a.markText(f.to,l(f.to.line,f.to.ch+1),{className:k}))}}if(d.length)if(x&&a.state.focused&&a.focus(),b=function(){a.operation(function(){for(var a=0;a<d.length;a++)d[a].clear()})},c)setTimeout(b,800);else return b}function w(a){a.operation(function(){n&&(n(),n=null);n=v(a,!1,a.state.matchBrackets)})}var x=/MSIE \d/.test(navigator.userAgent)&&(null==document.documentMode||8>document.documentMode),l=e.Pos,r={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"},n=null;e.defineOption("matchBrackets",
|
|
!1,function(a,c,b){b&&b!=e.Init&&a.off("cursorActivity",w);c&&(a.state.matchBrackets="object"==typeof c?c:{},a.on("cursorActivity",w))});e.defineExtension("matchBrackets",function(){v(this,!0)});e.defineExtension("findMatchingBracket",function(a,c,b){return t(this,a,c,b)});e.defineExtension("scanForBracket",function(a,c,b,e){return u(this,a,c,b,e)})}); |