From a19d9dbbb754d1d3965642147225d39ade4c5cfa Mon Sep 17 00:00:00 2001 From: DanyaPostfactum Date: Thu, 24 Jan 2013 05:38:30 +1000 Subject: [PATCH 01/14] Fix paren token type in php mode --- lib/ace/mode/php_highlight_rules.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ace/mode/php_highlight_rules.js b/lib/ace/mode/php_highlight_rules.js index eac9ecea..299a16b1 100644 --- a/lib/ace/mode/php_highlight_rules.js +++ b/lib/ace/mode/php_highlight_rules.js @@ -978,10 +978,10 @@ var PhpLangHighlightRules = function() { token : "keyword.operator", regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" }, { - token : "lparen", + token : "paren.lparen", regex : "[[({]" }, { - token : "rparen", + token : "paren.rparen", regex : "[\\])}]" }, { token : "text", From a432399742db6a1dd6479cf997269f6ea49afe32 Mon Sep 17 00:00:00 2001 From: DanyaPostfactum Date: Thu, 24 Jan 2013 05:39:31 +1000 Subject: [PATCH 02/14] Fix deletion behavior for single quotes --- lib/ace/mode/behaviour/cstyle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/mode/behaviour/cstyle.js b/lib/ace/mode/behaviour/cstyle.js index ccacd7ad..1f1d8210 100644 --- a/lib/ace/mode/behaviour/cstyle.js +++ b/lib/ace/mode/behaviour/cstyle.js @@ -350,7 +350,7 @@ var CstyleBehaviour = function () { if (!range.isMultiLine() && (selected == '"' || selected == "'")) { var line = session.doc.getLine(range.start.row); var rightChar = line.substring(range.start.column + 1, range.start.column + 2); - if (rightChar == '"') { + if (rightChar == '"' || rightChar == "'") { range.end.column++; return range; } From 26e107401765f86c6439d930bf59b96dbc1deb4f Mon Sep 17 00:00:00 2001 From: DanyaPostfactum Date: Thu, 24 Jan 2013 05:40:25 +1000 Subject: [PATCH 03/14] Fix Makefile script for windows line endings --- Makefile.dryice.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.dryice.js b/Makefile.dryice.js index 218cd7ef..1e7952a9 100755 --- a/Makefile.dryice.js +++ b/Makefile.dryice.js @@ -476,7 +476,7 @@ var detectTextModules = function(input, source) { input = input.replace(/\\/g, "\\\\").replace(/"/g, '\\"'); input = input.replace(/\n\s+/g, "\n"); - input = '"' + input.replace(/\n/g, '\\\n') + '"'; + input = '"' + input.replace(/\r?\n/g, '\\\n') + '"'; textModules[module] = input; return ""; From 35819e68df70d3c9bb98479f8f6320cc423822bc Mon Sep 17 00:00:00 2001 From: DanyaPostfactum Date: Thu, 24 Jan 2013 06:48:34 +1000 Subject: [PATCH 04/14] More font sizes to kitchen sink --- kitchen-sink.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kitchen-sink.html b/kitchen-sink.html index ce7d492f..a2e51d29 100644 --- a/kitchen-sink.html +++ b/kitchen-sink.html @@ -107,8 +107,10 @@ + + From 4ccbeb23fafd047c6763efe25a14d45ecbe221c1 Mon Sep 17 00:00:00 2001 From: DanyaPostfactum Date: Thu, 24 Jan 2013 06:49:02 +1000 Subject: [PATCH 05/14] Monokai theme tweak --- lib/ace/theme/monokai.css | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ace/theme/monokai.css b/lib/ace/theme/monokai.css index 1d772e24..d93600d2 100644 --- a/lib/ace/theme/monokai.css +++ b/lib/ace/theme/monokai.css @@ -1,6 +1,6 @@ .ace-monokai .ace_gutter { - background: #2f3129; - color: #f1f1f1 + background: #2F3129; + color: #8F908A } .ace-monokai .ace_print-margin { @@ -56,7 +56,7 @@ } .ace-monokai .ace_invisible { - color: #49483E + color: #52524d } .ace-monokai .ace_entity.ace_name.ace_tag, From 7ae929aecfd070f17b009e7a2371a67a7d42c335 Mon Sep 17 00:00:00 2001 From: DanyaPostfactum Date: Thu, 24 Jan 2013 19:19:08 +1000 Subject: [PATCH 06/14] Make container csspadding-proof --- lib/ace/css/editor.css | 8 +++++++- lib/ace/virtual_renderer.js | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/ace/css/editor.css b/lib/ace/css/editor.css index c4b40a4f..dfcb7aec 100644 --- a/lib/ace/css/editor.css +++ b/lib/ace/css/editor.css @@ -7,6 +7,8 @@ .ace_scroller { position: absolute; overflow: hidden; + top: 0; + bottom: 0; } .ace_content { @@ -20,8 +22,10 @@ .ace_gutter { position: absolute; overflow : hidden; - height: 100%; width: auto; + top: 0; + bottom: 0; + left: 0; cursor: default; z-index: 4; } @@ -66,6 +70,8 @@ overflow-x: hidden; overflow-y: scroll; right: 0; + top: 0; + bottom: 0; } .ace_scrollbar-inner { diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index 24d4bd06..75860d92 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -306,7 +306,6 @@ var VirtualRenderer = function(container, theme) { if (height && (force || size.height != height)) { size.height = height; - this.scroller.style.height = height + "px"; size.scrollerHeight = this.scroller.clientHeight; this.scrollBar.setHeight(size.scrollerHeight); From 4d43496201900b0cae2e8ade71212043112f0156 Mon Sep 17 00:00:00 2001 From: DanyaPostfactum Date: Thu, 24 Jan 2013 19:19:48 +1000 Subject: [PATCH 07/14] Tooltip css tweak --- lib/ace/css/editor.css | 7 ++++++- lib/ace/mouse/default_gutter_handler.js | 5 ++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/ace/css/editor.css b/lib/ace/css/editor.css index dfcb7aec..b78a7189 100644 --- a/lib/ace/css/editor.css +++ b/lib/ace/css/editor.css @@ -252,8 +252,9 @@ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.4); color: black; display: inline-block; + max-width: 500px; padding: 4px; - position: absolute; + position: fixed; z-index: 300; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; @@ -261,6 +262,10 @@ cursor: default; white-space: pre-line; word-wrap: break-word; + line-height: normal; + font-style: normal; + font-weight: normal; + letter-spacing: normal; } .ace_folding-enabled > .ace_gutter-cell { diff --git a/lib/ace/mouse/default_gutter_handler.js b/lib/ace/mouse/default_gutter_handler.js index 90d9747c..ee8f03af 100644 --- a/lib/ace/mouse/default_gutter_handler.js +++ b/lib/ace/mouse/default_gutter_handler.js @@ -66,7 +66,6 @@ function GutterHandler(mouseHandler) { function createTooltip() { tooltip = dom.createElement("div"); tooltip.className = "ace_gutter-tooltip"; - tooltip.style.maxWidth = "500px"; tooltip.style.display = "none"; editor.container.appendChild(tooltip); } @@ -111,10 +110,10 @@ function GutterHandler(mouseHandler) { function moveTooltip(e) { var rect = editor.renderer.$gutter.getBoundingClientRect(); - tooltip.style.left = e.x - rect.left + 15 + "px"; + tooltip.style.left = e.x + 15 + "px"; if (e.y + 3 * editor.renderer.lineHeight + 15 < rect.bottom) { tooltip.style.bottom = ""; - tooltip.style.top = e.y - rect.top + 15 + "px"; + tooltip.style.top = e.y + 15 + "px"; } else { tooltip.style.top = ""; tooltip.style.bottom = rect.bottom - e.y + 5 + "px"; From 3952ef9afdc657571b108864a052f1b12270cfb1 Mon Sep 17 00:00:00 2001 From: DanyaPostfactum Date: Thu, 24 Jan 2013 19:22:30 +1000 Subject: [PATCH 08/14] BlockIndent command ( Ctrl-[ and Ctrl-] ) --- lib/ace/commands/default_commands.js | 10 ++++++++++ lib/ace/editor.js | 15 ++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/ace/commands/default_commands.js b/lib/ace/commands/default_commands.js index b8583c06..94f68d76 100644 --- a/lib/ace/commands/default_commands.js +++ b/lib/ace/commands/default_commands.js @@ -414,6 +414,16 @@ exports.commands = [{ bindKey: bindKey("Tab", "Tab"), exec: function(editor) { editor.indent(); }, multiSelectAction: "forEach" +},{ + name: "blockoutdent", + bindKey: bindKey("Ctrl-[", "Ctrl-["), + exec: function(editor) { editor.blockOutdent(); }, + multiSelectAction: "forEach" +},{ + name: "blockindent", + bindKey: bindKey("Ctrl-]", "Ctrl-]"), + exec: function(editor) { editor.blockIndent(); }, + multiSelectAction: "forEach" }, { name: "insertstring", exec: function(editor, str) { editor.insert(str); }, diff --git a/lib/ace/editor.js b/lib/ace/editor.js index 5b5552d9..f87ad128 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -1245,8 +1245,8 @@ var Editor = function(renderer, session) { this.selection.setSelectionRange(originalRange); }; - /** - * Indents the current line. + /** + * Inserts an indentation into the current cursor position or indents the selected lines. * * @related EditSession.indentRows **/ @@ -1273,7 +1273,16 @@ var Editor = function(renderer, session) { } }; - /** + /** + * Indents the current line. + * @related EditSession.indentRows + **/ + this.blockIndent = function() { + var rows = this.$getSelectedRows(); + this.session.indentRows(rows.first, rows.last, "\t"); + }; + + /** * Outdents the current line. * @related EditSession.outdentRows **/ From 99f8aba562488fab2ecfc5c32b8a1be5c05d6a95 Mon Sep 17 00:00:00 2001 From: DanyaPostfactum Date: Thu, 24 Jan 2013 19:23:40 +1000 Subject: [PATCH 09/14] Read-only checkbox in kitchen sink --- demo/kitchen-sink/demo.js | 3 +++ demo/kitchen-sink/doclist.js | 2 +- kitchen-sink.html | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/demo/kitchen-sink/demo.js b/demo/kitchen-sink/demo.js index 183a872a..9ae70f4f 100644 --- a/demo/kitchen-sink/demo.js +++ b/demo/kitchen-sink/demo.js @@ -356,6 +356,9 @@ bindCheckbox("enable_behaviours", function(checked) { bindCheckbox("fade_fold_widgets", function(checked) { env.editor.setFadeFoldWidgets(checked); }); +bindCheckbox("read_only", function(checked) { + env.editor.setReadOnly(checked); +}); var secondSession = null; bindDropdown("split", function(value) { diff --git a/demo/kitchen-sink/doclist.js b/demo/kitchen-sink/doclist.js index 3ddbd0c5..f75e6e86 100644 --- a/demo/kitchen-sink/doclist.js +++ b/demo/kitchen-sink/doclist.js @@ -67,7 +67,7 @@ var docs = { "docs/AsciiDoc.asciidoc": "AsciiDoc", "docs/javascript.js": "JavaScript", "docs/clojure.clj": "Clojure", - "docs/coffeescript.coffee": "Coffeescript", + "docs/coffeescript.coffee": "CoffeeScript", "docs/coldfusion.cfm": "ColdFusion", "docs/cpp.cpp": "C/C++", "docs/csharp.cs": "C#", diff --git a/kitchen-sink.html b/kitchen-sink.html index a2e51d29..b9f55d5d 100644 --- a/kitchen-sink.html +++ b/kitchen-sink.html @@ -249,6 +249,14 @@ + + + + + + + + From 88a566977bae20a19fc6ffde455f1ef90253f0c2 Mon Sep 17 00:00:00 2001 From: DanyaPostfactum Date: Thu, 24 Jan 2013 19:54:07 +1000 Subject: [PATCH 10/14] ReadOnly fixes --- lib/ace/editor.js | 2 ++ lib/ace/keyboard/textinput.js | 5 ++++- lib/ace/mouse/dragdrop.js | 10 ++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/ace/editor.js b/lib/ace/editor.js index f87ad128..f85debf6 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -1015,6 +1015,8 @@ var Editor = function(renderer, session) { **/ this.setReadOnly = function(readOnly) { this.$readOnly = readOnly; + this.textInput.setReadOnly(readOnly); + this.renderer.$cursorLayer.setBlinking(!readOnly); }; /** diff --git a/lib/ace/keyboard/textinput.js b/lib/ace/keyboard/textinput.js index 3321f2b9..183260c9 100644 --- a/lib/ace/keyboard/textinput.js +++ b/lib/ace/keyboard/textinput.js @@ -355,11 +355,14 @@ var TextInput = function(parentNode, host) { event.addListener(text, "keyup", onCompositionUpdate); event.addListener(text, "compositionend", onCompositionEnd); - // CONTEXTMENU this.getElement = function() { return text; }; + this.setReadOnly = function(readOnly) { + text.readOnly = readOnly; + }; + this.onContextMenu = function(e) { if (!tempStyle) tempStyle = text.style.cssText; diff --git a/lib/ace/mouse/dragdrop.js b/lib/ace/mouse/dragdrop.js index 9f6c0c15..88f526b5 100644 --- a/lib/ace/mouse/dragdrop.js +++ b/lib/ace/mouse/dragdrop.js @@ -41,6 +41,8 @@ var DragdropHandler = function(mouseHandler) { var mouseTarget = editor.container; event.addListener(mouseTarget, "dragenter", function(e) { + if (editor.getReadOnly()) + return; counter++; if (!dragSelectionMarker) { range = editor.getSelectionRange(); @@ -55,6 +57,8 @@ var DragdropHandler = function(mouseHandler) { }); event.addListener(mouseTarget, "dragover", function(e) { + if (editor.getReadOnly()) + return; x = e.clientX; y = e.clientY; return event.preventDefault(e); @@ -67,10 +71,11 @@ var DragdropHandler = function(mouseHandler) { }; event.addListener(mouseTarget, "dragleave", function(e) { + if (editor.getReadOnly()) + return; counter--; if (counter > 0) return; - console.log(e.type, counter,e.target); clearInterval(timerId); editor.session.removeMarker(dragSelectionMarker); dragSelectionMarker = null; @@ -79,7 +84,8 @@ var DragdropHandler = function(mouseHandler) { }); event.addListener(mouseTarget, "drop", function(e) { - console.log(e.type, counter,e.target); + if (editor.getReadOnly()) + return; counter = 0; clearInterval(timerId); editor.session.removeMarker(dragSelectionMarker); From 144b29a7a7040162a978195da38998031bacbeee Mon Sep 17 00:00:00 2001 From: DanyaPostfactum Date: Fri, 25 Jan 2013 00:09:24 +1000 Subject: [PATCH 11/14] Fix label for readonly checkbox --- kitchen-sink.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kitchen-sink.html b/kitchen-sink.html index b9f55d5d..c846e2aa 100644 --- a/kitchen-sink.html +++ b/kitchen-sink.html @@ -251,7 +251,7 @@ - + From 13a5fde817e343c7500928d10be57651d941b00b Mon Sep 17 00:00:00 2001 From: DanyaPostfactum Date: Fri, 25 Jan 2013 02:31:58 +1000 Subject: [PATCH 12/14] Update php test (paren tokens) --- lib/ace/mode/_test/tokens_php.json | 34 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/ace/mode/_test/tokens_php.json b/lib/ace/mode/_test/tokens_php.json index ce7ce4b4..d8a41eec 100644 --- a/lib/ace/mode/_test/tokens_php.json +++ b/lib/ace/mode/_test/tokens_php.json @@ -8,25 +8,25 @@ ["keyword","function"], ["text"," "], ["identifier","nfact"], - ["lparen","("], + ["paren.lparen","("], ["variable","$n"], - ["rparen",")"], + ["paren.rparen",")"], ["text"," "], - ["lparen","{"] + ["paren.lparen","{"] ],[ "php-start", ["text"," "], ["keyword","if"], ["text"," "], - ["lparen","("], + ["paren.lparen","("], ["variable","$n"], ["text"," "], ["keyword.operator","=="], ["text"," "], ["constant.numeric","0"], - ["rparen",")"], + ["paren.rparen",")"], ["text"," "], - ["lparen","{"] + ["paren.lparen","{"] ],[ "php-start", ["text"," "], @@ -37,13 +37,13 @@ ],[ "php-start", ["text"," "], - ["rparen","}"] + ["paren.rparen","}"] ],[ "php-start", ["text"," "], ["keyword","else"], ["text"," "], - ["lparen","{"] + ["paren.lparen","{"] ],[ "php-start", ["text"," "], @@ -54,21 +54,21 @@ ["keyword.operator","*"], ["text"," "], ["identifier","nfact"], - ["lparen","("], + ["paren.lparen","("], ["variable","$n"], ["text"," "], ["keyword.operator","-"], ["text"," "], ["constant.numeric","1"], - ["rparen",")"], + ["paren.rparen",")"], ["text",";"] ],[ "php-start", ["text"," "], - ["rparen","}"] + ["paren.rparen","}"] ],[ "php-start", - ["rparen","}"] + ["paren.rparen","}"] ],[ "php-start" ],[ @@ -86,11 +86,11 @@ ["keyword.operator","="], ["text"," "], ["support.function","trim"], - ["lparen","("], + ["paren.lparen","("], ["support.function","fgets"], - ["lparen","("], + ["paren.lparen","("], ["constant.language","STDIN"], - ["rparen","))"], + ["paren.rparen","))"], ["text",";"] ],[ "php-start" @@ -112,9 +112,9 @@ ["string","\" = \""], ["text"," . "], ["identifier","nfact"], - ["lparen","("], + ["paren.lparen","("], ["variable","$num"], - ["rparen",")"], + ["paren.rparen",")"], ["text"," . "], ["string","\""], ["constant.language.escape","\\n\\n"], From 961053b7d08440d28a54f2bc5d5e8e629f2da85b Mon Sep 17 00:00:00 2001 From: DanyaPostfactum Date: Fri, 25 Jan 2013 02:32:20 +1000 Subject: [PATCH 13/14] Fix cstyle quote deletion behavior --- lib/ace/mode/behaviour/cstyle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/mode/behaviour/cstyle.js b/lib/ace/mode/behaviour/cstyle.js index 1f1d8210..54f75526 100644 --- a/lib/ace/mode/behaviour/cstyle.js +++ b/lib/ace/mode/behaviour/cstyle.js @@ -350,7 +350,7 @@ var CstyleBehaviour = function () { if (!range.isMultiLine() && (selected == '"' || selected == "'")) { var line = session.doc.getLine(range.start.row); var rightChar = line.substring(range.start.column + 1, range.start.column + 2); - if (rightChar == '"' || rightChar == "'") { + if (rightChar == selected) { range.end.column++; return range; } From 84b1f169679804cef4c19d45bf95cd18432128b6 Mon Sep 17 00:00:00 2001 From: DanyaPostfactum Date: Fri, 25 Jan 2013 02:32:55 +1000 Subject: [PATCH 14/14] Improve tooltip style --- lib/ace/css/editor.css | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ace/css/editor.css b/lib/ace/css/editor.css index b78a7189..c1dd818a 100644 --- a/lib/ace/css/editor.css +++ b/lib/ace/css/editor.css @@ -247,9 +247,12 @@ } .ace_gutter-tooltip { - background-color: #FFFFD5; + background-color: #FFF; + background-image: -webkit-linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1)); + background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1)); border: 1px solid gray; - box-shadow: 0 1px 1px rgba(0, 0, 0, 0.4); + border-radius: 1px; + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); color: black; display: inline-block; max-width: 500px;