<!DOCTYPE html>
<html>
	<head>
		<link rel="stylesheet" href="lib/codemirror.css"/>
		<link rel="stylesheet" href="beditor.css"/>
		<script src="lib/jquery.js" type="text/javascript"></script>
		<script src="lib/codemirror.js" type="text/javascript"></script>
		<script src="b.js" type="text/javascript"></script>
	</head>
	<body>
		<div id="container">
			<textarea id="code"></textarea>
		</div>
		<script>
			var TO;
			function onChange(cm) {
				line = cm.getCursor().line;
				if(!blexer.isInitialized()) {
					clearTimeout(TO);
					TO = setTimeout(function(){
						blexer.computeHighlighting(cm.getValue(), line + '');
					}, 100);
				} else {
					blexer.computeHighlighting(cm.getValue(), line + '');
				}
			}

			var code = document.getElementById('code');
			var editor = CodeMirror.fromTextArea(code, {
				lineNumbers: true,
				indentUnit: 4,
				autoCloseBrackets: true,
				matchBrackets: true,
				mode: "text/b"
			});
						
			editor.on("change", onChange);
			
			function changeFontSize(size) {
				editor.getWrapperElement().style["font-size"] = size+"px";
				editor.refresh();
			}
		</script>
	</body>
</html>

<!DOCTYPE html>
<html>
	<head>
		<link rel="stylesheet" href="lib/codemirror.css"/>
		<link rel="stylesheet" href="beditor.css"/>
		<script src="lib/jquery.js" type="text/javascript"></script>
		<script src="lib/codemirror.js" type="text/javascript"></script>
		<script src="b.js" type="text/javascript"></script>
	</head>
	<body>
		<div id="container">
			<textarea id="code"></textarea>
		</div>
		<script>
			var TO;
			function onChange(cm) {
				line = editor.getCursor().line;
				if(!blexer.isInitialized()) {
					clearTimeout(TO);
					TO = setTimeout(function(){
						blexer.computeHighlighting(cm.getValue(), line + '');
					}, 100);
				} else {
					blexer.computeHighlighting(cm.getValue(), line + '');
				}
			}

			var code = document.getElementById('code');
			var editor = CodeMirror.fromTextArea(code, {
				lineNumbers: true,
				indentUnit: 4,
				autoCloseBrackets: true,
				matchBrackets: true,
				mode: "text/b"
			});
						
			editor.on("change", onChange);
			
			function changeFontSize(size) {
				editor.getWrapperElement().style["font-size"] = size+"px";
				editor.refresh();
			}
		</script>
	</body>
</html>

Improve handling enter in BEditor
Improve handling enter in BEditor