From adde939166168918a7177a5a39e093b5c5b1be4f Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Wed, 20 Oct 2010 12:29:35 +0200 Subject: [PATCH 1/3] also highlight "if" --- src/ace/mode/JavaScriptHighlightRules.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ace/mode/JavaScriptHighlightRules.js b/src/ace/mode/JavaScriptHighlightRules.js index 3a2d29b1..6b1ede7f 100644 --- a/src/ace/mode/JavaScriptHighlightRules.js +++ b/src/ace/mode/JavaScriptHighlightRules.js @@ -19,8 +19,8 @@ JavaScriptHighlightRules = function() { var docComment = new DocCommentHighlightRules(); var keywords = lang.arrayToMap( - ("break|case|catch|continue|default|delete|do|else|finally|for|function|\ - if|in|instanceof|new|return|switch|throw|try|typeof|var|while|with").split("|") + ("break|case|catch|continue|default|delete|do|else|finally|for|function|" + + "if|in|instanceof|new|return|switch|throw|try|typeof|var|while|with").split("|") ); var buildinConstants = lang.arrayToMap( @@ -28,8 +28,8 @@ JavaScriptHighlightRules = function() { ); var futureReserved = lang.arrayToMap( - ("class|enum|extends|super|const|export|import|implements|let|private|\ - public|yield|interface|package|protected|static").split("|") + ("class|enum|extends|super|const|export|import|implements|let|private|" + + "public|yield|interface|package|protected|static").split("|") ); // regexp must not have capturing parentheses. Use (?:) instead. From 5f0213b11038b848b6fbbf00df2ce328b1a26eff Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Wed, 20 Oct 2010 12:52:21 +0200 Subject: [PATCH 2/3] change move to line start to act like in Eclipse and Netbeans --- src/ace/Document.js | 11 +++++++++++ src/ace/Selection.js | 9 ++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/ace/Document.js b/src/ace/Document.js index e064c24f..949685ad 100644 --- a/src/ace/Document.js +++ b/src/ace/Document.js @@ -249,10 +249,21 @@ var Document = function(text, mode) { } }; + /** + * Get a verbatim copy of the given line as it is in the document + */ this.getLine = function(row) { return this.lines[row] || ""; }; + /** + * Get a line as it is displayed on screen. Tabs are replaced by spaces. + */ + this.getDisplayLine = function(row) { + var tab = new Array(this.getTabSize()+1).join(" "); + return this.lines[row].replace(/\t/g, tab); + }; + this.getLines = function(firstRow, lastRow) { return this.lines.slice(firstRow, lastRow+1); }; diff --git a/src/ace/Selection.js b/src/ace/Selection.js index 6f6178ef..89ccea38 100644 --- a/src/ace/Selection.js +++ b/src/ace/Selection.js @@ -281,7 +281,14 @@ var Selection = function(doc) { }; this.moveCursorLineStart = function() { - this.moveCursorTo(this.selectionLead.row, 0); + var row = this.selectionLead.row; + var column = this.selectionLead.column; + var beforeCursor = this.doc.getDisplayLine(row).slice(0, column); + var leadingSpace = beforeCursor.match(/^\s+/); + if (!leadingSpace || leadingSpace[0].length >= column) + this.moveCursorTo(this.selectionLead.row, 0); + else + this.moveCursorTo(this.selectionLead.row, leadingSpace[0].length); }; this.moveCursorLineEnd = function() { From f6b03d1a0a38f9a7decc4452997a2397405f5fdb Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Wed, 20 Oct 2010 13:25:00 +0200 Subject: [PATCH 3/3] make default font size smaller --- src/ace/theme/tm.css | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ace/theme/tm.css b/src/ace/theme/tm.css index 2f7cdd73..be5ef74f 100644 --- a/src/ace/theme/tm.css +++ b/src/ace/theme/tm.css @@ -1,7 +1,7 @@ .ace-tm .ace_editor { border: 2px solid rgb(159, 159, 159); font-family: "Menlo", "Monaco", "Courier New", "Courier", monospace; - font-size: 12px; + font-size: 11px; } .ace-tm .ace_editor.ace_focus { @@ -12,8 +12,8 @@ width: 50px; background: #e8e8e8; color: #333; - font-family: Menlo, Monaco, "Courier New"; - font-size: 12px; + font-family: "Menlo", "Monaco", "Courier New", monospace; + font-size: 11px; overflow : hidden; }