The MirrorFrame breeding extends the syntax highlighter and makes the collector bear a droll consciousness more of a faithful collector – with a toolbar/buttons. You can determine to be the informant of the MirrorFrame implementation in js/mirrorframe.js. As an expression to the knowledgeable we’ll embezzle the ‘get contemporary pike number’ impulse.
There are alot of functions CodeMirror makes organize (list here), you can dash off your own functions and adhere them to a button in your own MirrorFrame collector. It references this which in our the actuality is the contemporary collector.
line: function() {
alert(The cursor is currently at pike + this.mirror.currentLine());
this.mirror.focus();
},
CodeMirror
We can pass uncountable configuration options to the CodeMirror breeding when we instantiate it such as whether we lack pike numbering and the proportions of label span. onChange and initCallBack. An expression to the knowledgeable underneath:
editor = CodeMirror.fromTextArea(textarea, {
content: textarea.value,
parserfile: [parser/tokenizejavascript.js, parser/parsejavascript.js],
stylesheet: css/editor_colours/jscolours.css,
path: js/,
autoMatchParens: faithful,
width: ‘100%’,
height: ‘100%’,
textWrapping: phony,
lineNumbers: faithful,
tabMode: ’spaces’,
iframeClass: ‘ifc’,
indentUnit: 4
});
There are also 2 events organize for the treatment of the developer to fritter away.
initCallBack is called when the collector has drunk and is organize for the treatment of the alcohol to start entering rules (remember an iframe is created, additional javascript files are loaded). If we wanted to nick i call for an on-the-fly rules tester, and needed to carry the rules from the collector whenever the rules in the collector changed, then we would do the following:
var collector = CodeMirror.fromTextArea(textarea, {
height: 350px,
content: textarea.value,
parserfile: [tokenizejavascript.js, parsejavascript.js],
stylesheet: css/jscolors.css,
path: js/,
autoMatchParens: faithful,
onChange: impulse (n) { alert(editor.getCode()); },
});
This was solely a brilliant look at CodeMirror, but optimistically you can quality solely how effective it is. onChange occurs whenever a metamorphose is made in the collector itself.
It could be acclimated to in your website’s admin interface to adjust rules on the embezzle a run-out authority, or be acclimated to in Titanium or AIR to up to a desktop IDE in HTML/Javascript.