@@ -54,23 +54,26 @@ module.exports = Console;
5454
5555} , { } ] , 2 :[ function ( require , module , exports ) {
5656var SessionStore = require ( './sessionstore' ) ;
57+
5758/**
58- * A code editor wrapper around Codemirror
59+ * A code editor wrapper around the client-side text editor
5960 *
60- * @param {$ } $element - Dom element the editor should bind to
61- * @returns {CodeMirror }
61+ * @param {String } selector - Dom element the editor should bind to
6262 */
63- function Editor ( $element ) {
64- this . $element = $element ;
65-
66- this . _editor = window . CodeMirror ( this . $element . get ( 0 ) , {
67- lineNumbers : true ,
68- matchBrackets : true ,
69- mode : 'text/x-php' ,
70- indentUnit : 2 ,
71- tabSize : 2 ,
72- autofocus : true ,
73- autoCloseBrackets : true
63+ function Editor ( selector ) {
64+ this . $element = $ ( '#' + selector ) ;
65+
66+ this . _editor = window . ace . edit ( selector ) ;
67+ this . _editor . getSession ( ) . setMode ( { path : 'ace/mode/php' , inline : true } ) ;
68+ this . _editor . getSession ( ) . setUseSoftTabs ( true ) ;
69+ this . _editor . getSession ( ) . setTabSize ( 2 ) ;
70+
71+ this . _editor . $blockScrolling = Infinity ;
72+ this . _editor . setShowPrintMargin ( false ) ;
73+ this . _editor . setOptions ( {
74+ enableBasicAutocompletion : true ,
75+ enableSnippets : true ,
76+ enableLiveAutocompletion : false
7477 } ) ;
7578
7679 this . _sessionStore = new SessionStore ( ) ;
@@ -98,19 +101,13 @@ Editor.prototype.setValue = function(val) {
98101 * @param {Number } line
99102 */
100103Editor . prototype . showLineError = function ( line ) {
101- // Find the dom element in the gutter
102- this . $element . find ( '.CodeMirror-linenumber' ) . each ( function ( ) {
103- // If the cell's line number matches the error line
104- if ( Number ( $ ( this ) . html ( ) ) === line ) {
105- // Make the background red
106- $ ( this ) . addClass ( 'error-gutter' ) ;
107- return ;
108- }
109- } ) ;
104+ this . $element
105+ . find ( '.ace_gutter-cell:nth-child(' + line + ')' )
106+ . addClass ( 'error-gutter' ) ;
110107} ;
111108
112109Editor . prototype . clearLineErrors = function ( ) {
113- this . $element . find ( '.CodeMirror-linenumber ' ) . removeClass ( 'error-gutter' ) ;
110+ this . $element . find ( '.ace_gutter-cell ' ) . removeClass ( 'error-gutter' ) ;
114111} ;
115112
116113Editor . prototype . saveSession = function ( ) {
@@ -285,7 +282,7 @@ var getQueryParams = require('./lib/getQueryParams');
285282var timestamp = require ( './lib/timestamp' ) ;
286283var utils = require ( './lib/utils' ) ;
287284
288- var editor = new Editor ( $ ( '# editor') ) ;
285+ var editor = new Editor ( ' editor') ;
289286var console = new Console ( $ ( '.console' ) ) ;
290287var sidebar = new Sidebar ( $ ( '.sidebar' ) ) ;
291288
0 commit comments