From b9515ddb010475514fc566d1d37bdfa0ba4e1594 Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 8 Dec 2011 13:27:35 +0400 Subject: [PATCH 1/5] keep existing macro if nothing new is recorded --- lib/ace/commands/command_manager.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/ace/commands/command_manager.js b/lib/ace/commands/command_manager.js index 439d5832..8f3fcbad 100644 --- a/lib/ace/commands/command_manager.js +++ b/lib/ace/commands/command_manager.js @@ -146,8 +146,13 @@ var CommandManager = function(platform, commands) { if (this.recording) { this.macro.pop(); this.exec = this.normal_exec; + + if (!this.macro.length) + this.macro = this.oldMacro; + return this.recording = false; } + this.oldMacro = this.macro; this.macro = []; this.normal_exec = this.exec; this.exec = function(command, editor, args) { @@ -158,10 +163,10 @@ var CommandManager = function(platform, commands) { }; this.replay = function(editor) { - if (this.$inReplay) + if (this.$inReplay || !this.macro) return; - if (!this.macro || this.recording) + if (this.recording) return this.toggleRecording(); try { From e6a0c0657579d6183c06ea6e8ab92dfcd46026d8 Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 8 Dec 2011 20:54:15 +0400 Subject: [PATCH 2/5] fix size computations depending on renderer $padding --- lib/ace/virtual_renderer.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index 1013384a..b10290a5 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -257,9 +257,9 @@ var VirtualRenderer = function(container, theme) { this.$loop.schedule(changes); }; - this.adjustWrapLimit = function(){ + this.adjustWrapLimit = function() { var availableWidth = this.$size.scrollerWidth - this.$padding * 2; - var limit = Math.floor(availableWidth / this.characterWidth) - 1; + var limit = Math.floor(availableWidth / this.characterWidth); return this.session.adjustWrapLimit(limit); }; @@ -333,7 +333,7 @@ var VirtualRenderer = function(container, theme) { } var style = this.$printMarginEl.style; - style.left = ((this.characterWidth * this.$printMarginColumn) + this.$padding * 2) + "px"; + style.left = ((this.characterWidth * this.$printMarginColumn) + this.$padding) + "px"; style.visibility = this.$showPrintMargin ? "visible" : "hidden"; }; @@ -362,7 +362,7 @@ var VirtualRenderer = function(container, theme) { var bounds = this.content.getBoundingClientRect(); var offset = this.layerConfig.offset; - textarea.style.left = (bounds.left + pos.left + this.$padding) + "px"; + textarea.style.left = (bounds.left + pos.left) + "px"; textarea.style.top = (bounds.top + pos.top - this.scrollTop + offset) + "px"; }; @@ -548,7 +548,7 @@ var VirtualRenderer = function(container, theme) { this.$gutterLayer.element.style.marginTop = (-offset) + "px"; this.content.style.marginTop = (-offset) + "px"; - this.content.style.width = longestLine + "px"; + this.content.style.width = longestLine + 2 * this.$padding + "px"; this.content.style.height = minHeight + "px"; // scroller.scrollWidth was smaller than scrollLeft we needed @@ -590,11 +590,11 @@ var VirtualRenderer = function(container, theme) { }; this.$getLongestLine = function() { - var charCount = this.session.getScreenWidth() + 1; + var charCount = this.session.getScreenWidth(); if (this.$textLayer.showInvisibles) charCount += 1; - return Math.max(this.$size.scrollerWidth, Math.round(charCount * this.characterWidth)); + return Math.max(this.$size.scrollerWidth - 2 * this.$padding, Math.round(charCount * this.characterWidth)); }; this.updateFrontMarkers = function() { From decebfc552981390f83455579b92572b5903d47f Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 8 Dec 2011 20:54:54 +0400 Subject: [PATCH 3/5] add scrollbar before scroller to not cover it --- lib/ace/scrollbar.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ace/scrollbar.js b/lib/ace/scrollbar.js index 64c418df..cc72e44b 100644 --- a/lib/ace/scrollbar.js +++ b/lib/ace/scrollbar.js @@ -50,16 +50,17 @@ var ScrollBar = function(parent) { this.inner = dom.createElement("div"); this.element.appendChild(this.inner); - parent.appendChild(this.element); - // in OSX lion the scrollbars appear to have no width. In this case resize // the to show the scrollbar but still pretend that the scrollbar has a width // of 0px // in Firefox 6+ scrollbar is hidden if element has the same width as scrollbar // make element a little bit wider to retain scrollbar when page is zoomed + // and insert it before other siblings to not cover them this.width = dom.scrollbarWidth(parent.ownerDocument); this.element.style.width = (this.width || 15) + 5 + "px"; + parent.insertBefore(this.element, parent.firstChild); + event.addListener(this.element, "scroll", this.onScroll.bind(this)); }; From 85e087f87dc6c909860d0a7a91bb9650118c7090 Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 8 Dec 2011 21:01:23 +0400 Subject: [PATCH 4/5] fix for jquery modal dialogs which doesn't break selection --- lib/ace/css/editor.css | 2 +- lib/ace/keyboard/textinput.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ace/css/editor.css b/lib/ace/css/editor.css index f7a5b7e8..b49e2d79 100644 --- a/lib/ace/css/editor.css +++ b/lib/ace/css/editor.css @@ -85,7 +85,7 @@ .ace_editor textarea { position: fixed; - z-index: 2000; + z-index: 0; width: 10px; height: 30px; opacity: 0; diff --git a/lib/ace/keyboard/textinput.js b/lib/ace/keyboard/textinput.js index b828dcf6..397178a5 100644 --- a/lib/ace/keyboard/textinput.js +++ b/lib/ace/keyboard/textinput.js @@ -50,7 +50,7 @@ var TextInput = function(parentNode, host) { text.setAttribute("x-palm-disable-auto-cap", true); text.style.left = "-10000px"; - parentNode.appendChild(text); + parentNode.insertBefore(text, parentNode.firstChild); var PLACEHOLDER = String.fromCharCode(0); sendText(); From 0d02902831ba8b1378e1386724beaa9307207164 Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 8 Dec 2011 21:27:18 +0400 Subject: [PATCH 5/5] snap scrolling to edges (it doesn't make sense to have editor scrolled by just one char) --- lib/ace/virtual_renderer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index b10290a5..5af85462 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -715,7 +715,7 @@ var VirtualRenderer = function(container, theme) { }; this.scrollToX = function(scrollLeft) { - if (scrollLeft <= this.$padding) + if (scrollLeft <= this.$padding + 2 * this.layerConfig.characterWidth) scrollLeft = 0; this.scroller.scrollLeft = scrollLeft;